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