1 19 20 package org.netbeans.modules.xml.axi; 21 22 import java.io.IOException ; 23 import javax.swing.text.BadLocationException ; 24 import javax.swing.text.Document ; 25 import junit.framework.*; 26 import org.netbeans.modules.xml.schema.model.SchemaModel; 27 import org.netbeans.modules.xml.xam.dom.AbstractDocumentModel; 28 29 30 34 public class SchemaTransformPerfTest extends AbstractTestCase { 35 36 public static final String OTA_SIMPLE_XSD = "resources/OTA_TI_simple.xsd"; 38 public static final String GLOBAL_ELEMENT = "Line"; 39 40 private Document doc = null; 41 42 public SchemaTransformPerfTest(String testName) { 43 super(testName, OTA_SIMPLE_XSD, GLOBAL_ELEMENT); 44 } 45 46 public static Test suite() { 47 TestSuite suite = new TestSuite(); 49 return suite; 51 } 52 53 public void testTransformPerf() { 54 print("testTransformPerf"); 55 try { 56 loadModel(OTA_SIMPLE_XSD); 57 } catch (Exception ex) { 58 assertTrue("Should not be here", false); 60 } 61 62 assertEquals("global complex types",3,getSchemaModel().getSchema().getComplexTypes().size()); 63 assertEquals("global attribute groups",2,getSchemaModel().getSchema().getAttributeGroups().size()); 64 assertEquals("global groups",0,getSchemaModel().getSchema().getGroups().size()); 65 assertEquals("global attributes",0,getSchemaModel().getSchema().getAttributes().size()); 66 assertEquals("global simple types",3,getSchemaModel().getSchema().getSimpleTypes().size()); 67 assertEquals("global elements",3,getSchemaModel().getSchema().getElements().size()); 68 69 try { 71 long start = System.currentTimeMillis(); 72 SchemaGeneratorFactory.getDefault().transformSchema( 73 axiModel.getSchemaModel(), SchemaGenerator.Pattern.RUSSIAN_DOLL); 74 long end = System.currentTimeMillis(); 75 print("Time taken to transform from VB to RD: "+(end-start)+"ms"); 76 } catch (IOException ex) { 77 assertTrue("Should not be here", false); 79 } 80 81 assertEquals("global complex types",0,getSchemaModel().getSchema().getComplexTypes().size()); 83 assertEquals("global simple types",0,getSchemaModel().getSchema().getSimpleTypes().size()); 84 assertEquals("global elements",2,getSchemaModel().getSchema().getElements().size()); 85 86 try { 88 long start = System.currentTimeMillis(); 89 SchemaGeneratorFactory.getDefault().transformSchema( 90 axiModel.getSchemaModel(), SchemaGenerator.Pattern.VENITIAN_BLIND); 91 long end = System.currentTimeMillis(); 92 print("Time taken to transform from RD to VB: "+(end-start)+"ms"); 93 } catch (IOException ex) { 94 assertTrue("Should not be here", false); 96 } 97 98 assertEquals("global complex types",2,getSchemaModel().getSchema().getComplexTypes().size()); 100 assertEquals("global simple types",5,getSchemaModel().getSchema().getSimpleTypes().size()); 101 assertEquals("global elements",2,getSchemaModel().getSchema().getElements().size()); 102 103 try { 105 long start = System.currentTimeMillis(); 106 SchemaGeneratorFactory.getDefault().transformSchema( 107 axiModel.getSchemaModel(), SchemaGenerator.Pattern.SALAMI_SLICE); 108 long end = System.currentTimeMillis(); 109 print("Time taken to transform from VB to SS: "+(end-start)+"ms"); 110 } catch (IOException ex) { 111 assertTrue("Should not be here", false); 113 } 114 115 assertEquals("global complex types",0,getSchemaModel().getSchema().getComplexTypes().size()); 117 assertEquals("global simple types",0,getSchemaModel().getSchema().getSimpleTypes().size()); 118 assertEquals("global elements",9,getSchemaModel().getSchema().getElements().size()); 119 120 try { 122 long start = System.currentTimeMillis(); 123 SchemaGeneratorFactory.getDefault().transformSchema( 124 axiModel.getSchemaModel(), SchemaGenerator.Pattern.VENITIAN_BLIND); 125 long end = System.currentTimeMillis(); 126 print("Time taken to transform from SS to VB: "+(end-start)+"ms"); 127 } catch (IOException ex) { 128 assertTrue("Should not be here", false); 130 } 131 132 assertEquals("global complex types",2,getSchemaModel().getSchema().getComplexTypes().size()); 134 assertEquals("global simple types",5,getSchemaModel().getSchema().getSimpleTypes().size()); 135 assertEquals("global elements",2,getSchemaModel().getSchema().getElements().size()); 136 137 138 try { 140 long start = System.currentTimeMillis(); 141 SchemaGeneratorFactory.getDefault().transformSchema( 142 axiModel.getSchemaModel(), SchemaGenerator.Pattern.GARDEN_OF_EDEN); 143 long end = System.currentTimeMillis(); 144 print("Time taken to transform from VB to GE: "+(end-start)+"ms"); 145 } catch (IOException ex) { 146 assertTrue("Should not be here", false); 148 } 149 150 assertEquals("global complex types",2,getSchemaModel().getSchema().getComplexTypes().size()); 152 assertEquals("global simple types",5,getSchemaModel().getSchema().getSimpleTypes().size()); 153 assertEquals("global elements",9,getSchemaModel().getSchema().getElements().size()); 154 155 try { 157 long start = System.currentTimeMillis(); 158 SchemaGeneratorFactory.getDefault().transformSchema( 159 axiModel.getSchemaModel(), SchemaGenerator.Pattern.VENITIAN_BLIND); 160 long end = System.currentTimeMillis(); 161 print("Time taken to transform from GE to VB: "+(end-start)+"ms"); 162 } catch (IOException ex) { 163 assertTrue("Should not be here", false); 165 } 166 167 assertEquals("global complex types",2,getSchemaModel().getSchema().getComplexTypes().size()); 169 assertEquals("global simple types",5,getSchemaModel().getSchema().getSimpleTypes().size()); 170 assertEquals("global elements",2,getSchemaModel().getSchema().getElements().size()); 171 } 172 173 private void printDocument() { 174 try { 175 SchemaModel sm = getSchemaModel(); 176 doc = ((AbstractDocumentModel)sm).getBaseDocument(); 177 print("doc: "+doc.getText(0, doc.getLength())); 178 } catch (BadLocationException ex) { 179 assertTrue("Should not be here", false); 181 } 182 } 183 184 } 185 | Popular Tags |