1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.datatype.KeyedReference; 19 import org.apache.juddi.datatype.RegistryObject; 20 import org.apache.juddi.datatype.response.AssertionStatusItem; 21 import org.apache.juddi.datatype.response.AssertionStatusReport; 22 import org.apache.juddi.datatype.response.CompletionStatus; 23 import org.apache.juddi.datatype.response.KeysOwned; 24 import org.apache.juddi.util.xml.XMLUtils; 25 import org.w3c.dom.Element ; 26 27 30 public class AssertionStatusReportHandlerTests extends HandlerTestCase 31 { 32 private static final String TEST_ID = "juddi.handler.AssertionStatusReport.test"; 33 private AssertionStatusReportHandler handler = null; 34 35 public AssertionStatusReportHandlerTests(String arg0) 36 { 37 super(arg0); 38 } 39 40 public static void main(String [] args) 41 { 42 junit.textui.TestRunner.run(AssertionStatusReportHandlerTests.class); 43 } 44 45 public void setUp() 46 { 47 HandlerMaker maker = HandlerMaker.getInstance(); 48 handler = (AssertionStatusReportHandler)maker.lookup(AssertionStatusReportHandler.TAG_NAME); 49 } 50 51 private RegistryObject getRegistryObject() 52 { 53 54 KeysOwned keysOwned = new KeysOwned(); 55 keysOwned.setFromKey("fe8af00d-3a2c-4e05-b7ca-95a1259aad4f"); 56 keysOwned.setToKey("dfddb58c-4853-4a71-865c-f84509017cc7"); 57 58 AssertionStatusItem item = new AssertionStatusItem(); 59 item.setFromKey("986d9a16-5d4d-46cf-9fac-6bb80a7091f6"); 60 item.setToKey("dd45a24c-74fc-4e82-80c2-f99cdc76d681"); 61 item.setKeyedReference(new KeyedReference("uuid:8ff45356-acde-4a4c-86bf-f953611d20c6","Subsidiary","1")); 62 item.setCompletionStatus(new CompletionStatus(CompletionStatus.COMPLETE)); 63 item.setKeysOwned(keysOwned); 64 65 AssertionStatusReport object = new AssertionStatusReport(); 66 object.setGeneric("2.0"); 67 object.setOperator("jUDDI.org"); 68 object.addAssertionStatusItem(item); 69 object.addAssertionStatusItem(item); 70 71 return object; 72 73 } 74 75 private Element getMarshalledElement(RegistryObject regObject) 76 { 77 Element parent = XMLUtils.newRootElement(); 78 Element child = null; 79 80 if(regObject == null) 81 regObject = this.getRegistryObject(); 82 83 handler.marshal(regObject,parent); 84 child = (Element )parent.getFirstChild(); 85 parent.removeChild(child); 86 87 return child; 88 } 89 90 public void testMarshal() 91 { 92 Element child = getMarshalledElement(null); 93 94 String marshalledString = this.getXMLString(child); 95 96 assertNotNull("Marshalled AssertionStatusReport ", marshalledString); 97 98 } 99 100 public void testUnMarshal() 101 { 102 103 Element child = getMarshalledElement(null); 104 RegistryObject regObject = handler.unmarshal(child); 105 106 assertNotNull("UnMarshalled AssertionStatusReport ", regObject); 107 108 } 109 110 public void testMarshUnMarshal() 111 { 112 Element child = getMarshalledElement(null); 113 114 String marshalledString = this.getXMLString(child); 115 116 assertNotNull("Marshalled AssertionStatusReport ", marshalledString); 117 118 RegistryObject regObject = handler.unmarshal(child); 119 120 child = getMarshalledElement(regObject); 121 122 String unMarshalledString = this.getXMLString(child); 123 124 assertNotNull("Unmarshalled AssertionStatusReport ", unMarshalledString); 125 126 boolean equals = marshalledString.equals(unMarshalledString); 127 128 assertEquals("Expected result: ", marshalledString, unMarshalledString ); 129 } 130 131 } 132 | Popular Tags |