summaryrefslogtreecommitdiffstats
path: root/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java')
-rw-r--r--sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java138
1 files changed, 0 insertions, 138 deletions
diff --git a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java b/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java
deleted file mode 100644
index 9f21b9efdb..0000000000
--- a/sandbox/rfeng/minicore/src/test/java/org/apache/tuscany/core/wire/WireObjectFactoryTestCase.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * 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.tuscany.core.wire;
-
-import java.lang.reflect.Type;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.tuscany.spi.idl.java.JavaServiceContract;
-import org.apache.tuscany.spi.model.Operation;
-import org.apache.tuscany.spi.model.ServiceContract;
-import org.apache.tuscany.spi.wire.ProxyService;
-import org.apache.tuscany.spi.wire.InvocationChain;
-import org.apache.tuscany.spi.wire.Wire;
-
-import junit.framework.TestCase;
-import org.easymock.EasyMock;
-
-/**
- * @version $Rev$ $Date$
- */
-public class WireObjectFactoryTestCase extends TestCase {
-
- @SuppressWarnings({"unchecked"})
- public void testCreateInstance() throws Exception {
- Operation<Type> op = new Operation<Type>("hello", null, null, null);
- InvocationChain chain = new InvocationChainImpl(op);
- Wire wire = EasyMock.createMock(Wire.class);
- Map<Operation<?>, InvocationChain> chains = new HashMap<Operation<?>, InvocationChain>();
- chains.put(op, chain);
- EasyMock.expect(wire.getInvocationChains()).andReturn(chains);
- EasyMock.expect(wire.isOptimizable()).andReturn(false);
- EasyMock.replay(wire);
- ProxyService service = EasyMock.createMock(ProxyService.class);
- service.createProxy(EasyMock.eq(Foo.class), EasyMock.eq(wire), EasyMock.isA(Map.class));
- EasyMock.expectLastCall().andReturn(new Foo() {
- public void hello() {
-
- }
- });
- EasyMock.replay(service);
-
- WireObjectFactory<Foo> factory = new WireObjectFactory<Foo>(Foo.class, wire, service);
- factory.getInstance();
- EasyMock.verify(service);
- EasyMock.verify(wire);
- }
-
- @SuppressWarnings("unchecked")
- public void testOptimizedCreateInstance() throws Exception {
- ServiceContract<?> contract = new JavaServiceContract(Foo.class);
- Wire wire = EasyMock.createMock(Wire.class);
- EasyMock.expect(wire.isOptimizable()).andReturn(true);
- EasyMock.expect(wire.getSourceContract()).andReturn(contract).atLeastOnce();
- EasyMock.expect(wire.getInvocationChains()).andReturn((Map) Collections.emptyMap());
- EasyMock.expect(wire.getTargetInstance()).andReturn(new Foo() {
- public void hello() {
- }
- });
- EasyMock.replay(wire);
- WireObjectFactory<Foo> factory = new WireObjectFactory<Foo>(Foo.class, wire, null);
- factory.getInstance();
- EasyMock.verify(wire);
-
- }
-
- /**
- * Verifies that a proxy is created when the required client contract is different than the wire contract
- */
- @SuppressWarnings("unchecked")
- public void testCannotOptimizeDifferentContractsCreateInstance() throws Exception {
- ServiceContract<?> contract = new JavaServiceContract(Object.class);
- Wire wire = EasyMock.createMock(Wire.class);
- EasyMock.expect(wire.isOptimizable()).andReturn(true);
- EasyMock.expect(wire.getSourceContract()).andReturn(contract).atLeastOnce();
- EasyMock.expect(wire.getInvocationChains()).andReturn((Map) Collections.emptyMap());
- EasyMock.replay(wire);
- ProxyService service = EasyMock.createMock(ProxyService.class);
- service.createProxy(EasyMock.eq(Foo.class), EasyMock.eq(wire), EasyMock.isA(Map.class));
- EasyMock.expectLastCall().andReturn(new Foo() {
- public void hello() {
-
- }
- });
- EasyMock.replay(service);
-
- WireObjectFactory<Foo> factory = new WireObjectFactory<Foo>(Foo.class, wire, service);
- factory.getInstance();
- EasyMock.verify(service);
- EasyMock.verify(wire);
- }
-
- @SuppressWarnings("unchecked")
- public void testNoJavaInterfaceCreateInstance() throws Exception {
- ServiceContract<?> contract = new JavaServiceContract();
- Wire wire = EasyMock.createMock(Wire.class);
- EasyMock.expect(wire.isOptimizable()).andReturn(true);
- EasyMock.expect(wire.getSourceContract()).andReturn(contract).atLeastOnce();
- EasyMock.expect(wire.getInvocationChains()).andReturn((Map) Collections.emptyMap());
- EasyMock.replay(wire);
- ProxyService service = EasyMock.createMock(ProxyService.class);
- service.createProxy(EasyMock.eq(Foo.class), EasyMock.eq(wire), EasyMock.isA(Map.class));
- EasyMock.expectLastCall().andReturn(new Foo() {
- public void hello() {
-
- }
- });
- EasyMock.replay(service);
-
- WireObjectFactory<Foo> factory = new WireObjectFactory<Foo>(Foo.class, wire, service);
- factory.getInstance();
- EasyMock.verify(service);
- EasyMock.verify(wire);
- }
-
- private interface Foo {
- void hello();
- }
-
-
-}