1 19 20 package org.netbeans.modules.xml.wsdl.model.extensions.bpel; 21 22 import java.util.ArrayList ; 23 import junit.framework.*; 24 import org.netbeans.modules.xml.wsdl.model.*; 25 import org.netbeans.modules.xml.wsdl.model.extensions.NamespaceLocation; 26 import org.netbeans.modules.xml.wsdl.model.extensions.TestCatalogModel; 27 import org.netbeans.modules.xml.wsdl.model.extensions.bpel.impl.CorrelationPropertyImpl; 28 import org.netbeans.modules.xml.wsdl.model.extensions.bpel.impl.DocumentationImpl; 29 import org.netbeans.modules.xml.wsdl.model.extensions.bpel.impl.QueryImpl; 30 31 35 public class ComponentUpdaterTest extends TestCase { 36 private WSDLModel model; 37 private Definitions definitions; 38 39 public ComponentUpdaterTest(String testName) { 40 super(testName); 41 } 42 43 protected void setUp() throws Exception { 44 } 45 46 protected void tearDown() throws Exception { 47 TestCatalogModel.getDefault().clearDocumentPool(); 48 } 49 50 public static Test suite() { 51 TestSuite suite = new TestSuite(ComponentUpdaterTest.class); 52 return suite; 53 } 54 55 public void testRemoveAll_Travel() throws Exception { 56 model = TestCatalogModel.getDefault().getWSDLModel(NamespaceLocation.TRAVEL); 57 definitions = model.getDefinitions(); 58 } 59 60 public void testRemoveAll_Airline() throws Exception { 61 model = TestCatalogModel.getDefault().getWSDLModel(NamespaceLocation.AIRLINE); 62 definitions = model.getDefinitions(); 63 } 64 65 public void testRemoveAll_Hotel() throws Exception { 66 model = TestCatalogModel.getDefault().getWSDLModel(NamespaceLocation.HOTEL); 67 definitions = model.getDefinitions(); 68 } 69 70 public void testRemoveAll_Vehicle() throws Exception { 71 model = TestCatalogModel.getDefault().getWSDLModel(NamespaceLocation.VEHICLE); 72 definitions = model.getDefinitions(); 73 } 74 75 static void checkRemoveAll(WSDLComponent target) throws Exception { 76 target.getModel().startTransaction(); 77 recursiveRemoveChildren(target); 78 assertEquals("children removed", 0, target.getChildren().size()); 79 target.getModel().endTransaction(); 80 } 81 82 static void recursiveRemoveChildren(WSDLComponent target) { 83 WSDLModel model = target.getModel(); 84 ArrayList <WSDLComponent> children = new ArrayList <WSDLComponent>(target.getChildren()); 85 for (WSDLComponent child : children) { 86 recursiveRemoveChildren(child); 87 } 88 if (target.getParent() != null) { 89 model.removeChildComponent(target); 90 } 91 } 92 93 public void NO_testCanPasteAll_Travel() throws Exception { 94 model = TestCatalogModel.getDefault().getWSDLModel(NamespaceLocation.TRAVEL); 95 recursiveCanPasteChildren(model.getDefinitions()); 96 recursiveCannotPasteChildren(model.getDefinitions()); 97 } 98 99 public void testCanNotPaste_Airline() throws Exception { 100 model = TestCatalogModel.getDefault().getWSDLModel(NamespaceLocation.AIRLINE); 101 PartnerLinkType plt = model.getDefinitions().getExtensibilityElements(PartnerLinkType.class).get(0); 102 Role role1 = plt.getRole1(); 103 assertFalse(role1.canPaste(plt)); 104 assertFalse(model.getDefinitions().canPaste(new QueryImpl(model))); 105 assertFalse(model.getDefinitions().getTypes().canPaste(new CorrelationPropertyImpl(model))); 106 } 107 108 public void NO_testCanPasteAll_Airline() throws Exception { 109 model = TestCatalogModel.getDefault().getWSDLModel(NamespaceLocation.AIRLINE); 110 recursiveCanPasteChildren(model.getDefinitions()); 111 recursiveCannotPasteChildren(model.getDefinitions()); 112 } 113 114 public void NO_testCanPasteAll_Hotel() throws Exception { 115 model = TestCatalogModel.getDefault().getWSDLModel(NamespaceLocation.HOTEL); 116 recursiveCanPasteChildren(model.getDefinitions()); 117 recursiveCannotPasteChildren(model.getDefinitions()); 118 } 119 120 public void NO_testCanPasteAll_Vehicle() throws Exception { 121 model = TestCatalogModel.getDefault().getWSDLModel(NamespaceLocation.VEHICLE); 122 recursiveCanPasteChildren(model.getDefinitions()); 123 recursiveCannotPasteChildren(model.getDefinitions()); 124 } 125 126 public static void recursiveCanPasteChildren(WSDLComponent target) { 127 WSDLModel model = target.getModel(); 128 ArrayList <WSDLComponent> children = new ArrayList <WSDLComponent>(target.getChildren()); 129 for (WSDLComponent child : children) { 130 recursiveCanPasteChildren(child); 131 } 132 if (target.getParent() != null) { 133 assertTrue(target.getParent().canPaste(target)); 134 } 135 } 136 137 public static void recursiveCannotPasteChildren(WSDLComponent target) { 138 WSDLModel model = target.getModel(); 139 ArrayList <WSDLComponent> children = new ArrayList <WSDLComponent>(target.getChildren()); 140 for (WSDLComponent child : children) { 141 recursiveCannotPasteChildren(child); 142 } 143 if (target.getParent() != null) { 144 String msg = target.getClass().getName() + " canPaste " + target.getParent().getClass().getName(); 145 assertFalse(msg, target.canPaste(target.getParent())); 146 } 147 } 148 } 149 | Popular Tags |