001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036:
037: package com.sun.xml.ws.tx.coordinator;
038:
039: import com.sun.corba.se.impl.orbutil.closure.Constant;
040: import com.sun.xml.ws.tx.common.Constants;
041: import com.sun.xml.ws.tx.webservice.member.coord.CoordinationContext;
042: import javax.xml.ws.EndpointReference;
043: import junit.framework.TestCase;
044:
045: /**
046: *
047: * @author Ryan.Shoemaker@Sun.COM
048: */
049: public class CoordinationContextTest extends TestCase {
050:
051: /** Creates a new instance of CoordinationContextTest */
052: public CoordinationContextTest(String testname) {
053: super (testname);
054: }
055:
056: CoordinationContextInterface c;
057:
058: protected void setUp() throws Exception {
059: // create a context to poke with a stick
060: c = ContextFactory.createTestContext(
061: Constants.WSAT_2004_PROTOCOL, 0l);
062: }
063:
064: public void testContextFactory1() throws Exception {
065: ContextFactory.createTestContext(Constants.WSAT_2004_PROTOCOL,
066: 0l);
067: }
068:
069: public void testContextFactory2() throws Exception {
070: try {
071: ContextFactory.createTestContext(
072: Constants.WSAT_OASIS_NSURI, 0l);
073: } catch (UnsupportedOperationException uoe) {
074: return; // pass - expected exception
075: }
076: fail("Was expecting UnsupportedOperationException");
077: }
078:
079: public void testContextType() throws Exception {
080: assertEquals(Constants.WSAT_SOAP_NSURI, c.getCoordinationType());
081: }
082:
083: public void testContextExpiration1() throws Exception {
084: assertEquals(0l, c.getExpires());
085: }
086:
087: public void testContextExpiration2() throws Exception {
088: CoordinationContext200410 c = new CoordinationContext200410();
089: c.setExpires(-1);
090: assert (c.getExpires() == 0l);
091: }
092:
093: public void testContextIdPrefix() throws Exception {
094: assert (c.getIdentifier().startsWith("uuid:WSCOOR-SUN-"));
095: }
096:
097: public void testContextRegServiceEPR() throws Exception {
098: EndpointReference epr = c.getRegistrationService();
099: // TODO: figure out how to assert that the EPR is our registration
100: // service EPR
101: }
102:
103: public void testContextGetAttrs() throws Exception {
104: assert (c.getOtherAttributes().size() == 0); // should initially be empty
105: }
106:
107: public void testContextRootReg() throws Exception {
108: assertNull(c.getRootRegistrationService()); // should initially be null
109: }
110:
111: public void testContextValue() throws Exception {
112: assert (c.getValue() instanceof CoordinationContext200410);
113: }
114:
115: public void testContextSetters() throws Exception {
116: CoordinationContext200410 c = new CoordinationContext200410();
117: c.setIdentifier("foo");
118: c.setExpires(5000);
119: c.setRegistrationService(null);
120: c.setRootCoordinatorRegistrationService(null);
121: }
122:
123: }
|