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