Package org.apache.tuscany.sca.implementation.java

Examples of org.apache.tuscany.sca.implementation.java.JavaImplementation


        }
    }

    public void testTwoDestroy() throws Exception {
        DestroyProcessor processor = new DestroyProcessor(assemblyFactory);
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Method method = Bar.class.getMethod("destroy");
        Method method2 = Bar.class.getMethod("destroy2");
        processor.visitMethod(method, type);
        try {
            processor.visitMethod(method2, type);
View Full Code Here


        javaImplementationFactory = new DefaultJavaImplementationFactory();
    }

    public void testInit() throws Exception {
        InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory());
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Method method = InitProcessorTestCase.Foo.class.getMethod("init");
        processor.visitMethod(method, type);
        assertNotNull(type.getInitMethod());
    }
View Full Code Here

        assertNotNull(type.getInitMethod());
    }

    public void testBadInit() throws Exception {
        InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory());
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Method method = InitProcessorTestCase.Bar.class.getMethod("badInit", String.class);
        try {
            processor.visitMethod(method, type);
            fail();
        } catch (IllegalInitException e) {
View Full Code Here

        }
    }

    public void testTwoInit() throws Exception {
        InitProcessor processor = new InitProcessor(new DefaultAssemblyFactory());
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Method method = InitProcessorTestCase.Bar.class.getMethod("init");
        Method method2 = InitProcessorTestCase.Bar.class.getMethod("init2");
        processor.visitMethod(method, type);
        try {
            processor.visitMethod(method2, type);
View Full Code Here

    /**
     * Verifies a single constructor is chosen with a parameter as the type
     */
    public void testSingleConstructorWithParam() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        org.apache.tuscany.sca.assembly.Property prop = factory.createProperty();
        prop.setName("foo");
        type.getProperties().add(prop);
        // Hack to add a property member
        JavaElementImpl element = new JavaElementImpl("foo", String.class, null);
        type.getPropertyMembers().put("foo", element);
        visitEnd(Foo1.class, type);
        assertNotNull(type.getConstructor().getConstructor());
        assertEquals("foo", type.getConstructor().getParameters()[0].getName());
    }
View Full Code Here

    /**
     * Verifies a single constructor is chosen with a reference as the type
     */
    public void testSingleConstructorWithRef() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        org.apache.tuscany.sca.assembly.Reference ref = factory.createReference();
        ref.setName("foo");
        type.getReferences().add(ref);
        type.getReferenceMembers().put("foo", new JavaElementImpl("foo", String.class, null));
        visitEnd(Foo1.class, type);
        assertNotNull(type.getConstructor().getConstructor());
        assertEquals("foo", type.getConstructor().getParameters()[0].getName());
    }
View Full Code Here

    /**
     * Verifies a single constructor is chosen with a property and a reference
     * as the type
     */
    public void testSingleConstructorWithPropRef() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();

        org.apache.tuscany.sca.assembly.Property prop = factory.createProperty();
        prop.setName("foo");
        type.getProperties().add(prop);
        // Hack to add a property member
        JavaElementImpl element = new JavaElementImpl("foo", String.class, null);
        type.getPropertyMembers().put("foo", element);

        org.apache.tuscany.sca.assembly.Reference ref = ModelHelper.createReference(factory, javaFactory, "ref", Foo1.class);
        type.getReferences().add(ref);
        type.getReferenceMembers().put("ref", new JavaElementImpl("ref", Foo1.class, null));
        visitEnd(Foo2.class, type);
        assertNotNull(type.getConstructor().getConstructor());
        assertEquals(2, type.getConstructor().getParameters().length);
    }
View Full Code Here

        assertNotNull(type.getConstructor().getConstructor());
        assertEquals(2, type.getConstructor().getParameters().length);
    }

    public void testSingleConstructorResolvableParam() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        visitEnd(Foo5.class, type);
        assertEquals(String.class, type.getPropertyMembers().get("string").getType());
    }
View Full Code Here

        visitEnd(Foo5.class, type);
        assertEquals(String.class, type.getPropertyMembers().get("string").getType());
    }

    public void testSingleConstructorResolvableRef() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        visitEnd(Foo6.class, type);
        assertTrue(ModelHelper.matches(ModelHelper.getReference(type, "ref"), Ref.class));
    }
View Full Code Here

        visitEnd(Foo6.class, type);
        assertTrue(ModelHelper.matches(ModelHelper.getReference(type, "ref"), Ref.class));
    }

    public void testSingleConstructorAmbiguousRef() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        org.apache.tuscany.sca.assembly.Reference ref = ModelHelper.createReference(factory, javaFactory, "ref", Foo1.class);
        type.getReferences().add(ref);
        type.getReferenceMembers().put("ref", new JavaElementImpl("ref", Foo1.class, null));
        org.apache.tuscany.sca.assembly.Reference ref2 = ModelHelper.createReference(factory, javaFactory, "ref2", Foo1.class);
        type.getReferences().add(ref2);
        type.getReferenceMembers().put("ref2", new JavaElementImpl("ref2", Foo1.class, null));
        try {
            visitEnd(Foo4.class, type);
            fail();
        } catch (AmbiguousConstructorException e) {
            // expected
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.implementation.java.JavaImplementation

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.