KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > juddi > handler > DeletePublisherHandlerTests


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.juddi.handler;
17
18 import org.apache.juddi.datatype.RegistryObject;
19 import org.apache.juddi.datatype.publisher.PublisherID;
20 import org.apache.juddi.datatype.request.AuthInfo;
21 import org.apache.juddi.datatype.request.DeletePublisher;
22 import org.apache.juddi.util.xml.XMLUtils;
23 import org.w3c.dom.Element JavaDoc;
24
25 /**
26  * @author anou_mana@apache.org
27  */

28 public class DeletePublisherHandlerTests extends HandlerTestCase
29 {
30     private static final String JavaDoc TEST_ID = "juddi.handler.DeletePublisher.test";
31     private DeletePublisherHandler handler = null;
32
33   public DeletePublisherHandlerTests(String JavaDoc arg0)
34   {
35     super(arg0);
36   }
37
38   public static void main(String JavaDoc[] args)
39   {
40     junit.textui.TestRunner.run(DeletePublisherHandlerTests.class);
41   }
42
43   public void setUp()
44   {
45         HandlerMaker maker = HandlerMaker.getInstance();
46         handler = (DeletePublisherHandler)maker.lookup(DeletePublisherHandler.TAG_NAME);
47   }
48
49     private RegistryObject getRegistryObject()
50     {
51         AuthInfo authInfo = new AuthInfo();
52         authInfo.setValue("6f157513-844e-4a95-a856-d257e6ba9726");
53
54         DeletePublisher object = new DeletePublisher();
55         object.setAuthInfo(authInfo);
56         object.addPublisherID(new PublisherID("jdoe"));
57         object.addPublisherID(new PublisherID("bpope"));
58         object.addPublisherID(new PublisherID("sviens"));
59
60         return object;
61
62     }
63
64     private Element JavaDoc getMarshalledElement(RegistryObject regObject)
65     {
66         Element JavaDoc parent = XMLUtils.newRootElement();
67         Element JavaDoc child = null;
68
69         if(regObject == null)
70             regObject = this.getRegistryObject();
71
72         handler.marshal(regObject,parent);
73         child = (Element JavaDoc)parent.getFirstChild();
74         parent.removeChild(child);
75
76         return child;
77     }
78
79     public void testMarshal()
80     {
81         Element JavaDoc child = getMarshalledElement(null);
82
83         String JavaDoc marshalledString = this.getXMLString(child);
84
85         assertNotNull("Marshalled DeletePublisher ", marshalledString);
86
87     }
88
89     public void testUnMarshal()
90     {
91
92         Element JavaDoc child = getMarshalledElement(null);
93         RegistryObject regObject = handler.unmarshal(child);
94
95         assertNotNull("UnMarshalled DeletePublisher ", regObject);
96
97     }
98
99   public void testMarshUnMarshal()
100   {
101         Element JavaDoc child = getMarshalledElement(null);
102
103         String JavaDoc marshalledString = this.getXMLString(child);
104
105         assertNotNull("Marshalled DeletePublisher ", marshalledString);
106
107         RegistryObject regObject = handler.unmarshal(child);
108
109         child = getMarshalledElement(regObject);
110
111         String JavaDoc unMarshalledString = this.getXMLString(child);
112
113         assertNotNull("Unmarshalled DeletePublisher ", unMarshalledString);
114
115         boolean equals = marshalledString.equals(unMarshalledString);
116
117         assertEquals("Expected result: ", marshalledString, unMarshalledString );
118   }
119
120 }
121
Popular Tags