1 16 package org.apache.juddi.handler; 17 18 import org.apache.juddi.datatype.RegistryObject; 19 import org.apache.juddi.datatype.assertion.PublisherAssertion; 20 import org.apache.juddi.datatype.request.AddPublisherAssertions; 21 import org.apache.juddi.datatype.request.AuthInfo; 22 import org.apache.juddi.util.xml.XMLUtils; 23 import org.w3c.dom.Element ; 24 25 28 public class AddPublisherAssertionsHandlerTests extends HandlerTestCase 29 { 30 private static final String TEST_ID = "juddi.handler.addpublisherassertionhandler.test"; 31 private AddPublisherAssertionsHandler handler = null; 32 33 public AddPublisherAssertionsHandlerTests(String arg0) 34 { 35 super(arg0); 36 } 37 38 public static void main(String [] args) 39 { 40 junit.textui.TestRunner.run(AddPublisherAssertionsHandlerTests.class); 41 } 42 43 public void setUp() 44 { 45 HandlerMaker maker = HandlerMaker.getInstance(); 46 handler = (AddPublisherAssertionsHandler)maker.lookup(AddPublisherAssertionsHandler.TAG_NAME); 47 } 48 49 private RegistryObject getRegistryObject() 50 { 51 52 AuthInfo authInfo = new AuthInfo(); 53 authInfo.setValue("6f157513-844e-4a95-a856-d257e6ba9726"); 54 55 PublisherAssertion assertion = new PublisherAssertion(); 56 assertion.setFromKey("3379ec11-a509-4668-9fee-19b134d0d09b"); 57 assertion.setToKey("3379ec11-a509-4668-9fee-19b134d0d09b"); 58 assertion.setKeyName("paKeyName"); 59 assertion.setKeyValue("paKeyValue"); 60 assertion.setTModelKey("uuid:3379ec11-a509-4668-9fee-19b134d0d09b"); 61 62 AddPublisherAssertions object = new AddPublisherAssertions(); 63 object.setAuthInfo(authInfo); 64 object.addPublisherAssertion(assertion); 65 object.addPublisherAssertion(assertion); 66 67 return object; 68 69 } 70 71 private Element getMarshalledElement(RegistryObject regObject) 72 { 73 Element parent = XMLUtils.newRootElement(); 74 Element child = null; 75 76 if(regObject == null) 77 regObject = this.getRegistryObject(); 78 79 handler.marshal(regObject,parent); 80 child = (Element )parent.getFirstChild(); 81 parent.removeChild(child); 82 83 return child; 84 } 85 86 public void testMarshal() 87 { 88 Element child = getMarshalledElement(null); 89 90 String marshalledString = this.getXMLString(child); 91 92 assertNotNull("Marshalled AddPublisherAssertions ", marshalledString); 93 94 } 95 96 public void testUnMarshal() 97 { 98 99 Element child = getMarshalledElement(null); 100 RegistryObject regObject = handler.unmarshal(child); 101 102 assertNotNull("UnMarshalled AddPublisherAssertions ", regObject); 103 104 } 105 106 public void testMarshUnMarshal() 107 { 108 Element child = getMarshalledElement(null); 109 110 String marshalledString = this.getXMLString(child); 111 112 assertNotNull("Marshalled AddPublisherAssertions ", marshalledString); 113 114 RegistryObject regObject = handler.unmarshal(child); 115 116 child = getMarshalledElement(regObject); 117 118 String unMarshalledString = this.getXMLString(child); 119 120 assertNotNull("Unmarshalled AddPublisherAssertions ", unMarshalledString); 121 122 boolean equals = marshalledString.equals(unMarshalledString); 123 124 assertEquals("Expected result: ", marshalledString, unMarshalledString ); 125 } 126 127 } 128 | Popular Tags |