001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)TestRegistrationInfo.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.binding.proxy;
030:
031: import javax.jbi.servicedesc.ServiceEndpoint;
032:
033: import javax.xml.namespace.QName;
034:
035: /**
036: * Tests for the InstanceEntry class
037: *
038: * @author Sun Microsystems, Inc.
039: */
040: public class TestRegistrationInfo extends junit.framework.TestCase {
041: /**
042: * The constructor for this testcase, forwards the test name to
043: * the jUnit TestCase base class.
044: * @param aTestName String with the name of this test.
045: */
046: public TestRegistrationInfo(String aTestName) {
047: super (aTestName);
048: }
049:
050: /**
051: * Setup for the test. This creates the ComponentRegistry instance
052: * and other objects needed for the tests.
053: * @throws Exception when set up fails for any reason.
054: */
055: public void setUp() throws Exception {
056: super .setUp();
057: }
058:
059: /**
060: * Cleanup for the test.
061: * @throws Exception when tearDown fails for any reason.
062: */
063: public void tearDown() throws Exception {
064: super .tearDown();
065: }
066:
067: // ============================= test methods ================================
068:
069: /**
070: * testGetters
071: * @throws Exception if an unexpected error occurs
072: */
073: public void testGetters() throws Exception {
074: QName sn;
075: ServiceEndpoint se = new ServiceEndpointImpl(sn = new QName(
076: "service"), "endpoint");
077: RegistrationInfo ri;
078:
079: ri = new RegistrationInfo(se, "i", null, "add");
080: assertEquals(ri.getInstanceId(), "i");
081: assertEquals(ri.getEndpointName(), "endpoint");
082: assertEquals(ri.getServiceName(), sn);
083: assertEquals(ri.getClassLoader(), null);
084: assertEquals(ri.getAction(), "add");
085: }
086:
087: /**
088: * testHashCode
089: * @throws Exception if an unexpected error occurs
090: */
091: public void testHashCode() throws Exception {
092: QName sn = new QName("service");
093: QName sn2 = new QName("service", "uri");
094: String e = "endpoint";
095: String e2 = "endpoint2";
096:
097: ServiceEndpoint se = new ServiceEndpointImpl(sn, e);
098: ServiceEndpoint se2 = new ServiceEndpointImpl(sn2, e);
099: ServiceEndpoint se3 = new ServiceEndpointImpl(sn, e2);
100: ServiceEndpoint se4 = new ServiceEndpointImpl(sn2, e2);
101: RegistrationInfo ria = new RegistrationInfo(se, "i", null,
102: "add");
103: RegistrationInfo rib = new RegistrationInfo(se, "i", null,
104: "add");
105: RegistrationInfo ria2 = new RegistrationInfo(se2, "i", null,
106: "add");
107: RegistrationInfo rib2 = new RegistrationInfo(se2, "i", null,
108: "add");
109: RegistrationInfo ria3 = new RegistrationInfo(se3, "i", null,
110: "add");
111: RegistrationInfo rib3 = new RegistrationInfo(se3, "i", null,
112: "add");
113: RegistrationInfo ria4 = new RegistrationInfo(se4, "i", null,
114: "add");
115: RegistrationInfo rib4 = new RegistrationInfo(se4, "i", null,
116: "add");
117:
118: assertEquals(ria.hashCode(), rib.hashCode());
119: assertEquals(ria2.hashCode(), rib2.hashCode());
120: assertEquals(ria3.hashCode(), rib3.hashCode());
121: assertEquals(ria4.hashCode(), rib4.hashCode());
122: }
123:
124: /**
125: * testEquals
126: * @throws Exception if an unexpected error occurs
127: */
128: public void testEquals() throws Exception {
129: QName sn = new QName("service");
130: QName sn2 = new QName("service", "uri");
131: String e = "endpoint";
132: String e2 = "endpoint2";
133:
134: ServiceEndpoint se = new ServiceEndpointImpl(sn, e);
135: ServiceEndpoint se2 = new ServiceEndpointImpl(sn2, e);
136: ServiceEndpoint se3 = new ServiceEndpointImpl(sn, e2);
137: ServiceEndpoint se4 = new ServiceEndpointImpl(sn2, e2);
138: RegistrationInfo ria = new RegistrationInfo(se, "i", null,
139: "add");
140: RegistrationInfo rib = new RegistrationInfo(se, "i", null,
141: "add");
142: RegistrationInfo ria2 = new RegistrationInfo(se2, "i", null,
143: "add");
144: RegistrationInfo rib2 = new RegistrationInfo(se2, "i", null,
145: "add");
146: RegistrationInfo ria3 = new RegistrationInfo(se3, "i", null,
147: "add");
148: RegistrationInfo rib3 = new RegistrationInfo(se3, "i", null,
149: "add");
150: RegistrationInfo ria4 = new RegistrationInfo(se4, "i", null,
151: "add");
152: RegistrationInfo rib4 = new RegistrationInfo(se4, "i", null,
153: "add");
154:
155: assertTrue(ria.equals(rib));
156: assertTrue(rib.equals(ria));
157: assertTrue(ria2.equals(rib2));
158: assertTrue(rib2.equals(ria2));
159: assertTrue(ria3.equals(rib3));
160: assertTrue(rib3.equals(ria3));
161: assertTrue(ria4.equals(rib4));
162: assertTrue(rib4.equals(ria4));
163: }
164: }
|