KickJava   Java API By Example, From Geeks To Geeks.

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


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.request.FindQualifier;
20 import org.apache.juddi.util.xml.XMLUtils;
21 import org.w3c.dom.Element JavaDoc;
22
23 /**
24  * @author anou_mana@apache.org
25  */

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