1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.datatype.CategoryBag; 19 import org.apache.juddi.datatype.Description; 20 import org.apache.juddi.datatype.IdentifierBag; 21 import org.apache.juddi.datatype.KeyedReference; 22 import org.apache.juddi.datatype.OverviewDoc; 23 import org.apache.juddi.datatype.RegistryObject; 24 import org.apache.juddi.datatype.UploadRegister; 25 import org.apache.juddi.datatype.request.AuthInfo; 26 import org.apache.juddi.datatype.request.SaveTModel; 27 import org.apache.juddi.datatype.tmodel.TModel; 28 import org.apache.juddi.util.xml.XMLUtils; 29 import org.w3c.dom.Element ; 30 31 34 public class SaveTModelHandlerTests extends HandlerTestCase 35 { 36 private static final String TEST_ID = "juddi.handler.DeleteSaveTModel.test"; 37 private SaveTModelHandler handler = null; 38 39 public SaveTModelHandlerTests(String arg0) 40 { 41 super(arg0); 42 } 43 44 public static void main(String [] args) 45 { 46 junit.textui.TestRunner.run( SaveTModelHandlerTests.class); 47 } 48 49 public void setUp() 50 { 51 HandlerMaker maker = HandlerMaker.getInstance(); 52 handler = ( SaveTModelHandler)maker.lookup( SaveTModelHandler.TAG_NAME); 53 } 54 55 private RegistryObject getRegistryObject() 56 { 57 AuthInfo authInfo = new AuthInfo(); 58 authInfo.setValue("6f157513-844e-4a95-a856-d257e6ba9726"); 59 60 OverviewDoc overDoc = new OverviewDoc(); 61 overDoc.setOverviewURL("http://www.juddi.org/service.html"); 62 overDoc.addDescription(new Description("over-doc Descr")); 63 overDoc.addDescription(new Description("over-doc Descr Two","en")); 64 65 CategoryBag catBag = new CategoryBag(); 66 catBag.addKeyedReference(new KeyedReference("catBagKeyName","catBagKeyValue")); 67 catBag.addKeyedReference(new KeyedReference("uuid:dfddb58c-4853-4a71-865c-f84509017cc7","catBagKeyName2","catBagKeyValue2")); 68 69 IdentifierBag idBag = new IdentifierBag(); 70 idBag.addKeyedReference(new KeyedReference("idBagKeyName","idBagkeyValue")); 71 idBag.addKeyedReference(new KeyedReference("uuid:f78a135a-4769-4e79-8604-54d440314bc0","idBagKeyName2","idBagkeyValue2")); 72 73 TModel tModel = new TModel(); 74 tModel.setTModelKey("uuid:269855db-62eb-4862-8e5a-1b06f2753038"); 75 tModel.setOperator("jUDDI"); 76 tModel.setAuthorizedName("Guest"); 77 tModel.setName("jUDDI TModel"); 78 tModel.addDescription(new Description("tModel whatever")); 79 tModel.addDescription(new Description("tModel whatever too","fr")); 80 tModel.setCategoryBag(catBag); 81 tModel.setIdentifierBag(idBag); 82 tModel.setOverviewDoc(overDoc); 83 84 SaveTModel object = new SaveTModel(); 85 object.setAuthInfo(authInfo); 86 object.addTModel(tModel); 87 object.addTModel(tModel); 88 object.addUploadRegister(new UploadRegister("http://www.juddi.org/businessEntity.xml")); 89 object.addUploadRegister(new UploadRegister("http://www.sourceforge.net/businessService.xml")); 90 object.addUploadRegister(new UploadRegister("http://www.uddi.org/bindingTemplate.xml")); 91 92 return object; 93 94 } 95 96 private Element getMarshalledElement(RegistryObject regObject) 97 { 98 Element parent = XMLUtils.newRootElement(); 99 Element child = null; 100 101 if(regObject == null) 102 regObject = this.getRegistryObject(); 103 104 handler.marshal(regObject,parent); 105 child = (Element )parent.getFirstChild(); 106 parent.removeChild(child); 107 108 return child; 109 } 110 111 public void testMarshal() 112 { 113 Element child = getMarshalledElement(null); 114 115 String marshalledString = this.getXMLString(child); 116 117 assertNotNull("Marshalled SaveTModel ", marshalledString); 118 119 } 120 121 public void testUnMarshal() 122 { 123 124 Element child = getMarshalledElement(null); 125 RegistryObject regObject = handler.unmarshal(child); 126 127 assertNotNull("UnMarshalled SaveTModel ", regObject); 128 129 } 130 131 public void testMarshUnMarshal() 132 { 133 Element child = getMarshalledElement(null); 134 135 String marshalledString = this.getXMLString(child); 136 137 assertNotNull("Marshalled SaveTModel ", marshalledString); 138 139 RegistryObject regObject = handler.unmarshal(child); 140 141 child = getMarshalledElement(regObject); 142 143 String unMarshalledString = this.getXMLString(child); 144 145 assertNotNull("Unmarshalled SaveTModel ", unMarshalledString); 146 147 boolean equals = marshalledString.equals(unMarshalledString); 148 149 assertEquals("Expected SaveTModel: ", marshalledString, unMarshalledString ); 150 } 151 152 } 153 | Popular Tags |