KickJava   Java API By Example, From Geeks To Geeks.

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


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.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 JavaDoc;
25
26 /**
27  * @author anou_mana@apache.org
28  */

29 public class AssertionStatusItemHandlerTests extends HandlerTestCase
30 {
31     private static final String JavaDoc TEST_ID = "juddi.handler.AssertionStatusItem.test";
32     private AssertionStatusItemHandler handler = null;
33
34   public AssertionStatusItemHandlerTests(String JavaDoc arg0)
35   {
36     super(arg0);
37   }
38
39   public static void main(String JavaDoc[] 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 JavaDoc getMarshalledElement(RegistryObject regObject)
69     {
70         Element JavaDoc parent = XMLUtils.newRootElement();
71         Element JavaDoc child = null;
72
73         if(regObject == null)
74             regObject = this.getRegistryObject();
75
76         handler.marshal(regObject,parent);
77         child = (Element JavaDoc)parent.getFirstChild();
78         parent.removeChild(child);
79
80         return child;
81     }
82
83     public void testMarshal()
84     {
85         Element JavaDoc child = getMarshalledElement(null);
86
87         String JavaDoc marshalledString = this.getXMLString(child);
88
89         assertNotNull("Marshalled AssertionStatusItem ", marshalledString);
90
91     }
92
93     public void testUnMarshal()
94     {
95
96         Element JavaDoc 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 JavaDoc child = getMarshalledElement(null);
106
107         String JavaDoc 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 JavaDoc 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