Changeset 1625 for trunk/autoquest-plugin-uml-test/src
- Timestamp:
- 07/29/14 14:32:42 (10 years ago)
- Location:
- trunk/autoquest-plugin-uml-test/src/test
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-plugin-uml-test/src/test/java/de/ugoe/cs/autoquest/plugin/uml/UMLUtilsTest.java
r1609 r1625 58 58 */ 59 59 public class UMLUtilsTest { 60 60 61 61 private final static String OUTPUT_DIR = "target/tmp/test-outputs/"; 62 62 63 63 /** 64 64 * 65 65 */ 66 @After67 public void tearDown() throws Exception {68 deleteFiles(new File(OUTPUT_DIR));69 }70 71 @Test(expected =java.lang.RuntimeException.class)72 public void createUMLTransitionSequence_1() throws Exception {66 @After 67 public void tearDown() throws Exception { 68 deleteFiles(new File(OUTPUT_DIR)); 69 } 70 71 @Test(expected = java.lang.RuntimeException.class) 72 public void testCreateUMLTransitionSequence_1() throws Exception { 73 73 // parse log file 74 74 HTTPLogParser parser = new HTTPLogParser(); … … 101 101 } 102 102 } 103 103 104 104 @Test 105 public void convertStateMachineToUsageProfile_1() throws Exception {105 public void testConvertStateMachineToUsageProfile_1() throws Exception { 106 106 // parse log file 107 107 HTTPLogParser parser = new HTTPLogParser(); … … 131 131 } 132 132 133 List<List<Transition>> matchingSequences = UMLUtils.determineMatchingTransitionSequences(httpSequence, stateMachine); 133 List<List<Transition>> matchingSequences = 134 UMLUtils.determineMatchingTransitionSequences(httpSequence, stateMachine); 134 135 if (matchingSequences.size() >= 1) { 135 136 List<Event> umlEventSequence = new LinkedList<>(); … … 141 142 } 142 143 UMLUtils.convertStateMachineToUsageProfile(umlSequences, stateMachine); 143 144 144 145 writeModelToFile(model, OUTPUT_DIR + "convertStateMachineToUsageProfile_1.uml"); 145 146 } 146 147 148 @Test 149 public void testCreateInteractionFromEventSequence_1() throws Exception { 150 // parse log file 151 HTTPLogParser parser = 152 new HTTPLogParser(new File(ClassLoader 153 .getSystemResource("testCreateInteractionFromEventSequence_1_properties.txt").getFile())); 154 parser.parseFile(new File(ClassLoader 155 .getSystemResource("testCreateInteractionFromEventSequence_1_usagedata.log").getFile())); 156 Collection<List<Event>> httpSequences = parser.getSequences(); 157 Model model = 158 loadModelFromInputStream(ClassLoader 159 .getSystemResourceAsStream("testCreateInteractionFromEventSequence_1_model.uml")); 160 161 for (List<Event> httpSequence : httpSequences) { 162 for (Iterator<Event> eventIter = httpSequence.iterator(); eventIter.hasNext();) { 163 Event event = eventIter.next(); 164 if (!(event.getType() instanceof SOAPEventType)) { 165 eventIter.remove(); 166 } 167 } 168 169 UMLUtils.createInteractionFromEventSequence(httpSequence, model, "testSequence"); 170 } 171 //writeModelToFile(model, "testCreateInteractionFromEventSequence_1_result.uml"); 172 } 173 147 174 private static void writeModelToFile(Model model, String filename) throws IOException { 148 175 final ResourceSet resourceSet = new ResourceSetImpl(); 176 UMLResourcesUtil.init(resourceSet); 149 177 resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() 150 178 .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new ResourceFactoryImpl() { 151 179 @Override 152 180 public Resource createResource(URI uri) { 153 return new XMIResourceImpl(uri); 181 return new XMIResourceImpl(uri) { 182 @Override 183 public boolean useUUIDs() 184 { 185 return true; 186 } 187 }; 154 188 } 155 189 }); 156 190 157 191 Resource resource = resourceSet.createResource(URI.createURI("binresource")); 158 192 159 193 resource.getContents().add(model); 160 194 FileOutputStream fos; 161 195 File file = new File(filename); 162 file.getParentFile().mkdirs();163 196 fos = new FileOutputStream(file); 164 197 resource.save(fos, null); … … 171 204 resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE); 172 205 resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE); 173 resourceSet.getResourceFactoryRegistry();174 206 resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() 175 207 .put(Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl()); … … 184 216 185 217 Resource resource = new XMIResourceImpl(); 186 /*187 * XMIResource.XMLMap xmlMap = new XMLMapImpl(); Map options = new HashMap();188 * options.put(XMIResource.OPTION_XML_MAP, xmlMap);189 */190 218 191 219 try { … … 201 229 } 202 230 203 private void deleteFiles(File file) {204 if (file.exists()) {205 if (file.isDirectory()) {206 for (File child : file.listFiles()) {207 deleteFiles(child);208 }209 }210 211 try {212 file.delete();213 }214 catch (Exception e) {215 // ignore and delete as much as possible216 }217 }218 }231 private void deleteFiles(File file) { 232 if (file.exists()) { 233 if (file.isDirectory()) { 234 for (File child : file.listFiles()) { 235 deleteFiles(child); 236 } 237 } 238 239 try { 240 file.delete(); 241 } 242 catch (Exception e) { 243 // ignore and delete as much as possible 244 } 245 } 246 } 219 247 220 248 }
Note: See TracChangeset
for help on using the changeset viewer.