KickJava   Java API By Example, From Geeks To Geeks.

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


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.AssertionStatusReport;
22 import org.apache.juddi.datatype.response.CompletionStatus;
23 import org.apache.juddi.datatype.response.KeysOwned;
24 import org.apache.juddi.util.xml.XMLUtils;
25 import org.w3c.dom.Element JavaDoc;
26
27 /**
28  * @author anou_mana@apache.org
29  */

30 public class AssertionStatusReportHandlerTests extends HandlerTestCase
31 {
32     private static final String JavaDoc TEST_ID = "juddi.handler.AssertionStatusReport.test";
33     private AssertionStatusReportHandler handler = null;
34
35   public AssertionStatusReportHandlerTests(String JavaDoc arg0)
36   {
37     super(arg0);
38   }
39
40   public static void main(String JavaDoc[] args)
41   {
42     junit.textui.TestRunner.run(AssertionStatusReportHandlerTests.class);
43   }
44
45   public void setUp()
46   {
47         HandlerMaker maker = HandlerMaker.getInstance();
48         handler = (AssertionStatusReportHandler)maker.lookup(AssertionStatusReportHandler.TAG_NAME);
49   }
50
51     private RegistryObject getRegistryObject()
52     {
53
54         KeysOwned keysOwned = new KeysOwned();
55         keysOwned.setFromKey("fe8af00d-3a2c-4e05-b7ca-95a1259aad4f");
56         keysOwned.setToKey("dfddb58c-4853-4a71-865c-f84509017cc7");
57
58         AssertionStatusItem item = new AssertionStatusItem();
59         item.setFromKey("986d9a16-5d4d-46cf-9fac-6bb80a7091f6");
60         item.setToKey("dd45a24c-74fc-4e82-80c2-f99cdc76d681");
61         item.setKeyedReference(new KeyedReference("uuid:8ff45356-acde-4a4c-86bf-f953611d20c6","Subsidiary","1"));
62         item.setCompletionStatus(new CompletionStatus(CompletionStatus.COMPLETE));
63         item.setKeysOwned(keysOwned);
64
65         AssertionStatusReport object = new AssertionStatusReport();
66         object.setGeneric("2.0");
67         object.setOperator("jUDDI.org");
68         object.addAssertionStatusItem(item);
69         object.addAssertionStatusItem(item);
70
71         return object;
72
73     }
74
75     private Element JavaDoc getMarshalledElement(RegistryObject regObject)
76     {
77         Element JavaDoc parent = XMLUtils.newRootElement();
78         Element JavaDoc child = null;
79
80         if(regObject == null)
81             regObject = this.getRegistryObject();
82
83         handler.marshal(regObject,parent);
84         child = (Element JavaDoc)parent.getFirstChild();
85         parent.removeChild(child);
86
87         return child;
88     }
89
90     public void testMarshal()
91     {
92         Element JavaDoc child = getMarshalledElement(null);
93
94         String JavaDoc marshalledString = this.getXMLString(child);
95
96         assertNotNull("Marshalled AssertionStatusReport ", marshalledString);
97
98     }
99
100     public void testUnMarshal()
101     {
102
103         Element JavaDoc child = getMarshalledElement(null);
104         RegistryObject regObject = handler.unmarshal(child);
105
106         assertNotNull("UnMarshalled AssertionStatusReport ", regObject);
107
108     }
109
110   public void testMarshUnMarshal()
111   {
112         Element JavaDoc child = getMarshalledElement(null);
113
114         String JavaDoc marshalledString = this.getXMLString(child);
115
116         assertNotNull("Marshalled AssertionStatusReport ", marshalledString);
117
118         RegistryObject regObject = handler.unmarshal(child);
119
120         child = getMarshalledElement(regObject);
121
122         String JavaDoc unMarshalledString = this.getXMLString(child);
123
124         assertNotNull("Unmarshalled AssertionStatusReport ", unMarshalledString);
125
126         boolean equals = marshalledString.equals(unMarshalledString);
127
128         assertEquals("Expected result: ", marshalledString, unMarshalledString );
129   }
130
131 }
132
Popular Tags