aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z..@apache.org
Subject svn commit: r1075143 [19/23] - in /aries/tags/blueprint-0.2.1: ./ blueprint-annotation-api/ blueprint-annotation-api/src/ blueprint-annotation-api/src/main/ blueprint-annotation-api/src/main/java/ blueprint-annotation-api/src/main/java/org/ blueprint-a...
Date Sun, 27 Feb 2011 20:50:51 GMT
Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/container/AggregateConverterTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/container/AggregateConverterTest.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/container/AggregateConverterTest.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/container/AggregateConverterTest.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,222 @@
+/*
+ * 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.aries.blueprint.container;
+
+import java.io.ByteArrayOutputStream;
+import java.math.BigInteger;
+import java.net.URI;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+import org.apache.aries.blueprint.TestBlueprintContainer;
+import org.osgi.service.blueprint.container.ReifiedType;
+import org.osgi.service.blueprint.container.Converter;
+
+public class AggregateConverterTest extends TestCase {
+
+    private AggregateConverter service;
+
+    protected void setUp() {
+        service = new AggregateConverter(new TestBlueprintContainer(null));
+    }
+
+    public void testConvertNumbers() throws Exception {
+        assertEquals(1, service.convert(1.46f, int.class));
+        assertEquals(1.0d, service.convert(1, double.class));
+    }
+
+    public void testConvertSimpleTypes() throws Exception {
+        assertEquals(123, service.convert("123", int.class));
+        assertEquals(123, service.convert("123", Integer.class));
+        assertEquals(123l, service.convert("123", long.class));
+        assertEquals(123l, service.convert("123", Long.class));
+        assertEquals((short) 123, service.convert("123", short.class));
+        assertEquals((short) 123, service.convert("123", Short.class));
+        assertEquals(1.5f, service.convert("1.5", float.class));
+        assertEquals(1.5f, service.convert("1.5", Float.class));
+        assertEquals(1.5, service.convert("1.5", double.class));
+        assertEquals(1.5, service.convert("1.5", Double.class));
+    }
+
+    public void testConvertCharacter() throws Exception {
+        assertEquals('c', service.convert("c", char.class));
+        assertEquals('c', service.convert("c", Character.class));
+        assertEquals('\u00F6', service.convert("\\u00F6", char.class));
+        assertEquals('\u00F6', service.convert("\\u00F6", Character.class));
+    }
+
+    public void testConvertBoolean() throws Exception {
+        assertEquals(Boolean.TRUE, service.convert("true", Boolean.class));
+        assertEquals(Boolean.TRUE, service.convert("yes", Boolean.class));
+        assertEquals(Boolean.TRUE, service.convert("on", Boolean.class));
+        assertEquals(Boolean.TRUE, service.convert("TRUE", Boolean.class));
+        assertEquals(Boolean.TRUE, service.convert("YES", Boolean.class));
+        assertEquals(Boolean.TRUE, service.convert("ON", Boolean.class));
+        assertEquals(Boolean.TRUE, service.convert("true", boolean.class));
+        assertEquals(Boolean.TRUE, service.convert("yes", boolean.class));
+        assertEquals(Boolean.TRUE, service.convert("on", boolean.class));
+        assertEquals(Boolean.TRUE, service.convert("TRUE", boolean.class));
+        assertEquals(Boolean.TRUE, service.convert("YES", boolean.class));
+        assertEquals(Boolean.TRUE, service.convert("ON", boolean.class));
+        assertEquals(Boolean.FALSE, service.convert("false", Boolean.class));
+        assertEquals(Boolean.FALSE, service.convert("no", Boolean.class));
+        assertEquals(Boolean.FALSE, service.convert("off", Boolean.class));
+        assertEquals(Boolean.FALSE, service.convert("FALSE", Boolean.class));
+        assertEquals(Boolean.FALSE, service.convert("NO", Boolean.class));
+        assertEquals(Boolean.FALSE, service.convert("OFF", Boolean.class));
+        assertEquals(Boolean.FALSE, service.convert("false", boolean.class));
+        assertEquals(Boolean.FALSE, service.convert("no", boolean.class));
+        assertEquals(Boolean.FALSE, service.convert("off", boolean.class));
+        assertEquals(Boolean.FALSE, service.convert("FALSE", boolean.class));
+        assertEquals(Boolean.FALSE, service.convert("NO", boolean.class));
+        assertEquals(Boolean.FALSE, service.convert("OFF", boolean.class));
+        
+        assertEquals(Boolean.FALSE, service.convert(false, boolean.class));
+        assertEquals(Boolean.TRUE, service.convert(true, boolean.class));        
+        assertEquals(Boolean.FALSE, service.convert(false, Boolean.class));
+        assertEquals(Boolean.TRUE, service.convert(true, Boolean.class));
+    }
+
+    public void testConvertOther() throws Exception {
+        assertEquals(URI.create("urn:test"), service.convert("urn:test", URI.class));
+        assertEquals(new URL("file:/test"), service.convert("file:/test", URL.class));
+        assertEquals(new BigInteger("12345"), service.convert("12345", BigInteger.class));
+    }
+
+    public void testConvertProperties() throws Exception {
+        Properties props = new Properties();
+        props.setProperty("key", "value");
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        props.store(baos, null);
+        props = (Properties) service.convert(baos.toString(), Properties.class);
+        assertEquals(1, props.size());
+        assertEquals("value", props.getProperty("key"));
+    }
+
+    public void testConvertLocale() throws Exception {
+        Object result;
+        result = service.convert("en", Locale.class);
+        assertTrue(result instanceof Locale);
+        assertEquals(new Locale("en"), result);
+        
+        result = service.convert("de_DE", Locale.class);
+        assertTrue(result instanceof Locale);
+        assertEquals(new Locale("de", "DE"), result);
+        
+        result = service.convert("_GB", Locale.class);
+        assertTrue(result instanceof Locale);
+        assertEquals(new Locale("", "GB"), result);
+        
+        result = service.convert("en_US_WIN", Locale.class);
+        assertTrue(result instanceof Locale);
+        assertEquals(new Locale("en", "US", "WIN"), result);
+        
+        result = service.convert("de__POSIX", Locale.class);
+        assertTrue(result instanceof Locale);
+        assertEquals(new Locale("de", "", "POSIX"), result);
+    }
+    
+    public void testConvertClass() throws Exception {
+        assertEquals(this, service.convert(this, AggregateConverterTest.class));
+        assertEquals(AggregateConverterTest.class, service.convert(this.getClass().getName(), Class.class));
+        assertEquals(int[].class, service.convert("int[]", Class.class));
+    }
+
+    public void testConvertArray() throws Exception {
+        Object obj = service.convert(Arrays.asList(Arrays.asList(1, 2), Arrays.asList(3, 4)),
+                                     GenericType.parse("java.util.List<java.lang.Integer>[]", getClass().getClassLoader()));
+        assertNotNull(obj);
+        assertTrue(obj.getClass().isArray());
+        Object[] o = (Object[]) obj;
+        assertEquals(2, o.length);
+        assertNotNull(o[0]);
+        assertTrue(o[0] instanceof List);
+        assertEquals(2, ((List) o[0]).size());
+        assertEquals(1, ((List) o[0]).get(0));
+        assertEquals(2, ((List) o[0]).get(1));
+        assertNotNull(o[0]);
+        assertTrue(o[1] instanceof List);
+        assertEquals(2, ((List) o[1]).size());
+        assertEquals(3, ((List) o[1]).get(0));
+        assertEquals(4, ((List) o[1]).get(1));
+        //assertEquals((Object) new int[] { 1, 2 }, (Object) service.convert(Arrays.asList(1, 2), int[].class));
+    }
+    
+    public void testCustom() throws Exception {
+        AggregateConverter s = new AggregateConverter(new TestBlueprintContainer(null));
+        s.registerConverter(new RegionConverter());
+        s.registerConverter(new EuRegionConverter());
+        
+        // lookup on a specific registered converter type
+        Object result;
+        result = s.convert(new Object(), Region.class);
+        assertTrue(result instanceof Region);
+        assertFalse(result instanceof EuRegion);
+                
+        result = s.convert(new Object(), EuRegion.class);
+        assertTrue(result instanceof EuRegion);
+        
+        // find first converter that matches the type
+        s = new AggregateConverter(new TestBlueprintContainer(null));
+        s.registerConverter(new AsianRegionConverter());
+        s.registerConverter(new EuRegionConverter());
+        
+        result = s.convert(new Object(), Region.class);
+        // TODO: check with the spec about the result
+        //assertTrue(result instanceof AsianRegion || result instanceof EuRegion);
+    }
+    
+    private interface Region {} 
+    
+    private interface EuRegion extends Region {}
+    
+    private interface AsianRegion extends Region {}
+    
+    private static class RegionConverter implements Converter {
+        public boolean canConvert(Object fromValue, ReifiedType toType) {
+            return Region.class == toType.getRawClass();
+        }
+        public Object convert(Object source, ReifiedType toType) throws Exception {
+            return new Region() {} ;
+        }
+    }
+    
+    private static class EuRegionConverter implements Converter {
+        public boolean canConvert(Object fromValue, ReifiedType toType) {
+            return toType.getRawClass().isAssignableFrom(EuRegion.class);
+        }
+        public Object convert(Object source, ReifiedType toType) throws Exception {
+            return new EuRegion() {} ;
+        }
+    }
+    
+    private static class AsianRegionConverter implements Converter {
+        public boolean canConvert(Object fromValue, ReifiedType toType) {
+            return toType.getRawClass().isAssignableFrom(AsianRegion.class);
+        }
+        public Object convert(Object source, ReifiedType toType) throws Exception {
+            return new AsianRegion() {} ;
+        }
+    }
+
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BeanRecipeTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BeanRecipeTest.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BeanRecipeTest.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BeanRecipeTest.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,135 @@
+/*
+ * 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.aries.blueprint.container;
+
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class BeanRecipeTest {
+	static class Base {
+		public static Object getObject() { return null; }
+		public static Object getOne(Object o) { return null; }
+
+		public static Object getMany(Object o, String n, String n2) { return null; }
+	}
+	
+	static class Middle extends Base {
+		public static Number getObject() { return null; }
+		public static Number getOne(Number n) { return null; }
+		public static Number getOne(Object o) { return null; }
+		
+		public static Object getMany(Object o, String n, Number i) { return null; }
+		public static Object getBasic(int n) { return 0; }
+	}
+	
+	static class Top extends Middle {
+		public static Integer getObject() { return null; }
+		public static Integer getOne(Integer n) { return null; }
+		
+		public static Object getMany(Object o, String n, Number i) { return null; }
+		public static Object getBasic(int n) { return 0; }
+	}
+	
+	static class Unrelated {
+		public static String getObject() { return null; }
+		public static Object getBasic(int n) { return 1; }
+	}
+	
+	@Test
+	public void parameterLessHiding() throws Exception {
+		Set<Method> methods = new HashSet<Method>(
+				Arrays.asList(
+						Base.class.getMethod("getObject"),
+						Middle.class.getMethod("getObject"),
+						Top.class.getMethod("getObject"),
+						Unrelated.class.getMethod("getObject")
+				));
+		
+		methods = applyStaticHidingRules(methods);
+
+		assertEquals(2, methods.size());
+		assertTrue(methods.contains(Top.class.getMethod("getObject")));
+		assertTrue(methods.contains(Unrelated.class.getMethod("getObject")));
+		assertFalse(methods.contains(Middle.class.getMethod("getObject")));
+	}
+	
+	@Test
+	public void parameterDistinction() throws Exception {
+		Set<Method> methods = new HashSet<Method>(
+				Arrays.asList(
+						Base.class.getMethod("getOne", Object.class),
+						Middle.class.getMethod("getOne", Number.class),
+						Middle.class.getMethod("getOne", Object.class),
+						Top.class.getMethod("getOne", Integer.class)
+				));
+		
+		methods = applyStaticHidingRules(methods);
+		
+		assertEquals(3, methods.size());
+		assertFalse(methods.contains(Base.class.getMethod("getOne", Object.class)));
+	}
+	
+	@Test
+	public void multiParameterTest() throws Exception {
+		Set<Method> methods = new HashSet<Method>(
+				Arrays.asList(
+						Base.class.getMethod("getMany", Object.class, String.class, String.class),
+						Middle.class.getMethod("getMany", Object.class, String.class, Number.class),
+						Top.class.getMethod("getMany", Object.class, String.class, Number.class)
+				));
+		
+		methods = applyStaticHidingRules(methods);
+		
+		assertEquals(2, methods.size());
+		assertFalse(methods.contains(Middle.class.getMethod("getMany", Object.class, String.class, Number.class)));
+		
+	}
+	
+	@Test
+	public void baseTypeHiding() throws Exception {
+		Set<Method> methods = new HashSet<Method>(
+				Arrays.asList(
+						Middle.class.getMethod("getBasic", int.class),
+						Top.class.getMethod("getBasic", int.class),
+						Unrelated.class.getMethod("getBasic", int.class)
+				));
+		
+		methods = applyStaticHidingRules(methods);
+		
+		assertEquals(2, methods.size());
+		assertFalse(methods.contains(Middle.class.getMethod("getBasic", int.class)));
+	}
+	
+	private Set<Method> applyStaticHidingRules(Collection<Method> methods) {
+		try {
+			Method m = BeanRecipe.class.getDeclaredMethod("applyStaticHidingRules", Collection.class);
+			m.setAccessible(true);
+			return new HashSet<Method>((List<Method>) m.invoke(null, methods));
+		} catch (Exception e) { 
+			throw new RuntimeException(e);
+		}
+	}
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/container/GenericTypeTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/container/GenericTypeTest.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/container/GenericTypeTest.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/container/GenericTypeTest.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,73 @@
+/*
+ * 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.aries.blueprint.container;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.net.URI;
+
+import junit.framework.TestCase;
+
+public class GenericTypeTest extends TestCase {
+
+    private GenericType parse(String expression) throws Exception {
+        GenericType type = GenericType.parse(expression, getClass().getClassLoader());
+        assertEquals(expression, type.toString());
+        return type;
+    }
+    
+    public void testArrays() {
+        assertTrue(AggregateConverter.isAssignable(new Object[0], new GenericType(Object[].class)));
+        assertFalse(AggregateConverter.isAssignable(new Object[0], new GenericType(String[].class)));
+        assertTrue(AggregateConverter.isAssignable(new String[0], new GenericType(String[].class)));
+        assertFalse(AggregateConverter.isAssignable(new String[0], new GenericType(URI[].class)));
+        assertTrue(AggregateConverter.isAssignable(new String[0], new GenericType(Object[].class)));
+    }
+
+    public void testParseTypes() throws Exception {
+        
+        GenericType type = parse("java.util.List<java.lang.String[]>");
+        assertEquals(List.class, type.getRawClass());
+        assertEquals(1, type.size());
+        assertEquals(String[].class, type.getActualTypeArgument(0).getRawClass());
+        assertEquals(1, type.getActualTypeArgument(0).size());
+        assertEquals(String.class, type.getActualTypeArgument(0).getActualTypeArgument(0).getRawClass());
+
+        type = parse("java.util.Map<int,java.util.List<java.lang.Integer>[]>");
+        assertEquals(Map.class, type.getRawClass());
+        assertEquals(2, type.size());
+        assertEquals(int.class, type.getActualTypeArgument(0).getRawClass());
+        assertEquals(List[].class, type.getActualTypeArgument(1).getRawClass());
+        assertEquals(1, type.getActualTypeArgument(1).size());
+        assertEquals(Integer.class, type.getActualTypeArgument(1).getActualTypeArgument(0).getActualTypeArgument(0).getRawClass());
+
+        type = parse("java.util.List<java.lang.Integer>[]");
+        assertEquals(List[].class, type.getRawClass());
+        assertEquals(1, type.size());
+        assertEquals(Integer.class, type.getActualTypeArgument(0).getActualTypeArgument(0).getRawClass());
+    }
+
+    public void testBasic() throws Exception {        
+        GenericType type = new GenericType(int[].class);
+        assertEquals("int[]", type.toString());
+        assertEquals(int[].class, type.getRawClass());
+        assertEquals(0, type.getActualTypeArgument(0).size());
+    }
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/ext/AbstractPropertyPlaceholderTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/ext/AbstractPropertyPlaceholderTest.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/ext/AbstractPropertyPlaceholderTest.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/ext/AbstractPropertyPlaceholderTest.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,77 @@
+/**
+ * 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.aries.blueprint.ext;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.service.blueprint.reflect.ValueMetadata;
+
+public class AbstractPropertyPlaceholderTest extends AbstractPropertyPlaceholder {
+    private final Map<String,String> values = new HashMap<String,String>();
+    private LateBindingValueMetadata sut;
+    
+    @Before
+    public void setup() {
+        values.clear();
+        bind("prop","value");
+        bind("prop2","other");
+    }
+    
+    @Test
+    public void singleProp() {
+        sut = makeProperty("${prop}");
+        assertEquals("value", sut.getStringValue());
+    }
+    
+    @Test
+    public void multipleProps() {
+        sut = makeProperty("the ${prop2} ${prop}");
+        assertEquals("the other value", sut.getStringValue());
+    }
+    
+    /*
+     * Test helper methods
+     */
+    
+    // Override to simulate actual property retrieval
+    protected String getProperty(String prop) {
+        return values.get(prop);
+    }
+    
+    private void bind(String prop, String val) {
+        values.put(prop, val);
+    }
+    
+    private LateBindingValueMetadata makeProperty(final String prop) {
+        return new LateBindingValueMetadata(new ValueMetadata() {
+            public String getType() {
+                return null;
+            }
+            
+            public String getStringValue() {
+                return prop;
+            }
+        });
+    }
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/AmbiguousPojo.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/AmbiguousPojo.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/AmbiguousPojo.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/AmbiguousPojo.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,41 @@
+/*
+ * 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.aries.blueprint.pojos;
+
+import java.util.List;
+
+public class AmbiguousPojo {
+    private int sum;
+    
+    public int getSum() {
+        return sum;
+    }
+    
+    public void setSum(int sum) {
+        this.sum = sum;
+    }
+    
+    public void setSum(List<Integer> numbers) {
+        this.sum = 0;
+        for (int i : numbers) {
+            this.sum += i;
+        }
+    }
+    
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanC.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanC.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanC.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanC.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,34 @@
+/*
+ * 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.aries.blueprint.pojos;
+
+import org.apache.aries.blueprint.CallbackTracker;
+import org.apache.aries.blueprint.CallbackTracker.Callback;
+
+public class BeanC {
+
+    public void init() {
+        CallbackTracker.add(new Callback(Callback.INIT, this));
+    }
+    
+    public void destroy() {
+        CallbackTracker.add(new Callback(Callback.DESTROY, this));
+    }
+    
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanD.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanD.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanD.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanD.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,44 @@
+/*
+ * 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.aries.blueprint.pojos;
+
+import org.apache.aries.blueprint.CallbackTracker;
+import org.apache.aries.blueprint.CallbackTracker.Callback;
+
+public class BeanD {
+
+    private String name;
+    
+    public void setName(String name) {
+        this.name = name;
+    }
+    
+    public String getName() {
+        return name;
+    }
+    
+    public void init() {
+        CallbackTracker.add(new Callback(Callback.INIT, this));
+    }
+    
+    public void destroy() {
+        CallbackTracker.add(new Callback(Callback.DESTROY, this));
+    }
+
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanE.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanE.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanE.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanE.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,37 @@
+/*
+ * 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.aries.blueprint.pojos;
+
+import org.apache.aries.blueprint.CallbackTracker;
+import org.apache.aries.blueprint.CallbackTracker.Callback;
+
+public class BeanE {
+
+    public BeanE(BeanC c) {        
+    }
+    
+    public void init() {
+        CallbackTracker.add(new Callback(Callback.INIT, this));
+    }
+    
+    public void destroy() {
+        CallbackTracker.add(new Callback(Callback.DESTROY, this));
+    }
+
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanF.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanF.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanF.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanF.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,41 @@
+/*
+ * 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.aries.blueprint.pojos;
+
+public class BeanF {
+
+    private Boolean wrapped;
+    private Boolean prim;
+
+    public BeanF(Boolean wrapped) {
+        this.wrapped = wrapped;
+    }
+
+    public BeanF(boolean prim) {
+        this.prim = prim;
+    }
+
+    public Boolean getWrapped() {
+        return wrapped;
+    }
+
+    public Boolean getPrim() {
+        return prim;
+    }
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterA.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterA.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterA.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterA.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,39 @@
+/*
+ * 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.aries.blueprint.pojos;
+
+import java.io.File;
+
+import org.osgi.service.blueprint.container.ReifiedType;
+import org.osgi.service.blueprint.container.Converter;
+
+public class ConverterA implements Converter {
+
+    public boolean canConvert(Object fromValue, ReifiedType toType) {
+        return fromValue instanceof String && toType.getRawClass() == File.class;
+    }
+
+    public Object convert(Object source, ReifiedType toType) throws Exception {
+        if (source instanceof String) {
+            return new File((String) source);
+        }
+        throw new Exception("Unable to convert from " + (source != null ? source.getClass().getName() : "<null>") + " to " + File.class.getName());
+    }
+
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterB.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterB.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterB.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterB.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,39 @@
+/*
+ * 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.aries.blueprint.pojos;
+
+import java.net.URI;
+
+import org.osgi.service.blueprint.container.ReifiedType;
+import org.osgi.service.blueprint.container.Converter;
+
+public class ConverterB implements Converter {
+
+    public boolean canConvert(Object fromValue, ReifiedType toType) {
+        return fromValue instanceof String && toType.getRawClass() == URI.class;
+    }
+
+    public Object convert(Object source, ReifiedType toType) throws Exception {
+        if (source instanceof String) {
+            return new URI((String) source);
+        }
+        throw new Exception("Unable to convert from " + (source != null ? source.getClass().getName() : "<null>") + " to " + URI.class.getName());
+    }
+
+}
\ No newline at end of file

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/FITestBean.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/FITestBean.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/FITestBean.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/FITestBean.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,31 @@
+/**
+ * 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.aries.blueprint.pojos;
+
+public class FITestBean {
+  private String attr;
+  private String upperCaseAttr;
+  private FITestSubBean bean = new FITestSubBean();
+  
+  public String getAttr() { return attr; }
+  
+  public String getUpperCaseAttr() { return upperCaseAttr; }
+  public void setUpperCaseAttr(String val) { upperCaseAttr = val.toUpperCase(); }
+  public String getBeanName() { return bean.getName(); }
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/FITestSubBean.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/FITestSubBean.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/FITestSubBean.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/FITestSubBean.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,27 @@
+/**
+ * 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.aries.blueprint.pojos;
+
+public class FITestSubBean {
+    private String name;
+    
+    public String getName() {
+        return name;
+    }
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/InterfaceA.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/InterfaceA.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/InterfaceA.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/InterfaceA.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,22 @@
+/*
+ * 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.aries.blueprint.pojos;
+
+public interface InterfaceA {
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ListenerA.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ListenerA.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ListenerA.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ListenerA.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,32 @@
+/*
+ * 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.aries.blueprint.pojos;
+
+import org.osgi.framework.ServiceReference;
+
+public class ListenerA {
+
+    public void bind(ServiceReference ref) {
+
+    }
+
+    public void unbind(ServiceReference ref) {
+        
+    }
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Multiple.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Multiple.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Multiple.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Multiple.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,89 @@
+/*
+ * 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.aries.blueprint.pojos;
+
+import java.util.Map;
+import java.util.Properties;
+
+public class Multiple {
+
+    private int intValue = -1;
+    private Integer integerValue = null;
+    private String stringValue = null;
+    private Map map;
+    private Properties properties;
+
+    public Multiple() {
+    }
+
+    public Multiple(Map map) {
+        this.map = map;
+    }
+
+    public Multiple(Properties props) {
+        this.properties = props;
+    }
+
+    public Multiple(String arg) {   
+        stringValue = arg;
+    }
+
+    public Multiple(int arg) {   
+        intValue = arg;
+    }
+    
+    public Multiple(Integer arg) {   
+        integerValue = arg;
+    }
+
+    public Map getMap() {
+        return map;
+    }
+
+    public Properties getProperties() {
+        return properties;
+    }
+
+    public int getInt() {
+        return intValue;
+    }
+    
+    public Integer getInteger() {
+        return integerValue;
+    }
+
+    public String getString() {
+        return stringValue;
+    }
+
+    public void setAmbiguous(int v) {
+    }
+
+    public void setAmbiguous(Object v) {
+    }
+
+    public static Multiple create(String arg1, Integer arg2) {
+        return new Multiple(arg2.intValue());
+    }
+    
+    public static Multiple create(String arg1, Boolean arg2) {
+        return new Multiple(arg1 + "-boolean");
+    }
+    
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoA.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoA.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoA.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoA.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,125 @@
+/*
+ * 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.aries.blueprint.pojos;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+public class PojoA implements InterfaceA {
+
+    private PojoB pojob;
+    private List list;
+    private Set set;
+    private Map map;
+    private Number number;
+    private Properties props;
+    
+    private Object[] array;
+    private int[] intArray;
+    private Number[] numberArray;
+
+    public PojoA() {
+    }
+
+    public PojoA(PojoB pojob) {
+        this.pojob = pojob;
+    }
+
+    public PojoB getPojob() {
+        return pojob;
+    }
+
+    public List getList() {
+        return list;
+    }
+
+    public void setList(List list) {
+        this.list = list;
+    }
+
+    public Set getSet() {
+        return set;
+    }
+
+    public void setSet(Set set) {
+        this.set = set;
+    }
+
+    public Map getMap() {
+        return map;
+    }
+
+    public void setMap(Map map) {
+        this.map = map;
+    }
+
+    public Properties getProps() {
+        return props;
+    }
+    
+    public void setProps(Properties props) {
+        this.props = props;
+    }
+    
+    public void setPojob(PojoB pojob) {
+        this.pojob = pojob;
+    }
+
+    public void setNumber(Number number) {
+        this.number = number;
+    }
+    
+    public Number getNumber() {
+        return number;
+    }
+    
+    public void setArray(Object[] array) {
+        this.array = array;
+    }
+    
+    public Object[] getArray() {
+        return array;
+    }
+    
+    public int[] getIntArray() {
+        return intArray;
+    }
+    
+    public void setIntArray(int[] array) {
+        intArray = array;
+    }
+    
+    public Number[] getNumberArray() {
+        return numberArray;
+    }
+    
+    public void setNumberArray(Number[] numberArray) {
+        this.numberArray = numberArray;
+    }
+    
+    public void start() {
+        System.out.println("Starting component " + this);
+    }
+
+    public void stop() {
+        System.out.println("Stopping component " + this);
+    }
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoB.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoB.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoB.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoB.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,92 @@
+/*
+ * 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.aries.blueprint.pojos;
+
+import java.net.URI;
+import java.util.List;
+
+public class PojoB {
+
+    private List<Object> objects;
+    private URI uri;
+    private int number;
+    private BeanD bean;
+    
+    private boolean initCalled;
+    private boolean destroyCalled;
+    
+    public PojoB() {
+    }
+    
+    public PojoB(URI uri, int number) {
+        this.uri = uri;
+        this.number = number;
+    }
+
+    public URI getUri() {
+        return uri;
+    }
+
+    public void setUri(URI uri) {
+        this.uri = uri;
+    }
+
+    public List<Object> getObjects() {
+        return objects;
+    }
+
+    public void setObjects(List<Object> objects) {
+        this.objects = objects;
+    }
+
+    public void init() {
+        initCalled = true;
+    }
+    
+    public boolean getInitCalled() {
+        return initCalled;
+    }
+    
+    public void destroy() {
+        destroyCalled = true;
+    }
+    
+    public boolean getDestroyCalled() {
+        return destroyCalled;
+    }
+    
+    public int getNumber() {
+        return number;
+    }
+    
+    public BeanD getBean() {
+        if (bean == null) {
+            bean = new BeanD();
+        }
+        return bean;
+    }
+    
+    public static PojoB createStatic(URI uri, int number) {
+        return new PojoB(URI.create(uri + "-static"), number);
+    }
+    
+    public PojoB createDynamic(URI uri, int number) {
+        return new PojoB(URI.create(uri + "-dynamic"), number);
+    }
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoCircular.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoCircular.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoCircular.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoCircular.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,42 @@
+/*
+ * 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.aries.blueprint.pojos;
+
+public class PojoCircular {
+
+    private PojoCircular circular;
+
+    public PojoCircular() {        
+    }
+    
+    public PojoCircular(PojoCircular circular) {
+        this.circular = circular;
+    }
+    
+    public PojoCircular getCircular() {
+        return circular;
+    }
+
+    public void setCircular(PojoCircular circular) {
+        this.circular = circular;
+    }
+    
+    public void init() {        
+    }
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoGenerics.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoGenerics.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoGenerics.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoGenerics.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,77 @@
+/*
+ * 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.aries.blueprint.pojos;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+public class PojoGenerics {
+
+    private List<Integer> list;
+    private Set<Long> set;
+    private Map<Short, Boolean> map;
+
+    public PojoGenerics() {
+    }
+    
+    public PojoGenerics(List<Integer> list) {
+        this.list = list;        
+    }
+    
+    public PojoGenerics(Set<Long> set) {
+        this.set = set;        
+    }
+    
+    public PojoGenerics(Map<Short, Boolean> map) {
+        this.map = map;
+    }
+
+    public List<Integer> getList() {
+        return list;
+    }
+
+    public void setList(List<Integer> list) {
+        this.list = list;
+    }
+
+    public Set<Long> getSet() {
+        return set;
+    }
+
+    public void setSet(Set<Long> set) {
+        this.set = set;
+    }
+
+    public Map<Short, Boolean> getMap() {
+        return map;
+    }
+
+    public void setMap(Map<Short, Boolean> map) {
+        this.map = map;
+    }
+     
+    public void start() {
+        System.out.println("Starting component " + this);
+    }
+
+    public void stop() {
+        System.out.println("Stopping component " + this);
+    }
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoListener.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoListener.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoListener.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoListener.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,42 @@
+/*
+ * 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.aries.blueprint.pojos;
+
+import java.util.Map;
+
+import org.osgi.framework.ServiceRegistration;
+
+public class PojoListener {
+
+    private ServiceRegistration registration;
+    
+    public ServiceRegistration getService() {
+        return registration;
+    }
+    
+    public void setService(ServiceRegistration registration) {
+        this.registration = registration;
+    }
+    
+    public void register(PojoB pojo, Map props) {        
+    }
+    
+    public void unregister(PojoB pojo, Map props) {        
+    }
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoRecursive.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoRecursive.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoRecursive.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoRecursive.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,46 @@
+/*
+ * 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.aries.blueprint.pojos;
+
+import org.osgi.service.blueprint.container.BlueprintContainer;
+
+public class PojoRecursive {
+
+    private BlueprintContainer container;
+    private String component;
+
+    public PojoRecursive(BlueprintContainer container, String component) {
+        this.container = container;
+        this.component = component;
+    }
+    
+    public PojoRecursive(BlueprintContainer container, String component, int foo) {
+        this.container = container;
+        this.component = component;
+        container.getComponentInstance(component);
+    }
+    
+    public void setFoo(int foo) {
+        container.getComponentInstance(component);
+    }
+    
+    public void init() {    
+        container.getComponentInstance(component);
+    }
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Primavera.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Primavera.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Primavera.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Primavera.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,31 @@
+/*
+ * 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.aries.blueprint.pojos;
+
+interface Product<T> {
+    void setProperty(T value);
+}
+
+public class Primavera implements Product<String> {
+    public String prop;
+
+    public void setProperty(String value) {
+        prop = value;
+    }    
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PrimaveraFactory.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PrimaveraFactory.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PrimaveraFactory.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PrimaveraFactory.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,37 @@
+/*
+ * 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.aries.blueprint.pojos;
+
+interface GenericFactory<T,U> {
+    T getObject();
+    T getObject(U value);
+}
+
+public class PrimaveraFactory implements GenericFactory<Primavera,String> {
+
+    public Primavera getObject() {
+        return new Primavera();
+    }
+
+    public Primavera getObject(String value) {
+        Primavera res = new Primavera();
+        res.setProperty(value);
+        return res;
+    }
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxySubclassGeneratorTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxySubclassGeneratorTest.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxySubclassGeneratorTest.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxySubclassGeneratorTest.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,385 @@
+/*
+ * 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.aries.blueprint.proxy;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class ProxySubclassGeneratorTest
+{
+  private static final Class<?> TEST_CLASS = ProxyTestClassGeneral.class;
+  private static final Class<?> FINAL_METHOD_CLASS = ProxyTestClassFinalMethod.class;
+  private static final Class<?> FINAL_CLASS = ProxyTestClassFinal.class;
+  private static final Class<?> GENERIC_CLASS = ProxyTestClassGeneric.class;
+  private static final Class<?> COVARIANT_CLASS = ProxyTestClassCovariantOverride.class;
+  private static ProxySubclassMethodHashSet<String> expectedMethods = new ProxySubclassMethodHashSet<String>(
+      12);
+  private InvocationHandler ih = null;
+  private Class<?> generatedProxySubclass = null;
+  private Object o = null;
+
+  /**
+   * @throws java.lang.Exception
+   */
+  @Before
+  public void setUp() throws Exception
+  {
+    ih = new FakeInvocationHandler();
+    ((FakeInvocationHandler)ih).setDelegate(TEST_CLASS.newInstance());
+    generatedProxySubclass = getGeneratedSubclass();
+    o = getSubclassInstance(generatedProxySubclass);
+  }
+
+  /**
+   * This test uses the ProxySubclassGenerator to generate and load a subclass
+   * of the specified TEST_CLASS.
+   * 
+   * Once the subclass is generated we check that it wasn't null. We check
+   * that the InvocationHandler constructor doesn't return a null object
+   * either
+   * 
+   * Test method for
+   * {@link org.apache.aries.blueprint.proxy.ProxySubclassGenerator#generateAndLoadSubclass()}
+   * .
+   */
+  @Test
+  public void testGenerateAndLoadSubclass() throws Exception
+  {
+    assertNotNull("Generated proxy subclass was null", generatedProxySubclass);
+    assertNotNull("Generated proxy subclass instance was null", o);
+  }
+
+  /**
+   * Test that the methods found declared on the generated proxy subclass are
+   * the ones that we expect.
+   */
+  @Test
+  public void testExpectedMethods() throws Exception
+  {
+    Class<?> superclass = TEST_CLASS;
+
+    do {
+      Method[] declaredMethods = superclass.getDeclaredMethods();
+      List<Method> listOfDeclaredMethods = new ArrayList<Method>();
+      for (Method m : declaredMethods) {
+        int i = m.getModifiers();
+        if (Modifier.isPrivate(i) || Modifier.isFinal(i)) {
+          // private or final don't get added
+        } else if (!(Modifier.isPublic(i) || Modifier.isPrivate(i) || Modifier.isProtected(i))) {
+          // the method is default visibility, check the package
+          if (m.getDeclaringClass().getPackage().equals(TEST_CLASS.getPackage())) {
+            // default vis with same package gets added
+            listOfDeclaredMethods.add(m);
+          }
+        } else {
+          listOfDeclaredMethods.add(m);
+        }
+      }
+
+      declaredMethods = listOfDeclaredMethods.toArray(new Method[] {});
+      ProxySubclassMethodHashSet<String> foundMethods = new ProxySubclassMethodHashSet<String>(
+          declaredMethods.length);
+      foundMethods.addMethodArray(declaredMethods);
+      // as we are using a set we shouldn't get duplicates
+      expectedMethods.addAll(foundMethods);
+      superclass = superclass.getSuperclass();
+    } while (superclass != null);
+
+    // add the getter and setter for the invocation handler to the expected
+    // set
+    // and the unwrapObject method
+    Method[] ihMethods = new Method[] {
+        generatedProxySubclass.getMethod("setInvocationHandler",
+            new Class[] { InvocationHandler.class }),
+        generatedProxySubclass.getMethod("getInvocationHandler", new Class[] {}) };
+    expectedMethods.addMethodArray(ihMethods);
+
+    Method[] generatedProxySubclassMethods = generatedProxySubclass.getDeclaredMethods();
+    ProxySubclassMethodHashSet<String> generatedMethods = new ProxySubclassMethodHashSet<String>(
+        generatedProxySubclassMethods.length);
+    generatedMethods.addMethodArray(generatedProxySubclassMethods);
+
+    // check that all the methods we have generated were expected
+    for (String gen : generatedMethods) {
+      assertTrue("Unexpected method: " + gen, expectedMethods.contains(gen));
+    }
+    // check that all the expected methods were generated
+    for (String exp : expectedMethods) {
+      assertTrue("Method was not generated: " + exp, generatedMethods.contains(exp));
+    }
+    // check the sets were the same
+    assertEquals("Sets were not the same", expectedMethods, generatedMethods);
+
+  }
+
+  /**
+   * Test a basic method invocation on the proxy subclass
+   */
+  @Test
+  public void testMethodInvocation() throws Exception
+  {
+    Method m = generatedProxySubclass.getDeclaredMethod("testMethod", new Class[] { String.class,
+        int.class, Object.class });
+    String x = "x";
+    String returned = (String) m.invoke(o, x, 1, new Object());
+    assertEquals("Object returned from invocation was not correct.", x, returned);
+  }
+
+  /**
+   * Test different argument types on a method invocation
+   */
+  @Test
+  public void testMethodArgs() throws Exception
+  {
+    Method m = generatedProxySubclass.getDeclaredMethod("testArgs", new Class[] { double.class,
+        short.class, long.class, char.class, byte.class, boolean.class });
+    Character xc = Character.valueOf('x');
+    String x = xc.toString();
+    String returned = (String) m.invoke(o, Double.MAX_VALUE, Short.MIN_VALUE, Long.MAX_VALUE, xc
+        .charValue(), Byte.MIN_VALUE, false);
+    assertEquals("Object returned from invocation was not correct.", x, returned);
+  }
+
+  /**
+   * Test a method that returns void
+   */
+  @Test
+  public void testReturnVoid() throws Exception
+  {
+    Method m = generatedProxySubclass.getDeclaredMethod("testReturnVoid", new Class[] {});
+    m.invoke(o);
+  }
+
+  /**
+   * Test a method that returns an int
+   */
+  @Test
+  public void testReturnInt() throws Exception
+  {
+    Method m = generatedProxySubclass.getDeclaredMethod("testReturnInt", new Class[] {});
+    Integer returned = (Integer) m.invoke(o);
+    assertEquals("Expected object was not returned from invocation", Integer.valueOf(17), returned);
+  }
+
+  /**
+   * Test a method that returns an Integer
+   */
+  @Test
+  public void testReturnInteger() throws Exception
+  {
+    Method m = generatedProxySubclass.getDeclaredMethod("testReturnInteger", new Class[] {});
+    Integer returned = (Integer) m.invoke(o);
+    assertEquals("Expected object was not returned from invocation", Integer.valueOf(1), returned);
+  }
+
+  /**
+   * Test a public method declared higher up the superclass hierarchy
+   */
+  @Test
+  public void testPublicHierarchyMethod() throws Exception
+  {
+    Method m = generatedProxySubclass.getDeclaredMethod("bMethod", new Class[] {});
+    m.invoke(o);
+  }
+
+  /**
+   * Test a protected method declared higher up the superclass hierarchy
+   */
+  @Test
+  public void testProtectedHierarchyMethod() throws Exception
+  {
+    Method m = generatedProxySubclass.getDeclaredMethod("bProMethod", new Class[] {});
+    m.invoke(o);
+  }
+
+  /**
+   * Test a default method declared higher up the superclass hierarchy
+   */
+  @Test
+  public void testDefaultHierarchyMethod() throws Exception
+  {
+    Method m = generatedProxySubclass.getDeclaredMethod("bDefMethod", new Class[] {});
+    m.invoke(o);
+  }
+
+  /**
+   * Test a covariant override method
+   */
+  @Test
+  public void testCovariant() throws Exception
+  {
+    ((FakeInvocationHandler)ih).setDelegate(COVARIANT_CLASS.newInstance());
+    o = ProxySubclassGenerator.newProxySubclassInstance(COVARIANT_CLASS, ih);
+    generatedProxySubclass = o.getClass();
+    Method m = generatedProxySubclass.getDeclaredMethod("getCovariant", new Class[] {});
+    Object returned = m.invoke(o);
+    assertTrue("Object was of wrong type: " + returned.getClass().getSimpleName(), COVARIANT_CLASS
+        .isInstance(returned));
+  }
+
+  /**
+   * Test a method with generics
+   */
+  @Test
+  public void testGenerics() throws Exception
+  {
+    ((FakeInvocationHandler)ih).setDelegate(GENERIC_CLASS.newInstance());
+    o = ProxySubclassGenerator.newProxySubclassInstance(GENERIC_CLASS, ih);
+    generatedProxySubclass = o.getClass();
+    Method m = generatedProxySubclass.getDeclaredMethod("setSomething",
+        new Class[] { String.class });
+    m.invoke(o, "aString");
+    m = generatedProxySubclass.getDeclaredMethod("getSomething", new Class[] {});
+    Object returned = m.invoke(o);
+    assertTrue("Object was of wrong type", String.class.isInstance(returned));
+    assertEquals("String had wrong value", "aString", returned);
+  }
+
+  /**
+   * Test a method marked final
+   */
+  @Test
+  public void testFinalMethod() throws Exception
+  {
+    try {
+      ProxySubclassGenerator.getProxySubclass(FINAL_METHOD_CLASS);
+    } catch (FinalModifierException e) {
+      assertFalse("Should have found final method not final class", e.isFinalClass());
+    }
+  }
+
+  /**
+   * Test a class marked final
+   */
+  @Test
+  public void testFinalClass() throws Exception
+  {
+    try {
+      ProxySubclassGenerator.getProxySubclass(FINAL_CLASS);
+    } catch (FinalModifierException e) {
+      assertTrue("Should have found final class", e.isFinalClass());
+    }
+  }
+
+  /**
+   * Test that we don't generate classes twice
+   */
+  @Test
+  public void testRetrieveClass() throws Exception
+  {
+    Class<?> retrieved = ProxySubclassGenerator.getProxySubclass(TEST_CLASS);
+    assertNotNull("The new class was null", retrieved);
+    assertEquals("The same class was not returned", generatedProxySubclass, retrieved);
+
+  }
+
+  /**
+   * Test a private constructor
+   */
+  @Test
+  public void testPrivateConstructor() throws Exception
+  {
+    Object o = ProxySubclassGenerator.newProxySubclassInstance(
+        ProxyTestClassPrivateConstructor.class, ih);
+    assertNotNull("The new instance was null", o);
+
+  }
+  
+  /**
+   * Test object equality between real and proxy using a Collaborator
+   */
+  @Test
+  public void testObjectEquality() throws Exception
+  {
+    Object delegate = TEST_CLASS.newInstance();
+    InvocationHandler collaborator = new Collaborator(null, null, delegate);
+    Object o = ProxySubclassGenerator.newProxySubclassInstance(TEST_CLASS, collaborator);
+    //Calling equals on the proxy with an arg of the unwrapped object should be true
+    assertTrue("The proxy object should be equal to its delegate",o.equals(delegate));
+    InvocationHandler collaborator2 = new Collaborator(null, null, delegate);
+    Object o2 = ProxySubclassGenerator.newProxySubclassInstance(TEST_CLASS, collaborator2);
+    //The proxy of a delegate should equal another proxy of the same delegate
+    assertTrue("The proxy object should be equal to another proxy instance of the same delegate", o2.equals(o));
+  }
+  
+  private static class ProxyTestOverridesFinalize {
+      public boolean finalizeCalled = false;
+      
+      @Override
+      protected void finalize() {
+          finalizeCalled = true;
+      }
+  }
+  
+  @Test
+  public void testFinalizeNotCalled() throws Exception {
+      ProxyTestOverridesFinalize testObj = new ProxyTestOverridesFinalize();
+      InvocationHandler ih = new Collaborator(null, null, testObj);
+      Object o = ProxySubclassGenerator.newProxySubclassInstance(ProxyTestOverridesFinalize.class, ih);
+      
+      Method m = o.getClass().getDeclaredMethod("finalize");
+      m.setAccessible(true);
+      m.invoke(o);
+      
+      assertFalse(testObj.finalizeCalled);
+  }
+  
+
+  private Class<?> getGeneratedSubclass() throws Exception
+  {
+    return ProxySubclassGenerator.getProxySubclass(TEST_CLASS);
+  }
+
+  private Object getSubclassInstance(Class<?> clazz) throws Exception
+  {
+    return clazz.getConstructor(InvocationHandler.class).newInstance(ih);
+  }
+
+  private class FakeInvocationHandler implements InvocationHandler
+  {
+    private Object delegate = null;
+    /*
+     * (non-Javadoc)
+     * 
+     * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object,
+     * java.lang.reflect.Method, java.lang.Object[])
+     */
+    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+    {
+      Object result = method.invoke(delegate, args);
+      return result;
+    }
+
+    void setDelegate(Object delegate){
+      this.delegate = delegate;
+    }
+    
+  }
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassCovariant.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassCovariant.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassCovariant.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassCovariant.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,30 @@
+/*
+ * 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.aries.blueprint.proxy;
+
+public class ProxyTestClassCovariant
+{
+
+  //this method is here to make sure we don't break on covariant override
+  public ProxyTestClassCovariant getCovariant()
+  {
+    return this;
+  }
+
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassCovariantOverride.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassCovariantOverride.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassCovariantOverride.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassCovariantOverride.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,29 @@
+/*
+ * 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.aries.blueprint.proxy;
+
+public class ProxyTestClassCovariantOverride extends ProxyTestClassCovariant
+{
+  //this method is here to make sure we don't break on covariant override
+  public ProxyTestClassCovariantOverride getCovariant()
+  {
+    return this;
+  }
+
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassFinal.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassFinal.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassFinal.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassFinal.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,29 @@
+/*
+ * 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.aries.blueprint.proxy;
+
+public final class ProxyTestClassFinal
+{
+
+  void someMethod()
+  {
+
+  }
+
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassFinalMethod.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassFinalMethod.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassFinalMethod.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassFinalMethod.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,27 @@
+/*
+ * 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.aries.blueprint.proxy;
+
+public class ProxyTestClassFinalMethod
+{
+  public final void someFinalMethod()
+  {
+
+  }
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassGeneral.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassGeneral.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassGeneral.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassGeneral.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,54 @@
+/*
+ * 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.aries.blueprint.proxy;
+
+public class ProxyTestClassGeneral extends ProxyTestClassSuper
+{
+
+  public String testMethod(String x, int y, Object z)
+  {
+    somePrivateMethod();
+    return x;
+  }
+
+  public String testArgs(double a, short b, long c, char d, byte e, boolean f)
+  {
+    return Character.toString(d);
+  }
+
+  protected void testReturnVoid()
+  {
+  }
+
+  int testReturnInt()
+  {
+    return 17;
+  }
+
+  public Integer testReturnInteger()
+  {
+    return Integer.valueOf(1);
+  }
+
+  private void somePrivateMethod()
+  {
+
+  }
+
+}



Mime
View raw message