1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
package org.apache.tuscany.core.builder.impl;
import java.lang.reflect.Method;
import java.util.Map;
import junit.framework.TestCase;
import org.apache.tuscany.core.builder.BuilderConfigException;
import org.apache.tuscany.core.context.QualifiedName;
import org.apache.tuscany.core.invocation.InvocationConfiguration;
import org.apache.tuscany.core.invocation.MethodHashMap;
import org.apache.tuscany.core.invocation.ProxyConfiguration;
import org.apache.tuscany.core.invocation.jdk.JDKProxyFactory;
import org.apache.tuscany.core.invocation.mock.SimpleTarget;
import org.apache.tuscany.core.invocation.spi.ProxyFactory;
import org.apache.tuscany.core.message.MessageFactory;
import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
public class NegativeDefaultWireBuilderTestCase extends TestCase {
private Method hello;
private Method goodbye;
public NegativeDefaultWireBuilderTestCase() {
super();
}
public NegativeDefaultWireBuilderTestCase(String arg0) {
super(arg0);
}
public void setUp() throws Exception {
hello = SimpleTarget.class.getMethod("hello", new Class[] { String.class });
goodbye = SimpleTarget.class.getMethod("goodbye", new Class[] { String.class });
}
public void testNoTargetInterceptorOrHandler() throws Exception {
MessageFactory msgFactory = new MessageFactoryImpl();
InvocationConfiguration source = new InvocationConfiguration(hello);
ProxyFactory sourceFactory = new JDKProxyFactory();
Map<Method, InvocationConfiguration> sourceInvocationConfigs = new MethodHashMap();
sourceInvocationConfigs.put(hello, source);
ProxyConfiguration sourceConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
sourceInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
sourceFactory.setProxyConfiguration(sourceConfig);
sourceFactory.setBusinessInterface(SimpleTarget.class);
InvocationConfiguration target = new InvocationConfiguration(hello);
ProxyFactory targetFactory = new JDKProxyFactory();
Map<Method, InvocationConfiguration> targetInvocationConfigs = new MethodHashMap();
targetInvocationConfigs.put(hello, target);
ProxyConfiguration targetConfig = new ProxyConfiguration(new QualifiedName("target/SimpleTarget"),
targetInvocationConfigs, Thread.currentThread().getContextClassLoader(), msgFactory);
targetFactory.setProxyConfiguration(targetConfig);
targetFactory.setBusinessInterface(SimpleTarget.class);
// connect the source to the target
DefaultWireBuilder builder = new DefaultWireBuilder();
try {
builder.connect(sourceFactory, targetFactory, null, true, null);
fail("Expected " + BuilderConfigException.class.getName());
} catch (BuilderConfigException e) {
// success
}
}
}
|