- Timestamp:
- 07/06/15 12:08:02 (9 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/eventcore/EqualSOAPDataMap.java
r1985 r1986 15 15 package de.ugoe.cs.autoquest.plugin.http.eventcore; 16 16 17 import java.io.IOException; 18 import java.io.ObjectInputStream; 19 import java.io.ObjectOutputStream; 20 import java.io.Serializable; 17 21 import java.util.Collections; 18 22 import java.util.HashMap; … … 30 34 * @author Steffen Herbold 31 35 */ 32 public class EqualSOAPDataMap {36 public class EqualSOAPDataMap implements Serializable { 33 37 38 /** */ 39 private static final long serialVersionUID = 1L; 40 34 41 /** 35 42 * Singleton. Handle to only instance of this class 36 43 */ 37 public finalstatic EqualSOAPDataMap INSTANCE = new EqualSOAPDataMap();44 transient private static EqualSOAPDataMap INSTANCE = new EqualSOAPDataMap(); 38 45 39 46 /** 40 47 * Map with all soapRequestBodies for all equal {@link SimpleSOAPEventType}s 41 48 */ 42 private finalMap<SimpleSOAPEventType, ListOrderedSet<String>> soapRequestBodies = new HashMap<>();49 private Map<SimpleSOAPEventType, ListOrderedSet<String>> soapRequestBodies = new HashMap<>(); 43 50 44 51 /** 45 52 * random number generator for picking a random request body 46 53 */ 47 private final Random random = new Random(1); // TODO static seed for testing 54 transient private final Random random; 55 56 /** 57 * <p> 58 * return the instance of the class 59 * </p> 60 * 61 * @return 62 */ 63 public static EqualSOAPDataMap getInstance() { 64 return INSTANCE; 65 } 48 66 49 67 private EqualSOAPDataMap() { 50 68 // private constructor to avoid initialization 69 random = new Random(); 70 } 71 72 /** 73 * <p> 74 * Manual serialization of the object. Necessary to guarantee the singleton 75 * property. 76 * </p> 77 * 78 * @param s 79 * output stream for the serialization 80 * @throws IOException 81 * thrown if there is problem writing to the output stream 82 */ 83 private void writeObject(ObjectOutputStream s) throws IOException { 84 s.defaultWriteObject(); 85 s.writeObject(soapRequestBodies); 86 } 87 88 /** 89 * <p> 90 * Manual de-serialization of the object. Necessary to guarantee the 91 * singleton property. 92 * 93 * @param s 94 * input stream for the de-serialization 95 * @throws IOException 96 * thrown if there is problem reading from the input stream 97 * @throws ClassNotFoundException 98 * thrown if there is a problem reading from the input stream 99 */ 100 @SuppressWarnings("unchecked") 101 private void readObject(ObjectInputStream s) throws IOException, 102 ClassNotFoundException { 103 s.defaultReadObject(); 104 if (INSTANCE == null) { 105 INSTANCE = new EqualSOAPDataMap(); 106 } 107 INSTANCE.soapRequestBodies = (Map<SimpleSOAPEventType, ListOrderedSet<String>>) s.readObject(); 108 } 109 110 /** 111 * <p> 112 * Manual de-serialization to guarantee the singleton property. 113 * </p> 114 * 115 * @return instance of the container 116 */ 117 private Object readResolve() { 118 return INSTANCE; 51 119 } 52 120 … … 97 165 return requestBodySet.get(random.nextInt(requestBodySet.size())); 98 166 } 167 168 /** 169 * <p> 170 * resets the internal map by creating new one 171 * </p> 172 * 173 */ 174 public void reset() { 175 soapRequestBodies = new HashMap<>(); 176 } 99 177 } -
trunk/autoquest-plugin-http/src/main/java/de/ugoe/cs/autoquest/plugin/http/eventcore/SimpleSOAPEventType.java
r1985 r1986 99 99 this.clientName = clientName; 100 100 this.soapRequestBody = SOAPUtils.getSerialization(soapRequestBody); 101 EqualSOAPDataMap. INSTANCE.add(this, this.soapRequestBody);101 EqualSOAPDataMap.getInstance().add(this, this.soapRequestBody); 102 102 } 103 103 … … 150 150 break; 151 151 case RANDOM: 152 requestBody = EqualSOAPDataMap. INSTANCE.getRandom(this);152 requestBody = EqualSOAPDataMap.getInstance().getRandom(this); 153 153 break; 154 154 default: … … 157 157 if( requestBody==null ) { 158 158 System.err.println("foobar" + this); 159 System.err.println(EqualSOAPDataMap. INSTANCE.getAll(this));159 System.err.println(EqualSOAPDataMap.getInstance().getAll(this)); 160 160 } 161 161 try {
Note: See TracChangeset
for help on using the changeset viewer.