Package org.apache.tuscany.spi.idl.java

Examples of org.apache.tuscany.spi.idl.java.JavaServiceContract


        ServiceDefinition serviceDefinition = (ServiceDefinition) services.values()
                                                                          .iterator()
                                                                          .next();
        ServiceContract serviceContract = serviceDefinition.getServiceContract();
        assertTrue(serviceContract instanceof JavaServiceContract);
        JavaServiceContract javaServiceContract = (JavaServiceContract) serviceContract;
        assertEquals(HelloWorldService.class,
                     javaServiceContract.getInterfaceClass());
    }
View Full Code Here


        EasyMock.expectLastCall().andReturn(null);
        EasyMock.replay(wireService);

        //Create a mocked InboundWire, make the call of ServiceExtension.getInterface() returns a Class
        InboundWire inboundWire = EasyMock.createNiceMock(InboundWire.class);
        JavaServiceContract contract = new JavaServiceContract(Greeter.class);
        Map<String, Operation<Type>> opMap = new HashMap<String, Operation<Type>>();
        for(Method m: Greeter.class.getMethods()) {
            opMap.put(m.getName(), new Operation<Type>(m.getName(), null, null, null));
        }
        contract.setOperations(opMap);
        EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
        if (callback) {
            contract.setCallbackName("");
        }
        EasyMock.replay(inboundWire);

        OutboundWire outboundWire = EasyMock.createNiceMock(OutboundWire.class);
        Map<Operation<?>, OutboundInvocationChain> map = new HashMap<Operation<?>, OutboundInvocationChain>();
View Full Code Here

        }
        reference.setName(name);

        reference.setRequired(autowireAnnot.required());

        ServiceContract<?> contract = new JavaServiceContract();
        contract.setInterfaceClass(param);
        reference.setServiceContract(contract);
        type.getReferences().put(name, reference);
        addName(injectionNames, pos, name);
    }
View Full Code Here

    public void testAsyncTargetInvoker() throws Exception {
        Axis2Reference axis2Reference = createAxis2Reference("testWebAppName", "testServiceName");
        //Create a mocked InboundWire, make the call of ServiceExtension.getInterface() returns a Class
        InboundWire inboundWire = EasyMock.createNiceMock(InboundWire.class);
        JavaServiceContract contract = new JavaServiceContract(Greeter.class);
        contract.setCallbackClass(GreetingCallback.class);
        Operation<Type> callbackOp = new Operation<Type>("sayHiCallback", null, null, null, true, null);
        HashMap<String,Operation<Type>> callbackOps = new HashMap<String,Operation<Type>>();
        callbackOps.put("sayHiCallback", callbackOp);
        contract.setCallbackOperations(callbackOps);
        EasyMock.expect(inboundWire.getServiceContract()).andReturn(contract).anyTimes();
        EasyMock.replay(inboundWire);

        axis2Reference.setInboundWire(inboundWire);
        Operation operation = new Operation<Type>("sayHi", null, null, null, true, null);
View Full Code Here

        List<DataType<Type>> types = new ArrayList<DataType<Type>>();
        types.add(type1);
        DataType<List<DataType<Type>>> inputType1 = new DataType<List<DataType<Type>>>(Object[].class, types);
        DataType<Type> outputType1 = new DataType<Type>(String.class, String.class);
        Operation<Type> op1 = new Operation<Type>("test", inputType1, outputType1, null);
        ServiceContract<Type> outboundContract = new JavaServiceContract(null);
        outboundContract.setDataBinding(String.class.getName());
        op1.setServiceContract(outboundContract);

        OutboundInvocationChain outboundChain = createMock(OutboundInvocationChain.class);
        outboundChains.put(op1, outboundChain);
        expect(outboundWire.getInvocationChains()).andReturn(outboundChains);
        outboundChain.addInterceptor(EasyMock.anyInt(), (Interceptor)EasyMock.anyObject());

        Map<Operation<?>, InboundInvocationChain> inboundChains =
            new HashMap<Operation<?>, InboundInvocationChain>();
        DataType<Type> type2 = new DataType<Type>(Node.class, Node.class);
        List<DataType<Type>> types2 = new ArrayList<DataType<Type>>();
        types2.add(type2);
        DataType<List<DataType<Type>>> inputType2 =
            new DataType<List<DataType<Type>>>(Object[].class, types2);
        DataType<Type> outputType2 = new DataType<Type>(String.class, String.class);
        Operation<Type> op2 = new Operation<Type>("test", inputType2, outputType2, null);
        ServiceContract<Type> inboundContract = new JavaServiceContract(null);
        inboundContract.setDataBinding(Node.class.getName());
        op2.setServiceContract(inboundContract);

        InboundInvocationChain inboundChain = createMock(InboundInvocationChain.class);
        inboundChains.put(op2, inboundChain);
        expect(inboundWire.getInvocationChains()).andReturn(inboundChains);

        ServiceContract<Type> contract = new JavaServiceContract();
        Map<String, Operation<Type>> operations = Collections.emptyMap();
        contract.setCallbackOperations(operations);
        expect(outboundWire.getServiceContract()).andReturn(contract);

        EasyMock.replay(composite, component, inboundWire, outboundWire, inboundChain, outboundChain);

        processor.process(outboundWire, inboundWire);
View Full Code Here

        List<DataType<Type>> types = new ArrayList<DataType<Type>>();
        types.add(type1);
        DataType<List<DataType<Type>>> inputType1 = new DataType<List<DataType<Type>>>(Object[].class, types);
        DataType<Type> outputType1 = new DataType<Type>(String.class, String.class);
        Operation<Type> op1 = new Operation<Type>("test", inputType1, outputType1, null);
        ServiceContract<Type> outboundContract = new JavaServiceContract(null);
        outboundContract.setDataBinding(String.class.getName());
        op1.setServiceContract(outboundContract);

        OutboundInvocationChain outboundChain = createMock(OutboundInvocationChain.class);
        outboundChains.put(op1, outboundChain);
        expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
        outboundChain.addInterceptor(EasyMock.anyInt(), (Interceptor)EasyMock.anyObject());

        Map<Operation<?>, InboundInvocationChain> inboundChains =
            new HashMap<Operation<?>, InboundInvocationChain>();
        DataType<Type> type2 = new DataType<Type>(Node.class, Node.class);
        List<DataType<Type>> types2 = new ArrayList<DataType<Type>>();
        types2.add(type2);
        DataType<List<DataType<Type>>> inputType2 =
            new DataType<List<DataType<Type>>>(Object[].class, types2);
        DataType<Type> outputType2 = new DataType<Type>(String.class, String.class);
        Operation<Type> op2 = new Operation<Type>("test", inputType2, outputType2, null);
        ServiceContract<Type> inboundContract = new JavaServiceContract(null);
        inboundContract.setDataBinding(Node.class.getName());
        op2.setServiceContract(inboundContract);

        InboundInvocationChain inboundChain = createMock(InboundInvocationChain.class);
        inboundChains.put(op2, inboundChain);
        expect(inboundWire.getInvocationChains()).andReturn(inboundChains).anyTimes();

        ServiceContract<Type> contract = new JavaServiceContract();
        Map<String, Operation<Type>> operations = Collections.emptyMap();
        contract.setCallbackOperations(operations);
        expect(inboundWire.getServiceContract()).andReturn(contract);
        expect(inboundChain.getTailInterceptor()).andReturn(null);

        EasyMock.replay(composite, reference, inboundWire, outboundWire, inboundChain, outboundChain);
View Full Code Here

        List<DataType<Type>> types = new ArrayList<DataType<Type>>();
        types.add(type1);
        DataType<List<DataType<Type>>> inputType1 = new DataType<List<DataType<Type>>>(Object[].class, types);
        DataType<Type> outputType1 = new DataType<Type>(String.class, String.class);
        Operation<Type> op1 = new Operation<Type>("test", inputType1, outputType1, null);
        ServiceContract<Type> outboundContract = new JavaServiceContract(null);
        outboundContract.setDataBinding(String.class.getName());
        op1.setServiceContract(outboundContract);

        OutboundInvocationChain outboundChain = createMock(OutboundInvocationChain.class);
        outboundChains.put(op1, outboundChain);
        expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
        // outboundChain.addInterceptor(EasyMock.anyInt(), (Interceptor)
        // EasyMock.anyObject());

        Map<Operation<?>, InboundInvocationChain> inboundChains =
            new HashMap<Operation<?>, InboundInvocationChain>();
        DataType<Type> type2 = new DataType<Type>(Node.class, Node.class);
        List<DataType<Type>> types2 = new ArrayList<DataType<Type>>();
        types2.add(type2);
        DataType<List<DataType<Type>>> inputType2 =
            new DataType<List<DataType<Type>>>(Object[].class, types2);
        DataType<Type> outputType2 = new DataType<Type>(String.class, String.class);
        Operation<Type> op2 = new Operation<Type>("test", inputType2, outputType2, null);
        ServiceContract<Type> inboundContract = new JavaServiceContract(null);
        inboundContract.setDataBinding(Node.class.getName());
        op2.setServiceContract(inboundContract);

        InboundInvocationChain inboundChain = createMock(InboundInvocationChain.class);
        inboundChains.put(op2, inboundChain);
        expect(inboundWire.getInvocationChains()).andReturn(inboundChains).anyTimes();
        inboundChain.addInterceptor(EasyMock.anyInt(), (Interceptor)EasyMock.anyObject());

        ServiceContract<Type> contract = new JavaServiceContract();
        Map<String, Operation<Type>> operations = Collections.emptyMap();
        contract.setCallbackOperations(operations);
        expect(inboundWire.getServiceContract()).andReturn(contract);

        EasyMock.replay(composite, service, inboundWire, outboundWire, inboundChain, outboundChain);

        processor.process(inboundWire, outboundWire);
View Full Code Here

    /**
     * @throws InvalidServiceContractException
     */
    public final void testVisitInterface() throws InvalidServiceContractException {
        DataBindingJavaInterfaceProcessor processor = new DataBindingJavaInterfaceProcessor();
        JavaServiceContract contract = new JavaServiceContract(MockInterface.class);
        Map<String, Operation<Type>> operations = new HashMap<String, Operation<Type>>();
        Operation<Type> operation = new Operation<Type>("call", null, null, null, false, null);
        Operation<Type> operation1 = new Operation<Type>("call1", null, null, null, false, null);
        operations.put("call", operation);
        operations.put("call1", operation1);
        contract.setOperations(operations);
        processor.visitInterface(MockInterface.class, null, contract);
        Assert.assertEquals("org.w3c.dom.Node", contract.getDataBinding());
        Assert.assertEquals("element", (String)contract.getMetaData().get("nodeType"));
        Assert.assertEquals("org.w3c.dom.Node", contract.getOperations().get("call").getDataBinding());
        Assert.assertEquals("xml:string", contract.getOperations().get("call1").getDataBinding());
    }
View Full Code Here

        Map services = comonentType.getServices();
        assertEquals(1, services.size());
        ServiceDefinition serviceDefinition = (ServiceDefinition) services.values().iterator().next();
        ServiceContract serviceContract = serviceDefinition.getServiceContract();
        assertTrue(serviceContract instanceof JavaServiceContract);
        JavaServiceContract javaServiceContract = (JavaServiceContract) serviceContract;
        assertEquals(HelloWorldService.class, javaServiceContract.getInterfaceClass());
    }
View Full Code Here

    public static <T> InboundWire createTargetWireFactory(String serviceName, Class<T> interfaze)
        throws InvalidServiceContractException {
        InboundWire wire = new InboundWireImpl();
        wire.setServiceName(serviceName);
        JavaServiceContract contract = new JavaServiceContract(interfaze);
        wire.setServiceContract(contract);
        wire.addInvocationChains(createInboundChains(interfaze));
        return wire;
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.spi.idl.java.JavaServiceContract

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.