You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by an...@apache.org on 2007/03/23 10:37:34 UTC
svn commit: r521646 [1/2] - in /incubator/cxf/trunk/rt:
core/src/main/java/org/apache/cxf/endpoint/
core/src/main/java/org/apache/cxf/service/
frontend/simple/src/main/java/org/apache/cxf/service/factory/ ws/rm/
ws/rm/src/main/java/org/apache/cxf/ws/rm...
Author: andreasmyth
Date: Fri Mar 23 02:37:32 2007
New Revision: 521646
URL: http://svn.apache.org/viewvc?view=rev&rev=521646
Log:
* Improved test coverage for org.apache.cxf.ws.rm package; used junit 4 annotations.
* Used current thread or executor instead of creating separate thread when sending CreateSequenceResponse from client/CreateSequenceRequest from server.
Added:
incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractEndpointTest.java (with props)
incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractRMInterceptorTest.java (with props)
incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationTest.java (with props)
incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ProxyTest.java (with props)
incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMContextUtilsTest.java (with props)
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/ServiceImpl.java
incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
incubator/cxf/trunk/rt/ws/rm/pom.xml
incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractRMInterceptor.java
incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Destination.java
incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/DestinationSequence.java
incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Proxy.java
incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMContextUtils.java
incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java
incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java
incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/WrappedService.java
incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractSequenceTest.java
incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationSequenceTest.java
incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMEndpointTest.java
incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMInInterceptorTest.java
incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java
incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMOutInterceptorTest.java
incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/SourceSequenceTest.java
Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java Fri Mar 23 02:37:32 2007
@@ -97,7 +97,7 @@
}
public Executor getExecutor() {
- return executor;
+ return executor == null ? service.getExecutor() : executor;
}
public void setExecutor(Executor e) {
Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/ServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/ServiceImpl.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/ServiceImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/ServiceImpl.java Fri Mar 23 02:37:32 2007
@@ -31,6 +31,7 @@
import org.apache.cxf.interceptor.AbstractAttributedInterceptorProvider;
import org.apache.cxf.service.invoker.Invoker;
import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.workqueue.SynchronousExecutor;
public class ServiceImpl extends AbstractAttributedInterceptorProvider implements Service, Configurable {
private ServiceInfo serviceInfo;
@@ -41,11 +42,12 @@
private boolean enableSchemaValidationForAllPort;
public ServiceImpl() {
-
+ this(null);
}
public ServiceImpl(ServiceInfo si) {
serviceInfo = si;
+ executor = SynchronousExecutor.getInstance();
}
public String getBeanName() {
Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java Fri Mar 23 02:37:32 2007
@@ -65,7 +65,6 @@
import org.apache.cxf.service.model.SchemaInfo;
import org.apache.cxf.service.model.ServiceInfo;
import org.apache.cxf.service.model.UnwrappedOperationInfo;
-import org.apache.cxf.workqueue.SynchronousExecutor;
import org.apache.cxf.wsdl11.WSDLServiceFactory;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
@@ -135,9 +134,7 @@
if (getExecutor() != null) {
getService().setExecutor(getExecutor());
- } else {
- getService().setExecutor(SynchronousExecutor.getInstance());
- }
+ }
if (getDataBinding() != null) {
getService().setDataBinding(getDataBinding());
}
Modified: incubator/cxf/trunk/rt/ws/rm/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/pom.xml?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/pom.xml (original)
+++ incubator/cxf/trunk/rt/ws/rm/pom.xml Fri Mar 23 02:37:32 2007
@@ -90,6 +90,41 @@
<build>
<plugins>
<plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ <configuration>
+ <instrumentation>
+ <ignores>
+ <ignore>org.apache.cxf.ws.rm.manager.*</ignore>
+ </ignores>
+ <excludes>
+ <exclude>org/apache/cxf/ws/rm/AcceptType.class</exclude>
+ <exclude>org/apache/cxf/ws/rm/AckRequestedType.class</exclude>
+ <exclude>org/apache/cxf/ws/rm/CreateSequenceResponseType.class</exclude>
+ <exclude>org/apache/cxf/ws/rm/CreateSequenceType.class</exclude>
+ <exclude>org/apache/cxf/ws/rm/Expires.class</exclude>
+ <exclude>org/apache/cxf/ws/rm/Identifier.class</exclude>
+ <exclude>org/apache/cxf/ws/rm/ObjectFactory.class</exclude>
+ <exclude>org/apache/cxf/ws/rm/OfferType.class</exclude>
+ <exclude>org/apache/cxf/ws/rm/SequenceAcknowledgement.class</exclude>
+ <exclude>org/apache/cxf/ws/rm/SequenceType.class</exclude>
+ <exclude>org/apache/cxf/ws/rm/SequenceFaultType.class</exclude>
+ <exclude>org/apache/cxf/ws/rm/TerminateSequenceType.class</exclude>
+ <exclude>org/apache/cxf/ws/rm/manager/*</exclude>
+ <exclude>org/apache/cxf/ws/rm/policy/*</exclude>
+ <exclude>**/*Test.class</exclude>
+ </excludes>
+ </instrumentation>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>clean</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-common-xsd</artifactId>
<version>${project.version}</version>
Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractRMInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractRMInterceptor.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractRMInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/AbstractRMInterceptor.java Fri Mar 23 02:37:32 2007
@@ -27,8 +27,8 @@
import org.apache.cxf.common.logging.LogUtils;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
-import org.apache.cxf.phase.PhaseInterceptor;
import org.apache.cxf.ws.policy.AssertionInfo;
import org.apache.cxf.ws.policy.AssertionInfoMap;
@@ -39,11 +39,15 @@
* The same interceptor can be used on multiple endpoints.
*
*/
-public abstract class AbstractRMInterceptor implements PhaseInterceptor<Message> {
+public abstract class AbstractRMInterceptor<T extends Message> extends AbstractPhaseInterceptor<T> {
private static final Logger LOG = LogUtils.getL7dLogger(AbstractRMInterceptor.class);
private RMManager manager;
private Bus bus;
+
+ protected AbstractRMInterceptor() {
+ setPhase(Phase.PRE_LOGICAL);
+ }
public RMManager getManager() {
if (null == manager) {
@@ -63,38 +67,19 @@
public void setBus(Bus bus) {
this.bus = bus;
}
-
- // PhaseInterceptor interface
-
-
-
- public String getPhase() {
- return Phase.PRE_LOGICAL;
- }
// Interceptor interface
public void handleMessage(Message msg) throws Fault {
try {
- handleMessage(msg, false);
+ handle(msg);
} catch (SequenceFault ex) {
LOG.log(Level.SEVERE, "SequenceFault", ex);
throw new Fault(ex);
}
}
- public void handleFault(Message msg) {
- try {
- handleMessage(msg, true);
- } catch (SequenceFault ex) {
- LOG.log(Level.SEVERE, "SequenceFault", ex);
- }
- }
-
- public void postHandleMessage(Message msg) throws Fault {
- }
-
/**
* Asserts all RMAssertion assertions for the current message, regardless their attributes
* (if there is more thsn one we have ensured that they are all supported by considering
@@ -117,8 +102,6 @@
}
}
- // rm logic
-
- abstract void handleMessage(Message msg, boolean isFault) throws SequenceFault;
-
+ protected abstract void handle(Message message) throws SequenceFault;
+
}
Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Destination.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Destination.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Destination.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Destination.java Fri Mar 23 02:37:32 2007
@@ -115,6 +115,7 @@
getReliableEndpoint().getProxy().acknowledge(seq);
} catch (IOException ex) {
LogUtils.log(LOG, Level.SEVERE, "SEQ_ACK_SEND_EXC", ex, seq);
+ // TODO
}
}
}
Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/DestinationSequence.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/DestinationSequence.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/DestinationSequence.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/DestinationSequence.java Fri Mar 23 02:37:32 2007
@@ -54,7 +54,7 @@
public DestinationSequence(Identifier i, EndpointReferenceType a, Destination d) {
this(i, a, null, null);
- setDestination(d);
+ destination = d;
}
public DestinationSequence(Identifier i, EndpointReferenceType a,
@@ -177,7 +177,7 @@
}
}
- final void setDestination(Destination d) {
+ void setDestination(Destination d) {
destination = d;
}
Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Proxy.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Proxy.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Proxy.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Proxy.java Fri Mar 23 02:37:32 2007
@@ -35,6 +35,7 @@
import org.apache.cxf.message.Message;
import org.apache.cxf.service.model.BindingInfo;
import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.service.model.InterfaceInfo;
import org.apache.cxf.service.model.OperationInfo;
import org.apache.cxf.transport.Conduit;
@@ -71,42 +72,13 @@
OperationInfo oi = reliableEndpoint.getService().getServiceInfo().getInterface()
.getOperation(RMConstants.getSequenceAckOperationName());
-
- /*
- Map<String, Object> requestContext = new HashMap<String, Object>();
- AddressingPropertiesImpl maps = new AddressingPropertiesImpl();
- maps.setTo(VersionTransformer.convert(ds.getAcksTo()).getAddress());
-
- if (null != reliableEndpoint.getTransportDestination()) {
- maps.setReplyTo(reliableEndpoint.getTransportDestination().getAddress());
- } else {
- maps.setReplyTo(RMUtils.createNoneReference());
- }
- requestContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, maps);
- Map<String, Object> context = CastUtils.cast(
- Collections.singletonMap(Client.REQUEST_CONTEXT, requestContext),
- String.class, Object.class);
- */
invoke(oi, new Object[] {}, null);
}
void terminate(SourceSequence ss) throws IOException {
OperationInfo oi = reliableEndpoint.getService().getServiceInfo().getInterface()
.getOperation(RMConstants.getTerminateSequenceOperationName());
- /*
- Map<String, Object> requestContext = new HashMap<String, Object>();
- AddressingPropertiesImpl maps = new AddressingPropertiesImpl();
- maps.setTo(ss.getTarget().getAddress());
- if (null != reliableEndpoint.getTransportDestination()) {
- maps.setReplyTo(reliableEndpoint.getTransportDestination().getAddress());
- } else {
- maps.setReplyTo(RMUtils.createNoneReference());
- }
- requestContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES, maps);
- Map<String, Object> context = CastUtils.cast(
- Collections.singletonMap(Client.REQUEST_CONTEXT, requestContext),
- String.class, Object.class);
- */
+
TerminateSequenceType ts = RMUtils.getWSRMFactory().createTerminateSequenceType();
ts.setIdentifier(ss.getIdentifier());
invoke(oi, new Object[] {ts}, null);
@@ -118,21 +90,12 @@
.getOperation(RMConstants.getCreateSequenceResponseOnewayOperationName());
// TODO: need to set relatesTo
-
- Runnable r = new Runnable() {
- public void run() {
- Proxy.this.invoke(oi, new Object[] {createResponse}, null);
- }
- };
- Thread t = new Thread(r);
- t.start();
-
- // invoke(oi, new Object[] {createResponse}, null);
+
+ invoke(oi, new Object[] {createResponse}, null);
}
public CreateSequenceResponseType createSequence(
- org.apache.cxf.ws.addressing.EndpointReferenceType to,
EndpointReferenceType defaultAcksTo,
RelatesToType relatesTo,
boolean isServer) throws IOException {
@@ -178,14 +141,13 @@
// tried using separate thread - did not help either
if (isServer) {
+ LOG.fine("sending CreateSequenceRequest from server side");
Runnable r = new Runnable() {
public void run() {
invoke(oi, new Object[] {create}, null);
}
};
- // reliableEndpoint.getApplicationEndpoint().getService().getExecutor().execute(r);
- Thread t = new Thread(r);
- t.start();
+ reliableEndpoint.getApplicationEndpoint().getExecutor().execute(r);
return null;
}
@@ -208,25 +170,24 @@
}
Object invoke(OperationInfo oi, Object[] params, Map<String, Object> context) {
- LOG.log(Level.INFO, "Invoking out-of-band RM protocol message {0} on thread "
- + Thread.currentThread(),
- oi == null ? null : oi.getName());
- // assuming we are on the client side
+ if (LOG.isLoggable(Level.INFO)) {
+ LOG.log(Level.INFO, "Invoking out-of-band RM protocol message {0} on thread "
+ + Thread.currentThread(),
+ oi == null ? null : oi.getName());
+ }
RMManager manager = reliableEndpoint.getManager();
Bus bus = manager.getBus();
Endpoint endpoint = reliableEndpoint.getEndpoint();
BindingInfo bi = reliableEndpoint.getBindingInfo();
-
- Client client = new RMClient(bus, endpoint, reliableEndpoint.getConduit(),
- reliableEndpoint.getReplyTo());
+ Conduit c = reliableEndpoint.getConduit();
+ org.apache.cxf.ws.addressing.EndpointReferenceType replyTo = reliableEndpoint.getReplyTo();
+ Client client = createClient(bus, endpoint, c, replyTo);
BindingOperationInfo boi = bi.getOperation(oi);
try {
- LOG.fine("invoking on client");
Object[] result = client.invoke(boi, params, context);
- LOG.fine("Returned from client invocation");
if (result != null && result.length > 0) {
return result[0];
}
@@ -237,6 +198,11 @@
return null;
}
+ protected Client createClient(Bus bus, Endpoint endpoint, Conduit conduit,
+ org.apache.cxf.ws.addressing.EndpointReferenceType address) {
+ return new RMClient(bus, endpoint, conduit, address);
+ }
+
class RMClient extends ClientImpl {
org.apache.cxf.ws.addressing.EndpointReferenceType address;
@@ -257,17 +223,24 @@
@Override
public Conduit getConduit() {
Conduit conduit = null;
- String originalAddress = endpoint.getEndpointInfo().getAddress();
+ EndpointInfo endpointInfo = endpoint.getEndpointInfo();
+ String originalAddress = endpointInfo.getAddress();
try {
if (null != address) {
- endpoint.getEndpointInfo().setAddress(address.getAddress().getValue());
+ endpointInfo.setAddress(address.getAddress().getValue());
}
conduit = super.getConduit();
} finally {
- endpoint.getEndpointInfo().setAddress(originalAddress);
+ endpointInfo.setAddress(originalAddress);
}
return conduit;
}
+ }
+
+ // for test
+
+ void setReliableEndpoint(RMEndpoint rme) {
+ reliableEndpoint = rme;
}
Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMContextUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMContextUtils.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMContextUtils.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMContextUtils.java Fri Mar 23 02:37:32 2007
@@ -21,7 +21,6 @@
import java.util.List;
-import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
import org.apache.cxf.ws.addressing.AddressingProperties;
@@ -173,9 +172,9 @@
* requestor
* @param handler true if HANDLER scope, APPLICATION scope otherwise
*/
- public static void storeMAPs(AddressingProperties maps, Message message, boolean isProviderContext,
- boolean isOutbound) {
- org.apache.cxf.ws.addressing.ContextUtils.storeMAPs(maps, message, isProviderContext, isOutbound);
+ public static void storeMAPs(AddressingProperties maps, Message message, boolean isOutbound,
+ boolean isRequestor) {
+ org.apache.cxf.ws.addressing.ContextUtils.storeMAPs(maps, message, isOutbound, isRequestor);
}
/**
@@ -185,18 +184,6 @@
*/
public static void ensureExposedVersion(AddressingProperties maps) {
((AddressingPropertiesImpl)maps).exposeAs(VersionTransformer.Names200408.WSA_NAMESPACE_NAME);
- }
-
- /**
- * Returns the endpoint of this message, i.e. the client endpoint if the
- * current messaging role is that of requestor, or the server endpoint
- * otherwise.
- *
- * @param message the current Message
- * @return the endpoint
- */
- public static Endpoint getEndpoint(Message message) {
- return message.getExchange().get(Endpoint.class);
}
private static String getRMPropertiesKey(boolean outbound) {
Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java Fri Mar 23 02:37:32 2007
@@ -41,7 +41,6 @@
import org.apache.cxf.service.model.MessagePartInfo;
import org.apache.cxf.service.model.OperationInfo;
import org.apache.cxf.service.model.ServiceInfo;
-import org.apache.cxf.service.model.UnwrappedOperationInfo;
import org.apache.cxf.transport.Conduit;
import org.apache.cxf.ws.addressing.Names;
import org.apache.cxf.ws.policy.EndpointPolicyInfo;
@@ -65,8 +64,8 @@
private static final QName TERMINATE_PART_NAME =
new QName(RMConstants.getWsdlNamespace(), "terminate");
- private final RMManager manager;
- private final Endpoint applicationEndpoint;
+ private RMManager manager;
+ private Endpoint applicationEndpoint;
private Conduit conduit;
private org.apache.cxf.ws.addressing.EndpointReferenceType replyTo;
private Source source;
@@ -75,7 +74,6 @@
private Endpoint endpoint;
private Proxy proxy;
private Servant servant;
- private boolean unwrapped;
public RMEndpoint(RMManager m, Endpoint ae) {
@@ -217,17 +215,20 @@
void createEndpoint() {
ServiceInfo si = service.getServiceInfo();
buildBindingInfo(si);
- String transportId = applicationEndpoint.getEndpointInfo().getTransportId();
+ EndpointInfo aei = applicationEndpoint.getEndpointInfo();
+ String transportId = aei.getTransportId();
EndpointInfo ei = new EndpointInfo(si, transportId);
- ei.setAddress(applicationEndpoint.getEndpointInfo().getAddress());
+ ei.setAddress(aei.getAddress());
ei.setName(PORT_NAME);
ei.setBinding(si.getBinding(BINDING_NAME));
- // get the addressing extensor from the application endpoint (must exist)
+ // if addressing was enabled on the application endpoint by means
+ // of the UsingAddressing element extensor, use this for the
+ // RM endpoint also
- Object ua = getUsingAddressing(applicationEndpoint.getEndpointInfo());
+ Object ua = getUsingAddressing(aei);
if (null != ua) {
ei.addExtensor(ua);
}
@@ -239,14 +240,7 @@
void setPolicies() {
- // if addressing was enabled on the application endpoint by means
- // of the UsingAddressing element extensor, use this for the
- // RM endpoint also
-
- Object ua = getUsingAddressing(applicationEndpoint.getEndpointInfo());
- if (null != ua) {
- endpoint.getEndpointInfo().addExtensor(ua);
- }
+ Endpoint e = getEndpoint();
// use same WS-policies as for application endpoint
@@ -256,17 +250,17 @@
OutPolicyInfo opi = new OutPolicyInfo();
opi.initialise(epi, engine);
- engine.setEndpointPolicyInfo(endpoint, epi);
+ engine.setEndpointPolicyInfo(e, epi);
- BindingInfo bi = endpoint.getEndpointInfo().getBinding();
+ BindingInfo bi = e.getEndpointInfo().getBinding();
Collection<BindingOperationInfo> bois = bi.getOperations();
for (BindingOperationInfo boi : bois) {
- engine.setServerRequestPolicyInfo(endpoint, boi, opi);
- engine.setServerResponsePolicyInfo(endpoint, boi, opi);
+ engine.setServerRequestPolicyInfo(e, boi, opi);
+ engine.setServerResponsePolicyInfo(e, boi, opi);
- engine.setClientRequestPolicyInfo(endpoint, boi, opi);
- engine.setClientResponsePolicyInfo(endpoint, boi, opi);
+ engine.setClientRequestPolicyInfo(e, boi, opi);
+ engine.setClientResponsePolicyInfo(e, boi, opi);
}
// TODO: FaultPolicy (SequenceFault)
@@ -289,9 +283,7 @@
OperationInfo operationInfo = null;
MessagePartInfo partInfo = null;
- UnwrappedOperationInfo unwrappedOperationInfo = null;
MessageInfo messageInfo = null;
- MessageInfo unwrappedMessageInfo = null;
operationInfo = ii.addOperation(RMConstants.getCreateSequenceOperationName());
messageInfo = operationInfo.createMessage(RMConstants.getCreateSequenceOperationName());
@@ -300,17 +292,6 @@
partInfo.setElementQName(RMConstants.getCreateSequenceOperationName());
partInfo.setElement(true);
partInfo.setTypeClass(CreateSequenceType.class);
-
- if (unwrapped) {
- unwrappedMessageInfo = new MessageInfo(operationInfo, messageInfo.getName());
- unwrappedOperationInfo = new UnwrappedOperationInfo(operationInfo);
- operationInfo.setUnwrappedOperation(unwrappedOperationInfo);
- unwrappedOperationInfo.setInput(operationInfo.getInputName(), unwrappedMessageInfo);
- partInfo = unwrappedMessageInfo.addMessagePart("create");
- partInfo.setElementQName(RMConstants.getCreateSequenceOperationName());
- partInfo.setElement(true);
- partInfo.setTypeClass(CreateSequenceType.class);
- }
messageInfo = operationInfo.createMessage(RMConstants.getCreateSequenceResponseOperationName());
operationInfo.setOutput(messageInfo.getName().getLocalPart(), messageInfo);
@@ -319,14 +300,6 @@
partInfo.setElement(true);
partInfo.setTypeClass(CreateSequenceResponseType.class);
partInfo.setIndex(-1);
- if (unwrapped) {
- unwrappedMessageInfo = new MessageInfo(operationInfo, messageInfo.getName());
- unwrappedOperationInfo.setOutput(operationInfo.getOutputName(), unwrappedMessageInfo);
- partInfo = unwrappedMessageInfo.addMessagePart(CREATE_RESPONSE_PART_NAME);
- partInfo.setElementQName(RMConstants.getCreateSequenceResponseOperationName());
- partInfo.setElement(true);
- partInfo.setTypeClass(CreateSequenceResponseType.class);
- }
operationInfo = ii.addOperation(RMConstants.getCreateSequenceOnewayOperationName());
messageInfo = operationInfo.createMessage(RMConstants.getCreateSequenceOperationName());
@@ -335,16 +308,6 @@
partInfo.setElementQName(RMConstants.getCreateSequenceOperationName());
partInfo.setElement(true);
partInfo.setTypeClass(CreateSequenceType.class);
- if (unwrapped) {
- unwrappedMessageInfo = new MessageInfo(operationInfo, messageInfo.getName());
- unwrappedOperationInfo = new UnwrappedOperationInfo(operationInfo);
- operationInfo.setUnwrappedOperation(unwrappedOperationInfo);
- unwrappedOperationInfo.setInput(operationInfo.getInputName(), unwrappedMessageInfo);
- partInfo = unwrappedMessageInfo.addMessagePart(CREATE_PART_NAME);
- partInfo.setElementQName(RMConstants.getCreateSequenceOperationName());
- partInfo.setElement(true);
- partInfo.setTypeClass(CreateSequenceType.class);
- }
operationInfo = ii.addOperation(RMConstants.getCreateSequenceResponseOnewayOperationName());
messageInfo = operationInfo.createMessage(RMConstants.getCreateSequenceResponseOperationName());
@@ -353,25 +316,13 @@
partInfo.setElementQName(RMConstants.getCreateSequenceResponseOperationName());
partInfo.setElement(true);
partInfo.setTypeClass(CreateSequenceResponseType.class);
- if (unwrapped) {
- unwrappedMessageInfo = new MessageInfo(operationInfo, messageInfo.getName());
- unwrappedOperationInfo = new UnwrappedOperationInfo(operationInfo);
- operationInfo.setUnwrappedOperation(unwrappedOperationInfo);
- unwrappedOperationInfo.setInput(operationInfo.getInputName(), unwrappedMessageInfo);
- partInfo = unwrappedMessageInfo.addMessagePart(CREATE_RESPONSE_PART_NAME);
- partInfo.setElementQName(RMConstants.getCreateSequenceResponseOperationName());
- partInfo.setElement(true);
- partInfo.setTypeClass(CreateSequenceResponseType.class);
- }
}
void buildTerminateSequenceOperationInfo(InterfaceInfo ii) {
OperationInfo operationInfo = null;
MessagePartInfo partInfo = null;
- UnwrappedOperationInfo unwrappedOperationInfo = null;
MessageInfo messageInfo = null;
- MessageInfo unwrappedMessageInfo = null;
operationInfo = ii.addOperation(RMConstants.getTerminateSequenceOperationName());
messageInfo = operationInfo.createMessage(RMConstants.getTerminateSequenceOperationName());
@@ -380,34 +331,16 @@
partInfo.setElementQName(RMConstants.getTerminateSequenceOperationName());
partInfo.setElement(true);
partInfo.setTypeClass(TerminateSequenceType.class);
- if (unwrapped) {
- unwrappedMessageInfo = new MessageInfo(operationInfo, messageInfo.getName());
- unwrappedOperationInfo = new UnwrappedOperationInfo(operationInfo);
- operationInfo.setUnwrappedOperation(unwrappedOperationInfo);
- unwrappedOperationInfo.setInput(operationInfo.getInputName(), unwrappedMessageInfo);
- partInfo = unwrappedMessageInfo.addMessagePart(TERMINATE_PART_NAME);
- partInfo.setElementQName(RMConstants.getTerminateSequenceOperationName());
- partInfo.setElement(true);
- partInfo.setTypeClass(TerminateSequenceType.class);
- }
}
void buildSequenceAckOperationInfo(InterfaceInfo ii) {
OperationInfo operationInfo = null;
- UnwrappedOperationInfo unwrappedOperationInfo = null;
MessageInfo messageInfo = null;
- MessageInfo unwrappedMessageInfo = null;
operationInfo = ii.addOperation(RMConstants.getSequenceAckOperationName());
messageInfo = operationInfo.createMessage(RMConstants.getSequenceAckOperationName());
operationInfo.setInput(messageInfo.getName().getLocalPart(), messageInfo);
- if (unwrapped) {
- unwrappedMessageInfo = new MessageInfo(operationInfo, messageInfo.getName());
- unwrappedOperationInfo = new UnwrappedOperationInfo(operationInfo);
- operationInfo.setUnwrappedOperation(unwrappedOperationInfo);
- unwrappedOperationInfo.setInput(operationInfo.getInputName(), unwrappedMessageInfo);
- }
}
void buildBindingInfo(ServiceInfo si) {
@@ -498,4 +431,11 @@
return ua;
}
+ void setAplicationEndpoint(Endpoint ae) {
+ applicationEndpoint = ae;
+ }
+
+ void setManager(RMManager m) {
+ manager = m;
+ }
}
Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java Fri Mar 23 02:37:32 2007
@@ -20,14 +20,10 @@
package org.apache.cxf.ws.rm;
import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
-import org.apache.cxf.Bus;
import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.message.Message;
import org.apache.cxf.ws.addressing.AddressingPropertiesImpl;
import org.apache.cxf.ws.addressing.MAPAggregator;
@@ -38,26 +34,17 @@
public class RMInInterceptor extends AbstractRMInterceptor {
private static final Logger LOG = LogUtils.getL7dLogger(RMInInterceptor.class);
- private Set<String> before = Collections.singleton(MAPAggregator.class.getName());
-
- public Set<String> getBefore() {
- return before;
- }
-
- public Set<String> getAfter() {
- return CastUtils.cast(Collections.EMPTY_SET);
+
+ public RMInInterceptor() {
+ addBefore(MAPAggregator.class.getName());
}
-
- public String getId() {
- return RMInInterceptor.class.getName();
- }
-
- void handleMessage(Message message, boolean isFault) throws SequenceFault {
+
+ protected void handle(Message message) throws SequenceFault {
LOG.entering(getClass().getName(), "handleMessage");
RMProperties rmps = RMContextUtils.retrieveRMProperties(message, false);
- message.getExchange().put(Bus.class, getBus());
+ // message.getExchange().put(Bus.class, getBus());
final AddressingPropertiesImpl maps = RMContextUtils.retrieveMAPs(message, false, false);
assert null != maps;
@@ -85,28 +72,6 @@
LOG.fine("isServerSide: " + isServer);
boolean isApplicationMessage = RMContextUtils.isAplicationMessage(action);
LOG.fine("isApplicationMessage: " + isApplicationMessage);
-
- /*
- if (RMConstants.getCreateSequenceAction().equals(action) && !isServer) {
- LOG.fine("Processing inbound CreateSequence on client side.");
- RMEndpoint rme = getManager().getReliableEndpoint(message);
- Servant servant = rme.getServant();
- CreateSequenceResponseType csr = servant.createSequence(message);
- Proxy proxy = rme.getProxy();
- proxy.createSequenceResponse(csr);
- return;
- }
-
-
- if (RMConstants.getCreateSequenceAction().equals(action)
- || RMConstants.getCreateSequenceResponseAction().equals(action)
- || RMConstants.getTerminateSequenceAction().equals(action)) {
- return;
- } else if (RMConstants.getSequenceAckAction().equals(action)) {
- processAcknowledgments(rmps);
- return;
- }
- */
// for application AND out of band messages
Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java Fri Mar 23 02:37:32 2007
@@ -101,7 +101,7 @@
}
public synchronized RMEndpoint getReliableEndpoint(Message message) {
- Endpoint endpoint = RMContextUtils.getEndpoint(message);
+ Endpoint endpoint = message.getExchange().get(Endpoint.class);
if (LOG.isLoggable(Level.FINE)) {
LOG.fine("Getting RMEndpoint for endpoint with info: " + endpoint.getEndpointInfo().getName());
}
@@ -186,7 +186,7 @@
Proxy proxy = source.getReliableEndpoint().getProxy();
CreateSequenceResponseType createResponse =
- proxy.createSequence(to, acksTo, relatesTo, isServer);
+ proxy.createSequence(acksTo, relatesTo, isServer);
if (!isServer) {
Servant servant = source.getReliableEndpoint().getServant();
servant.createSequenceResponse(createResponse);
Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMOutInterceptor.java Fri Mar 23 02:37:32 2007
@@ -21,13 +21,10 @@
import java.math.BigInteger;
import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.message.Message;
import org.apache.cxf.ws.addressing.AddressingProperties;
import org.apache.cxf.ws.addressing.MAPAggregator;
@@ -40,21 +37,12 @@
public class RMOutInterceptor extends AbstractRMInterceptor {
private static final Logger LOG = LogUtils.getL7dLogger(RMOutInterceptor.class);
- private Set<String> after = Collections.singleton(MAPAggregator.class.getName());
-
- public Set<String> getAfter() {
- return after;
- }
-
- public Set<String> getBefore() {
- return CastUtils.cast(Collections.EMPTY_SET);
- }
-
- public String getId() {
- return RMOutInterceptor.class.getName();
+
+ public RMOutInterceptor() {
+ addAfter(MAPAggregator.class.getName());
}
- void handleMessage(Message message, boolean isFault) throws SequenceFault {
+ protected void handle(Message message) throws SequenceFault {
LOG.entering(getClass().getName(), "handleMessage");
AddressingProperties maps =
Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/WrappedService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/WrappedService.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/WrappedService.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/WrappedService.java Fri Mar 23 02:37:32 2007
@@ -53,6 +53,10 @@
serviceInfo = info;
}
+ public Service getWrappedService() {
+ return wrappedService;
+ }
+
public DataBinding getDataBinding() {
return dataBinding;
}
Added: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractEndpointTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractEndpointTest.java?view=auto&rev=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractEndpointTest.java (added)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractEndpointTest.java Fri Mar 23 02:37:32 2007
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.rm;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+import org.apache.cxf.endpoint.Endpoint;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class AbstractEndpointTest extends TestCase {
+
+ private IMocksControl control;
+ private RMEndpoint rme;
+
+ @Before
+ public void setUp() {
+ control = EasyMock.createNiceControl();
+ rme = control.createMock(RMEndpoint.class);
+ }
+
+ @After
+ public void tearDown() {
+ control.verify();
+ }
+
+ @Test
+ public void testAccessors() {
+ QName n = new QName("abc");
+ EasyMock.expect(rme.getName()).andReturn(n);
+ Endpoint ae = control.createMock(Endpoint.class);
+ EasyMock.expect(rme.getApplicationEndpoint()).andReturn(ae);
+ RMManager mgr = control.createMock(RMManager.class);
+ EasyMock.expect(rme.getManager()).andReturn(mgr);
+ control.replay();
+ AbstractEndpoint tested = new AbstractEndpoint(rme);
+ assertSame(n, tested.getName());
+ assertSame(rme, tested.getReliableEndpoint());
+ assertSame(ae, tested.getEndpoint());
+ assertSame(mgr, tested.getManager());
+ }
+
+ @Test
+ public void testGenerateSequenceIdentifier() {
+ AbstractEndpoint tested = new AbstractEndpoint(null);
+ Identifier id1 = tested.generateSequenceIdentifier();
+ assertNotNull(id1);
+ assertNotNull(id1.getValue());
+ Identifier id2 = tested.generateSequenceIdentifier();
+ assertTrue(id1 != id2);
+ assertTrue(!id1.getValue().equals(id2.getValue()));
+ control.replay();
+ }
+}
Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractEndpointTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractEndpointTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractRMInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractRMInterceptorTest.java?view=auto&rev=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractRMInterceptorTest.java (added)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractRMInterceptorTest.java Fri Mar 23 02:37:32 2007
@@ -0,0 +1,125 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.rm;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import junit.framework.TestCase;
+import org.apache.cxf.Bus;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.ws.policy.AssertionInfo;
+import org.apache.cxf.ws.policy.AssertionInfoMap;
+import org.apache.neethi.Assertion;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class AbstractRMInterceptorTest extends TestCase {
+
+ private IMocksControl control;
+
+ @Before
+ public void setUp() {
+ control = EasyMock.createNiceControl();
+ }
+
+ @After
+ public void tearDown() {
+ control.verify();
+ }
+
+ @Test
+ public void testAccessors() {
+ RMInterceptor interceptor = new RMInterceptor();
+ assertEquals(Phase.PRE_LOGICAL, interceptor.getPhase());
+ Bus bus = control.createMock(Bus.class);
+ RMManager busMgr = control.createMock(RMManager.class);
+ EasyMock.expect(bus.getExtension(RMManager.class)).andReturn(busMgr);
+ RMManager mgr = control.createMock(RMManager.class);
+
+ control.replay();
+ assertNull(interceptor.getBus());
+ interceptor.setBus(bus);
+ assertSame(bus, interceptor.getBus());
+ assertSame(busMgr, interceptor.getManager());
+ interceptor.setManager(mgr);
+ assertSame(mgr, interceptor.getManager());
+ }
+
+ @Test
+ public void testHandleMessage() {
+ RMInterceptor interceptor = new RMInterceptor();
+ Message message = control.createMock(Message.class);
+ control.replay();
+ interceptor.handleMessage(message);
+ interceptor.setThrow(true);
+ try {
+ interceptor.handleMessage(message);
+ fail("Expected Fault not thrown.");
+ } catch (Fault f) {
+ assertTrue(f.getCause() instanceof SequenceFault);
+ }
+ }
+
+ @Test
+ public void testAssertReliability() {
+ RMInterceptor interceptor = new RMInterceptor();
+ Message message = control.createMock(Message.class);
+ EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(null);
+ AssertionInfoMap aim = control.createMock(AssertionInfoMap.class);
+ Collection<AssertionInfo> ais = new ArrayList<AssertionInfo>();
+ EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim).times(2);
+ Assertion a = control.createMock(Assertion.class);
+ AssertionInfo ai = new AssertionInfo(a);
+ EasyMock.expectLastCall();
+ control.replay();
+ interceptor.assertReliability(message);
+ assertTrue(!ai.isAsserted());
+ aim.put(RMConstants.getRMAssertionQName(), ais);
+ interceptor.assertReliability(message);
+ assertTrue(!ai.isAsserted());
+ ais.add(ai);
+ interceptor.assertReliability(message);
+ }
+
+ class RMInterceptor extends AbstractRMInterceptor {
+
+ private boolean doThrow;
+
+ void setThrow(boolean t) {
+ doThrow = t;
+ }
+
+ @Override
+ protected void handle(Message msg) throws SequenceFault {
+ if (doThrow) {
+ throw new SequenceFault("");
+ }
+ }
+ }
+}
Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractRMInterceptorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractRMInterceptorTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractSequenceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractSequenceTest.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractSequenceTest.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractSequenceTest.java Fri Mar 23 02:37:32 2007
@@ -19,9 +19,11 @@
package org.apache.cxf.ws.rm;
import junit.framework.TestCase;
+import org.junit.Test;
public class AbstractSequenceTest extends TestCase {
+ @Test
public void testIdentifierEquals() {
Identifier id1 = null;
Identifier id2 = null;
Modified: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationSequenceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationSequenceTest.java?view=diff&rev=521646&r1=521645&r2=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationSequenceTest.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationSequenceTest.java Fri Mar 23 02:37:32 2007
@@ -39,6 +39,9 @@
import org.apache.cxf.ws.rm.policy.RMAssertion.BaseRetransmissionInterval;
import org.easymock.classextension.EasyMock;
import org.easymock.classextension.IMocksControl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
public class DestinationSequenceTest extends TestCase {
@@ -52,6 +55,7 @@
private AcksPolicyType ap;
private DestinationPolicyType dp;
+ @Before
public void setUp() {
control = EasyMock.createNiceControl();
factory = new ObjectFactory();
@@ -60,6 +64,7 @@
id.setValue("seq");
}
+ @After
public void tearDown() {
ref = null;
destination = null;
@@ -70,6 +75,7 @@
}
+ @Test
public void testConstructors() {
Identifier otherId = factory.createIdentifier();
@@ -92,6 +98,7 @@
}
+ @Test
public void testEqualsAndHashCode() {
DestinationSequence seq = new DestinationSequence(id, ref, destination);
@@ -108,6 +115,7 @@
assertTrue(!seq.equals(this));
}
+ @Test
public void testGetSetDestination() {
control.replay();
DestinationSequence seq = new DestinationSequence(id, ref, destination);
@@ -115,6 +123,7 @@
assertSame(destination, seq.getDestination());
}
+ @Test
public void testGetEndpointIdentifier() {
setUpDestination();
QName qn = new QName("abc", "xyz");
@@ -126,6 +135,7 @@
control.verify();
}
+ @Test
public void testAcknowledgeBasic() throws SequenceFault {
setUpDestination();
Message message1 = setUpMessage("1");
@@ -151,6 +161,7 @@
control.verify();
}
+ @Test
public void testAcknowledgeLastMessageNumberExceeded() throws SequenceFault {
setUpDestination();
Message message1 = setUpMessage("1");
@@ -171,6 +182,7 @@
control.verify();
}
+ @Test
public void testAcknowledgeAppendRange() throws SequenceFault {
setUpDestination();
Message[] messages = new Message [] {
@@ -199,6 +211,7 @@
control.verify();
}
+ @Test
public void testAcknowledgeInsertRange() throws SequenceFault {
setUpDestination();
Message[] messages = new Message [] {
@@ -232,6 +245,7 @@
control.verify();
}
+ @Test
public void testAcknowledgePrependRange() throws SequenceFault {
setUpDestination();
Message[] messages = new Message [] {
@@ -260,6 +274,7 @@
control.verify();
}
+ @Test
public void testMerge() {
DestinationSequence seq = new DestinationSequence(id, ref, destination);
List<AcknowledgementRange> ranges = seq.getAcknowledgment().getAcknowledgementRange();
@@ -303,6 +318,7 @@
assertEquals(new BigInteger("15"), r.getUpper());
}
+ @Test
public void testMonitor() throws SequenceFault {
setUpDestination();
Message[] messages = new Message[15];
@@ -344,7 +360,7 @@
control.verify();
}
-
+ @Test
public void testAcknowledgeImmediate() throws SequenceFault {
setUpDestination();
Message message = setUpMessage("1");
@@ -362,6 +378,7 @@
control.verify();
}
+ @Test
public void testAcknowledgeDeferred() throws SequenceFault, IOException {
Timer timer = new Timer();
setUpDestination(timer);
@@ -407,6 +424,7 @@
control.verify();
}
+ @Test
public void testCorrelationID() {
setUpDestination();
DestinationSequence seq = new DestinationSequence(id, ref, destination);
@@ -418,6 +436,7 @@
seq.getCorrelationID());
}
+ @Test
public void testApplyDeliveryAssuranceAtMostOnce() {
setUpDestination();
@@ -450,6 +469,7 @@
}
+ @Test
public void testInOrderNoWait() {
setUpDestination();
@@ -477,6 +497,7 @@
control.verify();
}
+ @Test
public void testInOrderWait() {
setUpDestination();
Message[] messages = new Message[5];
@@ -545,6 +566,7 @@
control.verify();
}
+ @Test
public void testAllPredecessorsAcknowledged() {
SequenceAcknowledgement ack = control.createMock(SequenceAcknowledgement.class);
Added: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationTest.java?view=auto&rev=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationTest.java (added)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationTest.java Fri Mar 23 02:37:32 2007
@@ -0,0 +1,196 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.rm;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.math.BigInteger;
+
+import junit.framework.TestCase;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.ws.addressing.AddressingPropertiesImpl;
+import org.apache.cxf.ws.addressing.AttributedURIType;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.ws.addressing.JAXWSAConstants;
+import org.apache.cxf.ws.addressing.v200408.AttributedURI;
+import org.apache.cxf.ws.rm.persistence.RMStore;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class DestinationTest extends TestCase {
+
+ private IMocksControl control;
+ private RMEndpoint rme;
+ private Destination destination;
+
+ @Before
+ public void setUp() {
+ control = EasyMock.createNiceControl();
+ rme = control.createMock(RMEndpoint.class);
+ destination = new Destination(rme);
+ }
+
+ @After
+ public void tearDown() {
+ control.verify();
+ }
+
+ @Test
+ public void testGetSequence() {
+ Identifier id = control.createMock(Identifier.class);
+ String sid = "s1";
+ EasyMock.expect(id.getValue()).andReturn(sid);
+ control.replay();
+ assertNull(destination.getSequence(id));
+ }
+
+ @Test
+ public void testGetAllSequences() {
+ control.replay();
+ assertEquals(0, destination.getAllSequences().size());
+ }
+
+ @Test
+ public void testAddRemoveSequence() {
+ DestinationSequence ds = control.createMock(DestinationSequence.class);
+ ds.setDestination(destination);
+ EasyMock.expectLastCall();
+ Identifier id = control.createMock(Identifier.class);
+ EasyMock.expect(ds.getIdentifier()).andReturn(id).times(3);
+ String sid = "s1";
+ EasyMock.expect(id.getValue()).andReturn(sid).times(3);
+ RMManager manager = control.createMock(RMManager.class);
+ EasyMock.expect(rme.getManager()).andReturn(manager).times(2);
+ RMStore store = control.createMock(RMStore.class);
+ EasyMock.expect(manager.getStore()).andReturn(store).times(2);
+ store.createDestinationSequence(ds);
+ EasyMock.expectLastCall();
+ store.removeDestinationSequence(id);
+ EasyMock.expectLastCall();
+ control.replay();
+ destination.addSequence(ds, true);
+ assertEquals(1, destination.getAllSequences().size());
+ assertSame(ds, destination.getSequence(id));
+ destination.removeSequence(ds);
+ assertEquals(0, destination.getAllSequences().size());
+ }
+
+ @Test
+ public void testAcknowledgeNoSequence() throws SequenceFault {
+ Message message = setupMessage();
+ RMProperties rmps = control.createMock(RMProperties.class);
+ EasyMock.expect(message.get(RMMessageConstants.RM_PROPERTIES_INBOUND)).andReturn(rmps);
+ EasyMock.expect(rmps.getSequence()).andReturn(null);
+ control.replay();
+ destination.acknowledge(message);
+ }
+
+ @Test
+ public void testAcknowledgeUnknownSequence() {
+ Message message = setupMessage();
+ RMProperties rmps = control.createMock(RMProperties.class);
+ EasyMock.expect(message.get(RMMessageConstants.RM_PROPERTIES_INBOUND)).andReturn(rmps);
+ SequenceType st = control.createMock(SequenceType.class);
+ EasyMock.expect(rmps.getSequence()).andReturn(st);
+ Identifier id = control.createMock(Identifier.class);
+ EasyMock.expect(st.getIdentifier()).andReturn(id).times(2);
+ String sid = "sid";
+ EasyMock.expect(id.getValue()).andReturn(sid).times(2);
+ control.replay();
+ try {
+ destination.acknowledge(message);
+ fail("Expected SequenceFault not thrown.");
+ } catch (SequenceFault ex) {
+ assertEquals(RMConstants.getUnknownSequenceFaultCode(), ex.getFaultInfo().getFaultCode());
+ }
+ }
+
+ @Test
+ public void testAcknowledgeLastMessage() throws NoSuchMethodException, SequenceFault, IOException {
+
+ Method m1 = Destination.class.getDeclaredMethod("getSequence", new Class[] {Identifier.class});
+ Method m2 = Destination.class.getMethod("getReliableEndpoint", new Class[] {});
+
+ destination = control.createMock(Destination.class, new Method[] {m1, m2});
+ Message message = setupMessage();
+ RMProperties rmps = control.createMock(RMProperties.class);
+ EasyMock.expect(message.get(RMMessageConstants.RM_PROPERTIES_INBOUND)).andReturn(rmps);
+ SequenceType st = control.createMock(SequenceType.class);
+ EasyMock.expect(rmps.getSequence()).andReturn(st);
+ Identifier id = control.createMock(Identifier.class);
+ EasyMock.expect(st.getIdentifier()).andReturn(id);
+ DestinationSequence ds = control.createMock(DestinationSequence.class);
+ EasyMock.expect(destination.getSequence(id)).andReturn(ds);
+ ds.acknowledge(message);
+ EasyMock.expectLastCall();
+ SequenceType.LastMessage lm = control.createMock(SequenceType.LastMessage.class);
+ EasyMock.expect(st.getLastMessage()).andReturn(lm);
+ BigInteger nr = BigInteger.TEN;
+ EasyMock.expect(st.getMessageNumber()).andReturn(nr);
+ ds.setLastMessageNumber(nr);
+ EasyMock.expectLastCall();
+ ds.scheduleImmediateAcknowledgement();
+ EasyMock.expectLastCall();
+ AddressingPropertiesImpl maps = control.createMock(AddressingPropertiesImpl.class);
+ EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(null);
+ EasyMock.expect(message.get(JAXWSAConstants.SERVER_ADDRESSING_PROPERTIES_INBOUND)).andReturn(maps);
+ EndpointReferenceType replyToEPR = control.createMock(EndpointReferenceType.class);
+ EasyMock.expect(maps.getReplyTo()).andReturn(replyToEPR).times(2);
+ AttributedURIType replyToURI = control.createMock(AttributedURIType.class);
+ EasyMock.expect(replyToEPR.getAddress()).andReturn(replyToURI);
+ String replyToAddress = "replyTo";
+ EasyMock.expect(replyToURI.getValue()).andReturn(replyToAddress);
+ org.apache.cxf.ws.addressing.v200408.EndpointReferenceType acksToEPR =
+ control.createMock(org.apache.cxf.ws.addressing.v200408.EndpointReferenceType.class);
+ EasyMock.expect(ds.getAcksTo()).andReturn(acksToEPR);
+ AttributedURI acksToURI = control.createMock(AttributedURI.class);
+ EasyMock.expect(acksToEPR.getAddress()).andReturn(acksToURI);
+ String acksToAddress = "acksTo";
+ EasyMock.expect(acksToURI.getValue()).andReturn(acksToAddress);
+ EasyMock.expect(ds.canPiggybackAckOnPartialResponse()).andReturn(false);
+ EasyMock.expect(destination.getReliableEndpoint()).andReturn(rme);
+ Proxy proxy = control.createMock(Proxy.class);
+ EasyMock.expect(rme.getProxy()).andReturn(proxy);
+ proxy.acknowledge(ds);
+ EasyMock.expectLastCall().andThrow(new IOException(""));
+
+ control.replay();
+ destination.acknowledge(message);
+ }
+
+ private Message setupMessage() {
+ Message message = control.createMock(Message.class);
+ Exchange exchange = control.createMock(Exchange.class);
+ EasyMock.expect(message.getExchange()).andReturn(exchange);
+ EasyMock.expect(exchange.getOutMessage()).andReturn(null);
+ EasyMock.expect(exchange.getOutFaultMessage()).andReturn(null);
+ return message;
+ }
+
+
+
+}
Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/DestinationTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ProxyTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ProxyTest.java?view=auto&rev=521646
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ProxyTest.java (added)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ProxyTest.java Fri Mar 23 02:37:32 2007
@@ -0,0 +1,318 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.rm;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.datatype.Duration;
+
+import junit.framework.TestCase;
+import org.apache.cxf.Bus;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.jaxb.DatatypeFactory;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.InterfaceInfo;
+import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.workqueue.SynchronousExecutor;
+import org.apache.cxf.ws.addressing.AttributedURIType;
+import org.apache.cxf.ws.addressing.RelatesToType;
+import org.apache.cxf.ws.addressing.v200408.AttributedURI;
+import org.apache.cxf.ws.addressing.v200408.EndpointReferenceType;
+import org.apache.cxf.ws.rm.manager.SourcePolicyType;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class ProxyTest extends TestCase {
+
+ private IMocksControl control;
+ private RMEndpoint rme;
+
+ @Before
+ public void setUp() {
+ control = EasyMock.createNiceControl();
+ rme = control.createMock(RMEndpoint.class);
+ }
+
+ @After
+ public void tearDown() {
+ control.verify();
+ }
+
+ @Test
+ public void testCtor() {
+ Proxy proxy = new Proxy(rme);
+ assertSame(rme, proxy.getReliableEndpoint());
+ control.replay();
+ }
+
+ @Test
+ public void testOfferedIdentifier() {
+ OfferType offer = control.createMock(OfferType.class);
+ Identifier id = control.createMock(Identifier.class);
+ EasyMock.expect(offer.getIdentifier()).andReturn(id);
+ control.replay();
+ Proxy proxy = new Proxy(rme);
+ assertNull(proxy.getOfferedIdentifier());
+ proxy.setOfferedIdentifier(offer);
+ assertSame(id, proxy.getOfferedIdentifier());
+ }
+
+ @Test
+ public void testAcknowledgeNotSupported() throws IOException {
+ DestinationSequence ds = control.createMock(DestinationSequence.class);
+ EndpointReferenceType acksToEPR = control.createMock(EndpointReferenceType.class);
+ EasyMock.expect(ds.getAcksTo()).andReturn(acksToEPR);
+ AttributedURI acksToURI = control.createMock(AttributedURI.class);
+ EasyMock.expect(acksToEPR.getAddress()).andReturn(acksToURI);
+ String acksToAddress = RMConstants.getAnonymousAddress();
+ EasyMock.expect(acksToURI.getValue()).andReturn(acksToAddress);
+ control.replay();
+ Proxy proxy = new Proxy(rme);
+ proxy.acknowledge(ds);
+ }
+
+ @Test
+ public void testAcknowledge() throws NoSuchMethodException, IOException {
+ Method m = Proxy.class.getDeclaredMethod("invoke",
+ new Class[] {OperationInfo.class, Object[].class, Map.class});
+ Proxy proxy = control.createMock(Proxy.class, new Method[] {m});
+ proxy.setReliableEndpoint(rme);
+ DestinationSequence ds = control.createMock(DestinationSequence.class);
+ EndpointReferenceType acksToEPR = control.createMock(EndpointReferenceType.class);
+ EasyMock.expect(ds.getAcksTo()).andReturn(acksToEPR);
+ AttributedURI acksToURI = control.createMock(AttributedURI.class);
+ EasyMock.expect(acksToEPR.getAddress()).andReturn(acksToURI);
+ String acksToAddress = "acksTo";
+ EasyMock.expect(acksToURI.getValue()).andReturn(acksToAddress);
+ Service service = control.createMock(Service.class);
+ EasyMock.expect(rme.getService()).andReturn(service);
+ ServiceInfo si = control.createMock(ServiceInfo.class);
+ EasyMock.expect(service.getServiceInfo()).andReturn(si);
+ InterfaceInfo ii = control.createMock(InterfaceInfo.class);
+ EasyMock.expect(si.getInterface()).andReturn(ii);
+ OperationInfo oi = control.createMock(OperationInfo.class);
+ EasyMock.expect(ii.getOperation(RMConstants.getSequenceAckOperationName())).andReturn(oi);
+ expectInvoke(proxy, oi, null);
+ control.replay();
+ proxy.acknowledge(ds);
+ }
+
+ @Test
+ public void testTerminate() throws NoSuchMethodException, IOException {
+ Method m = Proxy.class.getDeclaredMethod("invoke",
+ new Class[] {OperationInfo.class, Object[].class, Map.class});
+ Proxy proxy = control.createMock(Proxy.class, new Method[] {m});
+ proxy.setReliableEndpoint(rme);
+ Service service = control.createMock(Service.class);
+ EasyMock.expect(rme.getService()).andReturn(service);
+ ServiceInfo si = control.createMock(ServiceInfo.class);
+ EasyMock.expect(service.getServiceInfo()).andReturn(si);
+ InterfaceInfo ii = control.createMock(InterfaceInfo.class);
+ EasyMock.expect(si.getInterface()).andReturn(ii);
+ OperationInfo oi = control.createMock(OperationInfo.class);
+ EasyMock.expect(ii.getOperation(RMConstants.getTerminateSequenceOperationName())).andReturn(oi);
+ SourceSequence ss = control.createMock(SourceSequence.class);
+ Identifier id = control.createMock(Identifier.class);
+ EasyMock.expect(ss.getIdentifier()).andReturn(id);
+ expectInvoke(proxy, oi, null);
+ control.replay();
+ proxy.terminate(ss);
+ }
+
+ @Test
+ public void testCreateSequenceResponse() throws NoSuchMethodException, IOException {
+ Method m = Proxy.class.getDeclaredMethod("invoke",
+ new Class[] {OperationInfo.class, Object[].class, Map.class});
+ Proxy proxy = control.createMock(Proxy.class, new Method[] {m});
+ proxy.setReliableEndpoint(rme);
+ Service service = control.createMock(Service.class);
+ EasyMock.expect(rme.getService()).andReturn(service);
+ ServiceInfo si = control.createMock(ServiceInfo.class);
+ EasyMock.expect(service.getServiceInfo()).andReturn(si);
+ InterfaceInfo ii = control.createMock(InterfaceInfo.class);
+ EasyMock.expect(si.getInterface()).andReturn(ii);
+ OperationInfo oi = control.createMock(OperationInfo.class);
+ EasyMock.expect(ii.getOperation(RMConstants.getCreateSequenceResponseOnewayOperationName()))
+ .andReturn(oi);
+ CreateSequenceResponseType csr = control.createMock(CreateSequenceResponseType.class);
+ expectInvoke(proxy, oi, null);
+ control.replay();
+ proxy.createSequenceResponse(csr);
+ }
+
+ @Test
+ public void testCreateSequenceOnClient() throws NoSuchMethodException, IOException {
+ testCreateSequence(false);
+ }
+
+ @Test
+ public void testCreateSequenceOnServer() throws NoSuchMethodException, IOException {
+ testCreateSequence(true);
+ }
+
+ @Test
+ public void testInvoke() throws Exception {
+ Method m = Proxy.class.getDeclaredMethod("createClient",
+ new Class[] {Bus.class, Endpoint.class, Conduit.class,
+ org.apache.cxf.ws.addressing.EndpointReferenceType.class});
+ Proxy proxy = control.createMock(Proxy.class, new Method[] {m});
+ proxy.setReliableEndpoint(rme);
+
+ RMManager manager = control.createMock(RMManager.class);
+ EasyMock.expect(rme.getManager()).andReturn(manager);
+ Bus bus = control.createMock(Bus.class);
+ EasyMock.expect(manager.getBus()).andReturn(bus);
+ Endpoint endpoint = control.createMock(Endpoint.class);
+ EasyMock.expect(rme.getEndpoint()).andReturn(endpoint);
+ BindingInfo bi = control.createMock(BindingInfo.class);
+ EasyMock.expect(rme.getBindingInfo()).andReturn(bi);
+
+ Conduit conduit = control.createMock(Conduit.class);
+ EasyMock.expect(rme.getConduit()).andReturn(conduit);
+ org.apache.cxf.ws.addressing.EndpointReferenceType replyTo
+ = control.createMock(org.apache.cxf.ws.addressing.EndpointReferenceType.class);
+ EasyMock.expect(rme.getReplyTo()).andReturn(replyTo);
+
+ OperationInfo oi = control.createMock(OperationInfo.class);
+ BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
+ EasyMock.expect(bi.getOperation(oi)).andReturn(boi);
+ Client client = control.createMock(Client.class);
+ EasyMock.expect(proxy.createClient(bus, endpoint, conduit, replyTo)).andReturn(client);
+ Object[] args = new Object[] {};
+ Map<String, Object> context = new HashMap<String, Object>();
+ Object[] results = new Object[] {"a", "b", "c"};
+ EasyMock.expect(client.invoke(boi, args, context)).andReturn(results);
+
+ control.replay();
+ assertEquals("a", proxy.invoke(oi, args, context));
+ }
+
+ @Test
+ public void testRMClientConstruction() {
+ Proxy proxy = new Proxy(rme);
+ Bus bus = control.createMock(Bus.class);
+ Endpoint endpoint = control.createMock(Endpoint.class);
+ Conduit conduit = control.createMock(Conduit.class);
+ org.apache.cxf.ws.addressing.EndpointReferenceType address =
+ control.createMock(org.apache.cxf.ws.addressing.EndpointReferenceType.class);
+ control.replay();
+ assertNotNull(proxy.createClient(bus, endpoint, conduit, address));
+ }
+
+ @Test
+ public void testRMClientGetConduit() {
+ Proxy proxy = new Proxy(rme);
+ Bus bus = control.createMock(Bus.class);
+ Endpoint endpoint = control.createMock(Endpoint.class);
+ Conduit conduit = control.createMock(Conduit.class);
+ org.apache.cxf.ws.addressing.EndpointReferenceType address =
+ control.createMock(org.apache.cxf.ws.addressing.EndpointReferenceType.class);
+ Proxy.RMClient client = proxy.new RMClient(bus, endpoint, conduit, address);
+ EndpointInfo endpointInfo = control.createMock(EndpointInfo.class);
+ EasyMock.expect(endpoint.getEndpointInfo()).andReturn(endpointInfo);
+ String oa = "oa";
+ EasyMock.expect(endpointInfo.getAddress()).andReturn(oa);
+ AttributedURIType uri = control.createMock(AttributedURIType.class);
+ EasyMock.expect(address.getAddress()).andReturn(uri);
+ String ta = "ta";
+ EasyMock.expect(uri.getValue()).andReturn(ta);
+ endpointInfo.setAddress(ta);
+ EasyMock.expectLastCall();
+ endpointInfo.setAddress(oa);
+ EasyMock.expectLastCall();
+ control.replay();
+ assertSame(conduit, client.getConduit());
+ }
+
+
+
+ private void testCreateSequence(boolean isServer) throws NoSuchMethodException, IOException {
+ Method m = Proxy.class.getDeclaredMethod("invoke",
+ new Class[] {OperationInfo.class, Object[].class, Map.class});
+ Proxy proxy = control.createMock(Proxy.class, new Method[] {m});
+ proxy.setReliableEndpoint(rme);
+
+ RMManager manager = control.createMock(RMManager.class);
+ EasyMock.expect(rme.getManager()).andReturn(manager);
+ SourcePolicyType sp = control.createMock(SourcePolicyType.class);
+ EasyMock.expect(manager.getSourcePolicy()).andReturn(sp);
+ EasyMock.expect(sp.getAcksTo()).andReturn(null);
+ Duration d = DatatypeFactory.createDuration("PT12H");
+ EasyMock.expect(sp.getSequenceExpiration()).andReturn(d);
+ EasyMock.expect(sp.isIncludeOffer()).andReturn(true);
+ Duration dOffered = DatatypeFactory.createDuration("PT24H");
+ EasyMock.expect(sp.getOfferedSequenceExpiration()).andReturn(dOffered);
+ Source source = control.createMock(Source.class);
+ EasyMock.expect(rme.getSource()).andReturn(source);
+ Identifier offeredId = control.createMock(Identifier.class);
+ EasyMock.expect(source.generateSequenceIdentifier()).andReturn(offeredId);
+
+ Service service = control.createMock(Service.class);
+ EasyMock.expect(rme.getService()).andReturn(service);
+ ServiceInfo si = control.createMock(ServiceInfo.class);
+ EasyMock.expect(service.getServiceInfo()).andReturn(si);
+ InterfaceInfo ii = control.createMock(InterfaceInfo.class);
+ EasyMock.expect(si.getInterface()).andReturn(ii);
+ OperationInfo oi = control.createMock(OperationInfo.class);
+ CreateSequenceResponseType csr = control.createMock(CreateSequenceResponseType.class);
+ if (isServer) {
+ EasyMock.expect(ii.getOperation(RMConstants.getCreateSequenceOnewayOperationName()))
+ .andReturn(oi);
+ Endpoint ae = control.createMock(Endpoint.class);
+ EasyMock.expect(rme.getApplicationEndpoint()).andReturn(ae);
+ EasyMock.expect(ae.getExecutor()).andReturn(SynchronousExecutor.getInstance());
+ expectInvoke(proxy, oi, null);
+ } else {
+ EasyMock.expect(ii.getOperation(RMConstants.getCreateSequenceOperationName()))
+ .andReturn(oi);
+ expectInvoke(proxy, oi, csr);
+ }
+
+ EndpointReferenceType defaultAcksTo = control.createMock(EndpointReferenceType.class);
+ RelatesToType relatesTo = control.createMock(RelatesToType.class);
+ control.replay();
+ if (isServer) {
+ assertNull(proxy.createSequence(defaultAcksTo, relatesTo, isServer));
+ } else {
+ assertSame(csr, proxy.createSequence(defaultAcksTo, relatesTo, isServer));
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void expectInvoke(Proxy proxy, OperationInfo oi, Object expectedReturn) {
+ EasyMock.expect(proxy.invoke(EasyMock.same(oi), EasyMock.isA(Object[].class),
+ (Map)EasyMock.isNull())).andReturn(expectedReturn);
+ }
+}
Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ProxyTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/ProxyTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date