You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by zo...@apache.org on 2011/02/27 22:05:20 UTC

svn commit: r1075147 [19/23] - in /aries/tags/blueprint-0.3: ./ 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-ann...

Added: aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/container/AggregateConverterTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/container/AggregateConverterTest.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/container/AggregateConverterTest.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/container/AggregateConverterTest.java Sun Feb 27 21:05:07 2011
@@ -0,0 +1,236 @@
+/*
+ * 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());
+        s.registerConverter(new NullMarkerConverter());
+        
+        result = s.convert(new Object(), Region.class);
+        // TODO: check with the spec about the result
+        //assertTrue(result instanceof AsianRegion || result instanceof EuRegion);
+        result = s.convert(new Object(), NullMarker.class);
+        assertNull(result);
+    }
+    
+    private interface Region {} 
+    
+    private interface EuRegion extends Region {}
+    
+    private interface AsianRegion extends Region {}
+
+    private interface NullMarker {}
+    
+    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() {} ;
+        }
+    }
+
+    private static class NullMarkerConverter implements Converter {
+        public boolean canConvert(Object fromValue, ReifiedType toType) {
+            return toType.getRawClass().isAssignableFrom(NullMarker.class);
+        }
+        public Object convert(Object source, ReifiedType toType) throws Exception {
+            return null;
+        }
+    }
+
+}

Added: aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BPQuiesceTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BPQuiesceTest.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BPQuiesceTest.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BPQuiesceTest.java Sun Feb 27 21:05:07 2011
@@ -0,0 +1,63 @@
+/*
+ * 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.Arrays;
+import java.util.concurrent.Semaphore;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.aries.quiesce.manager.QuiesceCallback;
+import org.apache.aries.unittest.mocks.MethodCall;
+import org.apache.aries.unittest.mocks.Skeleton;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+import static junit.framework.Assert.*;
+
+public class BPQuiesceTest {
+  @Test
+  public void canQuiesceNoBPBundle() throws Exception {
+    BundleContext ctx = Skeleton.newMock(BundleContext.class);
+    Bundle bpBundle = Skeleton.newMock(Bundle.class);
+    Bundle testBundle = Skeleton.newMock(Bundle.class);
+    
+    Skeleton.getSkeleton(ctx).setReturnValue(
+        new MethodCall(BundleContext.class, "getBundle"), bpBundle);
+    
+    BlueprintQuiesceParticipant bqp = new BlueprintQuiesceParticipant(ctx, new BlueprintExtender() {
+      @Override
+      protected BlueprintContainerImpl getBlueprintContainerImpl(Bundle bundle) {
+        return null;
+      }      
+    });
+    
+    final Semaphore result = new Semaphore(0);
+    
+    QuiesceCallback qc = new QuiesceCallback() {
+      public void bundleQuiesced(Bundle... bundlesQuiesced) {
+        result.release();
+      }
+    };
+    
+    bqp.quiesce(qc, Arrays.asList(testBundle));
+    
+    assertTrue(result.tryAcquire(2, TimeUnit.SECONDS));
+  }
+}

Added: aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BeanRecipeTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BeanRecipeTest.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BeanRecipeTest.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BeanRecipeTest.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/container/GenericTypeTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/container/GenericTypeTest.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/container/GenericTypeTest.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/container/GenericTypeTest.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/ext/AbstractPropertyPlaceholderTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/ext/AbstractPropertyPlaceholderTest.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/ext/AbstractPropertyPlaceholderTest.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/ext/AbstractPropertyPlaceholderTest.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/AmbiguousPojo.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/AmbiguousPojo.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/AmbiguousPojo.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/AmbiguousPojo.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanC.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanC.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanC.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanC.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanD.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanD.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanD.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanD.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanE.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanE.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanE.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanE.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanF.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanF.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanF.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/BeanF.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterA.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterA.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterA.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterA.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterB.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterB.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterB.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ConverterB.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/FITestBean.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/FITestBean.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/FITestBean.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/FITestBean.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/FITestSubBean.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/FITestSubBean.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/FITestSubBean.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/FITestSubBean.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/InterfaceA.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/InterfaceA.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/InterfaceA.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/InterfaceA.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ListenerA.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ListenerA.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ListenerA.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/ListenerA.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Multiple.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Multiple.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Multiple.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Multiple.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoA.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoA.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoA.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoA.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoB.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoB.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoB.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoB.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoCircular.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoCircular.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoCircular.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoCircular.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoGenerics.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoGenerics.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoGenerics.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoGenerics.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoListener.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoListener.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoListener.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoListener.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoRecursive.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoRecursive.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoRecursive.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PojoRecursive.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Primavera.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Primavera.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Primavera.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/Primavera.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PrimaveraFactory.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PrimaveraFactory.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PrimaveraFactory.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/PrimaveraFactory.java Sun Feb 27 21:05:07 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.3/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/DynamicCollectionTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/DynamicCollectionTest.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/DynamicCollectionTest.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/DynamicCollectionTest.java Sun Feb 27 21:05:07 2011
@@ -0,0 +1,113 @@
+/*
+ * 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.utils;
+
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+public class DynamicCollectionTest extends TestCase {
+
+    protected static final Object O0 = new Object();
+    protected static final Object O1 = new Object();
+    protected static final Object O2 = new Object();
+    protected static final Object O3 = new Object();
+
+    protected DynamicCollection<Object> collection;
+
+    protected void setUp() {
+        collection = new DynamicCollection<Object>();
+    }
+
+    public void testAddRemove() throws Exception {
+        assertEquals(0, collection.size());
+        assertTrue(collection.isEmpty());
+        collection.add(O0);
+        assertEquals(1, collection.size());
+        assertFalse(collection.isEmpty());
+        assertTrue(collection.contains(O0));
+        assertFalse(collection.contains(O1));
+        collection.clear();
+        assertEquals(0, collection.size());
+        collection.add(O0);
+        collection.add(O0);
+        assertEquals(2, collection.size());
+        assertTrue(collection.remove(O0));
+        assertEquals(1, collection.size());
+        assertTrue(collection.remove(O0));
+        assertEquals(0, collection.size());
+    }
+
+    public void testSimpleIterator() throws Exception {
+        collection.add(O0);
+
+        Iterator iterator = collection.iterator();
+        assertTrue(iterator.hasNext());
+        assertEquals(O0, iterator.next());
+        assertFalse(iterator.hasNext());
+    }
+
+    public void testAddWhileIterating() throws Exception {
+        Iterator iterator = collection.iterator();
+        assertFalse(iterator.hasNext());
+
+        collection.add(O0);
+        assertTrue(iterator.hasNext());
+        assertEquals(O0, iterator.next());
+        assertFalse(iterator.hasNext());
+    }
+
+    public void testRemoveElementWhileIterating() throws Exception {
+        collection.add(O0);
+        collection.add(O1);
+
+        Iterator iterator = collection.iterator();
+        assertTrue(iterator.hasNext());
+        collection.remove(O0);
+        assertEquals(O0, iterator.next());
+        assertTrue(iterator.hasNext());
+        assertEquals(O1, iterator.next());
+        assertFalse(iterator.hasNext());
+    }
+
+    public void testRemoveElementAfterWhileIterating() throws Exception {
+        collection.add(O0);
+        collection.add(O1);
+
+        Iterator iterator = collection.iterator();
+        assertTrue(iterator.hasNext());
+        assertEquals(O0, iterator.next());
+        collection.remove(O1);
+        assertFalse(iterator.hasNext());
+    }
+
+    public void testRemoveElementBeforeWhileIterating() throws Exception {
+        collection.add(O0);
+        collection.add(O1);
+
+        Iterator iterator = collection.iterator();
+        assertTrue(iterator.hasNext());
+        assertEquals(O0, iterator.next());
+        collection.remove(O0);
+        assertTrue(iterator.hasNext());
+        assertEquals(O1, iterator.next());
+        assertFalse(iterator.hasNext());
+    }
+
+}

Added: aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/HeaderParserTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/HeaderParserTest.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/HeaderParserTest.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/HeaderParserTest.java Sun Feb 27 21:05:07 2011
@@ -0,0 +1,70 @@
+/*
+ * 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.utils;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+import org.apache.aries.blueprint.utils.HeaderParser.PathElement;
+
+public class HeaderParserTest extends TestCase {
+
+    public void testSimple() throws Exception {
+        List<PathElement> paths = HeaderParser.parseHeader("/foo.xml, /foo/bar.xml");
+        assertEquals(2, paths.size());
+        assertEquals("/foo.xml", paths.get(0).getName());
+        assertEquals(0, paths.get(0).getAttributes().size());
+        assertEquals(0, paths.get(0).getDirectives().size());
+        assertEquals("/foo/bar.xml", paths.get(1).getName());
+        assertEquals(0, paths.get(1).getAttributes().size());
+        assertEquals(0, paths.get(1).getDirectives().size());
+    }
+    
+    public void testComplex() throws Exception {
+        List<PathElement> paths = HeaderParser.parseHeader("OSGI-INF/blueprint/comp1_named.xml;ignored-directive:=true,OSGI-INF/blueprint/comp2_named.xml;some-other-attribute=1");
+        assertEquals(2, paths.size());
+        assertEquals("OSGI-INF/blueprint/comp1_named.xml", paths.get(0).getName());
+        assertEquals(0, paths.get(0).getAttributes().size());
+        assertEquals(1, paths.get(0).getDirectives().size());
+        assertEquals("true", paths.get(0).getDirective("ignored-directive"));
+        assertEquals("OSGI-INF/blueprint/comp2_named.xml", paths.get(1).getName());
+        assertEquals(1, paths.get(1).getAttributes().size());
+        assertEquals("1", paths.get(1).getAttribute("some-other-attribute"));
+        assertEquals(0, paths.get(1).getDirectives().size());
+    }
+
+    public void testPaths() throws Exception {
+        List<PathElement> paths = HeaderParser.parseHeader("OSGI-INF/blueprint/comp1_named.xml;ignored-directive:=true,OSGI-INF/blueprint/comp2_named.xml;foo.xml;a=b;1:=2;c:=d;4=5");
+        assertEquals(3, paths.size());
+        assertEquals("OSGI-INF/blueprint/comp1_named.xml", paths.get(0).getName());
+        assertEquals(0, paths.get(0).getAttributes().size());
+        assertEquals(1, paths.get(0).getDirectives().size());
+        assertEquals("true", paths.get(0).getDirective("ignored-directive"));
+        assertEquals("OSGI-INF/blueprint/comp2_named.xml", paths.get(1).getName());
+        assertEquals(0, paths.get(1).getAttributes().size());
+        assertEquals(0, paths.get(1).getDirectives().size());
+        assertEquals("foo.xml", paths.get(2).getName());
+        assertEquals(2, paths.get(2).getAttributes().size());
+        assertEquals("b", paths.get(2).getAttribute("a"));
+        assertEquals("5", paths.get(2).getAttribute("4"));
+        assertEquals(2, paths.get(2).getDirectives().size());
+        assertEquals("d", paths.get(2).getDirective("c"));
+        assertEquals("2", paths.get(2).getDirective("1"));
+    }
+}

Added: aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/ReflectionUtilsTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/ReflectionUtilsTest.java?rev=1075147&view=auto
==============================================================================
--- aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/ReflectionUtilsTest.java (added)
+++ aries/tags/blueprint-0.3/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/ReflectionUtilsTest.java Sun Feb 27 21:05:07 2011
@@ -0,0 +1,291 @@
+/*
+ * 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.utils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+
+import org.apache.aries.blueprint.ExtendedBlueprintContainer;
+import org.apache.aries.blueprint.di.CircularDependencyException;
+import org.apache.aries.blueprint.di.ExecutionContext;
+import org.apache.aries.blueprint.di.Recipe;
+import org.apache.aries.blueprint.utils.ReflectionUtils.PropertyDescriptor;
+import org.apache.aries.unittest.mocks.Skeleton;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.service.blueprint.container.ComponentDefinitionException;
+import org.osgi.service.blueprint.container.ReifiedType;
+
+import static org.junit.Assert.*;
+
+public class ReflectionUtilsTest {
+    private PropertyDescriptor[] sut;
+    private final ExtendedBlueprintContainer mockBlueprint = Skeleton.newMock(ExtendedBlueprintContainer.class);
+    
+    static class GetterOnly {
+        public String getValue() { return "test"; }
+    }
+    
+    private class Inconvertible {}
+    
+    @BeforeClass
+    public static void before()
+    {
+        ExecutionContext.Holder.setContext(new ExecutionContext() {
+            public void addFullObject(String name, Object object) {}
+            public void addPartialObject(String name, Object object) {}
+            public boolean containsObject(String name) { return false; }
+
+            public Object convert(Object value, ReifiedType type) throws Exception {
+                if (type.getRawClass().equals(Inconvertible.class)) throw new Exception();
+                else if (type.getRawClass().equals(String.class)) return String.valueOf(value);
+                else if (type.getRawClass().equals(List.class)) {
+                    if (value == null) return null;
+                    else if (value instanceof Collection) return new ArrayList((Collection) value);
+                    else throw new Exception();
+                } else if (value == null) return null;
+                else if (type.getRawClass().isInstance(value)) return value;
+                else throw new Exception();
+            }
+            
+            public boolean canConvert(Object value, ReifiedType type) {
+                if (value instanceof Inconvertible) return false;
+                else if (type.getRawClass().equals(String.class)) return true;
+                else if (type.getRawClass().equals(List.class) && (value == null || value instanceof Collection)) return true;
+                else return false;
+            }
+
+            public Object getInstanceLock() { return null; }
+            public Object getObject(String name) { return null; }
+            public Object getPartialObject(String name) { return null; }
+            public Recipe getRecipe(String name) { return null; }
+            public Class loadClass(String className) throws ClassNotFoundException { return null; }
+            public Recipe pop() { return null; }
+            public void push(Recipe recipe) throws CircularDependencyException {}
+            public Object removePartialObject(String name) { return null; }            
+        });
+    }
+    
+    @Test
+    public void testGetterOnly() throws Exception {
+        loadProps(GetterOnly.class, true);
+        
+        assertEquals(2, sut.length);
+        assertEquals("class", sut[0].getName());
+        assertEquals("value", sut[1].getName());
+        
+        assertTrue(sut[1].allowsGet());
+        assertFalse(sut[1].allowsSet());
+        
+        assertEquals("test", sut[1].get(new GetterOnly(), mockBlueprint));
+    }
+    
+    static class SetterOnly {
+        private String f;
+        
+        public void setField(String val) { f = val; }
+        public String retrieve() { return f; }
+    }
+    
+    @Test
+    public void testSetterOnly() throws Exception {
+        loadProps(SetterOnly.class, false);
+        
+        assertEquals(2, sut.length);
+        assertEquals("field", sut[1].getName());
+        
+        assertFalse(sut[1].allowsGet());
+        assertTrue(sut[1].allowsSet());
+        
+        SetterOnly so = new SetterOnly();
+        sut[1].set(so, "trial", mockBlueprint);
+        assertEquals("trial", so.retrieve());
+    }
+    
+    static class SetterAndGetter {
+        private String f;
+        
+        public void setField(String val) { f = val; }
+        public String getField() { return f; }
+    }
+    
+    @Test
+    public void testSetterAndGetter() throws Exception {
+        loadProps(SetterAndGetter.class, false);
+        
+        assertEquals(2, sut.length);
+        assertEquals("field", sut[1].getName());
+        
+        assertTrue(sut[1].allowsGet());
+        assertTrue(sut[1].allowsSet());
+        
+        SetterAndGetter sag = new SetterAndGetter();
+        sut[1].set(sag, "tribulation", mockBlueprint);
+        assertEquals("tribulation", sut[1].get(sag, mockBlueprint));
+    }
+    
+    static class DuplicateGetter {
+        public boolean isField() { return true; }
+        public boolean getField() { return false; }
+    }
+    
+    @Test
+    public void testDuplicateGetter() {
+        loadProps(DuplicateGetter.class, false);
+        
+        assertEquals(1, sut.length);
+        assertEquals("class", sut[0].getName());
+    }
+    
+    static class FieldsAndProps {
+        private String hidden = "ordeal";
+        private String nonHidden;
+        
+        public String getHidden() { return hidden; }
+    }
+    
+    @Test
+    public void testFieldsAndProps() throws Exception {
+        loadProps(FieldsAndProps.class, true);
+        
+        assertEquals(3, sut.length);
+        
+        FieldsAndProps fap = new FieldsAndProps();
+        
+        // no mixing of setter and field injection
+        assertEquals("hidden", sut[1].getName());
+        assertTrue(sut[1].allowsGet());
+        assertTrue(sut[1].allowsSet());
+        
+        assertEquals("ordeal", sut[1].get(fap, mockBlueprint));
+        sut[1].set(fap, "calvary", mockBlueprint);
+        assertEquals("calvary", sut[1].get(fap, mockBlueprint));
+        
+        assertEquals("nonHidden", sut[2].getName());
+        assertTrue(sut[2].allowsGet());
+        assertTrue(sut[2].allowsSet());
+        
+        sut[2].set(fap, "predicament", mockBlueprint);
+        assertEquals("predicament", sut[2].get(fap, mockBlueprint));
+    }
+    
+    static class OverloadedSetters {
+        public Object field;
+        
+        public void setField(String val) { field = val; }
+        public void setField(List<String> val) { field = val; }
+    }
+    
+    @Test
+    public void testOverloadedSetters() throws Exception {
+        loadProps(OverloadedSetters.class, false);
+        
+        OverloadedSetters os = new OverloadedSetters();
+
+        sut[1].set(os, "scrutiny", mockBlueprint);
+        assertEquals("scrutiny", os.field);
+        
+        sut[1].set(os, Arrays.asList("evaluation"), mockBlueprint);
+        assertEquals(Arrays.asList("evaluation"), os.field);
+        
+        // conversion case, Integer -> String
+        sut[1].set(os, new Integer(3), mockBlueprint);
+        assertEquals("3", os.field);
+    }
+    
+    @Test(expected=ComponentDefinitionException.class)
+    public void testApplicableSetter() throws Exception {
+        loadProps(OverloadedSetters.class, false);
+        
+        sut[1].set(new OverloadedSetters(), new Inconvertible(), mockBlueprint);
+    }
+    
+    static class MultipleMatchesByConversion {
+        public void setField(String s) {}
+        public void setField(List<String> list) {}
+    }
+    
+    @Test(expected=ComponentDefinitionException.class)
+    public void testMultipleMatchesByConversion() throws Exception {
+        loadProps(MultipleMatchesByConversion.class, false);
+        
+        sut[1].set(new MultipleMatchesByConversion(), new HashSet<String>(), mockBlueprint);
+    }
+    
+    static class MultipleMatchesByType {
+        public void setField(List<String> list) {}
+        public void setField(Queue<String> list) {}
+        
+        public static int field;
+        
+        public void setOther(Collection<String> list) { field=1; }
+        public void setOther(List<String> list) { field=2; }
+    }
+    
+    @Test(expected=ComponentDefinitionException.class)
+    public void testMultipleSettersMatchByType() throws Exception {
+        loadProps(MultipleMatchesByType.class, false);
+        
+        sut[1].set(new MultipleMatchesByType(), new LinkedList<String>(), mockBlueprint);
+    }
+    
+    @Test
+    public void testDisambiguationByHierarchy() throws Exception {
+        loadProps(MultipleMatchesByType.class, false);
+        
+        sut[2].set(new MultipleMatchesByType(), new ArrayList<String>(), mockBlueprint);
+        assertEquals(2, MultipleMatchesByType.field);
+    }
+    
+    static class NullSetterDisambiguation {
+        public static int field;
+        
+        public void setField(int i) { field = i; }
+        public void setField(Integer i) { field = -1; }
+    }
+    
+    @Test
+    public void testNullDisambiguation() throws Exception {
+        loadProps(NullSetterDisambiguation.class, false);
+        
+        sut[1].set(new NullSetterDisambiguation(), null, mockBlueprint);
+        assertEquals(-1, NullSetterDisambiguation.field);
+    }
+    
+    private void loadProps(Class<?> clazz, boolean allowsFieldInjection)
+    {
+        List<PropertyDescriptor> props = new ArrayList<PropertyDescriptor>(
+                Arrays.asList(ReflectionUtils.getPropertyDescriptors(clazz, allowsFieldInjection)));
+        
+        Collections.sort(props, new Comparator<PropertyDescriptor>() {
+            public int compare(PropertyDescriptor o1, PropertyDescriptor o2) {
+                return o1.getName().compareTo(o2.getName());
+            }
+        });
+        
+        sut = props.toArray(new PropertyDescriptor[0]);
+    }
+}