fix test failure on equinox
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1479502 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/pom.xml b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/pom.xml
index 9929bfb..3f66d08 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/pom.xml
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/pom.xml
@@ -8,7 +8,7 @@
~ "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
+ ~ 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
@@ -31,7 +31,6 @@
<modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.felix</groupId>
<artifactId>ipojo-core-handler-test</artifactId>
<name>${project.artifactId}</name>
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/DummyImpl.java b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/DummyImpl.java
index f6a5329..08f9056 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/DummyImpl.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/DummyImpl.java
@@ -7,7 +7,7 @@
* "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
+ * 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
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/MyComponent.java b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/MyComponent.java
index 5c75293..b45d54e 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/MyComponent.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/components/MyComponent.java
@@ -7,7 +7,7 @@
* "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
+ * 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
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/handlers/DummyHandler.java b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/handlers/DummyHandler.java
index 46a306e..2414312 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/handlers/DummyHandler.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/handlers/DummyHandler.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -23,7 +23,9 @@
import org.apache.felix.ipojo.PrimitiveHandler;
import org.apache.felix.ipojo.architecture.ComponentTypeDescription;
import org.apache.felix.ipojo.metadata.Element;
-import org.osgi.service.useradmin.User;
+import org.apache.felix.ipojo.runtime.core.services.User;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
import java.util.Dictionary;
@@ -48,16 +50,20 @@
}
- private void bindUser(User user) {
+ public void bindUser(User user) {
// in order to test
user.getName();
}
- private void unBindUser(User user) {
+ public void unBindUser(User user) {
// in order to test
user.getType();
}
+ public void validate() {
+ // do nothing
+ }
+
@Override
public void start() {
}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/handlers/EmptyHandler.java b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/handlers/EmptyHandler.java
index be89fa5..22eef12 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/handlers/EmptyHandler.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/handlers/EmptyHandler.java
@@ -7,7 +7,7 @@
* "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
+ * 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
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Dummy.java b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Dummy.java
index 7307dd1..08fcf47 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Dummy.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/Dummy.java
@@ -7,7 +7,7 @@
* "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
+ * 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
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/MyService.java b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/MyService.java
index 94588a2..fc5e2ce 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/MyService.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/MyService.java
@@ -7,7 +7,7 @@
* "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
+ * 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
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/User.java b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/User.java
new file mode 100644
index 0000000..2d7ebbc
--- /dev/null
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/java/org/apache/felix/ipojo/runtime/core/services/User.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.felix.ipojo.runtime.core.services;
+
+/**
+ * Simple users.
+ */
+public interface User {
+
+ public String getName();
+
+ public int getType();
+}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/resources/dummy-component.xml b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/resources/dummy-component.xml
index 0383113..8e0b326 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/resources/dummy-component.xml
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/resources/dummy-component.xml
@@ -8,7 +8,7 @@
~ "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
+ ~ 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
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/resources/dummy-handler.xml b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/resources/dummy-handler.xml
index e533acc..3152b42 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/resources/dummy-handler.xml
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/resources/dummy-handler.xml
@@ -1,5 +1,5 @@
<?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
@@ -8,7 +8,7 @@
~ "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
+ ~ 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
@@ -18,19 +18,19 @@
~ under the License.
-->
- <!--
- <iPOJO xmlns:wbp="org.apache.felix.ipojo.whiteboard"
- xmlns:jmx="org.apache.felix.ipojo.handlers.jmx">
- -->
+<!--
+ <iPOJO xmlns:wbp="org.apache.felix.ipojo.whiteboard"
+ xmlns:jmx="org.apache.felix.ipojo.handlers.jmx">
+-->
<iPOJO>
- <!-- Declare the handler -->
- <handler classname="org.apache.felix.ipojo.runtime.core.handlers.DummyHandler" name="dummy"
- namespace="org.apache.felix.ipojo.test.dummy.handler.dummyhandler">
+ <!-- Declare the handler -->
+ <handler classname="org.apache.felix.ipojo.runtime.core.handlers.DummyHandler" name="dummy"
+ namespace="org.apache.felix.ipojo.test.dummy.handler.dummyhandler" architecture="true">
-
- <requires optional="true" aggregate="true">
- <callback type="bind" method="bindUser" />
- <callback type="unbind" method="unBindUser" />
- </requires>
- </handler>
+ <requires optional="true" aggregate="true">
+ <callback type="bind" method="bindUser"/>
+ <callback type="unbind" method="unBindUser"/>
+ </requires>
+ <callback transition="validate" method="validate"/>
+ </handler>
</iPOJO>
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/resources/ignorecase.xml b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/resources/ignorecase.xml
index 79e5902..5774c76 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/resources/ignorecase.xml
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/main/resources/ignorecase.xml
@@ -7,7 +7,7 @@
~ "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
+ ~ 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
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
index 7392d25..20da196 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/java/org/apache/felix/ipojo/runtime/core/Common.java
@@ -7,7 +7,7 @@
* "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
+ * 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
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/java/org/apache/felix/ipojo/runtime/core/DummyHandlerTest.java b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/java/org/apache/felix/ipojo/runtime/core/DummyHandlerTest.java
index 5fc21f9..35920eb 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/java/org/apache/felix/ipojo/runtime/core/DummyHandlerTest.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/java/org/apache/felix/ipojo/runtime/core/DummyHandlerTest.java
@@ -7,7 +7,7 @@
* "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
+ * 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
@@ -25,8 +25,8 @@
import org.apache.felix.ipojo.runtime.core.components.DummyImpl;
import org.apache.felix.ipojo.runtime.core.handlers.DummyHandler;
import org.apache.felix.ipojo.runtime.core.services.Dummy;
+import org.apache.felix.ipojo.runtime.core.services.User;
import org.junit.Test;
-import org.mockito.Mockito;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.OptionUtils;
@@ -35,7 +35,7 @@
import org.ops4j.pax.tinybundles.core.TinyBundles;
import org.osgi.framework.Constants;
import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.useradmin.User;
+import org.ow2.chameleon.testing.helpers.TimeUtils;
import org.ow2.chameleon.testing.tinybundles.ipojo.IPOJOStrategy;
import java.io.File;
@@ -43,9 +43,7 @@
import java.util.HashMap;
import java.util.Map;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
+import static org.junit.Assert.*;
import static org.ops4j.pax.exam.CoreOptions.bundle;
import static org.ops4j.pax.exam.CoreOptions.streamBundle;
import static org.ops4j.pax.tinybundles.core.TinyBundles.withBnd;
@@ -86,6 +84,7 @@
return OptionUtils.combine(options,
streamBundle(TinyBundles.bundle()
.add(Dummy.class)
+ .add(User.class)
.set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.runtime.core.services")
.set(Constants.BUNDLE_SYMBOLICNAME, "service")
.build(withBnd())
@@ -138,31 +137,30 @@
Factory factory = Tools.getValidFactory(osgiHelper, DUMMY_TEST_FACTORY);
assertNotNull(factory);
- // Create an instance
+ // Create an instance, it will be disposed by the helper
ComponentInstance instance = ipojoHelper.createComponentInstance(DUMMY_TEST_FACTORY);
+ assertTrue(instance.getState() == ComponentInstance.VALID);
- Map<User, ServiceRegistration> registrations = new HashMap<User, ServiceRegistration>();
+ Map<MyUser, ServiceRegistration> registrations = new HashMap<MyUser, ServiceRegistration>();
for (int i = 0; i < NB_MOCK; i++) {
- User service = mock(User.class);
+ MyUser service = new MyUser();
ServiceRegistration sr = bc.registerService(User.class.getName(), service, null);
registrations.put(service, sr);
}
+ TimeUtils.grace(200);
+ assertEquals(osgiHelper.getServiceReferences(User.class, null).length, NB_MOCK);
+
//verify that the bind method of the handler has been called
- for (User user : registrations.keySet()) {
- verify(user).getName();
+ for (MyUser user : registrations.keySet()) {
+ assertTrue(user.name);
}
//verify that the unbind has been called
- for (User user : registrations.keySet()) {
+ for (MyUser user : registrations.keySet()) {
registrations.get(user).unregister();
- verify(user).getType();
- }
-
- //verify no more interaction
- for (User user : registrations.keySet()) {
- Mockito.verifyNoMoreInteractions(user);
+ assertTrue(user.type);
}
}
@@ -173,10 +171,10 @@
public void testDummyTestBindBeforeStart() {
ComponentInstance instance = null;
- Map<User, ServiceRegistration> registrations = new HashMap<User, ServiceRegistration>();
+ Map<MyUser, ServiceRegistration> registrations = new HashMap<MyUser, ServiceRegistration>();
for (int i = 0; i < NB_MOCK; i++) {
- User service = mock(User.class);
+ MyUser service = new MyUser();
ServiceRegistration sr = bc.registerService(User.class.getName(), service, null);
registrations.put(service, sr);
}
@@ -185,22 +183,36 @@
Factory factory = Tools.getValidFactory(osgiHelper, DUMMY_TEST_FACTORY);
assertNotNull(factory);
- instance = ipojoHelper.createComponentInstance(DUMMY_TEST_FACTORY);
+ // The instance will be disposed by the helper
+ ipojoHelper.createComponentInstance(DUMMY_TEST_FACTORY);
//verify that the bind method of the handler has been called
- for (User user : registrations.keySet()) {
- verify(user).getName();
+ for (MyUser user : registrations.keySet()) {
+ assertTrue(user.name);
}
//verify that the unbind has been called
- for (User user : registrations.keySet()) {
+ for (MyUser user : registrations.keySet()) {
registrations.get(user).unregister();
- verify(user).getType();
+ assertTrue(user.type);
+ }
+ }
+
+ private class MyUser implements User {
+
+ boolean name;
+ boolean type;
+
+ @Override
+ public String getName() {
+ name = true;
+ return "name";
}
- //verify no more interaction
- for (User user : registrations.keySet()) {
- Mockito.verifyNoMoreInteractions(user);
+ @Override
+ public int getType() {
+ type = true;
+ return 1;
}
}
}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/java/org/apache/felix/ipojo/runtime/core/IgnoreCaseHandlerSelectionTest.java b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/java/org/apache/felix/ipojo/runtime/core/IgnoreCaseHandlerSelectionTest.java
index df8ca0b..cd1ca16 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/java/org/apache/felix/ipojo/runtime/core/IgnoreCaseHandlerSelectionTest.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/java/org/apache/felix/ipojo/runtime/core/IgnoreCaseHandlerSelectionTest.java
@@ -7,7 +7,7 @@
* "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
+ * 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
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/java/org/apache/felix/ipojo/runtime/core/Tools.java b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/java/org/apache/felix/ipojo/runtime/core/Tools.java
index c0f1882..a5e9f94 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/java/org/apache/felix/ipojo/runtime/core/Tools.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/java/org/apache/felix/ipojo/runtime/core/Tools.java
@@ -7,7 +7,7 @@
* "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
+ * 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
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/resources/exam.properties b/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/resources/exam.properties
deleted file mode 100644
index d8a500d..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-handler-test/src/test/resources/exam.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# 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.
-#
-