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

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


    /**
     * Verifies a service interface is calculated when only props and refs are
     * given
     */
    public void testExcludedPropertyAndReference() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        org.apache.tuscany.sca.assembly.Reference ref = factory.createReference();
        ref.setName("reference");
        type.getReferences().add(ref);
        type.getReferenceMembers().put("reference", new JavaElementImpl("reference", Ref.class, null));
        org.apache.tuscany.sca.assembly.Reference ref2 = factory.createReference();
        ref2.setName("reference2");
        type.getReferences().add(ref2);
        type.getReferenceMembers().put("reference2", new JavaElementImpl("reference2", Ref.class, null));
        org.apache.tuscany.sca.assembly.Property prop1 = factory.createProperty();
        prop1.setName("string1");
        type.getProperties().add(prop1);
        type.getPropertyMembers().put("string1", new JavaElementImpl("string1", String.class, null));
        org.apache.tuscany.sca.assembly.Property prop2 = factory.createProperty();
        prop2.setName("string2");
        type.getProperties().add(prop2);
        type.getPropertyMembers().put("string2", new JavaElementImpl("string2", String.class, null));
        visitEnd(MockService.class, type);
        assertEquals(1, type.getServices().size());
    }
View Full Code Here


        visitEnd(MockService.class, type);
        assertEquals(1, type.getServices().size());
    }

    public void testProtectedRemotableRefField() throws IntrospectionException, NoSuchMethodException {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<ProtectedRemotableRefFieldImpl> ctor = ProtectedRemotableRefFieldImpl.class.getConstructor();
        type.setConstructor(new JavaConstructorImpl<ProtectedRemotableRefFieldImpl>(ctor));
        processor.visitEnd(ProtectedRemotableRefFieldImpl.class, type);
        assertNotNull(ModelHelper.getReference(type, "otherRef"));
    }
View Full Code Here

        processor.visitEnd(ProtectedRemotableRefFieldImpl.class, type);
        assertNotNull(ModelHelper.getReference(type, "otherRef"));
    }

    public void testProtectedRemotableRefMethod() throws IntrospectionException, NoSuchMethodException {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<ProtectedRemotableRefMethodImpl> ctor = ProtectedRemotableRefMethodImpl.class.getConstructor();
        type.setConstructor(new JavaConstructorImpl<ProtectedRemotableRefMethodImpl>(ctor));
        processor.visitEnd(ProtectedRemotableRefMethodImpl.class, type);
        assertNotNull(ModelHelper.getReference(type, "otherRef"));
    }
View Full Code Here

        processor.visitEnd(ProtectedRemotableRefMethodImpl.class, type);
        assertNotNull(ModelHelper.getReference(type, "otherRef"));
    }

    public void testSetDataTypes() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<PropertyIntTypeOnConstructor> ctor = PropertyIntTypeOnConstructor.class.getConstructor();
        type.setConstructor(new JavaConstructorImpl<PropertyIntTypeOnConstructor>(ctor));
        processor.visitEnd(PropertyIntTypeOnConstructor.class, type);
        org.apache.tuscany.sca.assembly.Property foo = ModelHelper.getProperty(type, "foo");
        assertEquals(int.class, type.getPropertyMembers().get("foo").getType());
        assertEquals(new QName(JavaXMLMapper.URI_2001_SCHEMA_XSD, "int"), foo.getXSDType());
    }
View Full Code Here

     * references of an unannotated POJO (section 1.2.7).  This test makes sure that the earlier implementation
     * is corrected as per the errata.  A notable difference is that the interfaces annotated with @Service
     * no longer result in references.
     */
    public void testUpdatedRule() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        visitEnd(SomeServiceImpl.class, type);
        assertEquals(12, type.getReferenceMembers().size());
        assertTrue(type.getReferenceMembers().containsKey("rri1"));
        assertTrue(type.getReferenceMembers().containsKey("rri2"));
        assertTrue(type.getReferenceMembers().containsKey("rri3"));
        assertTrue(type.getReferenceMembers().containsKey("rri4"));

        assertTrue(type.getReferenceMembers().containsKey("rria1"));
        assertTrue(type.getReferenceMembers().containsKey("rria2"));
        assertTrue(type.getReferenceMembers().containsKey("rria3"));
        assertTrue(type.getReferenceMembers().containsKey("rria4"));

        assertTrue(type.getReferenceMembers().containsKey("rric1"));
        assertTrue(type.getReferenceMembers().containsKey("rric2"));
        assertTrue(type.getReferenceMembers().containsKey("rric3"));
        assertTrue(type.getReferenceMembers().containsKey("rric4"));
       
        assertEquals(16, type.getPropertyMembers().size());
        assertTrue(type.getPropertyMembers().containsKey("pnri1"));
        assertTrue(type.getPropertyMembers().containsKey("pnri2"));
        assertTrue(type.getPropertyMembers().containsKey("pnri3"));
        assertTrue(type.getPropertyMembers().containsKey("pnri4"));

        assertTrue(type.getPropertyMembers().containsKey("pnria1"));
        assertTrue(type.getPropertyMembers().containsKey("pnria2"));
        assertTrue(type.getPropertyMembers().containsKey("pnria3"));
        assertTrue(type.getPropertyMembers().containsKey("pnria4"));

        assertTrue(type.getPropertyMembers().containsKey("pnric1"));
        assertTrue(type.getPropertyMembers().containsKey("pnric2"));
        assertTrue(type.getPropertyMembers().containsKey("pnric3"));
        assertTrue(type.getPropertyMembers().containsKey("pnric4"));
       
        assertTrue(type.getPropertyMembers().containsKey("gen1"));
        assertTrue(type.getPropertyMembers().containsKey("gen2"));
        assertTrue(type.getPropertyMembers().containsKey("gen3"));
        assertTrue(type.getPropertyMembers().containsKey("gen4"));
    }
View Full Code Here

public class ConstructorPropertyTestCase extends AbstractProcessorTest {
   
    private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();

    public void testProperty() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
        visitConstructor(ctor, type);
        org.apache.tuscany.sca.assembly.Property property = getProperty(type, "myProp");
        assertTrue(property.isMustSupply());
        assertEquals("myProp", property.getName());
View Full Code Here

        assertTrue(property.isMustSupply());
        assertEquals("myProp", property.getName());
    }

    public void testTwoPropertiesSameType() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<Foo> ctor = Foo.class.getConstructor(String.class, String.class);
        visitConstructor(ctor, type);
        assertNotNull(getProperty(type, "myProp1"));
        assertNotNull(getProperty(type, "myProp2"));
    }
View Full Code Here

        assertNotNull(getProperty(type, "myProp1"));
        assertNotNull(getProperty(type, "myProp2"));
    }

    public void testDuplicateProperty() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class, String.class);
        try {
            visitConstructor(ctor, type);
            fail();
        } catch (DuplicatePropertyException e) {
View Full Code Here

            // expected
        }
    }

    public void testNoName() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class);
        try {
            visitConstructor(ctor, type);
            fail();
        } catch (InvalidPropertyException e) {
View Full Code Here

            // expected
        }
    }

    public void testNamesOnConstructor() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor<Foo> ctor = Foo.class.getConstructor(Integer.class);
        visitConstructor(ctor, type);
        assertNotNull(getProperty(type, "myProp"));
    }
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.