You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jm...@apache.org on 2006/05/22 02:31:52 UTC
svn commit: r408537 - in /incubator/tuscany/sandbox/jboynes/sca/core2/src:
main/java/org/apache/tuscany/core/builder/
main/java/org/apache/tuscany/core/wire/
main/java/org/apache/tuscany/core/wire/jdk/
test/java/org/apache/tuscany/core/builder/
Author: jmarino
Date: Sun May 21 17:31:51 2006
New Revision: 408537
URL: http://svn.apache.org/viewvc?rev=408537&view=rev
Log:
more connector testcases
Modified:
incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/RequestResponseInterceptor.java
incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/SourceInvocationChainImpl.java
incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInvocationHandler.java
incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/builder/ConnectorTestCase.java
Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java?rev=408537&r1=408536&r2=408537&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java Sun May 21 17:31:51 2006
@@ -114,7 +114,7 @@
e.setIdentifier(source.getReferenceName());
throw e;
}
- // if handler is configured, add that
+ // if handlers are configured, add them
if (targetChain.getRequestHandlers() != null || targetChain.getResponseHandlers() != null) {
sourceChain.setTargetRequestChannel(new MessageChannelImpl(targetChain
.getRequestHandlers()));
Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/RequestResponseInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/RequestResponseInterceptor.java?rev=408537&r1=408536&r2=408537&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/RequestResponseInterceptor.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/RequestResponseInterceptor.java Sun May 21 17:31:51 2006
@@ -37,7 +37,7 @@
private MessageChannel targetResponseChannel;
/**
- * Construct an interceptor that sends messages down the supplied channels.
+ * Creates an interceptor that sends messages down the supplied channels
*
* @param targetRequestChannel the channel to send request messages down
* @param targetResponseChannel the channel to sent response messages down
Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/SourceInvocationChainImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/SourceInvocationChainImpl.java?rev=408537&r1=408536&r2=408537&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/SourceInvocationChainImpl.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/SourceInvocationChainImpl.java Sun May 21 17:31:51 2006
@@ -93,7 +93,6 @@
if (targetInterceptorChainHead != null) {
// Connect source interceptor chain directly to target interceptor chain
interceptorChainTail.setNext(targetInterceptorChainHead);
- // interceptorChainTail = targetInterceptorChainHead;
} else {
// Connect source interceptor chain to the target request channel
Interceptor channelInterceptor = new RequestResponseInterceptor(null, targetRequestChannel, null,
Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInvocationHandler.java?rev=408537&r1=408536&r2=408537&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInvocationHandler.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInvocationHandler.java Sun May 21 17:31:51 2006
@@ -59,38 +59,38 @@
e.setIdentifier(method.getName());
throw e;
}
- InvocationChain config = holder.chain;
- if (config != null) {
- headInterceptor = config.getHeadInterceptor();
+ InvocationChain chain = holder.chain;
+ if (chain != null) {
+ headInterceptor = chain.getHeadInterceptor();
}
TargetInvoker invoker;
if (holder.cachedInvoker == null) {
- assert config != null;
- if (config.getTargetInvoker() == null) {
+ assert chain != null;
+ if (chain.getTargetInvoker() == null) {
TargetException e = new TargetException("No target invoker configured for operation");
- e.setIdentifier(config.getMethod().getName());
+ e.setIdentifier(chain.getMethod().getName());
throw e;
}
- if (config.getTargetInvoker().isCacheable()) {
+ if (chain.getTargetInvoker().isCacheable()) {
// clone and store the invoker locally
- holder.cachedInvoker = (TargetInvoker) config.getTargetInvoker().clone();
+ holder.cachedInvoker = (TargetInvoker) chain.getTargetInvoker().clone();
invoker = holder.cachedInvoker;
} else {
- invoker = config.getTargetInvoker();
+ invoker = chain.getTargetInvoker();
}
} else {
- assert config != null;
- invoker = config.getTargetInvoker();
+ assert chain != null;
+ invoker = chain.getTargetInvoker();
}
if (headInterceptor == null) {
try {
// short-circuit the dispatch and invoke the target directly
- if (config.getTargetInvoker() == null) {
+ if (chain.getTargetInvoker() == null) {
throw new AssertionError("No target invoker [" + method.getName() + "]");
}
- return config.getTargetInvoker().invokeTarget(args);
+ return chain.getTargetInvoker().invokeTarget(args);
} catch (InvocationTargetException e) {
// the cause was thrown by the target so throw it
throw e.getCause();
Modified: incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/builder/ConnectorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/builder/ConnectorTestCase.java?rev=408537&r1=408536&r2=408537&view=diff
==============================================================================
--- incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/builder/ConnectorTestCase.java (original)
+++ incubator/tuscany/sandbox/jboynes/sca/core2/src/test/java/org/apache/tuscany/core/builder/ConnectorTestCase.java Sun May 21 17:31:51 2006
@@ -53,7 +53,7 @@
TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
}
-
+ targetContext.prepare();
scopeContext.onEvent(new ModuleStart(this, null));
SimpleSource source = sourceContext.getService();
assertEquals("foo", source.getTarget().echo("foo"));
@@ -81,7 +81,7 @@
TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
}
-
+ targetContext.prepare();
scopeContext.onEvent(new ModuleStart(this, null));
assertEquals(0, interceptor.getCount());
SimpleSource source = sourceContext.getService();
@@ -110,7 +110,7 @@
TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
}
-
+ targetContext.prepare();
scopeContext.onEvent(new ModuleStart(this, null));
assertEquals(0, interceptor.getCount());
SimpleSource source = sourceContext.getService();
@@ -142,7 +142,7 @@
TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
}
-
+ targetContext.prepare();
scopeContext.onEvent(new ModuleStart(this, null));
assertEquals(0, sourceInterceptor.getCount());
assertEquals(0, targetInterceptor.getCount());
@@ -176,7 +176,41 @@
TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
}
+ targetContext.prepare();
+ scopeContext.onEvent(new ModuleStart(this, null));
+ assertEquals(0, interceptor.getCount());
+ assertEquals(0, handler.getCount());
+ SimpleSource source = sourceContext.getService();
+ assertEquals("foo", source.getTarget().echo("foo"));
+ assertEquals(1, handler.getCount());
+ assertEquals(1, interceptor.getCount());
+ scopeContext.onEvent(new ModuleStop(this, null));
+ scopeContext.stop();
+ }
+ /**
+ * Verifies an invocation with a target interceptor and a request handler
+ */
+ @SuppressWarnings("unchecked")
+ public void testTargetInterceptorTargetRequestHandler() throws Exception {
+ ConnectorImpl connector = new ConnectorImpl();
+ WorkContext workContext = new WorkContextImpl();
+ ModuleScopeContext scopeContext = new ModuleScopeContext(workContext);
+ scopeContext.start();
+
+ MockSyncInterceptor interceptor = new MockSyncInterceptor();
+ List<Interceptor> interceptors = new ArrayList<Interceptor>();
+ interceptors.add(interceptor);
+ MockHandler handler = new MockHandler();
+ List<MessageHandler> handlers = new ArrayList<MessageHandler>();
+ handlers.add(handler);
+ MockAtomicContext<SimpleSource> sourceContext = setupSource(scopeContext, null,null, null);
+ MockAtomicContext<SimpleTarget> targetContext = setupTarget(scopeContext, interceptors, handlers, null);
+ for (SourceWire<?> sourceWire : sourceContext.getSourceWires()) {
+ TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
+ connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
+ }
+ targetContext.prepare();
scopeContext.onEvent(new ModuleStart(this, null));
assertEquals(0, interceptor.getCount());
assertEquals(0, handler.getCount());
@@ -188,6 +222,8 @@
scopeContext.stop();
}
+
+
/**
* Verifies an invocation with a source interceptor and response handler
*/
@@ -210,7 +246,7 @@
TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
}
-
+ targetContext.prepare();
scopeContext.onEvent(new ModuleStart(this, null));
assertEquals(0, interceptor.getCount());
assertEquals(0, handler.getCount());
@@ -244,7 +280,7 @@
TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
}
-
+ targetContext.prepare();
scopeContext.onEvent(new ModuleStart(this, null));
assertEquals(0, interceptor.getCount());
assertEquals(0, handler.getCount());
@@ -275,7 +311,7 @@
TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
}
-
+ targetContext.prepare();
scopeContext.onEvent(new ModuleStart(this, null));
assertEquals(0, handler.getCount());
SimpleSource source = sourceContext.getService();
@@ -304,7 +340,7 @@
TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
}
-
+ targetContext.prepare();
scopeContext.onEvent(new ModuleStart(this, null));
assertEquals(0, handler.getCount());
SimpleSource source = sourceContext.getService();
@@ -333,7 +369,7 @@
TargetWire<SimpleTarget> targetWire = targetContext.getTargetWire(sourceWire.getTargetName().getPortName());
connector.connect((SourceWire<SimpleTarget>) sourceWire, targetWire, targetContext, false);
}
-
+ targetContext.prepare();
scopeContext.onEvent(new ModuleStart(this, null));
assertEquals(0, handler.getCount());
SimpleSource source = sourceContext.getService();
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org