You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2014/01/15 14:35:36 UTC
svn commit: r1558378 - in
/felix/trunk/ipojo/runtime/core-it/ipojo-core-annotations-test/src:
main/java/org/apache/felix/ipojo/runtime/core/test/components/
test/java/org/apache/felix/ipojo/runtime/core/test/annotations/
Author: clement
Date: Wed Jan 15 13:35:36 2014
New Revision: 1558378
URL: http://svn.apache.org/r1558378
Log:
Check FELIX-4380
(https://issues.apache.org/jira/browse/FELIX-4380)
Added:
felix/trunk/ipojo/runtime/core-it/ipojo-core-annotations-test/src/main/java/org/apache/felix/ipojo/runtime/core/test/components/DependencyUsingSpecification.java
Modified:
felix/trunk/ipojo/runtime/core-it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestDependency.java
Added: felix/trunk/ipojo/runtime/core-it/ipojo-core-annotations-test/src/main/java/org/apache/felix/ipojo/runtime/core/test/components/DependencyUsingSpecification.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-annotations-test/src/main/java/org/apache/felix/ipojo/runtime/core/test/components/DependencyUsingSpecification.java?rev=1558378&view=auto
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-annotations-test/src/main/java/org/apache/felix/ipojo/runtime/core/test/components/DependencyUsingSpecification.java (added)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-annotations-test/src/main/java/org/apache/felix/ipojo/runtime/core/test/components/DependencyUsingSpecification.java Wed Jan 15 13:35:36 2014
@@ -0,0 +1,55 @@
+/*
+ * 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.felix.ipojo.runtime.core.test.components;
+
+import org.apache.felix.ipojo.annotations.*;
+import org.apache.felix.ipojo.runtime.core.test.services.BarService;
+import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
+import org.apache.felix.ipojo.runtime.core.test.services.FooService;
+
+import java.util.*;
+import java.util.Properties;
+
+@Component
+@Provides
+public class DependencyUsingSpecification implements CheckService {
+
+ private boolean bound = false;
+
+ @Unbind
+ public synchronized void unbindBar() {
+ bound = false;
+ }
+
+ @Bind(specification = BarService.class, optional = true)
+ public synchronized void bindBar() {
+ bound = true;
+ }
+
+ @Override
+ public boolean check() {
+ return bound;
+ }
+
+ @Override
+ public Properties getProps() {
+ return null;
+ }
+}
Modified: felix/trunk/ipojo/runtime/core-it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestDependency.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/runtime/core-it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestDependency.java?rev=1558378&r1=1558377&r2=1558378&view=diff
==============================================================================
--- felix/trunk/ipojo/runtime/core-it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestDependency.java (original)
+++ felix/trunk/ipojo/runtime/core-it/ipojo-core-annotations-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/annotations/TestDependency.java Wed Jan 15 13:35:36 2014
@@ -19,10 +19,16 @@
package org.apache.felix.ipojo.runtime.core.test.annotations;
+import org.apache.felix.ipojo.ComponentInstance;
import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
import org.junit.Test;
+import org.osgi.framework.ServiceReference;
+import org.ow2.chameleon.testing.helpers.IPOJOHelper;
import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertNotNull;
import static org.junit.Assert.*;
public class TestDependency extends Common {
@@ -30,7 +36,8 @@ public class TestDependency extends Comm
@Test
public void testDependencyDeclaration() {
- Element meta = ipojoHelper.getMetadata(getTestBundle(), "org.apache.felix.ipojo.runtime.core.test.components.Dependency");
+ Element meta = IPOJOHelper.getMetadata(getTestBundle(),
+ "org.apache.felix.ipojo.runtime.core.test.components.Dependency");
Element[] deps = meta.getElements("requires");
// Check fs
@@ -106,6 +113,32 @@ public class TestDependency extends Comm
assertEquals("Check not proxied", "false", dep.getAttribute("proxy"));
}
+ /**
+ * Reproduce https://issues.apache.org/jira/browse/FELIX-4380.
+ */
+ @Test
+ public void testDependencyUsingSpecification() {
+ ComponentInstance instance = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core.test" +
+ ".components.DependencyUsingSpecification");
+
+ ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(),
+ instance.getInstanceName());
+
+ assertNotNull(ref);
+
+ CheckService svc = (CheckService) osgiHelper.getServiceObject(ref);
+ assertFalse(svc.check());
+
+ // The following instantiation exposes the BarService required by instance.
+ ComponentInstance bar = ipojoHelper.createComponentInstance("org.apache.felix.ipojo.runtime.core.test" +
+ ".components.ProvidesSimple");
+
+ assertTrue(svc.check());
+
+ bar.dispose();
+ assertFalse(svc.check());
+ }
+
private Element getDependencyById(Element[] deps, String name) {
for (int i = 0; i < deps.length; i++) {
String na = deps[i].getAttribute("id");