1 19 20 package org.netbeans.modules.xml.axi.sync; 21 22 import junit.framework.*; 23 import org.netbeans.modules.xml.axi.AXIModel; 24 import org.netbeans.modules.xml.axi.visitor.DeepAXITreeVisitor; 25 import org.netbeans.modules.xml.schema.model.GlobalElement; 26 import org.netbeans.modules.xml.schema.model.SchemaModel; 27 28 29 35 public class SyncPerfTest extends AbstractSyncTestCase { 36 37 public static final String OTA_XSD = "resources/OTA_TravelItinerary.xsd"; 38 public static final String HL7_XSD = "resources/hl7/fields.xsd"; 39 40 43 public SyncPerfTest(String testName) { 44 super(testName, HL7_XSD, null); 45 } 46 47 public static Test suite() { 48 TestSuite suite = new TestSuite(SyncPerfTest.class); 49 return suite; 50 } 51 52 public void testHealthcareSchemaSyncPerformance() { 53 doRun(getSchemaModel(), getAXIModel(), false); 54 } 56 57 63 private void doRun(SchemaModel sModel, AXIModel aModel, boolean worstCase) { 64 if(worstCase) { 65 DeepAXITreeVisitor visitor = new DeepAXITreeVisitor(); 66 visitor.visit(aModel.getRoot()); 67 } 68 int schemaChildCount = sModel.getSchema().getChildren().size(); 69 int axiChildCount = aModel.getRoot().getChildren().size(); 70 try { 71 getSchemaModel().startTransaction(); 72 GlobalElement ge = getSchemaModel().getFactory().createGlobalElement(); 73 ge.setName("NewGlobalElement"); 74 getSchemaModel().getSchema().addElement(ge); 75 getSchemaModel().endTransaction(); 76 long startTime = System.currentTimeMillis(); 77 getAXIModel().sync(); 78 long endTime = System.currentTimeMillis(); 79 print("Time taken to sync: " + 80 (endTime - startTime)); 81 } catch(Exception ex) { 82 ex.printStackTrace(); 83 } 84 assert(schemaChildCount+1 == sModel.getSchema().getChildren().size()); 85 assert(axiChildCount+1 == aModel.getRoot().getChildren().size()); 86 } 87 } 88 | Popular Tags |