[jboss-svn-commits] JBL Code SVN: r20195 - labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed May 28 09:42:08 EDT 2008
Author: adinn
Date: 2008-05-28 09:42:08 -0400 (Wed, 28 May 2008)
New Revision: 20195
Added:
labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/EnduranceTestCase.java
labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/RegistrationServiceExceptionTestCase.java
Modified:
labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/TestActivationCoordinatorProcessor.java
labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/TestRegistrationCoordinatorProcessor.java
labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/TestSuite.java
Log:
added remaining WS-C unit tests for 1.1 code
Copied: labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/EnduranceTestCase.java (from rev 20019, labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc/tests/junit/EnduranceTestCase.java)
===================================================================
--- labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/EnduranceTestCase.java (rev 0)
+++ labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/EnduranceTestCase.java 2008-05-28 13:42:08 UTC (rev 20195)
@@ -0,0 +1,311 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (c) 2002, 2003, Arjuna Technologies Limited.
+ *
+ * EnduranceTestCase.java
+ */
+
+package com.arjuna.wsc11.tests.junit;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+import javax.xml.ws.addressing.AddressingProperties;
+
+import junit.framework.TestCase;
+
+import com.arjuna.webservices.SoapFault;
+import com.arjuna.webservices.SoapFaultType;
+import com.arjuna.webservices11.SoapFault11;
+import com.arjuna.webservices.stax.URI;
+import com.arjuna.webservices11.wsaddr.AddressingHelper;
+import com.arjuna.webservices11.wsarj.ArjunaContext;
+import com.arjuna.webservices11.wscoor.CoordinationConstants;
+import com.arjuna.webservices11.wscoor.client.ActivationCoordinatorClient;
+import com.arjuna.webservices11.wscoor.processors.ActivationCoordinatorProcessor;
+import com.arjuna.webservices11.wscoor.processors.RegistrationCoordinatorProcessor;
+import com.arjuna.wsc.tests.TestUtil;
+import com.arjuna.wsc.*;
+import com.arjuna.wsc11.tests.TestUtil11;
+import com.arjuna.wsc11.tests.junit.TestActivationCoordinatorProcessor.CreateCoordinationContextDetails;
+import com.arjuna.wsc11.tests.junit.TestRegistrationCoordinatorProcessor.RegisterDetails;
+import com.arjuna.wsc11.tests.junit.TestActivationCoordinatorProcessor;
+import com.arjuna.wsc11.tests.junit.TestRegistrationCoordinatorProcessor;
+import com.arjuna.wsc11.ActivationCoordinator;
+import com.arjuna.wsc11.RegistrationCoordinator;
+import org.oasis_open.docs.ws_tx.wscoor._2006._06.*;
+
+public class EnduranceTestCase extends TestCase
+{
+ private ActivationCoordinatorProcessor origActivationCoordinatorProcessor ;
+ private RegistrationCoordinatorProcessor origRegistrationCoordinatorProcessor ;
+
+ private TestActivationCoordinatorProcessor testActivationCoordinatorProcessor = new TestActivationCoordinatorProcessor() ;
+
+ private TestRegistrationCoordinatorProcessor testRegistrationCoordinatorProcessor = new TestRegistrationCoordinatorProcessor() ;
+
+ private static final long TEST_DURATION = 30 * 1000;
+
+ protected void setUp()
+ throws Exception
+ {
+ origActivationCoordinatorProcessor = ActivationCoordinatorProcessor.setCoordinator(testActivationCoordinatorProcessor) ;
+
+ origRegistrationCoordinatorProcessor = RegistrationCoordinatorProcessor.setCoordinator(testRegistrationCoordinatorProcessor) ;
+ }
+
+ public void testCreateCoordinationContextRequest()
+ throws Exception
+ {
+ long startTime = System.currentTimeMillis();
+
+ int dialogIdentifierNumber = 0;
+ while ((System.currentTimeMillis() - startTime) < TEST_DURATION)
+ {
+ doCreateCoordinationContextRequest(Integer.toString(dialogIdentifierNumber));
+ dialogIdentifierNumber++;
+ }
+ }
+
+ public void testCreateCoordinationContextError()
+ throws Exception
+ {
+ long startTime = System.currentTimeMillis();
+
+ int dialogIdentifierNumber = 0;
+ while ((System.currentTimeMillis() - startTime) < TEST_DURATION)
+ {
+ doCreateCoordinationContextError(Integer.toString(dialogIdentifierNumber));
+ dialogIdentifierNumber++;
+ }
+ }
+
+ public void testRegisterRequest()
+ throws Exception
+ {
+ long startTime = System.currentTimeMillis();
+
+ int dialogIdentifierNumber = 0;
+ while ((System.currentTimeMillis() - startTime) < TEST_DURATION)
+ {
+ doRegisterRequest(Integer.toString(dialogIdentifierNumber));
+ dialogIdentifierNumber++;
+ }
+ }
+
+ public void testRegisterError()
+ throws Exception
+ {
+ long startTime = System.currentTimeMillis();
+
+ int dialogIdentifierNumber = 0;
+ while ((System.currentTimeMillis() - startTime) < TEST_DURATION)
+ {
+ doRegisterError(Integer.toString(dialogIdentifierNumber), dialogIdentifierNumber % 3);
+ dialogIdentifierNumber++;
+ }
+ }
+
+ public void testEachInTurn()
+ throws Exception
+ {
+ long startTime = System.currentTimeMillis();
+
+ int count = 0;
+ int dialogIdentifierNumber = 0;
+ while ((System.currentTimeMillis() - startTime) < TEST_DURATION)
+ {
+ if (count == 0)
+ doCreateCoordinationContextRequest(Integer.toString(dialogIdentifierNumber));
+ else if (count == 1)
+ doCreateCoordinationContextError(Integer.toString(dialogIdentifierNumber));
+ else if (count == 2)
+ doRegisterRequest(Integer.toString(dialogIdentifierNumber));
+ else
+ doRegisterError(Integer.toString(dialogIdentifierNumber), (dialogIdentifierNumber / 4) % 4);
+
+ count = (count + 1) % 4;
+ dialogIdentifierNumber++;
+ }
+ }
+
+ public void doCreateCoordinationContextRequest(final String messageId)
+ throws Exception
+ {
+ final String coordinationType = TestUtil.COORDINATION_TYPE ;
+ final AddressingProperties addressingProperties = AddressingHelper.createRequestContext(TestUtil11.activationCoordinatorService, messageId) ;
+ CreateCoordinationContextResponseType response =
+ ActivationCoordinatorClient.getClient().sendCreateCoordination(addressingProperties, coordinationType, null, null) ;
+
+ final CreateCoordinationContextDetails details = testActivationCoordinatorProcessor.getCreateCoordinationContextDetails(messageId, 10000) ;
+ final CreateCoordinationContextType requestCreateCoordinationContext = details.getCreateCoordinationContext() ;
+ final AddressingProperties requestAddressingProperties = details.getAddressingProperties() ;
+
+ assertEquals(requestAddressingProperties.getTo().getURI().toString(), TestUtil11.activationCoordinatorService);
+ assertEquals(requestAddressingProperties.getMessageID().getURI().toString(), messageId);
+
+ assertNull(requestCreateCoordinationContext.getExpires()) ;
+ assertNull(requestCreateCoordinationContext.getCurrentContext()) ;
+ assertEquals(requestCreateCoordinationContext.getCoordinationType(), coordinationType);
+
+ CoordinationContext context = response.getCoordinationContext();
+ assertNotNull(context);
+ assertNull(context.getExpires());
+ assertEquals(context.getCoordinationType(), coordinationType);
+ assertNotNull(context.getIdentifier());
+ }
+
+ public void doCreateCoordinationContextError(final String messageId)
+ throws Exception
+ {
+ final String coordinationType = TestUtil.INVALID_CREATE_PARAMETERS_COORDINATION_TYPE;
+ try {
+ ActivationCoordinator.createCoordinationContext(TestUtil11.activationCoordinatorService, messageId, coordinationType, null, null) ;
+ } catch (InvalidCreateParametersException icpe) {
+ final CreateCoordinationContextDetails details = testActivationCoordinatorProcessor.getCreateCoordinationContextDetails(messageId, 10000) ;
+ final CreateCoordinationContextType requestCreateCoordinationContext = details.getCreateCoordinationContext() ;
+ final AddressingProperties requestAddressingProperties = details.getAddressingProperties() ;
+ assertEquals(requestAddressingProperties.getTo().getURI().toString(), TestUtil11.activationCoordinatorService);
+ assertEquals(requestAddressingProperties.getMessageID().getURI().toString(), messageId);
+
+ assertNull(requestCreateCoordinationContext.getExpires()) ;
+ assertNull(requestCreateCoordinationContext.getCurrentContext()) ;
+ assertEquals(requestCreateCoordinationContext.getCoordinationType(), coordinationType);
+ return;
+ }
+ fail("expected invalid create parameters exception");
+ }
+
+ public void doRegisterRequest(final String messageId)
+ throws Exception
+ {
+ final String protocolIdentifier = TestUtil.PROTOCOL_IDENTIFIER ;
+ final W3CEndpointReference participantProtocolService = TestUtil11.getProtocolParticipantEndpoint("participant");
+ final CoordinationContextType coordinationContext = new CoordinationContextType() ;
+ CoordinationContextType.Identifier identifierInstance = new CoordinationContextType.Identifier();
+ coordinationContext.setCoordinationType(TestUtil.COORDINATION_TYPE) ;
+ coordinationContext.setIdentifier(identifierInstance) ;
+ identifierInstance.setValue("identifier");
+ coordinationContext.setRegistrationService(TestUtil11.getRegistrationEndpoint(identifierInstance.getValue())) ;
+
+ W3CEndpointReference coordinator = RegistrationCoordinator.register(coordinationContext, messageId, participantProtocolService, protocolIdentifier) ;
+
+ final RegisterDetails details = testRegistrationCoordinatorProcessor.getRegisterDetails(messageId, 10000) ;
+ final RegisterType requestRegister = details.getRegister() ;
+ final AddressingProperties requestAddressingProperties = details.getAddressingProperties() ;
+ final ArjunaContext requestArjunaContext = details.getArjunaContext() ;
+
+ assertEquals(requestAddressingProperties.getTo().getURI().toString(), TestUtil11.registrationCoordinatorService);
+ assertEquals(requestAddressingProperties.getMessageID().getURI().toString(), messageId);
+
+ assertNotNull(requestArjunaContext) ;
+ assertEquals(requestArjunaContext.getInstanceIdentifier().getInstanceIdentifier(), identifierInstance.getValue()) ;
+
+ assertEquals(protocolIdentifier, requestRegister.getProtocolIdentifier()) ;
+ assertNotNull(protocolIdentifier, requestRegister.getParticipantProtocolService()) ;
+
+ assertNotNull(coordinator);
+ }
+
+ public void doRegisterError(final String messageId, int count)
+ throws Exception
+ {
+ final String protocolIdentifier;
+ final W3CEndpointReference participantProtocolService = TestUtil11.getProtocolParticipantEndpoint("participant");
+ final CoordinationContextType coordinationContext = new CoordinationContextType() ;
+ CoordinationContextType.Identifier identifierInstance = new CoordinationContextType.Identifier();
+ coordinationContext.setCoordinationType(TestUtil.COORDINATION_TYPE) ;
+ coordinationContext.setIdentifier(identifierInstance) ;
+ identifierInstance.setValue("identifier");
+ coordinationContext.setRegistrationService(TestUtil11.getRegistrationEndpoint(identifierInstance.getValue())) ;
+
+ W3CEndpointReference coordinator = null;
+
+ switch (count) {
+ case 0:
+ protocolIdentifier = TestUtil.INVALID_PROTOCOL_PROTOCOL_IDENTIFIER;
+ try {
+ coordinator = RegistrationCoordinator.register(coordinationContext, messageId, participantProtocolService, protocolIdentifier) ;
+ } catch (InvalidProtocolException ipe) {
+ }
+ if (coordinator != null) {
+ fail("expected invalid protocol exception");
+ }
+ break;
+ case 1:
+ protocolIdentifier = TestUtil.INVALID_STATE_PROTOCOL_IDENTIFIER;
+ try {
+ coordinator = RegistrationCoordinator.register(coordinationContext, messageId, participantProtocolService, protocolIdentifier) ;
+ } catch (InvalidStateException ise) {
+ }
+ if (coordinator != null) {
+ fail("expected invalid state exception");
+ }
+ break;
+ case 3:
+ protocolIdentifier = TestUtil.NO_ACTIVITY_PROTOCOL_IDENTIFIER;
+ try {
+ coordinator = RegistrationCoordinator.register(coordinationContext, messageId, participantProtocolService, protocolIdentifier) ;
+ } catch (NoActivityException nae) {
+ }
+ if (coordinator != null) {
+ fail("expected no activity exception");
+ }
+ break;
+ default:
+ protocolIdentifier = TestUtil.ALREADY_REGISTERED_PROTOCOL_IDENTIFIER;
+ try {
+ coordinator = RegistrationCoordinator.register(coordinationContext, messageId, participantProtocolService, protocolIdentifier) ;
+ } catch (AlreadyRegisteredException are) {
+ }
+ if (coordinator != null) {
+ fail("expected already registered exception");
+ }
+ break;
+ }
+
+ final RegisterDetails details = testRegistrationCoordinatorProcessor.getRegisterDetails(messageId, 10000) ;
+ final RegisterType requestRegister = details.getRegister() ;
+ final AddressingProperties requestAddressingProperties = details.getAddressingProperties() ;
+ final ArjunaContext requestArjunaContext = details.getArjunaContext() ;
+
+ assertEquals(requestAddressingProperties.getTo().getURI().toString(), TestUtil11.registrationCoordinatorService);
+ assertEquals(requestAddressingProperties.getMessageID().getURI().toString(), messageId);
+
+ assertNotNull(requestArjunaContext) ;
+ assertEquals(requestArjunaContext.getInstanceIdentifier().getInstanceIdentifier(), identifierInstance.getValue()); ;
+
+ assertEquals(protocolIdentifier, requestRegister.getProtocolIdentifier()) ;
+ assertNotNull(protocolIdentifier, requestRegister.getParticipantProtocolService()) ;
+ }
+
+ protected void tearDown()
+ throws Exception
+ {
+ ActivationCoordinatorProcessor.setCoordinator(origActivationCoordinatorProcessor) ;
+ origActivationCoordinatorProcessor = null ;
+ testActivationCoordinatorProcessor = null ;
+
+ RegistrationCoordinatorProcessor.setCoordinator(origRegistrationCoordinatorProcessor) ;
+ origRegistrationCoordinatorProcessor = null ;
+ testRegistrationCoordinatorProcessor = null ;
+ }
+}
\ No newline at end of file
Copied: labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/RegistrationServiceExceptionTestCase.java (from rev 19937, labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc/tests/junit/RegistrationServiceExceptionTestCase.java)
===================================================================
--- labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/RegistrationServiceExceptionTestCase.java (rev 0)
+++ labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/RegistrationServiceExceptionTestCase.java 2008-05-28 13:42:08 UTC (rev 20195)
@@ -0,0 +1,136 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a full listing
+ * of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU General Public License, v. 2.0.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License,
+ * v. 2.0 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (c) 2002, 2003, Arjuna Technologies Limited.
+ *
+ * RegistrationServiceExceptionTestCase.java
+ */
+
+package com.arjuna.wsc11.tests.junit;
+
+import junit.framework.TestCase;
+
+import com.arjuna.webservices11.wscoor.CoordinationConstants;
+import com.arjuna.wsc.AlreadyRegisteredException;
+import com.arjuna.wsc.InvalidProtocolException;
+import com.arjuna.wsc.InvalidStateException;
+import com.arjuna.wsc.NoActivityException;
+import com.arjuna.wsc11.RegistrationCoordinator;
+import com.arjuna.wsc11.tests.TestUtil11;
+import com.arjuna.wsc.tests.TestUtil;
+import org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContextType;
+
+import javax.xml.ws.wsaddressing.W3CEndpointReference;
+
+public class RegistrationServiceExceptionTestCase extends TestCase
+{
+ public void testAlreadyRegisteredProtocolIdentifierException()
+ throws Exception
+ {
+ final String messageId = "testAlreadyRegisteredProtocolIdentifierException" ;
+ final String protocolIdentifier = TestUtil.ALREADY_REGISTERED_PROTOCOL_IDENTIFIER ;
+ final CoordinationContextType coordinationContext = new CoordinationContextType() ;
+ final CoordinationContextType.Identifier identifierInstance = new CoordinationContextType.Identifier();
+ coordinationContext.setCoordinationType(TestUtil.COORDINATION_TYPE) ;
+ coordinationContext.setIdentifier(identifierInstance);
+ identifierInstance.setValue("identifier") ;
+ coordinationContext.setRegistrationService(TestUtil11.getRegistrationEndpoint(identifierInstance.getValue())) ;
+ W3CEndpointReference participantEndpoint = TestUtil11.getProtocolParticipantEndpoint("participant");
+ try
+ {
+ RegistrationCoordinator.register(coordinationContext, messageId, participantEndpoint, protocolIdentifier) ;
+ }
+ catch (final AlreadyRegisteredException are) {}
+ catch (final Throwable th)
+ {
+ fail("Unexpected exception: " + th) ;
+ }
+ }
+
+ public void testInvalidProtocolProtocolIdentifierException()
+ throws Exception
+ {
+ final String messageId = "testInvalidProtocolProtocolIdentifierException" ;
+ final String protocolIdentifier = TestUtil.INVALID_PROTOCOL_PROTOCOL_IDENTIFIER ;
+ final CoordinationContextType coordinationContext = new CoordinationContextType() ;
+ final CoordinationContextType.Identifier identifierInstance = new CoordinationContextType.Identifier();
+ coordinationContext.setCoordinationType(TestUtil.COORDINATION_TYPE) ;
+ coordinationContext.setIdentifier(identifierInstance);
+ identifierInstance.setValue("identifier") ;
+ coordinationContext.setRegistrationService(TestUtil11.getRegistrationEndpoint(identifierInstance.getValue())) ;
+ W3CEndpointReference participantEndpoint = TestUtil11.getProtocolParticipantEndpoint("participant");
+ try
+ {
+ RegistrationCoordinator.register(coordinationContext, messageId, participantEndpoint, protocolIdentifier) ;
+ }
+ catch (final InvalidProtocolException ipe) {}
+ catch (final Throwable th)
+ {
+ fail("Unexpected exception: " + th) ;
+ }
+ }
+
+ public void testInvalidStateProtocolIdentifierException()
+ throws Exception
+ {
+ final String messageId = "testInvalidStateProtocolIdentifierException" ;
+ final String protocolIdentifier = TestUtil.INVALID_STATE_PROTOCOL_IDENTIFIER ;
+ final CoordinationContextType coordinationContext = new CoordinationContextType() ;
+ final CoordinationContextType.Identifier identifierInstance = new CoordinationContextType.Identifier();
+ coordinationContext.setCoordinationType(TestUtil.COORDINATION_TYPE) ;
+ coordinationContext.setIdentifier(identifierInstance);
+ identifierInstance.setValue("identifier") ;
+ coordinationContext.setRegistrationService(TestUtil11.getRegistrationEndpoint(identifierInstance.getValue())) ;
+ W3CEndpointReference participantEndpoint = TestUtil11.getProtocolParticipantEndpoint("participant");
+ try
+ {
+ RegistrationCoordinator.register(coordinationContext, messageId, participantEndpoint, protocolIdentifier) ;
+ }
+ catch (final InvalidStateException ise) {}
+ catch (final Throwable th)
+ {
+ fail("Unexpected exception: " + th) ;
+ }
+ }
+
+ public void testNoActivityProtocolIdentifierException()
+ throws Exception
+ {
+ final String messageId = "testNoActivityProtocolIdentifierException" ;
+ final String protocolIdentifier = TestUtil.NO_ACTIVITY_PROTOCOL_IDENTIFIER ;
+ final CoordinationContextType coordinationContext = new CoordinationContextType() ;
+ final CoordinationContextType.Identifier identifierInstance = new CoordinationContextType.Identifier();
+ coordinationContext.setCoordinationType(TestUtil.COORDINATION_TYPE) ;
+ coordinationContext.setIdentifier(identifierInstance);
+ identifierInstance.setValue("identifier") ;
+ coordinationContext.setRegistrationService(TestUtil11.getRegistrationEndpoint(identifierInstance.getValue())) ;
+ W3CEndpointReference participantEndpoint = TestUtil11.getProtocolParticipantEndpoint("participant");
+ try
+ {
+ RegistrationCoordinator.register(coordinationContext, messageId, participantEndpoint, protocolIdentifier) ;
+ }
+ catch (final NoActivityException nae) {}
+ catch (final Throwable th)
+ {
+ fail("Unexpected exception: " + th) ;
+ }
+ }
+}
\ No newline at end of file
Modified: labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/TestActivationCoordinatorProcessor.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/TestActivationCoordinatorProcessor.java 2008-05-28 13:19:53 UTC (rev 20194)
+++ labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/TestActivationCoordinatorProcessor.java 2008-05-28 13:42:08 UTC (rev 20195)
@@ -32,6 +32,7 @@
import com.arjuna.wsc.NoActivityException;
import com.arjuna.wsc11.tests.TestRegistrar;
import com.arjuna.wsc11.tests.TestUtil11;
+import com.arjuna.webservices.SoapFaultType;
import org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextType;
import org.oasis_open.docs.ws_tx.wscoor._2006._06.CreateCoordinationContextResponseType;
import org.oasis_open.docs.ws_tx.wscoor._2006._06.CoordinationContext;
@@ -40,6 +41,10 @@
import javax.xml.ws.addressing.AddressingProperties;
import javax.xml.ws.wsaddressing.W3CEndpointReference;
import javax.xml.ws.wsaddressing.W3CEndpointReferenceBuilder;
+import javax.xml.ws.soap.SOAPFaultException;
+import javax.xml.ws.ProtocolException;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPFault;
public class TestActivationCoordinatorProcessor extends
ActivationCoordinatorProcessor
@@ -55,11 +60,23 @@
messageIdMap.put(messageId, new CreateCoordinationContextDetails(createCoordinationContext, addressingProperties)) ;
messageIdMap.notifyAll() ;
}
+ String coordinationType = createCoordinationContext.getCoordinationType();
+ if (TestUtil.INVALID_CREATE_PARAMETERS_COORDINATION_TYPE.equals(coordinationType)) {
+ try {
+ SOAPFactory factory = SOAPFactory.newInstance();
+ SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PARAMETERS_QNAME);
+ soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PARAMETERS_QNAME).addTextNode("Invalid create parameters");
+ throw new SOAPFaultException(soapFault);
+ } catch (Throwable th) {
+ throw new ProtocolException(th);
+ }
+ }
+
// we have to return a value so lets cook one up
CreateCoordinationContextResponseType createCoordinationContextResponseType = new CreateCoordinationContextResponseType();
CoordinationContext coordinationContext = new CoordinationContext();
- coordinationContext.setCoordinationType(createCoordinationContext.getCoordinationType());
+ coordinationContext.setCoordinationType(coordinationType);
coordinationContext.setExpires(createCoordinationContext.getExpires());
String identifier = nextIdentifier();
CoordinationContextType.Identifier identifierInstance = new CoordinationContextType.Identifier();
Modified: labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/TestRegistrationCoordinatorProcessor.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/TestRegistrationCoordinatorProcessor.java 2008-05-28 13:19:53 UTC (rev 20194)
+++ labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/TestRegistrationCoordinatorProcessor.java 2008-05-28 13:42:08 UTC (rev 20195)
@@ -26,11 +26,18 @@
import com.arjuna.webservices11.wsarj.ArjunaContext;
import com.arjuna.webservices11.wsarj.InstanceIdentifier;
import com.arjuna.webservices11.wscoor.processors.RegistrationCoordinatorProcessor;
+import com.arjuna.webservices11.wscoor.CoordinationConstants;
import com.arjuna.wsc11.tests.TestUtil11;
+import com.arjuna.wsc.tests.TestUtil;
+import com.arjuna.webservices.SoapFaultType;
import org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterType;
import org.oasis_open.docs.ws_tx.wscoor._2006._06.RegisterResponseType;
import javax.xml.ws.addressing.AddressingProperties;
+import javax.xml.ws.soap.SOAPFaultException;
+import javax.xml.ws.ProtocolException;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPFault;
public class TestRegistrationCoordinatorProcessor extends
RegistrationCoordinatorProcessor
@@ -45,7 +52,47 @@
messageIdMap.put(messageId, new RegisterDetails(register, addressingProperties, arjunaContext)) ;
messageIdMap.notifyAll() ;
}
-
+ String protocolIdentifier = register.getProtocolIdentifier();
+ if (TestUtil.ALREADY_REGISTERED_PROTOCOL_IDENTIFIER.equals(protocolIdentifier)) {
+ try {
+ SOAPFactory factory = SOAPFactory.newInstance();
+ SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_ALREADY_REGISTERED_QNAME);
+ soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_ALREADY_REGISTERED_QNAME).addTextNode("already registered");
+ throw new SOAPFaultException(soapFault);
+ } catch (Throwable th) {
+ throw new ProtocolException(th);
+ }
+ }
+ if (TestUtil.INVALID_PROTOCOL_PROTOCOL_IDENTIFIER.equals(protocolIdentifier)) {
+ try {
+ SOAPFactory factory = SOAPFactory.newInstance();
+ SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PROTOCOL_QNAME);
+ soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_PROTOCOL_QNAME).addTextNode("invalid protocol");
+ throw new SOAPFaultException(soapFault);
+ } catch (Throwable th) {
+ throw new ProtocolException(th);
+ }
+ }
+ if (TestUtil.INVALID_STATE_PROTOCOL_IDENTIFIER.equals(protocolIdentifier)) {
+ try {
+ SOAPFactory factory = SOAPFactory.newInstance();
+ SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_STATE_QNAME);
+ soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_INVALID_STATE_QNAME).addTextNode("invalid state");
+ throw new SOAPFaultException(soapFault);
+ } catch (Throwable th) {
+ throw new ProtocolException(th);
+ }
+ }
+ if (TestUtil.NO_ACTIVITY_PROTOCOL_IDENTIFIER.equals(protocolIdentifier)) {
+ try {
+ SOAPFactory factory = SOAPFactory.newInstance();
+ SOAPFault soapFault = factory.createFault(SoapFaultType.FAULT_SENDER.getValue(), CoordinationConstants.WSCOOR_ERROR_CODE_NO_ACTIVITY_QNAME);
+ soapFault.addDetail().addDetailEntry(CoordinationConstants.WSCOOR_ERROR_CODE_NO_ACTIVITY_QNAME).addTextNode("no activity");
+ throw new SOAPFaultException(soapFault);
+ } catch (Throwable th) {
+ throw new ProtocolException(th);
+ }
+ }
// we need to cook up a response here
RegisterResponseType registerResponseType = new RegisterResponseType();
if (arjunaContext != null) {
Modified: labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/TestSuite.java
===================================================================
--- labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/TestSuite.java 2008-05-28 13:19:53 UTC (rev 20194)
+++ labs/jbosstm/trunk/XTS/WS-C/tests/src/com/arjuna/wsc11/tests/junit/TestSuite.java 2008-05-28 13:42:08 UTC (rev 20195)
@@ -36,9 +36,10 @@
addTest(new junit.framework.TestSuite(com.arjuna.wsc11.tests.junit.ActivationServiceTestCase.class));
addTest(new junit.framework.TestSuite(com.arjuna.wsc11.tests.junit.ActivationServiceExceptionTestCase.class));
addTest(new junit.framework.TestSuite(com.arjuna.wsc11.tests.junit.RegistrationServiceTestCase.class));
- //addTest(new junit.framework.TestSuite(com.arjuna.wsc11.tests.junit.RegistrationServiceExceptionTestCase.class));
+ addTest(new junit.framework.TestSuite(com.arjuna.wsc11.tests.junit.RegistrationServiceExceptionTestCase.class));
- //addTest(new junit.framework.TestSuite(com.arjuna.wsc11.tests.junit.EnduranceTestCase.class));
+ addTest(new junit.framework.TestSuite(com.arjuna.wsc11.tests.junit.EnduranceTestCase.class));
+ // this needs redesigning because 1.1. protocols are RPC pattern
//addTest(new junit.framework.TestSuite(com.arjuna.wsc11.tests.junit.ThreadedEnduranceTestCase.class));
}
}
\ No newline at end of file
More information about the jboss-svn-commits
mailing list