You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by lr...@apache.org on 2009/09/26 01:32:39 UTC

svn commit: r819062 - in /tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl: PropertyProcessorTestCase.java ReferenceProcessorTestCase.java

Author: lresende
Date: Fri Sep 25 23:32:39 2009
New Revision: 819062

URL: http://svn.apache.org/viewvc?rev=819062&view=rev
Log:
Minor testcase re-formatting

Modified:
    tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java
    tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java

Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java?rev=819062&r1=819061&r2=819062&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java Fri Sep 25 23:32:39 2009
@@ -46,6 +46,13 @@
     JavaImplementation type;
     PropertyProcessor processor;
 
+    @Before
+    public void setUp() throws Exception {
+        JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+        type = javaImplementationFactory.createJavaImplementation();
+        processor = new PropertyProcessor(new DefaultAssemblyFactory());
+    }
+
     @Test
     public void testMethodAnnotation() throws Exception {
         processor.visitMethod(Foo.class.getMethod("setFoo", String.class), type);
@@ -118,102 +125,6 @@
         }
     }
 
-    @Before
-    public void setUp() throws Exception {
-        JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
-        type = javaImplementationFactory.createJavaImplementation();
-        processor = new PropertyProcessor(new DefaultAssemblyFactory());
-    }
-
-    private class Foo {
-
-        @Property
-        protected String baz;
-        @Property(required = true)
-        protected String bazRequired;
-        @Property(name = "theBaz")
-        protected String bazField;
-
-        @Property
-        public void setFoo(String string) {
-        }
-
-        @Property(required = true)
-        public void setFooRequired(String string) {
-        }
-
-        @Property(name = "bar")
-        public void setBarMethod(String string) {
-        }
-
-    }
-
-    private class Bar {
-
-        @Property
-        protected String dup;
-
-        @Property(name = "dup")
-        protected String baz;
-
-        @Property
-        public void setDupMethod(String s) {
-        }
-
-        @Property(name = "dupMethod")
-        public void setDupSomeMethod(String s) {
-        }
-
-        @Property
-        public void badMethod() {
-        }
-
-    }
-
-    private class Multiple {
-        @Property
-        protected List<String> refs1;
-
-        @Property
-        protected String[] refs2;
-
-        @Property
-        public void setRefs3(String[] refs) {
-        }
-
-        @Property
-        public void setRefs4(Collection<String> refs) {
-        }
-
-    }
-    
-    private static class BadMethodProps {
-
-        @org.oasisopen.sca.annotation.Constructor()
-        public BadMethodProps(@Property(name = "myProp", required = true)String prop) {
-
-        }
-        
-        /** Java can't tell that the @reference argument is disallowed by SCA, but the run time must reject it*/
-        public void BadMethod(@Property(name = "badMethodArgProp")String methArg) 
-        {}
-
- 
-    }
-    
-    private static class BadStaticProps {
-    	
-    	@Property(name="badstaticfield")static int stint;
-    	
-    	@Property(name="badstaticfield")static void setStint(int theStint) {
-    		stint = theStint;
-    	}
-    }
-
-    private Class<?> getBaseType(JavaElementImpl element) {
-        return JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType());
-    }
-
     @Test
     public void testMultiplicityCollection() throws Exception {
         processor.visitField(Multiple.class.getDeclaredField("refs1"), type);
@@ -299,4 +210,96 @@
 
     }
 
+    /**
+     * Private classes utilized in the tests
+     */
+    
+    private class Foo {
+
+        @Property
+        protected String baz;
+        
+        @Property(required = true)
+        protected String bazRequired;
+        
+        @Property(name = "theBaz")
+        protected String bazField;
+
+        @Property
+        public void setFoo(String string) {
+        }
+
+        @Property(required = true)
+        public void setFooRequired(String string) {
+        }
+
+        @Property(name = "bar")
+        public void setBarMethod(String string) {
+        }
+
+    }
+
+    private class Bar {
+
+        @Property
+        protected String dup;
+
+        @Property(name = "dup")
+        protected String baz;
+
+        @Property
+        public void setDupMethod(String s) {
+        }
+
+        @Property(name = "dupMethod")
+        public void setDupSomeMethod(String s) {
+        }
+
+        @Property
+        public void badMethod() {
+        }
+    }
+
+    private class Multiple {
+        @Property
+        protected List<String> refs1;
+
+        @Property
+        protected String[] refs2;
+
+        @Property
+        public void setRefs3(String[] refs) {
+        }
+
+        @Property
+        public void setRefs4(Collection<String> refs) {
+        }
+    }
+    
+    private static class BadMethodProps {
+
+        @org.oasisopen.sca.annotation.Constructor()
+        public BadMethodProps(@Property(name = "myProp", required = true)String prop) {
+
+        }
+        
+        /** Java can't tell that the @reference argument is disallowed by SCA, but the run time must reject it*/
+        public void BadMethod(@Property(name = "badMethodArgProp")String methArg) {
+        
+        }
+    }
+    
+    private static class BadStaticProps {
+    	
+    	@Property(name="badstaticfield")static int stint;
+    	
+    	@Property(name="badstaticfield")static void setStint(int theStint) {
+    		stint = theStint;
+    	}
+    }
+
+    private Class<?> getBaseType(JavaElementImpl element) {
+        return JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType());
+    }
+   
 }

Modified: tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java?rev=819062&r1=819061&r2=819062&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessorTestCase.java Fri Sep 25 23:32:39 2009
@@ -48,6 +48,13 @@
     private JavaImplementation type;
     private ReferenceProcessor processor;
 
+    @Before
+    public void setUp() throws Exception {
+        JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
+        type = javaImplementationFactory.createJavaImplementation();
+        processor = new ReferenceProcessor(new DefaultAssemblyFactory(), new DefaultJavaInterfaceFactory());
+    }
+
     @Test
     public void testMethodAnnotation() throws Exception {
         processor.visitMethod(ReferenceProcessorTestCase.Foo.class.getMethod("setFoo", Ref.class), type);
@@ -142,22 +149,91 @@
 		}
     }
 
-    @Before
-    public void setUp() throws Exception {
-        JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
-        type = javaImplementationFactory.createJavaImplementation();
-        processor = new ReferenceProcessor(new DefaultAssemblyFactory(), new DefaultJavaInterfaceFactory());
+    @Test
+    public void testMultiplicity1ToN() throws Exception {
+        processor.visitField(Multiple.class.getDeclaredField("refs1"), type);
+        org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "refs1");
+        assertNotNull(ref);
+        assertSame(Ref.class, ((JavaInterface)ref.getInterfaceContract().getInterface()).getJavaClass());
+        assertEquals(Multiplicity.ONE_N, ref.getMultiplicity());
+        // assertEquals(Multiplicity.ONE_ONE, ref.getMultiplicity());
+    }
+
+    @Test
+    public void testMultiplicityTo0ToN() throws Exception {
+        processor.visitField(Multiple.class.getDeclaredField("refs2"), type);
+        org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "refs2");
+        assertNotNull(ref);
+        assertSame(Ref.class, ((JavaInterface)ref.getInterfaceContract().getInterface()).getJavaClass());
+        assertEquals(Multiplicity.ZERO_N, ref.getMultiplicity());
+        // assertFalse(ref.isMustSupply());
+    }
+
+    @Test
+    public void testMultiplicity1ToNMethod() throws Exception {
+        processor.visitMethod(Multiple.class.getMethod("setRefs3", Ref[].class), type);
+        org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "refs3");
+        assertNotNull(ref);
+        assertSame(Ref.class, ((JavaInterface)ref.getInterfaceContract().getInterface()).getJavaClass());
+        assertEquals(Multiplicity.ONE_N, ref.getMultiplicity());
+        // assertEquals(Multiplicity.ONE_ONE, ref.getMultiplicity());
+    }
+
+    @Test
+    public void testMultiplicity0ToNMethod() throws Exception {
+        processor.visitMethod(Multiple.class.getMethod("setRefs4", Collection.class), type);
+        org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "refs4");
+        assertNotNull(ref);
+        assertSame(Ref.class, ((JavaInterface)ref.getInterfaceContract().getInterface()).getJavaClass());
+        assertEquals(Multiplicity.ZERO_N, ref.getMultiplicity());
+        // assertFalse(ref.isMustSupply());
     }
+    
+    @Test
+    public void testRejectStaticFieldReference() throws Exception {
+    	try {
+    		processor.visitField(BadStaticRefs.class.getDeclaredField("stint"), type);
+    		fail("Processor should not accept a static field with Property annotation");
+    	}
+    	catch (IllegalReferenceException e) {
+			// System.out.println("Caught expected exception");
+		}
+    	catch (Exception e) {
+			fail("Wrong exception detected");
+			e.printStackTrace();
+		}
+    }
+    	
+    @Test
+    public void testRejectStaticMethodReference() throws Exception {
+    	try {
+    		processor.visitMethod(BadStaticRefs.class.getDeclaredMethod("setStint",int.class), type);
+    		fail("Processor should not accept a static method with Property annotation");
+    	}
+    	catch (IllegalPropertyException e) {
+			// System.out.println("Caught expected exception");
+		}
+    	catch (Exception e) {
+			fail("Wrong exception detected");
+			e.printStackTrace();
+		}
+
+    }
+
+    /**
+     * Private classes utilized in the tests
+     */
 
     private interface Ref {
     }
 
     private class Foo {
-
         @Reference
         protected Ref baz;
+        
         @Reference(required = true)
         protected Ref bazRequired;
+        
         @Reference(name = "theBaz")
         protected Ref bazField;
 
@@ -172,11 +248,9 @@
         @Reference(name = "bar")
         public void setBarMethod(Ref ref) {
         }
-
     }
 
     private class Bar {
-
         @Reference
         protected Ref dup;
 
@@ -211,7 +285,6 @@
         @Reference(required = false)
         public void setRefs4(Collection<Ref> refs) {
         }
-
     }
     
     private static class BadStaticRefs {
@@ -232,80 +305,8 @@
         }
         
         /** Java can't tell that the @reference argument is disallowed by SCA, but the run time must reject it*/
-        public void BadMethod(@Reference(name = "badMethodArgRef")String methArg) 
-        {}
-
-    }
-
-    @Test
-    public void testMultiplicity1ToN() throws Exception {
-        processor.visitField(Multiple.class.getDeclaredField("refs1"), type);
-        org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "refs1");
-        assertNotNull(ref);
-        assertSame(Ref.class, ((JavaInterface)ref.getInterfaceContract().getInterface()).getJavaClass());
-        assertEquals(Multiplicity.ONE_N, ref.getMultiplicity());
-        // assertEquals(Multiplicity.ONE_ONE, ref.getMultiplicity());
-    }
-
-    @Test
-    public void testMultiplicityTo0ToN() throws Exception {
-        processor.visitField(Multiple.class.getDeclaredField("refs2"), type);
-        org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "refs2");
-        assertNotNull(ref);
-        assertSame(Ref.class, ((JavaInterface)ref.getInterfaceContract().getInterface()).getJavaClass());
-        assertEquals(Multiplicity.ZERO_N, ref.getMultiplicity());
-        // assertFalse(ref.isMustSupply());
-    }
-
-    @Test
-    public void testMultiplicity1ToNMethod() throws Exception {
-        processor.visitMethod(Multiple.class.getMethod("setRefs3", Ref[].class), type);
-        org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "refs3");
-        assertNotNull(ref);
-        assertSame(Ref.class, ((JavaInterface)ref.getInterfaceContract().getInterface()).getJavaClass());
-        assertEquals(Multiplicity.ONE_N, ref.getMultiplicity());
-        // assertEquals(Multiplicity.ONE_ONE, ref.getMultiplicity());
-    }
-
-    @Test
-    public void testMultiplicity0ToNMethod() throws Exception {
-        processor.visitMethod(Multiple.class.getMethod("setRefs4", Collection.class), type);
-        org.apache.tuscany.sca.assembly.Reference ref = getReference(type, "refs4");
-        assertNotNull(ref);
-        assertSame(Ref.class, ((JavaInterface)ref.getInterfaceContract().getInterface()).getJavaClass());
-        assertEquals(Multiplicity.ZERO_N, ref.getMultiplicity());
-        // assertFalse(ref.isMustSupply());
-    }
-    
-    @Test
-    public void testRejectStaticFieldReference() throws Exception {
-    	try {
-    		processor.visitField(BadStaticRefs.class.getDeclaredField("stint"), type);
-    		fail("Processor should not accept a static field with Property annotation");
-    	}
-    	catch (IllegalReferenceException e) {
-			// System.out.println("Caught expected exception");
-		}
-    	catch (Exception e) {
-			fail("Wrong exception detected");
-			e.printStackTrace();
-		}
-    }
-    	
-    @Test
-    public void testRejectStaticMethodReference() throws Exception {
-    	try {
-    		processor.visitMethod(BadStaticRefs.class.getDeclaredMethod("setStint",int.class), type);
-    		fail("Processor should not accept a static method with Property annotation");
-    	}
-    	catch (IllegalPropertyException e) {
-			// System.out.println("Caught expected exception");
-		}
-    	catch (Exception e) {
-			fail("Wrong exception detected");
-			e.printStackTrace();
-		}
-
+        public void BadMethod(@Reference(name = "badMethodArgRef")String methArg) {
+        
+        }
     }
-
 }