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