aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z..@apache.org
Subject svn commit: r1075143 [20/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/proxy/ProxyTestClassGeneric.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassGeneric.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassGeneric.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassGeneric.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,28 @@
+/*
+ * 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 ProxyTestClassGeneric extends ProxyTestClassGenericSuper<String>
+{
+
+  public void setSomething(String s)
+  {
+    super.setSomething(s);
+  }
+}

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

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassPrivateConstructor.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassPrivateConstructor.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassPrivateConstructor.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassPrivateConstructor.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 ProxyTestClassPrivateConstructor
+{
+  private ProxyTestClassPrivateConstructor()
+  {
+
+  }
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassSuper.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassSuper.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassSuper.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/proxy/ProxyTestClassSuper.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.proxy;
+
+public class ProxyTestClassSuper
+{
+
+  public void bMethod()
+  {
+    aPrivateMethod();
+  }
+
+  protected void bProMethod()
+  {
+
+  }
+
+  void bDefMethod()
+  {
+
+  }
+
+  private void aPrivateMethod()
+  {
+
+  }
+
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/DynamicCollectionTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/DynamicCollectionTest.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/DynamicCollectionTest.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/DynamicCollectionTest.java Sun Feb 27 20:50:38 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.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/HeaderParserTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/HeaderParserTest.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/HeaderParserTest.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/HeaderParserTest.java Sun Feb 27 20:50:38 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.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/ReflectionUtilsTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/ReflectionUtilsTest.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/ReflectionUtilsTest.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/java/org/apache/aries/blueprint/utils/ReflectionUtilsTest.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,288 @@
+/*
+ * 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.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.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;
+    
+    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(), null));
+    }
+    
+    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", null);
+        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", null);
+        assertEquals("tribulation", sut[1].get(sag, null));
+    }
+    
+    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, null));
+        sut[1].set(fap, "calvary", null);
+        assertEquals("calvary", sut[1].get(fap, null));
+        
+        assertEquals("nonHidden", sut[2].getName());
+        assertTrue(sut[2].allowsGet());
+        assertTrue(sut[2].allowsSet());
+        
+        sut[2].set(fap, "predicament", null);
+        assertEquals("predicament", sut[2].get(fap, null));
+    }
+    
+    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", null);
+        assertEquals("scrutiny", os.field);
+        
+        sut[1].set(os, Arrays.asList("evaluation"), null);
+        assertEquals(Arrays.asList("evaluation"), os.field);
+        
+        // conversion case, Integer -> String
+        sut[1].set(os, new Integer(3), null);
+        assertEquals("3", os.field);
+    }
+    
+    @Test(expected=ComponentDefinitionException.class)
+    public void testApplicableSetter() throws Exception {
+        loadProps(OverloadedSetters.class, false);
+        
+        sut[1].set(new OverloadedSetters(), new Inconvertible(), null);
+    }
+    
+    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>(), null);
+    }
+    
+    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>(), null);
+    }
+    
+    @Test
+    public void testDisambiguationByHierarchy() throws Exception {
+        loadProps(MultipleMatchesByType.class, false);
+        
+        sut[2].set(new MultipleMatchesByType(), new ArrayList<String>(), null);
+        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, null);
+        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]);
+    }
+}

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/cache.xsd
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/cache.xsd?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/cache.xsd (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/cache.xsd Sun Feb 27 20:50:38 2011
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+    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.
+-->
+<xsd:schema xmlns="http://cache.org"
+            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+            targetNamespace="http://cache.org"
+            elementFormDefault="qualified"
+            attributeFormDefault="unqualified"
+            version="1.0.0">
+
+    <xsd:element name="lru-cache">
+        <xsd:complexType>
+            <xsd:attribute name="id" type="xsd:string"/>
+        </xsd:complexType>
+    </xsd:element>
+
+    <xsd:element name="operation">
+        <xsd:complexType>
+            <xsd:attribute name="name" type="xsd:string"/>
+        </xsd:complexType>
+    </xsd:element>
+
+</xsd:schema>

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-bad-id-ref.xml
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-bad-id-ref.xml?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-bad-id-ref.xml (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-bad-id-ref.xml Sun Feb 27 20:50:38 2011
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           default-availability="mandatory" >
+
+   <bean id="badIdRef" class="org.apache.aries.blueprint.pojos.BeanD">
+        <property name="name">
+          <idref component-id="doesnotexist"/>
+        </property>
+    </bean>
+    
+</blueprint>
\ No newline at end of file

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-circular.xml
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-circular.xml?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-circular.xml (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-circular.xml Sun Feb 27 20:50:38 2011
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <bean id="a" class="org.apache.aries.blueprint.pojos.PojoCircular">
+        <property name="circular" ref="b"/>
+    </bean>
+
+    <bean id="b" class="org.apache.aries.blueprint.pojos.PojoCircular">
+        <property name="circular" ref="a"/>
+    </bean>
+    
+    <bean id="c" class="org.apache.aries.blueprint.pojos.PojoCircular" init-method = "init">
+        <property name="circular" ref="d"/>
+    </bean>
+
+    <bean id="d" class="org.apache.aries.blueprint.pojos.PojoCircular">
+        <property name="circular" ref="c"/>
+    </bean>
+    
+    
+    
+    <bean id="serviceBean" class="org.apache.aries.blueprint.pojos.PojoB">
+        <property name="uri" value="urn:myuri" />
+    </bean>
+    
+    <bean id="listener" class="org.apache.aries.blueprint.pojos.PojoListener">
+        <property name="service" ref="service" />
+    </bean>
+    
+    <service id="service" ref="serviceBean" interface="org.apache.aries.blueprint.pojos.PojoB">
+        <service-properties>
+            <entry key="key1" value="value1"/>
+            <entry key="key2" value="value2"/>
+        </service-properties>
+        <registration-listener ref="listener"
+           registration-method="register"
+           unregistration-method="unregister"/>
+    </service>
+    
+    <!-- for prototype cycle tests -->
+    
+    <bean id="circularPrototype" class="org.apache.aries.blueprint.pojos.PojoCircular" scope = "prototype">
+        <property name="circular" ref="circularPrototype"/>
+    </bean>
+    
+    <bean id="circularPrototypeDriver" class="org.apache.aries.blueprint.pojos.PojoCircular" scope = "prototype">
+        <property name="circular" ref="circularPrototypeDriver"/>
+    </bean>
+            
+     <!-- for dynamic cycle tests (blueprintContainer.getComponentInstance()) -->
+     
+    <bean id="recursiveConstructor" class="org.apache.aries.blueprint.pojos.PojoRecursive">
+        <argument ref="blueprintContainer"/>
+        <argument value="recursiveConstructor"/>
+        <argument value="1"/>
+    </bean>
+    
+    <bean id="recursiveSetter" class="org.apache.aries.blueprint.pojos.PojoRecursive">
+        <argument ref="blueprintContainer"/>
+        <argument value="recursiveSetter"/>
+        <property name="foo" value="1"/>
+    </bean>
+    
+    <bean id="recursiveInitMethod" class="org.apache.aries.blueprint.pojos.PojoRecursive" init-method = "init">
+        <argument ref="blueprintContainer"/>
+        <argument value="recursiveInitMethod"/>
+    </bean>
+
+    <!-- for breaking dependency cycle tests  -->
+
+    <bean id="c1" class="org.apache.aries.blueprint.pojos.PojoCircular">
+        <argument ref="c2"/>
+    </bean>
+    
+    <bean id="c2" class="org.apache.aries.blueprint.pojos.PojoCircular">
+        <argument ref="c3"/>
+    </bean>
+    
+    <bean id="c3" class="org.apache.aries.blueprint.pojos.PojoCircular">
+        <property name="circular" ref="c1"/>
+    </bean>
+    
+</blueprint>
\ No newline at end of file

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-constructor.xml
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-constructor.xml?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-constructor.xml (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-constructor.xml Sun Feb 27 20:50:38 2011
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+            default-availability="mandatory" >
+
+    <bean id="pojoB" class="org.apache.aries.blueprint.pojos.PojoB">
+        <argument value="urn:myuri" />
+        <argument value="10" />
+    </bean>
+    
+    <bean id="pojoA" class="org.apache.aries.blueprint.pojos.PojoA">
+        <argument ref="pojoB" />
+        <property name="number">
+            <value type="java.math.BigInteger">10</value>
+        </property>
+    </bean>
+
+    <bean id="pojoC" class="org.apache.aries.blueprint.pojos.PojoB" factory-method = "createStatic" >
+        <argument><value type="int">15</value></argument>
+        <argument value="urn:myuri" />
+    </bean>
+    
+    <bean id="pojoD" class="org.apache.aries.blueprint.pojos.PojoB" factory-method = "createStatic" >
+        <argument value="15" index = "1" />
+        <argument value="urn:myuri" index = "0" />
+    </bean>
+    
+    <bean id="pojoE" factory-method = "createDynamic" factory-ref = "pojoB" >
+        <argument><value type="int">20</value></argument>
+        <argument value="urn:myuri" />
+    </bean>
+    
+    <bean id="multipleInt" class="org.apache.aries.blueprint.pojos.Multiple">
+        <argument type="int" value="123"/>
+    </bean>
+    
+    <bean id="multipleInteger" class="org.apache.aries.blueprint.pojos.Multiple">
+        <argument type="java.lang.Integer" value="123"/>
+    </bean>
+    
+    <bean id="multipleString" class="org.apache.aries.blueprint.pojos.Multiple">
+        <argument type="java.lang.String" value="123"/>
+    </bean>
+    
+    <bean id="multipleStringConvertable" class="org.apache.aries.blueprint.pojos.Multiple">
+        <argument value="hello"/>
+    </bean>
+    
+    <bean id="multipleFactory1" class="org.apache.aries.blueprint.pojos.Multiple"
+          factory-method = "create" >
+        <argument value="hello"/>
+        <argument value="1234"/>
+    </bean>
+        
+    <bean id="multipleFactory2" class="org.apache.aries.blueprint.pojos.Multiple"
+          factory-method = "create" >
+        <argument value="helloCreate"/>
+        <argument value="yes"/>
+    </bean>
+
+    <bean id="multipleFactoryNull" class="org.apache.aries.blueprint.pojos.Multiple"
+          factory-method = "create" >
+        <argument value="helloNull"/>
+        <argument><null/></argument>
+    </bean>
+    
+     <bean id="multipleFactoryTypedNull" class="org.apache.aries.blueprint.pojos.Multiple"
+          factory-method = "create" >
+        <argument value="hello"/>
+        <argument type = "java.lang.Boolean"><null/></argument>
+    </bean>
+    
+    <bean id="mapConstruction" class="org.apache.aries.blueprint.pojos.Multiple">
+        <argument>
+            <map>
+                <entry key="a" value="b"/>
+            </map>
+        </argument>
+    </bean>
+
+    <bean id="propsConstruction" class="org.apache.aries.blueprint.pojos.Multiple">
+        <argument>
+            <props>
+                <prop key="a" value="b"/>
+            </props>
+        </argument>
+    </bean>
+
+    <bean id="booleanPrim" class="org.apache.aries.blueprint.pojos.BeanF">
+        <argument><value type="boolean">no</value></argument>
+    </bean>
+
+    <bean id="booleanWrapped" class="org.apache.aries.blueprint.pojos.BeanF">
+        <argument type="java.lang.Boolean" value="no" />
+    </bean>
+
+</blueprint>

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-custom-nodes.xml
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-custom-nodes.xml?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-custom-nodes.xml (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-custom-nodes.xml Sun Feb 27 20:50:38 2011
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:cache="http://cache.org">
+
+    <cache:lru-cache id="myCache" />
+    
+    <bean id="fooService" class="FooServiceImpl" cache:cache-return-values="true">
+        <cache:operation name="getVolatile" />
+
+        <property name="myProp" value="12" />
+    </bean>
+    
+    <bean id="barService" class="BarServiceImpl">
+        <property name="localCache">
+            <cache:lru-cache />
+        </property>
+    </bean>
+
+</blueprint>
\ No newline at end of file

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-depends-on.xml
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-depends-on.xml?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-depends-on.xml (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-depends-on.xml Sun Feb 27 20:50:38 2011
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <bean id="c" class="org.apache.aries.blueprint.pojos.BeanC" depends-on="d" init-method="init" destroy-method="destroy"/>
+
+    <bean id="d" class="org.apache.aries.blueprint.pojos.BeanD" init-method="init" destroy-method="destroy"/>
+    
+    <bean id="e" class="org.apache.aries.blueprint.pojos.BeanE" init-method="init" destroy-method="destroy">
+        <argument ref="c"/>
+    </bean>
+
+</blueprint>
\ No newline at end of file

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-generics.xml
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-generics.xml?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-generics.xml (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-generics.xml Sun Feb 27 20:50:38 2011
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+            default-availability="mandatory" >
+
+    <bean id="method" class="org.apache.aries.blueprint.pojos.PojoGenerics">
+        <property name="list">
+            <list>
+                <value>10</value>
+                <value>20</value>
+                <value>50</value>
+            </list>
+        </property>
+        <property name="set">
+            <set>
+                <value>1000</value>
+                <value>2000</value>
+                <value>5000</value>
+            </set>
+        </property>
+        <property name="map">
+            <map>
+                <entry key="1" value="yes"/>
+                <entry key="2" value="no" />
+                <entry>
+                     <key><value>5</value></key>
+                     <value>true</value>
+                </entry>
+            </map>
+        </property>        
+    </bean>
+    
+    <bean id="constructorList" class="org.apache.aries.blueprint.pojos.PojoGenerics">
+        <argument type="java.util.List">
+            <list>
+                <value>10</value>
+                <value>20</value>
+                <value>50</value>
+            </list>
+        </argument>      
+    </bean>
+    
+    <bean id="constructorSet" class="org.apache.aries.blueprint.pojos.PojoGenerics">
+       <argument type="java.util.Set">
+            <set>
+                <value>1000</value>
+                <value>2000</value>
+                <value>5000</value>
+            </set>
+        </argument>
+    </bean>
+    
+    <bean id="constructorMap" class="org.apache.aries.blueprint.pojos.PojoGenerics">
+        <argument>
+            <map>
+                <entry key="1" value="yes"/>
+                <entry key="2" value="no" />
+                <entry>
+                     <key><value>5</value></key>
+                     <value>true</value>
+                </entry>
+            </map>
+        </argument>
+    </bean>
+    
+		<bean id="genericPojoFactory" class="org.apache.aries.blueprint.pojos.PrimaveraFactory" />
+		<bean id="genericPojo" factory-ref="genericPojoFactory" factory-method="getObject">
+				<property name="property" value="string" />
+		</bean>
+
+		<bean id="doubleGenericPojo" factory-ref="genericPojoFactory" factory-method="getObject">
+	    	<property name="property" value="stringToo" />
+		</bean>
+    
+</blueprint>

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-simple-component.xml
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-simple-component.xml?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-simple-component.xml (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-simple-component.xml Sun Feb 27 20:50:38 2011
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+    <bean id="pojoA" class="org.apache.aries.blueprint.pojos.PojoA" depends-on=" pojoB  pojoC ">
+        <argument value="val0"/>
+        <argument ref="val1" />
+        <argument>
+            <description>null value</description>
+            <null/>
+        </argument>
+        <argument type="java.lang.String">
+            <value>val3</value>
+        </argument>
+        <argument>
+            <array>
+                <value>val0</value>
+                <bean class="java.lang.String"/>
+                <null/>
+            </array>
+        </argument>
+        <argument>
+            <ref component-id="pojoB"/>
+        </argument>
+        <property name="prop1" ref="pojoB"/>
+        <property name="prop2" value="value" />
+        <property name="prop3">
+            <description>property</description>
+            <value>val</value>
+        </property>
+    </bean>
+
+    <bean id="pojoB" class="org.apache.aries.blueprint.pojos.PojoA" init-method="initPojo" >
+        <argument index = "1" value="val0"/>
+        <argument index = "0" ref="val1" />
+    </bean>
+
+</blueprint>
\ No newline at end of file

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-wiring.xml
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-wiring.xml?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-wiring.xml (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test-wiring.xml Sun Feb 27 20:50:38 2011
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
+           default-availability="mandatory" >
+
+    <type-converters>
+            <bean id="converter1" class="org.apache.aries.blueprint.pojos.ConverterA">
+                <property name="bundle" ref="blueprintBundleContext" />
+            </bean>
+    </type-converters>
+
+    <service id="service1" ref="pojoB" interface="org.apache.aries.blueprint.pojos.PojoB">
+        <service-properties>
+            <entry key="key1" value="value1"/>
+            <entry key="key2" value="value2"/>
+        </service-properties>    
+    </service>
+
+    <bean id="pojoC" class="org.apache.aries.blueprint.pojos.PojoB" scope = "prototype">
+        <property name="uri" value="urn:myuri" />
+        <property name="objects">
+            <list>
+                <value>list value</value>
+            </list>
+        </property>
+    </bean>
+    
+    <bean id="pojoB" class="org.apache.aries.blueprint.pojos.PojoB" init-method = "init" destroy-method = "destroy" >
+        <property name="uri" value="urn:myuri" />
+    </bean>
+
+    <bean id="pojoA" class="org.apache.aries.blueprint.pojos.PojoA">
+        <property name="pojob" ref="pojoB"/>
+        <property name="map">
+            <map>
+                <entry key="key" value="val"/>
+                <entry key-ref="pojoB" value-ref="pojoB" />
+                <entry>
+                     <key><value type="java.lang.Integer">5</value></key>
+                     <value type="java.net.URI">http://geronimo.apache.org</value>
+                </entry>
+            </map>
+        </property>
+        <property name="set">
+            <set value-type="java.net.URI">
+                <value type="java.lang.String">set value</value>
+                <ref component-id="pojoB" />
+                <value>http://geronimo.apache.org</value>
+            </set>
+        </property>
+        <property name="list">
+            <list>
+                <value>list value</value>
+                <ref component-id="pojoC" />
+                <value type="java.lang.Integer">55</value>
+                <value type="java.net.URI">http://geronimo.apache.org</value>
+                <ref component-id="pojoC" />
+            </list>
+        </property>
+        <property name="props">
+            <props>
+                <prop key="key1" value="value1" />
+                <prop key="2" value="value2" />
+                <prop key="foo">bar</prop>
+            </props>
+        </property>
+        <property name="array">
+            <array>
+                <value>list value</value>
+                <ref component-id="pojoB" />
+                <value type="java.lang.Integer">55</value>
+                <value type="java.net.URI">http://geronimo.apache.org</value>
+            </array>
+        </property>        
+        <property name="intArray">
+            <array>
+                <value>1</value>
+                <value>50</value>
+                <value>100</value>
+            </array>
+        </property>
+        <property name="numberArray">
+            <array>
+                <value type="int">1</value>
+                <value type="java.math.BigInteger">50</value>
+                <value type="java.lang.Long">100</value>
+                <value type="int">200</value>
+            </array>
+        </property>
+        <property name="number">
+            <value type="java.math.BigInteger">10</value>
+        </property>
+    </bean>
+
+    <bean id="compound" class="org.apache.aries.blueprint.pojos.PojoB">
+        <property name="bean.name" value="hello bean property" />
+    </bean>
+    
+    <bean id="goodIdRef" class="org.apache.aries.blueprint.pojos.BeanD">
+        <property name="name">
+          <idref component-id="pojoA"/>
+        </property>
+    </bean>
+    
+    <bean id="FITestBean" ext:field-injection="true" class="org.apache.aries.blueprint.pojos.FITestBean">
+        <property name="attr" value="value" />
+        <property name="upperCaseAttr" value="is_lower" />
+        <property name="bean.name" value="aName" />
+    </bean>
+
+    <bean id="FIFailureTestBean" class="org.apache.aries.blueprint.pojos.FITestBean">
+        <property name="attr" value="value" />
+    </bean>
+    
+    <bean id="FIFailureTest2Bean" class="org.apache.aries.blueprint.pojos.FITestBean" ext:field-injection="false">
+        <property name="attr" value="value" />
+    </bean>
+    
+    <bean id="ambiguousViaInt" class="org.apache.aries.blueprint.pojos.AmbiguousPojo">
+    	<property name="sum" value="5" />
+    </bean>
+    
+    <bean id="ambiguousViaList" class="org.apache.aries.blueprint.pojos.AmbiguousPojo">
+    	<property name="sum">
+    		<list>
+    			<value>3</value>
+    			<value>4</value>
+    		</list>
+    	</property>
+    </bean>
+
+</blueprint>
\ No newline at end of file

Added: aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test.xml
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test.xml?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test.xml (added)
+++ aries/tags/blueprint-0.2.1/blueprint-core/src/test/resources/test.xml Sun Feb 27 20:50:38 2011
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           default-availability="mandatory">
+
+    <description>
+        This is a parsing test application
+    </description>
+
+    <type-converters>
+        <bean class="org.apache.aries.blueprint.pojos.ConverterA"/>
+        <ref component-id="converterB"/>
+    </type-converters>
+
+    <bean id="pojoA" class="org.apache.aries.blueprint.pojos.PojoA">
+        <property name="pojob" ref="pojoB"/>
+    </bean>
+
+    <bean id="pojoAcns" class="org.apache.aries.blueprint.pojos.PojoA">
+        <argument ref="pojoB"/>
+    </bean>
+
+    <bean id="pojoB" class="org.apache.aries.blueprint.pojos.PojoB">
+        <property name="uri" value="urn:myuri"/>
+    </bean>
+
+    <bean id="pojoBcns" class="org.apache.aries.blueprint.pojos.PojoB">
+        <argument value="urn:myuri"/>
+    </bean>
+
+    <bean id="converterB" class="org.apache.aries.blueprint.pojos.ConverterB"/>
+
+    <reference id="refA" filter="(key=prop)" interface="org.apache.aries.blueprint.pojos.InterfaceA"/>
+
+    <reference id="refB" availability="optional">
+        <interfaces>
+            <value>org.apache.aries.blueprint.pojos.InterfaceA</value>
+        </interfaces>
+        <listener   ref="listenerA" bind-method="bind" unbind-method="unbind"/>
+    </reference>
+
+    <service interface="org.apache.aries.blueprint.pojos.InterfaceA" ref="pojoA"/>
+
+    <bean id="listenerA" class="org.apache.aries.blueprint.pojos.ListenerA"/>
+
+    <reference-list availability="optional" member-type="service-object"/>
+
+</blueprint>
\ No newline at end of file

Added: aries/tags/blueprint-0.2.1/blueprint-itests/pom.xml
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-itests/pom.xml?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-itests/pom.xml (added)
+++ aries/tags/blueprint-0.2.1/blueprint-itests/pom.xml Sun Feb 27 20:50:38 2011
@@ -0,0 +1,198 @@
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.aries.blueprint</groupId>
+        <artifactId>blueprint</artifactId>
+        <version>0.2.1</version>
+    </parent>
+
+    <artifactId>org.apache.aries.blueprint.itests</artifactId>
+    <name>Apache Aries Blueprint iTests</name>
+    <description>
+        Integration tests using the standalone blueprint-bundle for the implementation
+        and blueprint-sample for the blueprint application to be tested.
+    </description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse</groupId>
+            <artifactId>osgi</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.blueprint</groupId>
+            <artifactId>org.apache.aries.blueprint</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries</groupId>
+            <artifactId>org.apache.aries.util</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.blueprint</groupId>
+            <artifactId>org.apache.aries.blueprint.sample</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.blueprint</groupId>
+            <artifactId>org.apache.aries.blueprint.testbundlea</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.aries.blueprint</groupId>
+            <artifactId>org.apache.aries.blueprint.testbundleb</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-container-default</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-junit-extender-impl</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.runner</groupId>
+            <artifactId>pax-runner-no-jcl</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.configadmin</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.logging</groupId>
+            <artifactId>pax-logging-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.logging</groupId>
+            <artifactId>pax-logging-service</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.url</groupId>
+            <artifactId>pax-url-mvn</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix.bundles</groupId>
+            <artifactId>org.apache.servicemix.bundles.cglib</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>asm</groupId>
+            <artifactId>asm-all</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <forkMode>pertest</forkMode>
+                    <excludes>
+                        <exclude>**/*$*</exclude>
+                        <exclude>**/Abstract*.java</exclude>
+                    </excludes>
+                    <includes>
+                        <include>**/Test*.java</include>
+                        <include>**/*Test.java</include>
+                    </includes>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.ops4j.pax.exam</groupId>
+                <artifactId>maven-paxexam-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>generate-config</id>
+                        <goals>
+                            <goal>generate-depends-file</goal>
+                        </goals>
+                        <configuration>
+                            <outputFile>${project.build.directory}/test-classes/META-INF/maven/dependencies.properties</outputFile>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <profiles>
+        <profile>
+            <id>ci-build-profile</id>
+            <activation>
+                <property>
+                    <name>maven.repo.local</name>
+                </property>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <configuration>
+                            <!--
+                                when the local repo location has been specified, we need to pass
+                                on this information to PAX mvn url
+                            -->
+                            <argLine>-Dorg.ops4j.pax.url.mvn.localRepository=${maven.repo.local}</argLine>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
+</project>

Added: aries/tags/blueprint-0.2.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/AbstractIntegrationTest.java
URL: http://svn.apache.org/viewvc/aries/tags/blueprint-0.2.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/AbstractIntegrationTest.java?rev=1075143&view=auto
==============================================================================
--- aries/tags/blueprint-0.2.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/AbstractIntegrationTest.java (added)
+++ aries/tags/blueprint-0.2.1/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/AbstractIntegrationTest.java Sun Feb 27 20:50:38 2011
@@ -0,0 +1,300 @@
+/*
+ * 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.itests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.*;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Currency;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.aries.blueprint.sample.Account;
+import org.apache.aries.blueprint.sample.AccountFactory;
+import org.apache.aries.blueprint.sample.Bar;
+import org.apache.aries.blueprint.sample.Foo;
+import org.junit.After;
+import org.junit.Before;
+import org.ops4j.pax.exam.CoreOptions;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.wrappedBundle;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import static org.ops4j.pax.exam.OptionUtils.combine;
+import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.osgi.util.tracker.ServiceTracker;
+
+public abstract class AbstractIntegrationTest {
+
+    public static final long DEFAULT_TIMEOUT = 30000;
+
+    private List<ServiceTracker> srs;
+
+    @Before
+    public void setUp() {
+        srs = new ArrayList<ServiceTracker>();
+    }
+    
+    @After
+    public void tearDown() throws Exception{
+        for (ServiceTracker st : srs) {
+            if (st != null) {
+                st.close();
+            }  
+        }
+    }
+    
+    @Inject
+    protected BundleContext bundleContext;
+
+    protected BlueprintContainer getBlueprintContainerForBundle(String symbolicName) throws Exception {
+        return getBlueprintContainerForBundle(symbolicName, DEFAULT_TIMEOUT);
+    }
+
+    protected BlueprintContainer getBlueprintContainerForBundle(String symbolicName, long timeout) throws Exception {
+        return getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=" + symbolicName + ")", timeout);
+    }
+    
+    protected BlueprintContainer getBlueprintContainerForBundle(BundleContext bc, String symbolicName, long timeout) throws Exception {
+        return getOsgiService(bc, BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=" + symbolicName + ")", timeout);
+    }
+
+    protected <T> T getOsgiService(Class<T> type, long timeout) {
+        return getOsgiService(type, null, timeout);
+    }
+
+    protected <T> T getOsgiService(Class<T> type) {
+        return getOsgiService(type, null, DEFAULT_TIMEOUT);
+    }
+    
+    protected <T> T getOsgiService(BundleContext bc, Class<T> type, String filter, long timeout) {
+        ServiceTracker tracker = null;
+        try {
+            String flt;
+            if (filter != null) {
+                if (filter.startsWith("(")) {
+                    flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")" + filter + ")";
+                } else {
+                    flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")(" + filter + "))";
+                }
+            } else {
+                flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
+            }
+            Filter osgiFilter = FrameworkUtil.createFilter(flt);
+            tracker = new ServiceTracker(bc == null ? bundleContext : bc, osgiFilter, null);
+            tracker.open();
+            
+            // add tracker to the list of trackers we close at tear down
+            srs.add(tracker);
+            Object svc = type.cast(tracker.waitForService(timeout));
+            if (svc == null) {
+                throw new RuntimeException("Gave up waiting for service " + flt);
+            }
+            return type.cast(svc);
+        } catch (InvalidSyntaxException e) {
+            throw new IllegalArgumentException("Invalid filter", e);
+        } catch (InterruptedException e) {
+            throw new RuntimeException(e);
+        }
+    }
+    
+    protected <T> T getOsgiService(Class<T> type, String filter, long timeout) {
+        return getOsgiService(null, type, filter, timeout);
+    }
+
+    protected Bundle installBundle(String groupId, String artifactId) throws Exception {
+        MavenArtifactProvisionOption mvnUrl = mavenBundle(groupId, artifactId);
+        return bundleContext.installBundle(mvnUrl.getURL());
+    }
+
+    protected Bundle getInstalledBundle(String symbolicName) {
+        for (Bundle b : bundleContext.getBundles()) {
+            if (b.getSymbolicName().equals(symbolicName)) {
+                return b;
+            }
+        }
+        return null;
+    }
+
+    public static MavenArtifactProvisionOption mavenBundle(String groupId, String artifactId) {
+        return CoreOptions.mavenBundle().groupId(groupId).artifactId(artifactId).versionAsInProject();
+    }
+    
+    public static MavenArtifactProvisionOption mavenBundleInTest(String groupId, String artifactId) {
+        return CoreOptions.mavenBundle().groupId(groupId).artifactId(artifactId).version(getArtifactVersion(groupId, artifactId));
+    }
+
+    //TODO getArtifactVersion and getFileFromClasspath are borrowed and modified from pax-exam.  They should be moved back ASAP.
+    public static String getArtifactVersion( final String groupId,
+                                             final String artifactId )
+    {
+        final Properties dependencies = new Properties();
+        try
+        {
+            InputStream in = getFileFromClasspath("META-INF/maven/dependencies.properties");
+            try {
+                dependencies.load(in);
+            } finally {
+                in.close();
+            }
+            final String version = dependencies.getProperty( groupId + "/" + artifactId + "/version" );
+            if( version == null )
+            {
+                throw new RuntimeException(
+                    "Could not resolve version. Do you have a dependency for " + groupId + "/" + artifactId
+                    + " in your maven project?"
+                );
+            }
+            return version;
+        }
+        catch( IOException e )
+        {
+            // TODO throw a better exception
+            throw new RuntimeException(
+                "Could not resolve version. Did you configured the plugin in your maven project?"
+                + "Or maybe you did not run the maven build and you are using an IDE?"
+            );
+        }
+    }
+
+    private static InputStream getFileFromClasspath( final String filePath )
+        throws FileNotFoundException
+    {
+        try
+        {
+            URL fileURL = AbstractIntegrationTest.class.getClassLoader().getResource( filePath );
+            if( fileURL == null )
+            {
+                throw new FileNotFoundException( "File [" + filePath + "] could not be found in classpath" );
+            }
+            return fileURL.openStream();
+        }
+        catch (IOException e)
+        {
+            throw new FileNotFoundException( "File [" + filePath + "] could not be found: " + e.getMessage() );
+        }
+    }
+
+
+    protected static Option[] updateOptions(Option[] options) {
+        // We need to add pax-exam-junit here when running with the ibm
+        // jdk to avoid the following exception during the test run:
+        // ClassNotFoundException: org.ops4j.pax.exam.junit.Configuration
+        if ("IBM Corporation".equals(System.getProperty("java.vendor"))) {
+            Option[] ibmOptions = options(
+                wrappedBundle(mavenBundle("org.ops4j.pax.exam", "pax-exam-junit"))
+            );
+            options = combine(ibmOptions, options);
+        }
+
+        return options;
+    }
+    
+    protected void testBlueprintContainer(Bundle bundle) throws Exception {
+        testBlueprintContainer(bundleContext, bundle);
+    }
+    
+    
+    protected void testBlueprintContainer(BundleContext bc, Bundle bundle) throws Exception {
+        BlueprintContainer blueprintContainer = getBlueprintContainerForBundle(
+                bc == null ? bundleContext : bc, "org.apache.aries.blueprint.sample",
+                5000);
+        assertNotNull(blueprintContainer);
+
+        Object obj = blueprintContainer.getComponentInstance("bar");
+        assertNotNull(obj);
+        assertEquals(Bar.class, obj.getClass());
+        Bar bar = (Bar) obj;
+        assertNotNull(bar.getContext());
+        assertEquals("Hello FooBar", bar.getValue());
+        assertNotNull(bar.getList());
+        assertEquals(2, bar.getList().size());
+        assertEquals("a list element", bar.getList().get(0));
+        assertEquals(Integer.valueOf(5), bar.getList().get(1));
+        obj = blueprintContainer.getComponentInstance("foo");
+        assertNotNull(obj);
+        assertEquals(Foo.class, obj.getClass());
+        Foo foo = (Foo) obj;
+        assertEquals(5, foo.getA());
+        assertEquals(10, foo.getB());
+        assertSame(bar, foo.getBar());
+        assertEquals(Currency.getInstance("PLN"), foo.getCurrency());
+        assertEquals(new SimpleDateFormat("yyyy.MM.dd").parse("2009.04.17"),
+                foo.getDate());
+
+        assertTrue(foo.isInitialized());
+        assertFalse(foo.isDestroyed());
+
+        obj = getOsgiService(bc == null ? bundleContext : bc, Foo.class, null, 5000);
+        assertNotNull(obj);
+        assertSame(foo, obj);
+        
+        obj = blueprintContainer.getComponentInstance("accountOne");
+        assertNotNull(obj);
+        Account account = (Account)obj;
+        assertEquals(1, account.getAccountNumber());
+     
+        obj = blueprintContainer.getComponentInstance("accountTwo");
+        assertNotNull(obj);
+        account = (Account)obj;
+        assertEquals(2, account.getAccountNumber());
+        
+        obj = blueprintContainer.getComponentInstance("accountThree");
+        assertNotNull(obj);
+        account = (Account)obj;
+        assertEquals(3, account.getAccountNumber());
+        
+        obj = blueprintContainer.getComponentInstance("accountFactory");
+        assertNotNull(obj);
+        AccountFactory accountFactory = (AccountFactory)obj;
+        assertEquals("account factory", accountFactory.getFactoryName());
+        
+        bundle.stop();
+
+        Thread.sleep(1000);
+
+        try {
+            blueprintContainer = getBlueprintContainerForBundle(bc == null ? bundleContext : bc, 
+                    "org.apache.aries.blueprint.sample", 1);
+            fail("BlueprintContainer should have been unregistered");
+        } catch (Exception e) {
+            // Expected, as the module container should have been unregistered
+        }
+
+        assertTrue(foo.isInitialized());
+        assertTrue(foo.isDestroyed());
+    }
+
+}



Mime
View raw message