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