You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2017/01/13 17:49:16 UTC
svn commit: r1778640 [1/2] -
/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/
Author: cziegeler
Date: Fri Jan 13 17:49:16 2017
New Revision: 1778640
URL: http://svn.apache.org/viewvc?rev=1778640&view=rev
Log:
Clean up test code (replace deprecated usage, remove unused)
Modified:
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ActivateSignatureTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/AnnoConfigTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/CircularFactoryTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentConcurrencyTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationPidTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentDisposeTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentEnableTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationChangeTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationComponentFactoryTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ExtenderTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix3680Test.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix3680_2Test.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix4984Test.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5248Test.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5276Test.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5356Test.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/LocateTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/LocationTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/MinimumCardinalityTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/MutablePropertiesTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/PersistentComponentFactoryTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindGreedyTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceBindTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceChangedTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ServiceComponentTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/TargetPropertyTest.java
felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/TargetedPIDTest.java
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ActivateSignatureTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ActivateSignatureTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ActivateSignatureTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ActivateSignatureTest.java Fri Jan 13 17:49:16 2017
@@ -21,21 +21,21 @@ package org.apache.felix.scr.integration
import java.util.Collection;
-import junit.framework.TestCase;
-
import org.apache.felix.scr.integration.components.activatesignature.AbstractActivateSignatureTestComponent;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
import org.osgi.service.component.runtime.dto.ComponentDescriptionDTO;
+import junit.framework.TestCase;
+
/**
* The <code>ActivateSignatureTest</code> tests various DS 1.1 activation
* signatures for the default method name
*/
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class ActivateSignatureTest extends ComponentTestBase
{
@@ -62,12 +62,12 @@ public class ActivateSignatureTest exten
for ( ComponentDescriptionDTO component : components )
{
TestCase.assertTrue( "Expecting component " + component.name + " to be enabled", component
- .defaultEnabled );
+ .defaultEnabled );
ComponentConfigurationDTO cc = findComponentConfigurationByName(component.name, 0);
TestCase.assertEquals( "Expecting component " + component.name + " to be active",
- ComponentConfigurationDTO.ACTIVE, cc.state );
-
+ ComponentConfigurationDTO.ACTIVE, cc.state );
+
TestCase.assertNotNull("Expect activate method to be called", AbstractActivateSignatureTestComponent.getInstance(component.name));
}
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/AnnoConfigTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/AnnoConfigTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/AnnoConfigTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/AnnoConfigTest.java Fri Jan 13 17:49:16 2017
@@ -24,8 +24,6 @@ import java.util.Hashtable;
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
-
import org.apache.felix.scr.integration.components.annoconfig.AnnoComponent;
import org.apache.felix.scr.integration.components.annoconfig.AnnoComponent.A1;
import org.apache.felix.scr.integration.components.annoconfig.AnnoComponent.A1Arrays;
@@ -36,23 +34,25 @@ import org.apache.felix.scr.integration.
import org.apache.felix.scr.integration.components.annoconfig.NestedAnnoComponent.E2;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.service.cm.Configuration;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
-@RunWith(JUnit4TestRunner.class)
+import junit.framework.TestCase;
+
+@RunWith(PaxExam.class)
public class AnnoConfigTest extends ComponentTestBase
{
static
{
// uncomment to enable debugging of this test class
-// paxRunnerVmOption = DEBUG_VM_OPTION;
+ // paxRunnerVmOption = DEBUG_VM_OPTION;
descriptorFile = "/integration_test_annoconfig.xml";
COMPONENT_PACKAGE = COMPONENT_PACKAGE + ".annoconfig";
- }
-
+ }
+
@Test
public void testAnnoConfig() throws Exception
{
@@ -61,10 +61,10 @@ public class AnnoConfigTest extends Comp
AnnoComponent ac = getServiceFromConfiguration(dto, AnnoComponent.class);
checkA1NoValues(ac.m_a1_activate);
checkA1ArraysNoValues(ac.m_a1Arrays_activate);
-
+
Configuration c = configure(name, null, allValues());
delay();
-
+
checkA1(ac.m_a1_modified);
checkA1Array(ac.m_a1Arrays_modified);
@@ -74,33 +74,33 @@ public class AnnoConfigTest extends Comp
ac = getServiceFromConfiguration(dto, AnnoComponent.class);
checkA1(ac.m_a1_activate);
checkA1Array(ac.m_a1Arrays_activate);
-
+
c.delete();
delay();
-
+
checkA1NoValues(ac.m_a1_modified);
checkA1ArraysNoValues(ac.m_a1Arrays_modified);
-
+
c = configure(name, null, arrayValues());
delay();
-
+
checkA1FromArray(ac.m_a1_modified);
checkA1ArrayFromArray(ac.m_a1Arrays_modified, false);
-
+
c.delete();
delay();
-
+
checkA1NoValues(ac.m_a1_modified);
checkA1ArraysNoValues(ac.m_a1Arrays_modified);
-
+
c = configure(name, null, collectionValues());
delay();
-
+
checkA1FromArray(ac.m_a1_modified);
checkA1ArrayFromArray(ac.m_a1Arrays_modified, true);
}
-
+
private Hashtable<String, Object> allValues()
{
Hashtable<String, Object> values = new Hashtable<String, Object>();
@@ -132,7 +132,7 @@ public class AnnoConfigTest extends Comp
values.put("string", new String[] {});
return values;
}
-
+
private Hashtable<String, Object> collectionValues()
{
Hashtable<String, Object> values = arrayValues();
@@ -145,7 +145,8 @@ public class AnnoConfigTest extends Comp
collectionValues.remove("string");
return collectionValues;
}
-
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
private List<?> toList(Object value)
{
List result = new ArrayList();
@@ -172,7 +173,7 @@ public class AnnoConfigTest extends Comp
private void checkA1FromArray(A1 a)
- {
+ {
TestCase.assertEquals(true, a.bool());
TestCase.assertEquals((byte)12, a.byt());
TestCase.assertEquals(String.class, a.clas());
@@ -184,7 +185,7 @@ public class AnnoConfigTest extends Comp
TestCase.assertEquals((short)3, a.shor());
TestCase.assertEquals(null, a.string());
}
-
+
private void checkA1Array(A1Arrays a)
{
assertArrayEquals(new boolean[] {true}, a.bool());
@@ -198,7 +199,7 @@ public class AnnoConfigTest extends Comp
assertArrayEquals(new short[] {(short)3}, a.shor());
assertArrayEquals(new String[] {"3"}, a.string());
}
-
+
private void checkA1ArrayFromArray(A1Arrays a, boolean caBug)
{
assertArrayEquals(new boolean[] {true, false}, a.bool());
@@ -215,7 +216,7 @@ public class AnnoConfigTest extends Comp
assertArrayEquals(new String[] {}, a.string());
}
}
-
+
private void assertArrayEquals(Object a, Object b)
{
TestCase.assertTrue(a.getClass().isArray());
@@ -226,9 +227,9 @@ public class AnnoConfigTest extends Comp
{
TestCase.assertEquals("different value at " + i, Array.get(a, i), Array.get(b, i));
}
-
+
}
-
+
private void checkA1NoValues(A1 a)
{
TestCase.assertEquals(false, a.bool());
@@ -256,7 +257,7 @@ public class AnnoConfigTest extends Comp
TestCase.assertEquals(null, a.shor());
TestCase.assertEquals(null, a.string());
}
-
+
@Test
public void testNestedAnnoConfig() throws Exception
{
@@ -264,17 +265,17 @@ public class AnnoConfigTest extends Comp
ComponentConfigurationDTO dto = findComponentConfigurationByName(name, ComponentConfigurationDTO.SATISFIED);
NestedAnnoComponent ac = getServiceFromConfiguration(dto, NestedAnnoComponent.class);
checkA2NoValues(ac.m_a2_activate);
-
- Configuration c = configure(name, null, allNestedValues());
+
+ configure(name, null, allNestedValues());
delay();
-
+
checkA2(ac.m_a2_modified);
ungetServiceFromConfiguration(dto, NestedAnnoComponent.class);
checkA2(ac.m_a2_deactivate);
ac = getServiceFromConfiguration(dto, NestedAnnoComponent.class);
checkA2(ac.m_a2_activate);
-
+
}
private Hashtable<String, Object> allNestedValues()
@@ -306,9 +307,9 @@ public class AnnoConfigTest extends Comp
checkB2(a.b2s()[2], E2.c);
}
- private void checkB2(B2 b, E2 e2) {
- TestCase.assertEquals(true, b.bool());
- TestCase.assertEquals(e2, b.e2());
- }
+ private void checkB2(B2 b, E2 e2) {
+ TestCase.assertEquals(true, b.bool());
+ TestCase.assertEquals(e2, b.e2());
+ }
}
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/CircularFactoryTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/CircularFactoryTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/CircularFactoryTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/CircularFactoryTest.java Fri Jan 13 17:49:16 2017
@@ -18,34 +18,32 @@
*/
package org.apache.felix.scr.integration;
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
import org.apache.felix.scr.integration.components.circularFactory.FactoryClient;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.ServiceReference;
-@RunWith(JUnit4TestRunner.class)
+import junit.framework.TestCase;
+
+@RunWith(PaxExam.class)
public class CircularFactoryTest extends ComponentTestBase
{
static
{
// uncomment to enable debugging of this test class
-// paxRunnerVmOption = DEBUG_VM_OPTION;
+ // paxRunnerVmOption = DEBUG_VM_OPTION;
descriptorFile = "/integration_test_circularFactory.xml";
COMPONENT_PACKAGE = COMPONENT_PACKAGE + ".circularFactory";
- }
-
+ }
+
@Test
public void testCircularFactory() throws Exception
{
ServiceReference<FactoryClient> sr = bundle.getBundleContext().getServiceReference( FactoryClient.class );
- FactoryClient fc = bundle.getBundleContext().getService( sr );
+ bundle.getBundleContext().getService( sr );
for ( String message: log.foundWarnings() )
{
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java Fri Jan 13 17:49:16 2017
@@ -20,34 +20,37 @@
package org.apache.felix.scr.integration;
-import junit.framework.TestCase;
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+
+import java.util.Collection;
+
import org.apache.felix.scr.integration.components.circular.A;
import org.apache.felix.scr.integration.components.circular.B;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertNotNull;
+import junit.framework.TestCase;
/**
* @version $Rev$ $Date$
*/
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class CircularReferenceTest extends ComponentTestBase
{
static
{
// uncomment to enable debugging of this test class
-// paxRunnerVmOption = DEBUG_VM_OPTION;
+ // paxRunnerVmOption = DEBUG_VM_OPTION;
descriptorFile = "/integration_test_circular.xml";
COMPONENT_PACKAGE = COMPONENT_PACKAGE + ".circular";
- }
+ }
/**
@@ -57,15 +60,15 @@ public class CircularReferenceTest exten
public void test_A11_B11()
{
String componentNameA = "1.A.1.1.dynamic";
- final ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.UNSATISFIED_REFERENCE );
+ findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.UNSATISFIED_REFERENCE );
String componentNameB = "1.B.1.1.dynamic";
- final ComponentConfigurationDTO componentB = findComponentConfigurationByName( componentNameB, ComponentConfigurationDTO.UNSATISFIED_REFERENCE );
+ findComponentConfigurationByName( componentNameB, ComponentConfigurationDTO.UNSATISFIED_REFERENCE );
}
/**
* A > 1.1 > B > 0..n > A Both should start (A first), but B should not have an A reference.
- * @throws InvalidSyntaxException
+ * @throws InvalidSyntaxException
*/
@Test
public void test_A11_B0n_immediate_A_first() throws InvalidSyntaxException
@@ -83,7 +86,7 @@ public class CircularReferenceTest exten
}
/**
* A > 1.1 > B > 0..n > A Both should start (B first), and B should have an A reference.
- * @throws InvalidSyntaxException
+ * @throws InvalidSyntaxException
*/
@Test
public void test_A11_B0n_immediate_B_first() throws InvalidSyntaxException
@@ -131,15 +134,15 @@ public class CircularReferenceTest exten
String componentNameB = "4.B.0.n.dynamic";
final ComponentConfigurationDTO componentB = findComponentConfigurationByName( componentNameB, ComponentConfigurationDTO.SATISFIED);
- ServiceReference[] serviceReferencesB = bundleContext.getServiceReferences( B.class.getName(), "(service.pid=" + componentNameB + ")" );
- TestCase.assertEquals( 1, serviceReferencesB.length );
- ServiceReference serviceReferenceB = serviceReferencesB[0];
+ Collection<ServiceReference<B>> serviceReferencesB = bundleContext.getServiceReferences( B.class, "(service.pid=" + componentNameB + ")" );
+ TestCase.assertEquals( 1, serviceReferencesB.size() );
+ ServiceReference<B> serviceReferenceB = serviceReferencesB.iterator().next();
Object serviceB = bundleContext.getService( serviceReferenceB );
assertNotNull( serviceB );
- ServiceReference[] serviceReferencesA = bundleContext.getServiceReferences( A.class.getName(), "(service.pid=" + componentNameA + ")" );
- TestCase.assertEquals( 1, serviceReferencesA.length );
- ServiceReference serviceReferenceA = serviceReferencesA[0];
+ Collection<ServiceReference<A>> serviceReferencesA = bundleContext.getServiceReferences( A.class, "(service.pid=" + componentNameA + ")" );
+ TestCase.assertEquals( 1, serviceReferencesA.size() );
+ ServiceReference<A> serviceReferenceA = serviceReferencesA.iterator().next();
Object serviceA = bundleContext.getService( serviceReferenceA );
assertNotNull( serviceA );
@@ -167,7 +170,7 @@ public class CircularReferenceTest exten
}
/**
* A > 1.1 > B > 0..1 > A Both should start (A first), but B should not have an A reference.
- * @throws InvalidSyntaxException
+ * @throws InvalidSyntaxException
*/
@Test
public void test_A11_B01_immediate_A_first() throws InvalidSyntaxException
@@ -184,7 +187,7 @@ public class CircularReferenceTest exten
}
/**
* A > 1.1 > B > 0..1 > A Both should start (B first), and B should have an A reference.
- * @throws InvalidSyntaxException
+ * @throws InvalidSyntaxException
*/
@Test
public void test_A11_B01_immediate_B_first() throws InvalidSyntaxException
@@ -211,9 +214,9 @@ public class CircularReferenceTest exten
String componentNameB = "7.B.0.1.dynamic";
final ComponentConfigurationDTO componentB = findComponentConfigurationByName( componentNameB, ComponentConfigurationDTO.SATISFIED );
- ServiceReference[] serviceReferences = bundleContext.getServiceReferences( A.class.getName(), "(service.pid=" + componentNameA + ")" );
- TestCase.assertEquals( 1, serviceReferences.length );
- ServiceReference serviceReference = serviceReferences[0];
+ Collection<ServiceReference<A>> serviceReferences = bundleContext.getServiceReferences( A.class, "(service.pid=" + componentNameA + ")" );
+ TestCase.assertEquals( 1, serviceReferences.size() );
+ ServiceReference<A> serviceReference = serviceReferences.iterator().next();
Object service = bundleContext.getService( serviceReference );
assertNotNull( service );
@@ -235,15 +238,15 @@ public class CircularReferenceTest exten
String componentNameB = "7.B.0.1.dynamic";
final ComponentConfigurationDTO componentB = findComponentConfigurationByName( componentNameB, ComponentConfigurationDTO.SATISFIED );
- ServiceReference[] serviceReferencesB = bundleContext.getServiceReferences( B.class.getName(), "(service.pid=" + componentNameB + ")" );
- TestCase.assertEquals( 1, serviceReferencesB.length );
- ServiceReference serviceReferenceB = serviceReferencesB[0];
+ Collection<ServiceReference<B>> serviceReferencesB = bundleContext.getServiceReferences( B.class, "(service.pid=" + componentNameB + ")" );
+ TestCase.assertEquals( 1, serviceReferencesB.size() );
+ ServiceReference<B> serviceReferenceB = serviceReferencesB.iterator().next();
Object serviceB = bundleContext.getService( serviceReferenceB );
assertNotNull( serviceB );
- ServiceReference[] serviceReferencesA = bundleContext.getServiceReferences( A.class.getName(), "(service.pid=" + componentNameA + ")" );
- TestCase.assertEquals( 1, serviceReferencesA.length );
- ServiceReference serviceReferenceA = serviceReferencesA[0];
+ Collection<ServiceReference<A>> serviceReferencesA = bundleContext.getServiceReferences( A.class, "(service.pid=" + componentNameA + ")" );
+ TestCase.assertEquals( 1, serviceReferencesA.size() );
+ ServiceReference<A> serviceReferenceA = serviceReferencesA.iterator().next();
Object serviceA = bundleContext.getService( serviceReferenceA );
assertNotNull( serviceA );
@@ -277,18 +280,18 @@ public class CircularReferenceTest exten
@Test
public void test_A11_immediate_B0n_delayed_B_first() throws InvalidSyntaxException
{
- String componentNameB = "8.B.0.n.dynamic";
- final ComponentConfigurationDTO componentB = findComponentConfigurationByName( componentNameB, ComponentConfigurationDTO.SATISFIED | ComponentConfigurationDTO.ACTIVE );
- ServiceReference[] serviceReferencesB = bundleContext.getServiceReferences( B.class.getName(), "(service.pid=" + componentNameB + ")" );
- TestCase.assertEquals( 1, serviceReferencesB.length );
- ServiceReference<B> serviceReferenceB = serviceReferencesB[0];
+ String componentNameB = "8.B.0.n.dynamic";
+ findComponentConfigurationByName( componentNameB, ComponentConfigurationDTO.SATISFIED | ComponentConfigurationDTO.ACTIVE );
+ Collection<ServiceReference<B>> serviceReferencesB = bundleContext.getServiceReferences( B.class, "(service.pid=" + componentNameB + ")" );
+ TestCase.assertEquals( 1, serviceReferencesB.size() );
+ ServiceReference<B> serviceReferenceB = serviceReferencesB.iterator().next();
B b = bundleContext.getService( serviceReferenceB );
String componentNameA = "8.A.1.1.static";
- ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.SATISFIED | ComponentConfigurationDTO.ACTIVE );
- ServiceReference[] serviceReferencesA = bundleContext.getServiceReferences( A.class.getName(), "(service.pid=" + componentNameA + ")" );
- TestCase.assertEquals( 1, serviceReferencesA.length );
- ServiceReference<A> serviceReferenceA = serviceReferencesA[0];
+ findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.SATISFIED | ComponentConfigurationDTO.ACTIVE );
+ Collection<ServiceReference<A>> serviceReferencesA = bundleContext.getServiceReferences( A.class, "(service.pid=" + componentNameA + ")" );
+ TestCase.assertEquals( 1, serviceReferencesA.size() );
+ ServiceReference<A> serviceReferenceA = serviceReferencesA.iterator().next();
A a = bundleContext.getService( serviceReferenceA );
assertNotNull( a );
assertEquals( 1, a.getBs().size());
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java Fri Jan 13 17:49:16 2017
@@ -19,18 +19,18 @@
package org.apache.felix.scr.integration;
-import junit.framework.TestCase;
-
import org.apache.felix.scr.integration.components.ActivatorComponent;
import org.apache.felix.scr.integration.components.SimpleServiceImpl;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
+import junit.framework.TestCase;
+
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class ComponentActivationTest extends ComponentTestBase
{
@@ -121,9 +121,9 @@ public class ComponentActivationTest ext
ActivatorComponent ac = ActivatorComponent.getInstance();
TestCase.assertNotNull( ac.getSimpleService() );
-
+
disableAndCheck( cc );
-
+
TestCase.assertNull( ac.getSimpleService() );
}
@@ -141,7 +141,7 @@ public class ComponentActivationTest ext
disableAndCheck( cc );
}
-
+
@Test
public void test_activate_service_factory_register_service() throws Exception
{
@@ -155,7 +155,7 @@ public class ComponentActivationTest ext
disableAndCheck( cc );
}
-
+
@Test
public void test_activate_register_service_single_static_dependency() throws Exception
{
@@ -202,15 +202,15 @@ public class ComponentActivationTest ext
ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
SimpleServiceImpl ss = SimpleServiceImpl.create( bundleContext, "foo" );
-
+
findComponentConfigurationByName(componentname, ComponentConfigurationDTO.SATISFIED);
ServiceReference<ActivatorComponent> ref = bundleContext.getServiceReference( ActivatorComponent.class );
-
+
ss.drop();
findComponentConfigurationByName(componentname, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
-
+
TestCase.assertNull(bundleContext.getServiceReference( ActivatorComponent.class ));
ss = SimpleServiceImpl.create( bundleContext, "foo" );
ref = bundleContext.getServiceReference( ActivatorComponent.class );
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentConcurrencyTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentConcurrencyTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentConcurrencyTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentConcurrencyTest.java Fri Jan 13 17:49:16 2017
@@ -10,34 +10,29 @@
*/
package org.apache.felix.scr.integration;
-import java.util.Iterator;
-
-import javax.inject.Inject;
-
-import junit.framework.TestCase;
-
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.framework.BundleContext;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
-@RunWith(JUnit4TestRunner.class)
+import junit.framework.TestCase;
+
+@RunWith(PaxExam.class)
public class ComponentConcurrencyTest extends ComponentTestBase
{
static
{
// uncomment to enable debugging of this test class
-// paxRunnerVmOption = DEBUG_VM_OPTION;
+ // paxRunnerVmOption = DEBUG_VM_OPTION;
descriptorFile = "/integration_test_component_concurrency.xml";
COMPONENT_PACKAGE = COMPONENT_PACKAGE + ".concurrency";
restrictedLogging = true;
ignoredWarnings = new String[] {"FrameworkEvent: ERROR",
- "FrameworkEvent ERROR",
- "Could not get service from ref",
- "Failed creating the component instance; see log for reason",
- "Cannot create component instance due to failure to bind reference",
- "DependencyManager : invokeBindMethod : Service not available from service registry for ServiceReference"};
+ "FrameworkEvent ERROR",
+ "Could not get service from ref",
+ "Failed creating the component instance; see log for reason",
+ "Cannot create component instance due to failure to bind reference",
+ "DependencyManager : invokeBindMethod : Service not available from service registry for ServiceReference"};
DS_LOGLEVEL = "warn";
}
@@ -57,8 +52,8 @@ public class ComponentConcurrencyTest ex
{
- ComponentConfigurationDTO ccA = getDisabledConfigurationAndEnable( "org.apache.felix.scr.integration.components.concurrency.AFactory", ComponentConfigurationDTO.ACTIVE );
- ComponentConfigurationDTO ccC = getDisabledConfigurationAndEnable( "org.apache.felix.scr.integration.components.concurrency.CFactory", ComponentConfigurationDTO.ACTIVE );
+ getDisabledConfigurationAndEnable( "org.apache.felix.scr.integration.components.concurrency.AFactory", ComponentConfigurationDTO.ACTIVE );
+ getDisabledConfigurationAndEnable( "org.apache.felix.scr.integration.components.concurrency.CFactory", ComponentConfigurationDTO.ACTIVE );
delay( 30 );
if ( ! log.foundWarnings().isEmpty() )
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationPidTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationPidTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationPidTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationPidTest.java Fri Jan 13 17:49:16 2017
@@ -19,17 +19,17 @@
package org.apache.felix.scr.integration;
-import junit.framework.TestCase;
-
import org.apache.felix.scr.integration.components.SimpleComponent;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
import org.osgi.service.component.runtime.dto.ComponentDescriptionDTO;
+import junit.framework.TestCase;
+
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class ComponentConfigurationPidTest extends ComponentTestBase
{
static
@@ -68,7 +68,7 @@ public class ComponentConfigurationPidTe
disableAndCheck( cd );
TestCase.assertNull( SimpleComponent.INSTANCE );
}
-
+
@Test
public void test_configurationpid_must_not_use_name_as_pid() throws Exception
{
@@ -88,7 +88,7 @@ public class ComponentConfigurationPidTe
deleteConfig( pid );
delay();
-
+
disableAndCheck( cd );
}
}
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentConfigurationTest.java Fri Jan 13 17:49:16 2017
@@ -20,28 +20,25 @@ package org.apache.felix.scr.integration
import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
import org.apache.felix.scr.integration.components.SimpleComponent;
import org.apache.felix.scr.integration.components.SimpleServiceImpl;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.Constants;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
+import junit.framework.TestCase;
-@RunWith(JUnit4TestRunner.class)
+
+@RunWith(PaxExam.class)
public class ComponentConfigurationTest extends ComponentTestBase
{
static
{
// uncomment to enable debugging of this test class
-// paxRunnerVmOption = DEBUG_VM_OPTION;
+ // paxRunnerVmOption = DEBUG_VM_OPTION;
}
@@ -55,7 +52,7 @@ public class ComponentConfigurationTest
delay();
ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE);
-
+
TestCase.assertNotNull( SimpleComponent.INSTANCE );
TestCase.assertNull( SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
@@ -106,9 +103,9 @@ public class ComponentConfigurationTest
TestCase.assertNotSame( "Expect new instance object after reconfiguration", firstInstance, secondInstance );
TestCase.assertNotSame( "Expect new instance object after configuration deletion (1)", firstInstance,
- thirdInstance );
+ thirdInstance );
TestCase.assertNotSame( "Expect new instance object after configuration deletion (2)", secondInstance,
- thirdInstance );
+ thirdInstance );
disableAndCheck( cc );
TestCase.assertNull( SimpleComponent.INSTANCE );
@@ -122,7 +119,7 @@ public class ComponentConfigurationTest
deleteConfig( pid );
delay();
-
+
TestCase.assertNull( SimpleComponent.INSTANCE );
getConfigurationsDisabledThenEnable(pid, 0, ComponentConfigurationDTO.UNSATISFIED_REFERENCE);
@@ -156,7 +153,7 @@ public class ComponentConfigurationTest
deleteConfig( pid );
configure( pid );
delay();
-
+
TestCase.assertNull( SimpleComponent.INSTANCE );
ComponentConfigurationDTO cc = getConfigurationsDisabledThenEnable(pid, 1, ComponentConfigurationDTO.ACTIVE).iterator().next();
@@ -192,7 +189,7 @@ public class ComponentConfigurationTest
boolean recreateOnDelete = false;
dynamicConfigTest(pid, pre13, recreateOnDelete);
}
-
+
@Test
public void test_SimpleComponent_dynamic_configuration_flag() throws Exception
{
@@ -203,20 +200,20 @@ public class ComponentConfigurationTest
}
- private void dynamicConfigTest(final String pid, boolean pre13, boolean recreateOnDelete) throws Exception
- {
- Object pidWithout;
- Object pidWith;
- if (pre13)
- {
- pidWithout = pid + ".description";
- pidWith = pid;
- }
- else
- {
- pidWithout = pid + ".description";
- pidWith = Arrays.asList(new String[] {pid + ".description", pid});
- }
+ private void dynamicConfigTest(final String pid, boolean pre13, boolean recreateOnDelete) throws Exception
+ {
+ Object pidWithout;
+ Object pidWith;
+ if (pre13)
+ {
+ pidWithout = pid + ".description";
+ pidWith = pid;
+ }
+ else
+ {
+ pidWithout = pid + ".description";
+ pidWith = Arrays.asList(new String[] {pid + ".description", pid});
+ }
deleteConfig( pid );
delay();
@@ -253,7 +250,7 @@ public class ComponentConfigurationTest
disableAndCheck( cc );
TestCase.assertNull( SimpleComponent.INSTANCE );
- }
+ }
@Test
@@ -375,7 +372,7 @@ public class ComponentConfigurationTest
{
service2.drop();
}
- // same instance after reconfiguration
+ // same instance after reconfiguration
findComponentConfigurationByName(pid, ComponentConfigurationDTO.ACTIVE);
TestCase.assertEquals( instance, SimpleComponent.INSTANCE );
TestCase.assertEquals( PROP_NAME, SimpleComponent.INSTANCE.getProperty( PROP_NAME ) );
@@ -484,7 +481,7 @@ public class ComponentConfigurationTest
}
finally
{
-// Thread.sleep( 60000 );
+ // Thread.sleep( 60000 );
theConfig.remove( targetProp );
if ( service != null )
{
@@ -527,7 +524,7 @@ public class ComponentConfigurationTest
}
/**
- * same as test_SimpleComponent_factory_configuration except configurations are present before
+ * same as test_SimpleComponent_factory_configuration except configurations are present before
* component is enabled to test initialization.
*/
@Test
@@ -570,8 +567,8 @@ public class ComponentConfigurationTest
// no component config exists without configuration
// create two factory configurations expecting two components
- final String pid0 = createFactoryConfiguration( factoryPid, "?" );
- final String pid1 = createFactoryConfiguration( factoryPid, "?" );
+ createFactoryConfiguration( factoryPid, "?" );
+ createFactoryConfiguration( factoryPid, "?" );
delay();
// expect two components, all active
@@ -583,11 +580,11 @@ public class ComponentConfigurationTest
// create a configuration
- final String pid3 = createFactoryConfiguration( factoryPid, "?" );
+ createFactoryConfiguration( factoryPid, "?" );
delay();
getConfigurationsDisabledThenEnable(factoryPid, 3, ComponentConfigurationDTO.ACTIVE);
-
+
}
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentDisposeTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentDisposeTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentDisposeTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentDisposeTest.java Fri Jan 13 17:49:16 2017
@@ -19,22 +19,19 @@
package org.apache.felix.scr.integration;
-import java.lang.reflect.Field;
import java.util.Collection;
-import java.util.Map;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
import org.apache.felix.scr.integration.components.SimpleComponent;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.service.component.ComponentContext;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
+import junit.framework.Assert;
+import junit.framework.TestCase;
-@RunWith(JUnit4TestRunner.class)
+
+@RunWith(PaxExam.class)
public class ComponentDisposeTest extends ComponentTestBase
{
static
@@ -55,17 +52,17 @@ public class ComponentDisposeTest extend
getConfigurationsDisabledThenEnable(factoryPid, 0, ComponentConfigurationDTO.ACTIVE);//there should be none
// create two factory configurations expecting two components
- final String pid0 = createFactoryConfiguration( factoryPid, "?" );
- final String pid1 = createFactoryConfiguration( factoryPid, "?" );
+ createFactoryConfiguration( factoryPid, "?" );
+ createFactoryConfiguration( factoryPid, "?" );
delay();
Collection<ComponentConfigurationDTO> ccs = findComponentConfigurationsByName(factoryPid, ComponentConfigurationDTO.ACTIVE);
- Assert.assertEquals(2, ccs.size());
+ Assert.assertEquals(2, ccs.size());
// expect two components, only first is active, second is disabled
TestCase.assertEquals( 2, SimpleComponent.INSTANCES.size() );
for (ComponentConfigurationDTO cc: ccs)
{
- TestCase.assertTrue(SimpleComponent.INSTANCES.containsKey(cc.id));
+ TestCase.assertTrue(SimpleComponent.INSTANCES.containsKey(cc.id));
}
// dispose an instance
@@ -79,11 +76,8 @@ public class ComponentDisposeTest extend
ComponentConfigurationDTO cc = findComponentConfigurationByName(factoryPid, ComponentConfigurationDTO.ACTIVE);
TestCase.assertEquals( 1, SimpleComponent.INSTANCES.size() );
- TestCase.assertTrue(SimpleComponent.INSTANCES.containsKey(cc.id));
-
- final SimpleComponent instance = SimpleComponent.INSTANCES.values().iterator().next();
+ TestCase.assertTrue(SimpleComponent.INSTANCES.containsKey(cc.id));
+ SimpleComponent.INSTANCES.values().iterator().next();
}
-
-
}
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentEnableTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentEnableTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentEnableTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentEnableTest.java Fri Jan 13 17:49:16 2017
@@ -19,23 +19,17 @@
package org.apache.felix.scr.integration;
-import java.lang.reflect.Field;
-import java.util.Collection;
-import java.util.Map;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
import org.apache.felix.scr.integration.components.EnableComponent;
import org.apache.felix.scr.integration.components.SimpleComponent;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.service.component.ComponentContext;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
+import junit.framework.TestCase;
+
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class ComponentEnableTest extends ComponentTestBase
{
static
@@ -51,11 +45,11 @@ public class ComponentEnableTest extends
{
final String enable = "org.apache.felix.scr.integration.components.enable";
final String name = "org.apache.felix.scr.integration.components.SimpleComponent";
-
+
ComponentConfigurationDTO dto = findComponentConfigurationByName(enable, ComponentConfigurationDTO.SATISFIED);
-
+
EnableComponent ec = getServiceFromConfiguration(dto, EnableComponent.class);
-
+
TestCase.assertEquals(0, SimpleComponent.INSTANCES.size());
ec.enable(name);
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentFactoryTest.java Fri Jan 13 17:49:16 2017
@@ -28,7 +28,7 @@ import org.apache.felix.scr.integration.
import org.apache.felix.scr.integration.components.SimpleServiceImpl;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.service.component.ComponentException;
import org.osgi.service.component.ComponentFactory;
@@ -38,7 +38,7 @@ import org.osgi.service.log.LogService;
import junit.framework.TestCase;
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class ComponentFactoryTest extends ComponentTestBase
{
@@ -179,8 +179,8 @@ public class ComponentFactoryTest extend
}
private ComponentInstance testConfiguredFactory(final String componentname, final String componentfactory,
- boolean optional, boolean expectComponent)
- throws InvocationTargetException, InterruptedException, InvalidSyntaxException
+ boolean optional, boolean expectComponent)
+ throws InvocationTargetException, InterruptedException, InvalidSyntaxException
{
// ensure there is no configuration for the component
deleteConfig( componentname );
@@ -212,7 +212,7 @@ public class ComponentFactoryTest extend
checkConfigurationCount( componentname, 1, ComponentConfigurationDTO.ACTIVE );
- // delete config, ensure factory is not active anymore and component instance gone
+ // delete config, ensure factory is not active anymore and component instance gone
//(configuration required >> dispose of instance. Also for pre-1.3 components, removing config unconditionally
//deactivates component.
deleteConfig( componentname );
@@ -284,7 +284,7 @@ public class ComponentFactoryTest extend
}
final SimpleServiceImpl noMatch = SimpleServiceImpl.create( bundleContext, "nomatch" ).setFilterProperty(
- "nomatch" );
+ "nomatch" );
delay();
final ComponentInstance instanceNonMatch = factory.newInstance( propsNonMatch );
@@ -330,7 +330,7 @@ public class ComponentFactoryTest extend
//set up the component that refers to the service the factory will create.
final String referringComponentName = "ComponentReferringToFactoryObject";
getConfigurationsDisabledThenEnable( referringComponentName, 1,
- ComponentConfigurationDTO.UNSATISFIED_REFERENCE );
+ ComponentConfigurationDTO.UNSATISFIED_REFERENCE );
final String componentname = "factory.component.referred";
final String componentfactory = "factory.component.factory.referred";
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentTestBase.java Fri Jan 13 17:49:16 2017
@@ -58,12 +58,12 @@ import org.apache.felix.scr.impl.ScrComm
import org.apache.felix.scr.integration.components.SimpleComponent;
import org.junit.After;
import org.junit.Before;
+import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.OptionUtils;
+import org.ops4j.pax.exam.ProbeBuilder;
import org.ops4j.pax.exam.TestProbeBuilder;
-import org.ops4j.pax.exam.junit.Configuration;
-import org.ops4j.pax.exam.junit.ProbeBuilder;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -146,18 +146,18 @@ public abstract class ComponentTestBase
public TestProbeBuilder extendProbe(TestProbeBuilder builder)
{
builder.setHeader( "Export-Package",
- "org.apache.felix.scr.integration.components,"
- + "org.apache.felix.scr.integration.components.activatesignature,"
- + "org.apache.felix.scr.integration.components.annoconfig,"
- + "org.apache.felix.scr.integration.components.circular,"
- + "org.apache.felix.scr.integration.components.circularFactory,"
- + "org.apache.felix.scr.integration.components.concurrency,"
- + "org.apache.felix.scr.integration.components.deadlock,"
- + "org.apache.felix.scr.integration.components.felix3680,"
- + "org.apache.felix.scr.integration.components.felix3680_2,"
- + "org.apache.felix.scr.integration.components.felix4984,"
- + "org.apache.felix.scr.integration.components.felix5248,"
- + "org.apache.felix.scr.integration.components.felix5276" );
+ "org.apache.felix.scr.integration.components,"
+ + "org.apache.felix.scr.integration.components.activatesignature,"
+ + "org.apache.felix.scr.integration.components.annoconfig,"
+ + "org.apache.felix.scr.integration.components.circular,"
+ + "org.apache.felix.scr.integration.components.circularFactory,"
+ + "org.apache.felix.scr.integration.components.concurrency,"
+ + "org.apache.felix.scr.integration.components.deadlock,"
+ + "org.apache.felix.scr.integration.components.felix3680,"
+ + "org.apache.felix.scr.integration.components.felix3680_2,"
+ + "org.apache.felix.scr.integration.components.felix4984,"
+ + "org.apache.felix.scr.integration.components.felix5248,"
+ + "org.apache.felix.scr.integration.components.felix5276" );
builder.setHeader( "Import-Package", "org.apache.felix.scr.component" );
builder.setHeader( "Bundle-ManifestVersion", "2" );
return builder;
@@ -171,18 +171,18 @@ public abstract class ComponentTestBase
if ( !bundleFile.canRead() )
{
throw new IllegalArgumentException( "Cannot read from bundle file " + bundleFileName + " specified in the "
- + BUNDLE_JAR_SYS_PROP + " system property" );
+ + BUNDLE_JAR_SYS_PROP + " system property" );
}
final Option[] base = options(
- provision( CoreOptions.bundle( bundleFile.toURI().toString() ),
- mavenBundle( "org.ops4j.pax.tinybundles", "tinybundles", "1.0.0" ),
- mavenBundle( "org.apache.felix", "org.apache.felix.configadmin", felixCaVersion ) ),
- junitBundles(), frameworkProperty( "org.osgi.framework.bsnversion" ).value( bsnVersionUniqueness ),
- systemProperty( "ds.factory.enabled" ).value( Boolean.toString( NONSTANDARD_COMPONENT_FACTORY_BEHAVIOR ) ),
- systemProperty( "ds.loglevel" ).value( DS_LOGLEVEL )
+ provision( CoreOptions.bundle( bundleFile.toURI().toString() ),
+ mavenBundle( "org.ops4j.pax.tinybundles", "tinybundles", "1.0.0" ),
+ mavenBundle( "org.apache.felix", "org.apache.felix.configadmin", felixCaVersion ) ),
+ junitBundles(), frameworkProperty( "org.osgi.framework.bsnversion" ).value( bsnVersionUniqueness ),
+ systemProperty( "ds.factory.enabled" ).value( Boolean.toString( NONSTANDARD_COMPONENT_FACTORY_BEHAVIOR ) ),
+ systemProperty( "ds.loglevel" ).value( DS_LOGLEVEL )
- );
+ );
final Option vmOption = ( paxRunnerVmOption != null )? CoreOptions.vmOption( paxRunnerVmOption ): null;
NONSTANDARD_COMPONENT_FACTORY_BEHAVIOR = false;
return OptionUtils.combine( base, vmOption );
@@ -197,10 +197,10 @@ public abstract class ComponentTestBase
bundleContext.registerService( LogService.class.getName(), log, null );
scrTracker = new ServiceTracker<ServiceComponentRuntime, ServiceComponentRuntime>( bundleContext,
- ServiceComponentRuntime.class, null );
+ ServiceComponentRuntime.class, null );
scrTracker.open();
configAdminTracker = new ServiceTracker<ConfigurationAdmin, ConfigurationAdmin>( bundleContext,
- ConfigurationAdmin.class, null );
+ ConfigurationAdmin.class, null );
configAdminTracker.open();
bundle = installBundle( descriptorFile, COMPONENT_PACKAGE );
@@ -250,7 +250,7 @@ public abstract class ComponentTestBase
}
protected Collection<ComponentConfigurationDTO> findComponentConfigurationsByName(Bundle b, String name,
- int expected)
+ int expected)
{
ServiceComponentRuntime scr = scrTracker.getService();
if ( scr == null )
@@ -276,9 +276,9 @@ public abstract class ComponentTestBase
for ( ComponentConfigurationDTO cc : ccs )
{
Assert.assertTrue(
- "for ComponentConfiguration name: " + cc.description.name + " properties" + cc.properties
+ "for ComponentConfiguration name: " + cc.description.name + " properties" + cc.properties
+ "Expected one of state " + sb.toString() + " but was " + STATES.get( cc.state ),
- ( expected & cc.state ) == cc.state );
+ ( expected & cc.state ) == cc.state );
}
}
return ccs;
@@ -306,13 +306,13 @@ public abstract class ComponentTestBase
static
{
STATES.put( ComponentConfigurationDTO.UNSATISFIED_REFERENCE,
- "Unsatisfied (" + ComponentConfigurationDTO.UNSATISFIED_REFERENCE + ")" );
+ "Unsatisfied (" + ComponentConfigurationDTO.UNSATISFIED_REFERENCE + ")" );
STATES.put( ComponentConfigurationDTO.SATISFIED, "Satisified (" + ComponentConfigurationDTO.SATISFIED + ")" );
STATES.put( ComponentConfigurationDTO.ACTIVE, "Active (" + ComponentConfigurationDTO.ACTIVE + ")" );
}
protected ComponentConfigurationDTO getDisabledConfigurationAndEnable(Bundle b, String name, int initialState)
- throws InvocationTargetException, InterruptedException
+ throws InvocationTargetException, InterruptedException
{
int count = 1;
Collection<ComponentConfigurationDTO> ccs = getConfigurationsDisabledThenEnable( b, name, count, initialState );
@@ -321,13 +321,13 @@ public abstract class ComponentTestBase
}
protected ComponentConfigurationDTO getDisabledConfigurationAndEnable(String name, int initialState)
- throws InvocationTargetException, InterruptedException
+ throws InvocationTargetException, InterruptedException
{
return getDisabledConfigurationAndEnable( bundle, name, initialState );
}
protected Collection<ComponentConfigurationDTO> getConfigurationsDisabledThenEnable(Bundle b, String name,
- int count, int initialState) throws InvocationTargetException, InterruptedException
+ int count, int initialState) throws InvocationTargetException, InterruptedException
{
ServiceComponentRuntime scr = scrTracker.getService();
if ( scr == null )
@@ -344,13 +344,13 @@ public abstract class ComponentTestBase
for ( ComponentConfigurationDTO cc : ccs )
{
Assert.assertEquals( "Expected state " + STATES.get( initialState ) + " but was " + STATES.get( cc.state ),
- initialState, cc.state );
+ initialState, cc.state );
}
return ccs;
}
protected Collection<ComponentConfigurationDTO> getConfigurationsDisabledThenEnable(String name, int count,
- int initialState) throws InvocationTargetException, InterruptedException
+ int initialState) throws InvocationTargetException, InterruptedException
{
return getConfigurationsDisabledThenEnable( bundle, name, count, initialState );
}
@@ -372,8 +372,8 @@ public abstract class ComponentTestBase
for ( ComponentConfigurationDTO cc : ccs )
{
Assert.assertEquals(
- "Expected state " + STATES.get( expectedState ) + " but was " + STATES.get( cc.state ),
- expectedState, cc.state );
+ "Expected state " + STATES.get( expectedState ) + " but was " + STATES.get( cc.state ),
+ expectedState, cc.state );
}
}
return cd;
@@ -502,7 +502,7 @@ public abstract class ComponentTestBase
}
protected org.osgi.service.cm.Configuration configure(String pid, String bundleLocation,
- Dictionary<String, Object> props)
+ Dictionary<String, Object> props)
{
ConfigurationAdmin ca = getConfigurationAdmin();
try
@@ -581,7 +581,7 @@ public abstract class ComponentTestBase
protected ComponentFactory getComponentFactory(final String componentfactory) throws InvalidSyntaxException
{
final ServiceReference[] refs = bundleContext.getServiceReferences( ComponentFactory.class.getName(),
- "(" + ComponentConstants.COMPONENT_FACTORY + "=" + componentfactory + ")" );
+ "(" + ComponentConstants.COMPONENT_FACTORY + "=" + componentfactory + ")" );
TestCase.assertNotNull( refs );
TestCase.assertEquals( 1, refs.length );
final ComponentFactory factory = (ComponentFactory) bundleContext.getService( refs[0] );
@@ -590,10 +590,10 @@ public abstract class ComponentTestBase
}
protected void checkFactory(final String componentfactory, boolean expectFactoryPresent)
- throws InvalidSyntaxException
+ throws InvalidSyntaxException
{
ServiceReference[] refs = bundleContext.getServiceReferences( ComponentFactory.class.getName(),
- "(" + ComponentConstants.COMPONENT_FACTORY + "=" + componentfactory + ")" );
+ "(" + ComponentConstants.COMPONENT_FACTORY + "=" + componentfactory + ")" );
if ( expectFactoryPresent )
{
TestCase.assertNotNull( refs );
@@ -607,7 +607,7 @@ public abstract class ComponentTestBase
}
protected ComponentInstance createFactoryComponentInstance(final String componentfactory)
- throws InvalidSyntaxException
+ throws InvalidSyntaxException
{
Hashtable<String, String> props = new Hashtable<String, String>();
props.put( PROP_NAME_FACTORY, PROP_NAME_FACTORY );
@@ -616,7 +616,7 @@ public abstract class ComponentTestBase
}
protected ComponentInstance createFactoryComponentInstance(final String componentfactory,
- Hashtable<String, String> props) throws InvalidSyntaxException
+ Hashtable<String, String> props) throws InvalidSyntaxException
{
final ComponentFactory factory = getComponentFactory( componentfactory );
@@ -690,17 +690,17 @@ public abstract class ComponentTestBase
}
protected Bundle installBundle(final String descriptorFile, String componentPackage, String symbolicName,
- String version, String location) throws BundleException
+ String version, String location) throws BundleException
{
final InputStream bundleStream = bundle().add( "OSGI-INF/components.xml",
- getClass().getResource( descriptorFile ) )
+ getClass().getResource( descriptorFile ) )
- .set( Constants.BUNDLE_SYMBOLICNAME, symbolicName ).set( Constants.BUNDLE_VERSION, version ).set(
- Constants.IMPORT_PACKAGE, componentPackage ).set( "Service-Component", "OSGI-INF/components.xml" ).set(
- Constants.REQUIRE_CAPABILITY,
- ExtenderNamespace.EXTENDER_NAMESPACE
- + ";filter:=\"(&(osgi.extender=osgi.component)(version>=1.3)(!(version>=2.0)))\"" ).build(
- withBnd() );
+ .set( Constants.BUNDLE_SYMBOLICNAME, symbolicName ).set( Constants.BUNDLE_VERSION, version ).set(
+ Constants.IMPORT_PACKAGE, componentPackage ).set( "Service-Component", "OSGI-INF/components.xml" ).set(
+ Constants.REQUIRE_CAPABILITY,
+ ExtenderNamespace.EXTENDER_NAMESPACE
+ + ";filter:=\"(&(osgi.extender=osgi.component)(version>=1.3)(!(version>=2.0)))\"" ).build(
+ withBnd() );
try
{
@@ -838,7 +838,7 @@ public abstract class ComponentTestBase
private static final int RESTRICTED_LOG_SIZE = 1000;
private final SimpleDateFormat m_sdf = new SimpleDateFormat( "HH:mm:ss,S" );
private final static PrintStream m_out = new PrintStream(
- new BufferedOutputStream( new FileOutputStream( FileDescriptor.err ), 128 ) );
+ new BufferedOutputStream( new FileOutputStream( FileDescriptor.err ), 128 ) );
private final List<String> m_warnings = Collections.synchronizedList( new ArrayList<String>() );
private LinkedBlockingQueue<LogEntry> m_logQueue = new LinkedBlockingQueue<LogEntry>();
private volatile Thread m_logThread;
@@ -909,6 +909,7 @@ public abstract class ComponentTestBase
return firstFrameworkThrowable;
}
+ @Override
public void run()
{
try
@@ -980,6 +981,7 @@ public abstract class ComponentTestBase
return true;
}
+ @Override
public void frameworkEvent(final FrameworkEvent event)
{
int eventType = event.getType();
@@ -994,11 +996,13 @@ public abstract class ComponentTestBase
// ------------ LogService ----------------------------------------------------------------
+ @Override
public void log(int level, String message)
{
log( level, message, null );
}
+ @Override
public void log(int level, String message, Throwable exception)
{
if ( level > getEnabledLogLevel() )
@@ -1008,11 +1012,13 @@ public abstract class ComponentTestBase
m_logQueue.offer( new LogEntry( level, message, exception ) );
}
+ @Override
public void log(ServiceReference sr, int osgiLevel, String message)
{
log( sr, osgiLevel, message, null );
}
+ @Override
public void log(ServiceReference sr, int level, String msg, Throwable exception)
{
if ( sr != null )
@@ -1056,20 +1062,20 @@ public abstract class ComponentTestBase
{
switch (event)
{
- case FrameworkEvent.ERROR:
- return "FrameworkEvent: ERROR";
- case FrameworkEvent.INFO:
- return "FrameworkEvent INFO";
- case FrameworkEvent.PACKAGES_REFRESHED:
- return "FrameworkEvent: PACKAGE REFRESHED";
- case FrameworkEvent.STARTED:
- return "FrameworkEvent: STARTED";
- case FrameworkEvent.STARTLEVEL_CHANGED:
- return "FrameworkEvent: STARTLEVEL CHANGED";
- case FrameworkEvent.WARNING:
- return "FrameworkEvent: WARNING";
- default:
- return null;
+ case FrameworkEvent.ERROR:
+ return "FrameworkEvent: ERROR";
+ case FrameworkEvent.INFO:
+ return "FrameworkEvent INFO";
+ case FrameworkEvent.PACKAGES_REFRESHED:
+ return "FrameworkEvent: PACKAGE REFRESHED";
+ case FrameworkEvent.STARTED:
+ return "FrameworkEvent: STARTED";
+ case FrameworkEvent.STARTLEVEL_CHANGED:
+ return "FrameworkEvent: STARTLEVEL CHANGED";
+ case FrameworkEvent.WARNING:
+ return "FrameworkEvent: WARNING";
+ default:
+ return null;
}
}
}
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationChangeTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationChangeTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationChangeTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationChangeTest.java Fri Jan 13 17:49:16 2017
@@ -20,21 +20,20 @@ package org.apache.felix.scr.integration
import java.util.Hashtable;
-import junit.framework.TestCase;
-
import org.apache.felix.scr.integration.components.SimpleComponent;
import org.apache.felix.scr.integration.components.SimpleServiceImpl;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
-import org.osgi.framework.InvalidSyntaxException;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.ComponentConstants;
import org.osgi.service.component.ComponentFactory;
import org.osgi.service.component.ComponentInstance;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
-@RunWith(JUnit4TestRunner.class)
+import junit.framework.TestCase;
+
+@RunWith(PaxExam.class)
public class ConfigurationChangeTest extends ComponentTestBase
{
private static final String PROP_NAME_FACTORY = ComponentTestBase.PROP_NAME + ".factory";
@@ -42,7 +41,7 @@ public class ConfigurationChangeTest ext
static
{
// uncomment to enable debugging of this test class
-// paxRunnerVmOption = DEBUG_VM_OPTION;
+ // paxRunnerVmOption = DEBUG_VM_OPTION;
descriptorFile = "/integration_test_simple_components_configuration_change.xml";
}
@@ -111,8 +110,8 @@ public class ConfigurationChangeTest ext
theConfig.put("ref.target", "(value=srv1)");
configure( pid );
delay();//all cm event to complete
-
- getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE);
+
+ getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE);
final SimpleComponent comp10 = SimpleComponent.INSTANCE;
TestCase.assertNotNull( comp10 );
TestCase.assertEquals( srv1, comp10.m_singleRef );
@@ -133,7 +132,7 @@ public class ConfigurationChangeTest ext
comp20 = comp10;
TestCase.assertEquals( 2, comp20.m_singleRefBind );
TestCase.assertEquals( 1, comp20.m_singleRefUnbind);
- }
+ }
else
{
TestCase.assertEquals( 0, comp10.m_modified );
@@ -214,7 +213,7 @@ public class ConfigurationChangeTest ext
theConfig.put("ref.target", "(value=srv1)");
configure( pid );
delay();//let cm thread finish before enabling.
-
+
getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE);
final SimpleComponent comp10 = SimpleComponent.INSTANCE;
@@ -237,7 +236,7 @@ public class ConfigurationChangeTest ext
comp20 = comp10;
TestCase.assertEquals( 2, comp20.m_multiRefBind );
TestCase.assertEquals( 1, comp20.m_multiRefUnbind);
- }
+ }
else
{
TestCase.assertEquals( 0, comp10.m_modified );
@@ -252,9 +251,9 @@ public class ConfigurationChangeTest ext
TestCase.assertEquals( 1, comp20.m_multiRef.size() );
TestCase.assertEquals( srv2, comp20.m_multiRef.iterator().next() );
}
-
+
//I'm not sure what should happen in this case, asking on dev list.
-// @Test
+ // @Test
public void testSingleDynamicRequiredFactory() throws Exception
{
String pid = "test_required_single_dynamic_factory";
@@ -268,10 +267,10 @@ public class ConfigurationChangeTest ext
configure( pid );
getDisabledConfigurationAndEnable(pid, ComponentConfigurationDTO.ACTIVE); //?????? Not clear what should happen.
-
+
// create a component instance
final ServiceReference[] refs = bundleContext.getServiceReferences( ComponentFactory.class.getName(), "("
- + ComponentConstants.COMPONENT_FACTORY + "=" + factoryPid + ")" );
+ + ComponentConstants.COMPONENT_FACTORY + "=" + factoryPid + ")" );
TestCase.assertNotNull( refs );
TestCase.assertEquals( 1, refs.length );
final ComponentFactory factory = ( ComponentFactory ) bundleContext.getService( refs[0] );
@@ -305,7 +304,7 @@ public class ConfigurationChangeTest ext
comp20 = comp10;
TestCase.assertEquals( 2, comp20.m_singleRefBind );
TestCase.assertEquals( 1, comp20.m_singleRefUnbind);
- }
+ }
else
{
TestCase.assertEquals( 0, comp10.m_modified );
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationComponentFactoryTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationComponentFactoryTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationComponentFactoryTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ConfigurationComponentFactoryTest.java Fri Jan 13 17:49:16 2017
@@ -23,7 +23,7 @@ import java.util.Dictionary;
import org.apache.felix.scr.integration.components.SimpleComponent;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.service.cm.Configuration;
import org.osgi.service.component.ComponentFactory;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
@@ -34,7 +34,7 @@ import junit.framework.TestCase;
* Tests of nonstandard ComponentFactory behavior
*/
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class ConfigurationComponentFactoryTest extends ComponentTestBase
{
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ExtenderTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ExtenderTest.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ExtenderTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ExtenderTest.java Fri Jan 13 17:49:16 2017
@@ -23,31 +23,31 @@ import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.BundleException;
import org.osgi.framework.wiring.BundleWire;
import org.osgi.framework.wiring.BundleWiring;
import org.osgi.namespace.extender.ExtenderNamespace;
import org.osgi.service.component.ComponentConstants;
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class ExtenderTest extends ComponentTestBase
{
static
{
// uncomment to enable debugging of this test class
-// paxRunnerVmOption = DEBUG_VM_OPTION;
+ // paxRunnerVmOption = DEBUG_VM_OPTION;
}
-
+
@Test
- public void testWired() throws BundleException
+ public void testWired() throws BundleException
{
if (isAtLeastR5())
{
BundleWiring scrWiring = bundle.adapt(BundleWiring.class);
List<BundleWire> extenderWires = scrWiring.getRequiredWires(ExtenderNamespace.EXTENDER_NAMESPACE);
boolean wired = false;
- for (BundleWire wire: extenderWires)
+ for (BundleWire wire: extenderWires)
{
if (ComponentConstants.COMPONENT_CAPABILITY_NAME.equals(wire.getCapability().getAttributes().get(ExtenderNamespace.EXTENDER_NAMESPACE)))
{
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix3680Test.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix3680Test.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix3680Test.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix3680Test.java Fri Jan 13 17:49:16 2017
@@ -22,18 +22,18 @@ import java.util.Iterator;
import javax.inject.Inject;
-import junit.framework.TestCase;
-
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.runtime.dto.ComponentDescriptionDTO;
+import junit.framework.TestCase;
+
/**
* This test validates the FELIX-3680 issue.
*/
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class Felix3680Test extends ComponentTestBase
{
static
@@ -44,7 +44,7 @@ public class Felix3680Test extends Compo
COMPONENT_PACKAGE = COMPONENT_PACKAGE + ".felix3680";
restrictedLogging = true;
//comment to get debug logging if the test fails.
-// DS_LOGLEVEL = "warn";
+ // DS_LOGLEVEL = "warn";
}
@Inject
@@ -70,14 +70,14 @@ public class Felix3680Test extends Compo
delay(30);
disableAndCheck( main );
delay( ); //async deactivate
- for (Iterator it = log.foundWarnings().iterator(); it.hasNext();)
+ for (Iterator<String> it = log.foundWarnings().iterator(); it.hasNext();)
{
- String message = (String) it.next();
+ String message = it.next();
if (message.startsWith("Performed ") && message.endsWith(" tests."))
{
continue;
}
TestCase.fail("unexpected warning or error logged: " + message);
- }
+ }
}
}
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix3680_2Test.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix3680_2Test.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix3680_2Test.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix3680_2Test.java Fri Jan 13 17:49:16 2017
@@ -23,16 +23,16 @@ import java.util.Iterator;
import javax.inject.Inject;
-import junit.framework.TestCase;
-
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.runtime.dto.ComponentDescriptionDTO;
+import junit.framework.TestCase;
-@RunWith(JUnit4TestRunner.class)
+
+@RunWith(PaxExam.class)
public class Felix3680_2Test extends ComponentTestBase
{
static
@@ -41,10 +41,10 @@ public class Felix3680_2Test extends Com
// paxRunnerVmOption = DEBUG_VM_OPTION;
descriptorFile = "/integration_test_FELIX_3880_2.xml";
COMPONENT_PACKAGE = COMPONENT_PACKAGE + ".felix3680_2";
-
+
restrictedLogging = true;
// Comment this for displaying debug messages
-// DS_LOGLEVEL = "warn";
+ // DS_LOGLEVEL = "warn";
}
@Inject
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix4188Test.java Fri Jan 13 17:49:16 2017
@@ -28,13 +28,10 @@ import java.util.concurrent.CountDownLat
import javax.inject.Inject;
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
import org.apache.felix.scr.integration.components.felix4188.Felix4188Component;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -43,21 +40,24 @@ import org.osgi.framework.InvalidSyntaxE
import org.osgi.framework.ServiceReference;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
/**
* This test validates the FELIX-4188 issue.
*/
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class Felix4188Test extends ComponentTestBase
{
static
{
// uncomment to enable debugging of this test class
-// paxRunnerVmOption = DEBUG_VM_OPTION;
+ // paxRunnerVmOption = DEBUG_VM_OPTION;
descriptorFile = "/integration_test_FELIX_4188.xml";
-// restrictedLogging = true;
+ // restrictedLogging = true;
//comment to get debug logging if the test fails.
-// DS_LOGLEVEL = "warn";
+ // DS_LOGLEVEL = "warn";
}
@Inject
@@ -83,6 +83,7 @@ public class Felix4188Test extends Compo
final CountDownLatch latch = new CountDownLatch(1);
new Thread() {
+ @Override
public void run() {
Bundle scrBundle = scrTracker.getServiceReference().getBundle();
try {
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix4350Test.java Fri Jan 13 17:49:16 2017
@@ -20,32 +20,32 @@ package org.apache.felix.scr.integration
import java.lang.reflect.InvocationTargetException;
-import junit.framework.TestCase;
import org.apache.felix.scr.integration.components.Felix4350Component;
import org.apache.felix.scr.integration.components.SimpleComponent;
import org.apache.felix.scr.integration.components.SimpleComponent2;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.runtime.dto.ComponentDescriptionDTO;
+import junit.framework.TestCase;
+
/**
* This test validates the FELIX-4350 issue.
*/
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class Felix4350Test extends ComponentTestBase
{
static
{
// uncomment to enable debugging of this test class
-// paxRunnerVmOption = DEBUG_VM_OPTION;
+ // paxRunnerVmOption = DEBUG_VM_OPTION;
descriptorFile = "/integration_test_FELIX_4350.xml";
//comment to get debug logging if the test fails.
-// DS_LOGLEVEL = "warn";
+ // DS_LOGLEVEL = "warn";
}
@Test
@@ -82,7 +82,7 @@ public class Felix4350Test extends Compo
{
ServiceRegistration dep1Reg = register(new SimpleComponent(), 0);
ServiceRegistration dep2Reg = register(new SimpleComponent2(), 1000);
-
+
final ComponentDescriptionDTO main = findComponentDescriptorByName(componentName);
TestCase.assertNotNull(main);
@@ -106,7 +106,7 @@ public class Felix4350Test extends Compo
dep1Reg = register(new SimpleComponent(), 0);
dep2Reg = register(new SimpleComponent2(), 1000);
Felix4350Component.check(1, 1, false);
-
+
asyncEnable(main); //needs to be async
delay(300);
dep1Reg.unregister();
@@ -116,13 +116,14 @@ public class Felix4350Test extends Compo
Felix4350Component.check(2, 1, true); //n.b. counts are cumulative
}
-
+
protected void asyncEnable( final ComponentDescriptionDTO cd ) throws Exception
{
- new Thread( new Runnable() {
+ new Thread( new Runnable() {
- public void run() {
- try
+ @Override
+ public void run() {
+ try
{
enableAndCheck( cd );
}
@@ -132,16 +133,18 @@ public class Felix4350Test extends Compo
catch (InterruptedException e)
{
}
- }}).start();
+ }}).start();
}
protected ServiceRegistration register(final Object service, final int delay) {
return bundleContext.registerService(service.getClass().getName(), new ServiceFactory() {
+ @Override
public Object getService(Bundle bundle, ServiceRegistration registration)
{
delay(delay);
return service;
}
+ @Override
public void ungetService(Bundle bundle, ServiceRegistration registration, Object service)
{
}
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix4984Test.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix4984Test.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix4984Test.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix4984Test.java Fri Jan 13 17:49:16 2017
@@ -25,7 +25,7 @@ import org.apache.felix.scr.integration.
import org.apache.felix.scr.integration.components.felix4984.B;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -35,7 +35,7 @@ import org.osgi.service.log.LogService;
import junit.framework.TestCase;
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class Felix4984Test extends ComponentTestBase
{
static
@@ -56,7 +56,7 @@ public class Felix4984Test extends Compo
bundle.stop();
for (int i = 0; i < 1000; i ++) {
- bundle.start();
+ bundle.start();
String componentNameA = "felix4984.A.1.1.dynamic";
ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.SATISFIED );
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5248Test.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5248Test.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5248Test.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5248Test.java Fri Jan 13 17:49:16 2017
@@ -22,12 +22,12 @@ import java.util.Hashtable;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.service.cm.Configuration;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
import org.osgi.service.log.LogService;
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class Felix5248Test extends ComponentTestBase
{
static
@@ -48,7 +48,7 @@ public class Felix5248Test extends Compo
String componentName = "Component";
ComponentConfigurationDTO component = findComponentConfigurationByName( componentName,
- ComponentConfigurationDTO.SATISFIED );
+ ComponentConfigurationDTO.SATISFIED );
log.log( LogService.LOG_INFO, "A checked satisfied (not active)" );
props.clear();
Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5276Test.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5276Test.java?rev=1778640&r1=1778639&r2=1778640&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5276Test.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5276Test.java Fri Jan 13 17:49:16 2017
@@ -24,12 +24,12 @@ import java.util.Hashtable;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.exam.junit.PaxExam;
import org.osgi.service.cm.Configuration;
import org.osgi.service.component.runtime.dto.ComponentConfigurationDTO;
import org.osgi.service.log.LogService;
-@RunWith(JUnit4TestRunner.class)
+@RunWith(PaxExam.class)
public class Felix5276Test extends ComponentTestBase
{
static
@@ -49,7 +49,7 @@ public class Felix5276Test extends Compo
String componentNameA = "A";
ComponentConfigurationDTO componentA = findComponentConfigurationByName(componentNameA,
- ComponentConfigurationDTO.ACTIVE);
+ ComponentConfigurationDTO.ACTIVE);
log.log(LogService.LOG_INFO, "A checked active");
String componentNameB = "B";