You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by gn...@apache.org on 2018/01/31 10:42:05 UTC

svn commit: r1822786 - in /aries/trunk/blueprint/blueprint-core/src/test: java/org/apache/aries/blueprint/ java/org/apache/aries/blueprint/container/ java/org/apache/aries/blueprint/pojos/ resources/

Author: gnodet
Date: Wed Jan 31 10:42:05 2018
New Revision: 1822786

URL: http://svn.apache.org/viewvc?rev=1822786&view=rev
Log:
[ARIES-1098] BeanRecipe.findMatchingMethods does not support "varargs"

Added:
    aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/VarArg.java
    aries/trunk/blueprint/blueprint-core/src/test/resources/test-vararg.xml
Modified:
    aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/WiringTest.java
    aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BeanRecipeTest.java

Modified: aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/WiringTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/WiringTest.java?rev=1822786&r1=1822785&r2=1822786&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/WiringTest.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/WiringTest.java Wed Jan 31 10:42:05 2018
@@ -49,6 +49,8 @@ import org.apache.aries.blueprint.proxy.
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.blueprint.container.ComponentDefinitionException;
 
+import static org.junit.Assert.assertArrayEquals;
+
 public class WiringTest extends AbstractBlueprintTest {
 
     public void testWiring() throws Exception {
@@ -517,6 +519,13 @@ public class WiringTest extends Abstract
         repository.create("queueCountCache");
     }
 
+    public void testVarArgPojo() throws Exception {
+        ComponentDefinitionRegistryImpl registry = parse("/test-vararg.xml");
+        Repository repository = new TestBlueprintContainer(registry).getRepository();
+        VarArg va = (VarArg) repository.create("vararg");
+        assertArrayEquals(new String[] { "-web" }, va.args);
+    }
+
     public void testCircular() throws Exception {
         BlueprintRepository repository = createBlueprintContainer().getRepository();
 

Modified: aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BeanRecipeTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BeanRecipeTest.java?rev=1822786&r1=1822785&r2=1822786&view=diff
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BeanRecipeTest.java (original)
+++ aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/BeanRecipeTest.java Wed Jan 31 10:42:05 2018
@@ -139,6 +139,10 @@ public class BeanRecipeTest {
         }
     }
 
+    static public class VarArg {
+	    public VarArg(String... as) {
+        }
+    }
 
     @Test
     public void parameterWithGenerics() throws Exception {
@@ -178,6 +182,16 @@ public class BeanRecipeTest {
         recipe.setArgTypes(Arrays.<String>asList((String) null));
         ExecutionContext.Holder.setContext(new BlueprintRepository(container));
         recipe.create();
+    }
+
+    @Test
+    public void constructorWithVarArg() throws Exception {
+        BlueprintContainerImpl container = new BlueprintContainerImpl(null, null, null, null, null, null, null, null, null, null);
+        BeanRecipe recipe = new BeanRecipe("example", container, VarArg.class, false, false);
+        recipe.setArguments(Arrays.<Object>asList(Arrays.asList("-web")));
+        recipe.setArgTypes(Arrays.<String>asList((String) null));
+        ExecutionContext.Holder.setContext(new BlueprintRepository(container));
+        recipe.create();
     }
 
     @Test

Added: aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/VarArg.java
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/VarArg.java?rev=1822786&view=auto
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/VarArg.java (added)
+++ aries/trunk/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/pojos/VarArg.java Wed Jan 31 10:42:05 2018
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.aries.blueprint.pojos;
+
+public class VarArg {
+
+    public final String[] args;
+
+    public VarArg(String... args) {
+        this.args = args;
+    }
+
+}

Added: aries/trunk/blueprint/blueprint-core/src/test/resources/test-vararg.xml
URL: http://svn.apache.org/viewvc/aries/trunk/blueprint/blueprint-core/src/test/resources/test-vararg.xml?rev=1822786&view=auto
==============================================================================
--- aries/trunk/blueprint/blueprint-core/src/test/resources/test-vararg.xml (added)
+++ aries/trunk/blueprint/blueprint-core/src/test/resources/test-vararg.xml Wed Jan 31 10:42:05 2018
@@ -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="vararg" class="org.apache.aries.blueprint.pojos.VarArg">
+        <argument>
+            <list>
+                <value>-web</value>
+            </list>
+        </argument>
+    </bean>
+
+</blueprint>
\ No newline at end of file