You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by al...@apache.org on 2025/05/09 20:33:46 UTC
(aries) 02/05: [MAINTENANCE] Import static all assert* methods
This is an automated email from the ASF dual-hosted git repository.
alien11689 pushed a commit to branch remove-usage-of-deprecated-junit-3-api
in repository https://gitbox.apache.org/repos/asf/aries.git
commit 680fb36a2d4cff43a1bfaaed9d9740d04f0420bc
Author: Dominik Przybysz <al...@gmail.com>
AuthorDate: Fri May 9 14:39:26 2025 +0200
[MAINTENANCE] Import static all assert* methods
---
.../blueprint/plugin/model/BlueprintTest.java | 9 +-
.../impl/SecurityAnnoationParserTest.java | 25 +--
.../org/apache/aries/blueprint/WiringTest.java | 5 +-
.../blueprint/container/DampingPolicyTest.java | 7 +-
.../blueprint/container/LifecyclePolicyTest.java | 18 +-
.../extender/SpringXsdVersionResolverTest.java | 6 +-
.../aries/blueprint/itests/FragmentTest.java | 6 +-
.../FragmentTestBundleBlueprintAttribute.java | 6 +-
.../blueprint/itests/QuiesceBlueprintTest.java | 21 ++-
.../apache/aries/jmx/framework/FrameworkTest.java | 198 +++++++++++----------
.../aries/jmx/framework/PackageStateTest.java | 24 +--
.../jmx/permissionadmin/PermissionAdminTest.java | 29 +--
.../apache/aries/jmx/useradmin/UserAdminTest.java | 114 ++++++------
.../aries/jmx/framework/ServiceStateMBeanTest.java | 1 -
.../wiring/BundleWiringStateMBeanTest.java | 47 +++--
.../ClientWeavingHookGenericCapabilityTest.java | 91 +++++-----
.../dynamic/ClientWeavingHookOSGi43Test.java | 14 +-
.../spifly/dynamic/ClientWeavingHookTest.java | 96 +++++-----
.../aries/spifly/statictool/ConsumerTest.java | 27 +--
.../apache/aries/spifly/statictool/MainTest.java | 8 +-
.../aries/spifly/statictool/RequirementTest.java | 29 +--
.../subsystem/core/archive/Aries1453Test.java | 8 +-
.../apache/aries/subsystem/itests/FeatureTest.java | 47 ++---
.../subsystem/itests/ServiceDependencyTest.java | 63 ++++---
.../modelling/utils/DeployedBundlesTest.java | 47 ++---
.../utils/PackageRequirementMergerTest.java | 42 +++--
.../org/apache/aries/unittest/mocks/Skeleton.java | 8 +-
.../aries/transaction/ComponentTxDataTest.java | 7 +-
.../itests/AbstractIntegrationTest.java | 7 +-
.../aries/transaction/itests/RollbackOnTest.java | 9 +-
.../java/org/apache/aries/util/log/LoggerTest.java | 46 ++---
31 files changed, 556 insertions(+), 509 deletions(-)
diff --git a/blueprint-maven-plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BlueprintTest.java b/blueprint-maven-plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BlueprintTest.java
index 7107d089f..adc6b60b2 100644
--- a/blueprint-maven-plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BlueprintTest.java
+++ b/blueprint-maven-plugin/blueprint-maven-plugin/src/test/java/org/apache/aries/blueprint/plugin/model/BlueprintTest.java
@@ -21,7 +21,6 @@ package org.apache.aries.blueprint.plugin.model;
import org.apache.aries.blueprint.plugin.BlueprintConfigurationImpl;
import org.apache.aries.blueprint.plugin.test.MyBean3;
import org.apache.aries.blueprint.plugin.test.ServiceReferences;
-import org.junit.Assert;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -45,15 +44,15 @@ public class BlueprintTest {
@Test
public void testLists() {
Blueprint blueprint = new Blueprint(blueprintConfiguration, MyBean3.class);
- Assert.assertEquals(1, blueprint.getBeans().size());
- Assert.assertEquals(0, getOsgiServices(blueprint).size());
+ assertEquals(1, blueprint.getBeans().size());
+ assertEquals(0, getOsgiServices(blueprint).size());
}
@Test
public void testLists2() {
Blueprint blueprint = new Blueprint(blueprintConfiguration, ServiceReferences.class);
- Assert.assertEquals(1, blueprint.getBeans().size());
- Assert.assertEquals(3, getOsgiServices(blueprint).size());
+ assertEquals(1, blueprint.getBeans().size());
+ assertEquals(3, getOsgiServices(blueprint).size());
}
private Set<String> getOsgiServices(Blueprint blueprint) {
diff --git a/blueprint/blueprint-authz/src/test/java/org/apache/aries/blueprint/authorization/impl/SecurityAnnoationParserTest.java b/blueprint/blueprint-authz/src/test/java/org/apache/aries/blueprint/authorization/impl/SecurityAnnoationParserTest.java
index 9408d0d2a..a75b8c397 100644
--- a/blueprint/blueprint-authz/src/test/java/org/apache/aries/blueprint/authorization/impl/SecurityAnnoationParserTest.java
+++ b/blueprint/blueprint-authz/src/test/java/org/apache/aries/blueprint/authorization/impl/SecurityAnnoationParserTest.java
@@ -25,9 +25,12 @@ import javax.annotation.security.PermitAll;
import javax.annotation.security.RolesAllowed;
import org.apache.aries.blueprint.authorization.impl.test.SecuredClass;
-import org.junit.Assert;
import org.junit.Test;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
public class SecurityAnnoationParserTest {
private SecurityAnotationParser annParser;
@@ -38,23 +41,23 @@ public class SecurityAnnoationParserTest {
@Test
public void testIsSecured() {
- Assert.assertTrue(annParser.isSecured(SecuredClass.class));
- Assert.assertFalse(annParser.isSecured(Object.class));
- Assert.assertFalse(annParser.isSecured(Activator.class));
+ assertTrue(annParser.isSecured(SecuredClass.class));
+ assertFalse(annParser.isSecured(Object.class));
+ assertFalse(annParser.isSecured(Activator.class));
}
@Test
public void testAnnotationType() throws NoSuchMethodException, SecurityException {
- Assert.assertTrue(getEffective("admin") instanceof RolesAllowed);
- Assert.assertTrue(getEffective("user") instanceof RolesAllowed);
- Assert.assertTrue(getEffective("anon") instanceof PermitAll);
- Assert.assertTrue(getEffective("closed") instanceof DenyAll);
+ assertTrue(getEffective("admin") instanceof RolesAllowed);
+ assertTrue(getEffective("user") instanceof RolesAllowed);
+ assertTrue(getEffective("anon") instanceof PermitAll);
+ assertTrue(getEffective("closed") instanceof DenyAll);
}
@Test
public void testRoles() throws NoSuchMethodException, SecurityException {
- Assert.assertArrayEquals(new String[]{"admin"}, getRoles("admin"));
- Assert.assertArrayEquals(new String[]{"user"}, getRoles("user"));
+ assertArrayEquals(new String[]{"admin"}, getRoles("admin"));
+ assertArrayEquals(new String[]{"user"}, getRoles("user"));
}
private Annotation getEffective(String methodName) throws NoSuchMethodException {
@@ -63,7 +66,7 @@ public class SecurityAnnoationParserTest {
private String[] getRoles(String methodName) throws NoSuchMethodException {
Annotation ann = getEffective(methodName);
- Assert.assertTrue(ann instanceof RolesAllowed);
+ assertTrue(ann instanceof RolesAllowed);
return ((RolesAllowed)ann).value();
}
diff --git a/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/WiringTest.java b/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/WiringTest.java
index e0aad28c4..5d3629ac4 100644
--- a/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/WiringTest.java
+++ b/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/WiringTest.java
@@ -33,7 +33,6 @@ import java.util.Properties;
import java.util.Set;
import java.util.TimeZone;
-import org.junit.Assert;
import org.apache.aries.blueprint.CallbackTracker.Callback;
import org.apache.aries.blueprint.container.BlueprintRepository;
@@ -186,13 +185,13 @@ public class WiringTest extends AbstractBlueprintTest {
// fail if field-injection is not specified
try {
repository.create("FIFailureTestBean");
- Assert.fail("Expected exception");
+ fail("Expected exception");
} catch (ComponentDefinitionException cde) {}
// fail if field-injection is false
try {
repository.create("FIFailureTest2Bean");
- Assert.fail("Expected exception");
+ fail("Expected exception");
} catch (ComponentDefinitionException cde) {}
}
diff --git a/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/DampingPolicyTest.java b/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/DampingPolicyTest.java
index 587dee416..2a6116e99 100644
--- a/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/DampingPolicyTest.java
+++ b/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/DampingPolicyTest.java
@@ -25,7 +25,6 @@ import org.apache.aries.blueprint.container.SatisfiableRecipe.SatisfactionListen
import org.apache.aries.blueprint.reflect.ReferenceMetadataImpl;
import org.apache.aries.blueprint.services.ExtendedBlueprintContainer;
import org.easymock.EasyMock;
-import org.junit.Assert;
import org.junit.Test;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
@@ -33,6 +32,8 @@ import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceReference;
+import static org.junit.Assert.assertSame;
+
public class DampingPolicyTest {
@Test
@@ -75,7 +76,7 @@ public class DampingPolicyTest {
EasyMock.replay(container, containerContext, svcRef1);
recipe.start(listener);
- Assert.assertSame(svcRef1, currentReference.get());
+ assertSame(svcRef1, currentReference.get());
EasyMock.verify(container, containerContext, svcRef1);
EasyMock.reset(container, containerContext, svcRef1);
@@ -91,7 +92,7 @@ public class DampingPolicyTest {
EasyMock.replay(container, containerContext, svcRef1, svcRef2);
recipe.serviceChanged(event2);
- Assert.assertSame(svcRef2, currentReference.get());
+ assertSame(svcRef2, currentReference.get());
EasyMock.verify(container, containerContext, svcRef1, svcRef2);
}
diff --git a/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/LifecyclePolicyTest.java b/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/LifecyclePolicyTest.java
index 2778ab60e..63b360ed2 100644
--- a/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/LifecyclePolicyTest.java
+++ b/blueprint/blueprint-core/src/test/java/org/apache/aries/blueprint/container/LifecyclePolicyTest.java
@@ -39,7 +39,6 @@ import org.apache.aries.blueprint.reflect.RefMetadataImpl;
import org.apache.aries.blueprint.reflect.ReferenceMetadataImpl;
import org.apache.aries.proxy.ProxyManager;
import org.easymock.EasyMock;
-import org.junit.Assert;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -52,6 +51,9 @@ import org.osgi.service.blueprint.container.BlueprintContainer;
import org.osgi.service.blueprint.container.BlueprintEvent;
import org.osgi.service.blueprint.container.BlueprintListener;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
public class LifecyclePolicyTest {
@Test
@@ -149,9 +151,9 @@ public class LifecyclePolicyTest {
recipe.start(container);
Bean2 bean2i = (Bean2) container.getRepository().create("bean2");
- Assert.assertNotNull(bean2i);
- Assert.assertEquals(1, Bean2.initialized);
- Assert.assertEquals(0, Bean2.destroyed);
+ assertNotNull(bean2i);
+ assertEquals(1, Bean2.initialized);
+ assertEquals(0, Bean2.destroyed);
EasyMock.verify(bundle, bundleContext, extenderBundle, extenderBundleContext,
eventDispatcher, namespaceHandlerRegistry, namespaceHandlerSet, proxyManager,
@@ -177,8 +179,8 @@ public class LifecyclePolicyTest {
svcRef1, registration);
recipe.serviceChanged(new ServiceEvent(ServiceEvent.UNREGISTERING, svcRef1));
- Assert.assertEquals(1, Bean2.initialized);
- Assert.assertEquals(1, Bean2.destroyed);
+ assertEquals(1, Bean2.initialized);
+ assertEquals(1, Bean2.destroyed);
EasyMock.verify(bundle, bundleContext, extenderBundle, extenderBundleContext,
eventDispatcher, namespaceHandlerRegistry, namespaceHandlerSet, proxyManager,
@@ -205,8 +207,8 @@ public class LifecyclePolicyTest {
svcRef1, registration);
recipe.serviceChanged(new ServiceEvent(ServiceEvent.REGISTERED, svcRef1));
- Assert.assertEquals(2, Bean2.initialized);
- Assert.assertEquals(1, Bean2.destroyed);
+ assertEquals(2, Bean2.initialized);
+ assertEquals(1, Bean2.destroyed);
EasyMock.verify(bundle, bundleContext, extenderBundle, extenderBundleContext,
eventDispatcher, namespaceHandlerRegistry, namespaceHandlerSet, proxyManager,
diff --git a/blueprint/blueprint-spring-extender/src/test/java/org/apache/aries/blueprint/spring/extender/SpringXsdVersionResolverTest.java b/blueprint/blueprint-spring-extender/src/test/java/org/apache/aries/blueprint/spring/extender/SpringXsdVersionResolverTest.java
index 02026bbda..aedef5b5b 100644
--- a/blueprint/blueprint-spring-extender/src/test/java/org/apache/aries/blueprint/spring/extender/SpringXsdVersionResolverTest.java
+++ b/blueprint/blueprint-spring-extender/src/test/java/org/apache/aries/blueprint/spring/extender/SpringXsdVersionResolverTest.java
@@ -16,8 +16,8 @@
*/
package org.apache.aries.blueprint.spring.extender;
-import static org.hamcrest.CoreMatchers.equalTo;
-import org.junit.Assert;
+import static org.junit.Assert.assertEquals;
+
import org.junit.Test;
/**
@@ -30,6 +30,6 @@ public class SpringXsdVersionResolverTest {
public void testResolve() {
final String xsdVersion = SpringXsdVersionResolver.resolve();
- Assert.assertThat(xsdVersion, equalTo("5.3"));
+ assertEquals("5.3", xsdVersion);
}
}
diff --git a/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/FragmentTest.java b/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/FragmentTest.java
index f52828bdb..89b9a5c23 100644
--- a/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/FragmentTest.java
+++ b/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/FragmentTest.java
@@ -19,11 +19,11 @@
package org.apache.aries.blueprint.itests;
import static org.apache.aries.blueprint.itests.Helper.mvnBundle;
+import static org.junit.Assert.assertNotNull;
import static org.ops4j.pax.exam.CoreOptions.streamBundle;
import java.io.InputStream;
-import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
@@ -41,9 +41,9 @@ public class FragmentTest extends AbstractBlueprintIntegrationTest
public void testFragmentProvidesBlueprintFile() throws Exception
{
Runnable r = context().getService(Runnable.class);
- Assert.assertNotNull("Could not find blueprint registered service", r);
+ assertNotNull("Could not find blueprint registered service", r);
BlueprintContainer bc = Helper.getBlueprintContainerForBundle(context(), "org.apache.aries.test.host");
- Assert.assertNotNull("Could not find blueprint container for bundle", bc);
+ assertNotNull("Could not find blueprint container for bundle", bc);
}
@Configuration
diff --git a/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/FragmentTestBundleBlueprintAttribute.java b/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/FragmentTestBundleBlueprintAttribute.java
index cd438de7a..41dc57bb9 100644
--- a/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/FragmentTestBundleBlueprintAttribute.java
+++ b/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/FragmentTestBundleBlueprintAttribute.java
@@ -18,11 +18,11 @@
*/
package org.apache.aries.blueprint.itests;
+import static org.junit.Assert.assertNotNull;
import static org.ops4j.pax.exam.CoreOptions.streamBundle;
import java.io.InputStream;
-import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
@@ -40,9 +40,9 @@ public class FragmentTestBundleBlueprintAttribute extends AbstractBlueprintInteg
public void testFragmentProvidesBlueprintFile() throws Exception
{
Runnable r = context().getService(Runnable.class);
- Assert.assertNotNull("Could not find blueprint registered service", r);
+ assertNotNull("Could not find blueprint registered service", r);
BlueprintContainer bc = Helper.getBlueprintContainerForBundle(context(), "org.apache.aries.test.host");
- Assert.assertNotNull("Could not find blueprint container for bundle", bc);
+ assertNotNull("Could not find blueprint container for bundle", bc);
}
@Configuration
diff --git a/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/QuiesceBlueprintTest.java b/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/QuiesceBlueprintTest.java
index b2507431d..f2589fc82 100644
--- a/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/QuiesceBlueprintTest.java
+++ b/blueprint/itests/blueprint-itests/src/test/java/org/apache/aries/blueprint/itests/QuiesceBlueprintTest.java
@@ -16,6 +16,7 @@
package org.apache.aries.blueprint.itests;
import static org.apache.aries.blueprint.itests.Helper.mvnBundle;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.ops4j.pax.exam.CoreOptions.bootDelegationPackages;
@@ -24,8 +25,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Arrays;
-import org.junit.Assert;
-
import org.apache.aries.blueprint.testquiescebundle.TestBean;
import org.apache.aries.quiesce.manager.QuiesceCallback;
import org.apache.aries.quiesce.participant.QuiesceParticipant;
@@ -153,13 +152,13 @@ private QuiesceParticipant getParticipant(String bundleName) throws InvalidSynta
Thread.sleep(1000);
- Assert.assertEquals("Quiesce callback should not have occurred yet; calls should be 0, but it is " + callback.getCalls(), 0, callback.getCalls());
+ assertEquals("Quiesce callback should not have occurred yet; calls should be 0, but it is " + callback.getCalls(), 0, callback.getCalls());
t.join();
System.out.println("After join");
- Assert.assertEquals("Quiesce callback should have occurred once; calls should be 1, but it is " + callback.getCalls(), 1, callback.getCalls());
+ assertEquals("Quiesce callback should have occurred once; calls should be 1, but it is " + callback.getCalls(), 1, callback.getCalls());
}
else
@@ -212,8 +211,8 @@ private QuiesceParticipant getParticipant(String bundleName) throws InvalidSynta
Thread.sleep(200);
- Assert.assertEquals("Quiesce callback B should have occurred; calls should be 1, but it is " + callbackB.getCalls(), 1, callbackB.getCalls());
- Assert.assertEquals("Quiesce callback A should not have occurred yet; calls should be 0, but it is " + callbackA.getCalls(), 0, callbackA.getCalls());
+ assertEquals("Quiesce callback B should have occurred; calls should be 1, but it is " + callbackB.getCalls(), 1, callbackB.getCalls());
+ assertEquals("Quiesce callback A should not have occurred yet; calls should be 0, but it is " + callbackA.getCalls(), 0, callbackA.getCalls());
bundleb.stop();
@@ -224,8 +223,8 @@ private QuiesceParticipant getParticipant(String bundleName) throws InvalidSynta
System.out.println("After second sleep");
- Assert.assertEquals("Quiesce callback A should have occurred once; calls should be 1, but it is " + callbackA.getCalls(), 1, callbackA.getCalls());
- Assert.assertEquals("Quiesce callback B should have occurred once; calls should be 1, but it is " + callbackB.getCalls(), 1, callbackB.getCalls());
+ assertEquals("Quiesce callback A should have occurred once; calls should be 1, but it is " + callbackA.getCalls(), 1, callbackA.getCalls());
+ assertEquals("Quiesce callback B should have occurred once; calls should be 1, but it is " + callbackB.getCalls(), 1, callbackB.getCalls());
}else{
throw new Exception("No Quiesce Participant found for the blueprint service");
@@ -277,13 +276,13 @@ private QuiesceParticipant getParticipant(String bundleName) throws InvalidSynta
Thread.sleep(500);
- Assert.assertEquals("Quiesce callback should have occurred once for bundle a but not for bundle q; calls should be 1, but it is " + callback.getCalls(), 1, callback.getCalls());
+ assertEquals("Quiesce callback should have occurred once for bundle a but not for bundle q; calls should be 1, but it is " + callback.getCalls(), 1, callback.getCalls());
Thread.sleep(1500);
System.out.println("After second sleep");
- Assert.assertEquals("Quiesce callback should have occurred twice, once for bundle a and q respectively; calls should be 2, but it is " + callback.getCalls(), 2, callback.getCalls());
+ assertEquals("Quiesce callback should have occurred twice, once for bundle a and q respectively; calls should be 2, but it is " + callback.getCalls(), 2, callback.getCalls());
}else{
throw new Exception("No Quiesce Participant found for the blueprint service");
@@ -332,7 +331,7 @@ private QuiesceParticipant getParticipant(String bundleName) throws InvalidSynta
Thread.sleep(5000);
- Assert.assertEquals("Quiesce callback should have occurred once; calls should be 1, but it is " + callback.getCalls(), 1, callback.getCalls());
+ assertEquals("Quiesce callback should have occurred once; calls should be 1, but it is " + callback.getCalls(), 1, callback.getCalls());
}else{
diff --git a/jmx/jmx-core/src/test/java/org/apache/aries/jmx/framework/FrameworkTest.java b/jmx/jmx-core/src/test/java/org/apache/aries/jmx/framework/FrameworkTest.java
index 38b79f008..0727683d4 100644
--- a/jmx/jmx-core/src/test/java/org/apache/aries/jmx/framework/FrameworkTest.java
+++ b/jmx/jmx-core/src/test/java/org/apache/aries/jmx/framework/FrameworkTest.java
@@ -23,7 +23,6 @@ import javax.management.openmbean.CompositeData;
import org.apache.aries.jmx.codec.BatchActionResult;
import org.apache.aries.jmx.codec.BatchInstallResult;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@@ -36,6 +35,13 @@ import org.osgi.jmx.framework.FrameworkMBean;
import org.osgi.service.packageadmin.PackageAdmin;
import org.osgi.service.startlevel.StartLevel;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
/**
* {@link FrameworkMBean} test case.
*
@@ -62,7 +68,7 @@ public class FrameworkTest {
public void testGetFrameworkStartLevel() throws IOException {
Mockito.when(startLevel.getStartLevel()).thenReturn(1);
int level = mbean.getFrameworkStartLevel();
- Assert.assertEquals(1, level);
+ assertEquals(1, level);
}
@Test
@@ -70,7 +76,7 @@ public class FrameworkTest {
Mockito.when(startLevel.getInitialBundleStartLevel()).thenReturn(2);
int level = mbean.getInitialBundleStartLevel();
Mockito.verify(startLevel).getInitialBundleStartLevel();
- Assert.assertEquals(2, level);
+ assertEquals(2, level);
}
@Test
@@ -79,13 +85,13 @@ public class FrameworkTest {
Mockito.when(context.installBundle("file:test.jar")).thenReturn(bundle);
Mockito.when(bundle.getBundleId()).thenReturn(Long.valueOf(2));
long bundleId = mbean.installBundle("file:test.jar");
- Assert.assertEquals(2, bundleId);
+ assertEquals(2, bundleId);
Mockito.reset(context);
Mockito.when(context.installBundle("file:test2.jar")).thenThrow(new BundleException("location doesn't exist"));
try {
mbean.installBundle("file:test2.jar");
- Assert.fail("Shouldn't go to this stage, location doesn't exist");
+ fail("Shouldn't go to this stage, location doesn't exist");
} catch (IOException e) {
// ok
}
@@ -101,7 +107,7 @@ public class FrameworkTest {
InputStream stream = Mockito.mock(InputStream.class);
Mockito.doReturn(stream).when(spiedMBean).createStream("test.jar");
long bundleId = spiedMBean.installBundleFromURL("file:test.jar", "test.jar");
- Assert.assertEquals(2, bundleId);
+ assertEquals(2, bundleId);
Mockito.reset(context);
Mockito.doReturn(stream).when(spiedMBean).createStream(Mockito.anyString());
Mockito.when(context.installBundle(Mockito.anyString(), Mockito.any(InputStream.class))).thenThrow(
@@ -109,7 +115,7 @@ public class FrameworkTest {
try {
spiedMBean.installBundleFromURL("file:test2.jar", "test.jar");
- Assert.fail("Shouldn't go to this stage, location doesn't exist");
+ fail("Shouldn't go to this stage, location doesn't exist");
} catch (IOException e) {
// ok
}
@@ -123,23 +129,23 @@ public class FrameworkTest {
Mockito.when(bundle.getBundleId()).thenReturn(Long.valueOf(2));
CompositeData data = mbean.installBundles(locations);
BatchInstallResult batch = BatchInstallResult.from(data);
- Assert.assertNotNull(batch);
- Assert.assertEquals(2, batch.getCompleted()[0]);
- Assert.assertTrue(batch.isSuccess());
- Assert.assertNull(batch.getError());
- Assert.assertNull(batch.getRemainingLocationItems());
+ assertNotNull(batch);
+ assertEquals(2, batch.getCompleted()[0]);
+ assertTrue(batch.isSuccess());
+ assertNull(batch.getError());
+ assertNull(batch.getRemainingLocationItems());
Mockito.reset(context);
Mockito.when(context.installBundle("file:test.jar")).thenThrow(new BundleException("location doesn't exist"));
CompositeData data2 = mbean.installBundles(locations);
BatchInstallResult batch2 = BatchInstallResult.from(data2);
- Assert.assertNotNull(batch2);
- Assert.assertNotNull(batch2.getCompleted());
- Assert.assertEquals(0, batch2.getCompleted().length);
- Assert.assertFalse(batch2.isSuccess());
- Assert.assertNotNull(batch2.getError());
- Assert.assertEquals("file:test.jar", batch2.getBundleInError());
- Assert.assertNotNull(batch2.getRemainingLocationItems());
- Assert.assertEquals(0, batch2.getRemainingLocationItems().length);
+ assertNotNull(batch2);
+ assertNotNull(batch2.getCompleted());
+ assertEquals(0, batch2.getCompleted().length);
+ assertFalse(batch2.isSuccess());
+ assertNotNull(batch2.getError());
+ assertEquals("file:test.jar", batch2.getBundleInError());
+ assertNotNull(batch2.getRemainingLocationItems());
+ assertEquals(0, batch2.getRemainingLocationItems().length);
}
@Test
@@ -151,26 +157,26 @@ public class FrameworkTest {
InputStream stream = Mockito.mock(InputStream.class);
Mockito.doReturn(stream).when(spiedMBean).createStream(Mockito.anyString());
CompositeData data = spiedMBean.installBundlesFromURL(new String[] { "file:test.jar" }, new String[] { "test.jar" });
- Assert.assertNotNull(data);
+ assertNotNull(data);
BatchInstallResult batch = BatchInstallResult.from(data);
- Assert.assertEquals(2, batch.getCompleted()[0]);
- Assert.assertTrue(batch.isSuccess());
- Assert.assertNull(batch.getError());
- Assert.assertNull(batch.getRemainingLocationItems());
+ assertEquals(2, batch.getCompleted()[0]);
+ assertTrue(batch.isSuccess());
+ assertNull(batch.getError());
+ assertNull(batch.getRemainingLocationItems());
Mockito.reset(context);
Mockito.when(spiedMBean.createStream(Mockito.anyString())).thenReturn(stream);
Mockito.when(context.installBundle(Mockito.anyString(), Mockito.any(InputStream.class))).thenThrow(
new BundleException("location doesn't exist"));
CompositeData data2 = spiedMBean.installBundlesFromURL(new String[] { "file:test.jar" }, new String[] { "test.jar" });
BatchInstallResult batch2 = BatchInstallResult.from(data2);
- Assert.assertNotNull(batch2);
- Assert.assertNotNull(batch2.getCompleted());
- Assert.assertEquals(0, batch2.getCompleted().length);
- Assert.assertFalse(batch2.isSuccess());
- Assert.assertNotNull(batch2.getError());
- Assert.assertEquals("file:test.jar", batch2.getBundleInError());
- Assert.assertNotNull(batch2.getRemainingLocationItems());
- Assert.assertEquals(0, batch2.getRemainingLocationItems().length);
+ assertNotNull(batch2);
+ assertNotNull(batch2.getCompleted());
+ assertEquals(0, batch2.getCompleted().length);
+ assertFalse(batch2.isSuccess());
+ assertNotNull(batch2.getError());
+ assertEquals("file:test.jar", batch2.getBundleInError());
+ assertNotNull(batch2.getRemainingLocationItems());
+ assertEquals(0, batch2.getRemainingLocationItems().length);
}
@Test
@@ -183,7 +189,7 @@ public class FrameworkTest {
try {
mbean.refreshBundle(2);
- Assert.fail("IOException should be thrown");
+ fail("IOException should be thrown");
} catch (IOException e) {
// expected
}
@@ -246,17 +252,17 @@ public class FrameworkTest {
CompositeData data = mbean.setBundleStartLevels(new long[] { 2 }, new int[] { 2 });
Mockito.verify(startLevel).setBundleStartLevel(bundle, 2);
BatchActionResult batch = BatchActionResult.from(data);
- Assert.assertEquals(2, batch.getCompleted()[0]);
- Assert.assertTrue(batch.isSuccess());
- Assert.assertNull(batch.getError());
- Assert.assertNull(batch.getRemainingItems());
+ assertEquals(2, batch.getCompleted()[0]);
+ assertTrue(batch.isSuccess());
+ assertNull(batch.getError());
+ assertNull(batch.getRemainingItems());
CompositeData data2 = mbean.setBundleStartLevels(new long[] { 2 }, new int[] { 2, 4 });
BatchActionResult batch2 = BatchActionResult.from(data2);
- Assert.assertNull(batch2.getCompleted());
- Assert.assertFalse(batch2.isSuccess());
- Assert.assertNotNull(batch2.getError());
- Assert.assertNull(batch2.getRemainingItems());
+ assertNull(batch2.getCompleted());
+ assertFalse(batch2.isSuccess());
+ assertNotNull(batch2.getError());
+ assertNull(batch2.getRemainingItems());
}
@@ -296,7 +302,7 @@ public class FrameworkTest {
try {
mbean.startBundle(6);
- Assert.fail("Shouldn't go to this stage, BundleException was thrown");
+ fail("Shouldn't go to this stage, BundleException was thrown");
} catch (IOException ioe) {
// expected
}
@@ -304,7 +310,7 @@ public class FrameworkTest {
Mockito.when(context.getBundle(6)).thenReturn(null);
try {
mbean.startBundle(6);
- Assert.fail("IOException should be thrown");
+ fail("IOException should be thrown");
} catch (IOException e) {
//expected
}
@@ -318,18 +324,18 @@ public class FrameworkTest {
Mockito.verify(bundle).start();
BatchActionResult batch = BatchActionResult.from(data);
- Assert.assertEquals(5, batch.getCompleted()[0]);
- Assert.assertTrue(batch.isSuccess());
- Assert.assertNull(batch.getError());
- Assert.assertNull(batch.getRemainingItems());
+ assertEquals(5, batch.getCompleted()[0]);
+ assertTrue(batch.isSuccess());
+ assertNull(batch.getError());
+ assertNull(batch.getRemainingItems());
CompositeData data2 = mbean.startBundles(null);
BatchActionResult batch2 = BatchActionResult.from(data2);
- Assert.assertNull(batch2.getCompleted());
- Assert.assertFalse(batch2.isSuccess());
- Assert.assertNotNull(batch2.getError());
- Assert.assertNull(batch2.getRemainingItems());
+ assertNull(batch2.getCompleted());
+ assertFalse(batch2.isSuccess());
+ assertNotNull(batch2.getError());
+ assertNull(batch2.getRemainingItems());
}
@Test
@@ -342,7 +348,7 @@ public class FrameworkTest {
Mockito.when(context.getBundle(5)).thenReturn(null);
try {
mbean.stopBundle(5);
- Assert.fail("IOException should be thrown");
+ fail("IOException should be thrown");
} catch (IOException e) {
//expected
}
@@ -357,18 +363,18 @@ public class FrameworkTest {
Mockito.verify(bundle).stop();
BatchActionResult batch = BatchActionResult.from(data);
- Assert.assertEquals(5, batch.getCompleted()[0]);
- Assert.assertTrue(batch.isSuccess());
- Assert.assertNull(batch.getError());
- Assert.assertNull(batch.getRemainingItems());
+ assertEquals(5, batch.getCompleted()[0]);
+ assertTrue(batch.isSuccess());
+ assertNull(batch.getError());
+ assertNull(batch.getRemainingItems());
CompositeData data2 = mbean.stopBundles(null);
BatchActionResult batch2 = BatchActionResult.from(data2);
- Assert.assertNull(batch2.getCompleted());
- Assert.assertFalse(batch2.isSuccess());
- Assert.assertNotNull(batch2.getError());
- Assert.assertNull(batch2.getRemainingItems());
+ assertNull(batch2.getCompleted());
+ assertFalse(batch2.isSuccess());
+ assertNotNull(batch2.getError());
+ assertNull(batch2.getRemainingItems());
}
@Test
@@ -386,18 +392,18 @@ public class FrameworkTest {
CompositeData data = mbean.uninstallBundles(new long[] { 5 });
Mockito.verify(bundle).uninstall();
BatchActionResult batch = BatchActionResult.from(data);
- Assert.assertEquals(5, batch.getCompleted()[0]);
- Assert.assertTrue(batch.isSuccess());
- Assert.assertNull(batch.getError());
- Assert.assertNull(batch.getRemainingItems());
+ assertEquals(5, batch.getCompleted()[0]);
+ assertTrue(batch.isSuccess());
+ assertNull(batch.getError());
+ assertNull(batch.getRemainingItems());
CompositeData data2 = mbean.uninstallBundles(null);
BatchActionResult batch2 = BatchActionResult.from(data2);
- Assert.assertNull(batch2.getCompleted());
- Assert.assertFalse(batch2.isSuccess());
- Assert.assertNotNull(batch2.getError());
- Assert.assertNull(batch2.getRemainingItems());
+ assertNull(batch2.getCompleted());
+ assertFalse(batch2.isSuccess());
+ assertNotNull(batch2.getError());
+ assertNull(batch2.getRemainingItems());
}
@Test
@@ -426,28 +432,28 @@ public class FrameworkTest {
CompositeData data = mbean.updateBundles(new long[] { 5 });
Mockito.verify(bundle).update();
BatchActionResult batch = BatchActionResult.from(data);
- Assert.assertEquals(5, batch.getCompleted()[0]);
- Assert.assertTrue(batch.isSuccess());
- Assert.assertNull(batch.getError());
- Assert.assertNull(batch.getRemainingItems());
+ assertEquals(5, batch.getCompleted()[0]);
+ assertTrue(batch.isSuccess());
+ assertNull(batch.getError());
+ assertNull(batch.getRemainingItems());
CompositeData data2 = mbean.updateBundles(null);
BatchActionResult batch2 = BatchActionResult.from(data2);
- Assert.assertNull(batch2.getCompleted());
- Assert.assertFalse(batch2.isSuccess());
- Assert.assertNotNull(batch2.getError());
- Assert.assertNull(batch2.getRemainingItems());
+ assertNull(batch2.getCompleted());
+ assertFalse(batch2.isSuccess());
+ assertNotNull(batch2.getError());
+ assertNull(batch2.getRemainingItems());
Mockito.reset(bundle);
CompositeData data3 = mbean.updateBundles(new long[] { 6 });
Mockito.when(context.getBundle(6)).thenReturn(bundle);
Mockito.doThrow(new BundleException("")).when(bundle).update();
BatchActionResult batch3 = BatchActionResult.from(data3);
- Assert.assertEquals(0, batch3.getCompleted().length);
- Assert.assertFalse(batch3.isSuccess());
- Assert.assertNotNull(batch3.getError());
- Assert.assertEquals(6, batch3.getBundleInError());
+ assertEquals(0, batch3.getCompleted().length);
+ assertFalse(batch3.isSuccess());
+ assertNotNull(batch3.getError());
+ assertEquals(6, batch3.getBundleInError());
Bundle bundle6 = Mockito.mock(Bundle.class);
Bundle bundle8 = Mockito.mock(Bundle.class);
@@ -459,15 +465,15 @@ public class FrameworkTest {
CompositeData data4 = mbean.updateBundles(new long[] { 6, 8, 7 });
BatchActionResult batch4 = BatchActionResult.from(data4);
Mockito.verify(bundle6).update();
- Assert.assertEquals(1, batch4.getCompleted().length);
+ assertEquals(1, batch4.getCompleted().length);
// should contain only bundleid 6
- Assert.assertEquals(6, batch4.getCompleted()[0]);
- Assert.assertFalse(batch4.isSuccess());
- Assert.assertNotNull(batch4.getError());
- Assert.assertEquals(8, batch4.getBundleInError());
- Assert.assertEquals(1, batch4.getRemainingItems().length);
+ assertEquals(6, batch4.getCompleted()[0]);
+ assertFalse(batch4.isSuccess());
+ assertNotNull(batch4.getError());
+ assertEquals(8, batch4.getBundleInError());
+ assertEquals(1, batch4.getRemainingItems().length);
// should contain only bundleid 7
- Assert.assertEquals(7, batch4.getRemainingItems()[0]);
+ assertEquals(7, batch4.getRemainingItems()[0]);
}
@Test
@@ -480,17 +486,17 @@ public class FrameworkTest {
CompositeData data = spiedMBean.updateBundlesFromURL(new long[] { 5 }, new String[] { "file:test.jar" });
Mockito.verify(bundle).update(stream);
BatchActionResult batch = BatchActionResult.from(data);
- Assert.assertEquals(5, batch.getCompleted()[0]);
- Assert.assertTrue(batch.isSuccess());
- Assert.assertNull(batch.getError());
- Assert.assertNull(batch.getRemainingItems());
+ assertEquals(5, batch.getCompleted()[0]);
+ assertTrue(batch.isSuccess());
+ assertNull(batch.getError());
+ assertNull(batch.getRemainingItems());
CompositeData data2 = spiedMBean.updateBundlesFromURL(new long[] { 2, 4 }, new String[] { "file:test.jar" });
BatchActionResult batch2 = BatchActionResult.from(data2);
- Assert.assertFalse(batch2.isSuccess());
- Assert.assertNotNull(batch2.getError());
- Assert.assertNotNull(batch2.getError());
- Assert.assertNull(batch2.getRemainingItems());
+ assertFalse(batch2.isSuccess());
+ assertNotNull(batch2.getError());
+ assertNotNull(batch2.getError());
+ assertNull(batch2.getRemainingItems());
}
@Test
diff --git a/jmx/jmx-core/src/test/java/org/apache/aries/jmx/framework/PackageStateTest.java b/jmx/jmx-core/src/test/java/org/apache/aries/jmx/framework/PackageStateTest.java
index afe5e038a..f54d32382 100644
--- a/jmx/jmx-core/src/test/java/org/apache/aries/jmx/framework/PackageStateTest.java
+++ b/jmx/jmx-core/src/test/java/org/apache/aries/jmx/framework/PackageStateTest.java
@@ -22,7 +22,6 @@ import java.util.Collection;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.TabularData;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@@ -35,6 +34,11 @@ import org.osgi.jmx.framework.PackageStateMBean;
import org.osgi.service.packageadmin.ExportedPackage;
import org.osgi.service.packageadmin.PackageAdmin;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
/**
* {@link PackageStateMBean} test case.
*
@@ -70,8 +74,8 @@ public class PackageStateTest {
Mockito.when(bundle2.getBundleId()).thenReturn(Long.valueOf(6));
Mockito.when(admin.getExportedPackages(Mockito.anyString())).thenReturn(new ExportedPackage[]{exported, exported2});
long[] ids = mbean.getExportingBundles("test", "1.0.0");
- Assert.assertNotNull(ids);
- Assert.assertArrayEquals(new long[]{5,6}, ids);
+ assertNotNull(ids);
+ assertArrayEquals(new long[]{5,6}, ids);
}
@Test
@@ -86,7 +90,7 @@ public class PackageStateTest {
Mockito.when(bundle.getBundleId()).thenReturn(Long.valueOf(4));
Mockito.when(admin.getExportedPackages(Mockito.anyString())).thenReturn(new ExportedPackage[]{exported});
long[] ids = mbean.getImportingBundles("test", "1.0.0", 2);
- Assert.assertArrayEquals(new long[]{4}, ids);
+ assertArrayEquals(new long[]{4}, ids);
}
@Test
@@ -99,7 +103,7 @@ public class PackageStateTest {
Mockito.when(expBundle.getBundleId()).thenReturn(Long.valueOf(2));
Mockito.when(admin.getExportedPackages(Mockito.anyString())).thenReturn(new ExportedPackage[]{exported});
boolean isRemoval = mbean.isRemovalPending("test", "1.0.0", Long.valueOf(2));
- Assert.assertTrue(isRemoval);
+ assertTrue(isRemoval);
}
@Test
@@ -116,16 +120,16 @@ public class PackageStateTest {
Mockito.when(impBundle.getBundleId()).thenReturn(Long.valueOf(5));
Mockito.when(admin.getExportedPackages(bundle)).thenReturn(new ExportedPackage[]{exported});
TabularData table = mbean.listPackages();
- Assert.assertEquals(PackageStateMBean.PACKAGES_TYPE,table.getTabularType());
+ assertEquals(PackageStateMBean.PACKAGES_TYPE,table.getTabularType());
Collection values = table.values();
- Assert.assertEquals(1, values.size());
+ assertEquals(1, values.size());
CompositeData data = (CompositeData) values.iterator().next();
Long[] exportingBundles = (Long[])data.get(PackageStateMBean.EXPORTING_BUNDLES);
- Assert.assertArrayEquals(new Long[]{Long.valueOf(4)}, exportingBundles);
+ assertArrayEquals(new Long[]{Long.valueOf(4)}, exportingBundles);
String name = (String) data.get(PackageStateMBean.NAME);
- Assert.assertEquals("test", name);
+ assertEquals("test", name);
String version = (String) data.get(PackageStateMBean.VERSION);
- Assert.assertEquals("1.0.0", version);
+ assertEquals("1.0.0", version);
}
}
diff --git a/jmx/jmx-core/src/test/java/org/apache/aries/jmx/permissionadmin/PermissionAdminTest.java b/jmx/jmx-core/src/test/java/org/apache/aries/jmx/permissionadmin/PermissionAdminTest.java
index 6d047411e..08d118382 100644
--- a/jmx/jmx-core/src/test/java/org/apache/aries/jmx/permissionadmin/PermissionAdminTest.java
+++ b/jmx/jmx-core/src/test/java/org/apache/aries/jmx/permissionadmin/PermissionAdminTest.java
@@ -18,7 +18,6 @@ package org.apache.aries.jmx.permissionadmin;
import java.io.IOException;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@@ -27,6 +26,12 @@ import org.mockito.MockitoAnnotations;
import org.osgi.jmx.service.permissionadmin.PermissionAdminMBean;
import org.osgi.service.permissionadmin.PermissionInfo;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+
/**
* {@link PermissionAdminMBean} test case.
*
@@ -53,16 +58,16 @@ public class PermissionAdminTest {
Mockito.when(permAdmin.getPermissions(Mockito.anyString())).thenReturn(permInfos);
String[] permissions = mbean.getPermissions("test");
- Assert.assertNotNull(permissions);
- Assert.assertEquals(2, permissions.length);
- Assert.assertArrayEquals("Checks encoded permissions", new String[] { info.getEncoded(), info.getEncoded() },
+ assertNotNull(permissions);
+ assertEquals(2, permissions.length);
+ assertArrayEquals("Checks encoded permissions", new String[] { info.getEncoded(), info.getEncoded() },
permissions);
Mockito.reset(permAdmin);
Mockito.when(permAdmin.getPermissions(Mockito.anyString())).thenReturn(null);
String[] permissions2 = mbean.getPermissions("test");
- Assert.assertNull(permissions2);
+ assertNull(permissions2);
}
@Test
@@ -73,16 +78,16 @@ public class PermissionAdminTest {
Mockito.when(permAdmin.getDefaultPermissions()).thenReturn(permInfos);
String[] permissions = mbean.listDefaultPermissions();
- Assert.assertNotNull(permissions);
- Assert.assertEquals(2, permissions.length);
- Assert.assertArrayEquals("Checks encoded default permissions", new String[] { info.getEncoded(), info.getEncoded() },
+ assertNotNull(permissions);
+ assertEquals(2, permissions.length);
+ assertArrayEquals("Checks encoded default permissions", new String[] { info.getEncoded(), info.getEncoded() },
permissions);
Mockito.reset(permAdmin);
Mockito.when(permAdmin.getDefaultPermissions()).thenReturn(null);
String[] permissions2 = mbean.listDefaultPermissions();
- Assert.assertNull(permissions2);
+ assertNull(permissions2);
}
@Test
@@ -90,9 +95,9 @@ public class PermissionAdminTest {
String[] locations1 = new String[] { "test1", "test2" };
Mockito.when(permAdmin.getLocations()).thenReturn(locations1);
String[] locations2 = mbean.listLocations();
- Assert.assertNotNull(locations2);
- Assert.assertEquals(2, locations2.length);
- Assert.assertSame(locations1, locations2);
+ assertNotNull(locations2);
+ assertEquals(2, locations2.length);
+ assertSame(locations1, locations2);
}
@Test
diff --git a/jmx/jmx-core/src/test/java/org/apache/aries/jmx/useradmin/UserAdminTest.java b/jmx/jmx-core/src/test/java/org/apache/aries/jmx/useradmin/UserAdminTest.java
index 47488ca67..33cdbbfce 100644
--- a/jmx/jmx-core/src/test/java/org/apache/aries/jmx/useradmin/UserAdminTest.java
+++ b/jmx/jmx-core/src/test/java/org/apache/aries/jmx/useradmin/UserAdminTest.java
@@ -27,7 +27,6 @@ import org.apache.aries.jmx.codec.AuthorizationData;
import org.apache.aries.jmx.codec.GroupData;
import org.apache.aries.jmx.codec.RoleData;
import org.apache.aries.jmx.codec.UserData;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@@ -39,6 +38,12 @@ import org.osgi.service.useradmin.Group;
import org.osgi.service.useradmin.Role;
import org.osgi.service.useradmin.User;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
+
/**
* UserAdminMBean test case.
*
@@ -73,7 +78,7 @@ public class UserAdminTest {
Mockito.when(user1.getType()).thenReturn(Role.USER);
Mockito.when(user1.getCredentials()).thenReturn(credentials);
mbean.addCredential("password", new byte[] { 1, 2 }, "user1");
- Assert.assertArrayEquals(new byte[] { 1, 2 }, (byte[]) credentials.get("password"));
+ assertArrayEquals(new byte[] { 1, 2 }, (byte[]) credentials.get("password"));
}
@@ -92,7 +97,7 @@ public class UserAdminTest {
Mockito.when(user1.getType()).thenReturn(Role.USER);
Mockito.when(user1.getCredentials()).thenReturn(credentials);
mbean.addCredentialString("password", "1234", "user1");
- Assert.assertEquals("1234", (String) credentials.get("password"));
+ assertEquals("1234", (String) credentials.get("password"));
}
/**
@@ -109,7 +114,7 @@ public class UserAdminTest {
Mockito.when(group1.getType()).thenReturn(Role.GROUP);
Mockito.when(group1.addMember(user1)).thenReturn(true);
boolean isAdded = mbean.addMember("group1", "user1");
- Assert.assertTrue(isAdded);
+ assertTrue(isAdded);
Mockito.verify(group1).addMember(user1);
}
@@ -128,7 +133,7 @@ public class UserAdminTest {
Mockito.when(user1.getType()).thenReturn(Role.USER);
Mockito.when(user1.getProperties()).thenReturn(props);
mbean.addPropertyString("key", "1234", "user1");
- Assert.assertEquals("1234", (String) props.get("key"));
+ assertEquals("1234", (String) props.get("key"));
}
/**
@@ -145,7 +150,7 @@ public class UserAdminTest {
Mockito.when(user1.getType()).thenReturn(Role.USER);
Mockito.when(user1.getProperties()).thenReturn(props);
mbean.addProperty("key", new byte[] { 1, 2 }, "user1");
- Assert.assertArrayEquals(new byte[] { 1, 2 }, (byte[]) props.get("key"));
+ assertArrayEquals(new byte[] { 1, 2 }, (byte[]) props.get("key"));
}
/**
@@ -163,7 +168,7 @@ public class UserAdminTest {
Mockito.when(group1.getType()).thenReturn(Role.GROUP);
Mockito.when(group1.addRequiredMember(user1)).thenReturn(true);
boolean isAdded = mbean.addRequiredMember("group1", "user1");
- Assert.assertTrue(isAdded);
+ assertTrue(isAdded);
Mockito.verify(group1).addRequiredMember(user1);
}
@@ -185,12 +190,7 @@ public class UserAdminTest {
*/
@Test
public void testCreateRole() throws IOException {
- try {
- mbean.createRole("role1");
- Assert.fail("Function did not throw exception as expected");
- } catch (IOException e) {
- // expected
- }
+ assertThrows(IOException.class, () -> mbean.createRole("role1"));
}
/**
@@ -219,11 +219,11 @@ public class UserAdminTest {
Mockito.when(auth.getName()).thenReturn("auth1");
Mockito.when(auth.getRoles()).thenReturn(new String[]{"role1"});
CompositeData data = mbean.getAuthorization("role1");
- Assert.assertNotNull(data);
+ assertNotNull(data);
AuthorizationData authData = AuthorizationData.from(data);
- Assert.assertNotNull(authData);
- Assert.assertEquals("auth1", authData.getName());
- Assert.assertArrayEquals(new String[] { "role1" }, authData.getRoles());
+ assertNotNull(authData);
+ assertEquals("auth1", authData.getName());
+ assertArrayEquals(new String[] { "role1" }, authData.getRoles());
}
/**
@@ -240,12 +240,12 @@ public class UserAdminTest {
Mockito.when(user1.getType()).thenReturn(Role.USER);
Mockito.when(userAdmin.getRole(Mockito.anyString())).thenReturn(user1);
TabularData data = mbean.getCredentials("user1");
- Assert.assertNotNull(data);
- Assert.assertEquals(JmxConstants.PROPERTIES_TYPE, data.getTabularType());
+ assertNotNull(data);
+ assertEquals(JmxConstants.PROPERTIES_TYPE, data.getTabularType());
CompositeData composite = data.get(new Object[] { "key" });
- Assert.assertNotNull(composite);
- Assert.assertEquals("key", (String) composite.get(JmxConstants.KEY));
- Assert.assertEquals("value", (String) composite.get(JmxConstants.VALUE));
+ assertNotNull(composite);
+ assertEquals("key", (String) composite.get(JmxConstants.KEY));
+ assertEquals("value", (String) composite.get(JmxConstants.VALUE));
}
/**
@@ -266,13 +266,13 @@ public class UserAdminTest {
Mockito.when(group1.getMembers()).thenReturn(new Role[] { role2 });
Mockito.when(userAdmin.getRole(Mockito.anyString())).thenReturn(group1);
CompositeData data = mbean.getGroup("group1");
- Assert.assertNotNull(data);
+ assertNotNull(data);
GroupData group = GroupData.from(data);
- Assert.assertNotNull(group);
- Assert.assertEquals("group1", group.getName());
- Assert.assertEquals(Role.GROUP, group.getType());
- Assert.assertArrayEquals(new String[] { "role2" }, group.getMembers());
- Assert.assertArrayEquals(new String[] { "role1" }, group.getRequiredMembers());
+ assertNotNull(group);
+ assertEquals("group1", group.getName());
+ assertEquals(Role.GROUP, group.getType());
+ assertArrayEquals(new String[] { "role2" }, group.getMembers());
+ assertArrayEquals(new String[] { "role1" }, group.getRequiredMembers());
Mockito.verify(userAdmin).getRole(Mockito.anyString());
}
@@ -288,7 +288,7 @@ public class UserAdminTest {
Mockito.when(group1.getName()).thenReturn("group1");
Mockito.when(userAdmin.getRoles("name=group1")).thenReturn(new Role[] { group1 });
String[] groups = mbean.getGroups("name=group1");
- Assert.assertArrayEquals(new String[] { "group1" }, groups);
+ assertArrayEquals(new String[] { "group1" }, groups);
}
/**
@@ -305,7 +305,7 @@ public class UserAdminTest {
Mockito.when(userAdmin.getRole("role1")).thenReturn(user1);
Mockito.when(userAdmin.getAuthorization(user1)).thenReturn(auth);
String[] roles = mbean.getImpliedRoles("role1");
- Assert.assertArrayEquals(new String[] { "role1" }, roles);
+ assertArrayEquals(new String[] { "role1" }, roles);
}
/**
@@ -323,7 +323,7 @@ public class UserAdminTest {
Mockito.when(group1.getMembers()).thenReturn(new Role[] { user1 });
Mockito.when(userAdmin.getRole("group1")).thenReturn(group1);
String[] members = mbean.getMembers("group1");
- Assert.assertArrayEquals(new String[] { "user1" }, members);
+ assertArrayEquals(new String[] { "user1" }, members);
}
/**
@@ -339,12 +339,12 @@ public class UserAdminTest {
Mockito.when(user1.getProperties()).thenReturn(properties);
Mockito.when(userAdmin.getRole(Mockito.anyString())).thenReturn(user1);
TabularData data = mbean.getProperties("user1");
- Assert.assertNotNull(data);
- Assert.assertEquals(JmxConstants.PROPERTIES_TYPE, data.getTabularType());
+ assertNotNull(data);
+ assertEquals(JmxConstants.PROPERTIES_TYPE, data.getTabularType());
CompositeData composite = data.get(new Object[] { "key" });
- Assert.assertNotNull(composite);
- Assert.assertEquals("key", (String) composite.get(JmxConstants.KEY));
- Assert.assertEquals("value", (String) composite.get(JmxConstants.VALUE));
+ assertNotNull(composite);
+ assertEquals("key", (String) composite.get(JmxConstants.KEY));
+ assertEquals("value", (String) composite.get(JmxConstants.VALUE));
}
/**
@@ -362,7 +362,7 @@ public class UserAdminTest {
Mockito.when(group1.getRequiredMembers()).thenReturn(new Role[] { user1 });
Mockito.when(userAdmin.getRole("group1")).thenReturn(group1);
String[] members = mbean.getRequiredMembers("group1");
- Assert.assertArrayEquals(new String[] { "user1" }, members);
+ assertArrayEquals(new String[] { "user1" }, members);
}
/**
@@ -377,11 +377,11 @@ public class UserAdminTest {
Mockito.when(user1.getName()).thenReturn("user1");
Mockito.when(userAdmin.getRole(Mockito.anyString())).thenReturn(user1);
CompositeData data = mbean.getRole("user1");
- Assert.assertNotNull(data);
+ assertNotNull(data);
RoleData role = RoleData.from(data);
- Assert.assertNotNull(role);
- Assert.assertEquals("user1", role.getName());
- Assert.assertEquals(Role.USER, role.getType());
+ assertNotNull(role);
+ assertEquals("user1", role.getName());
+ assertEquals(Role.USER, role.getType());
Mockito.verify(userAdmin).getRole(Mockito.anyString());
}
@@ -397,7 +397,7 @@ public class UserAdminTest {
Mockito.when(user1.getName()).thenReturn("user1");
Mockito.when(userAdmin.getRoles("name=user1")).thenReturn(new Role[] { user1 });
String[] roles = mbean.getRoles("name=user1");
- Assert.assertArrayEquals(new String[] { "user1" }, roles);
+ assertArrayEquals(new String[] { "user1" }, roles);
}
/**
@@ -412,11 +412,11 @@ public class UserAdminTest {
Mockito.when(user1.getName()).thenReturn("user1");
Mockito.when(userAdmin.getRole(Mockito.anyString())).thenReturn(user1);
CompositeData data = mbean.getUser("user1");
- Assert.assertNotNull(data);
+ assertNotNull(data);
UserData user = UserData.from(data);
- Assert.assertNotNull(user);
- Assert.assertEquals("user1", user.getName());
- Assert.assertEquals(Role.USER, user.getType());
+ assertNotNull(user);
+ assertEquals("user1", user.getName());
+ assertEquals(Role.USER, user.getType());
Mockito.verify(userAdmin).getRole(Mockito.anyString());
}
@@ -432,7 +432,7 @@ public class UserAdminTest {
Mockito.when(user1.getName()).thenReturn("user1");
Mockito.when(userAdmin.getUser("key", "valuetest")).thenReturn(user1);
String username = mbean.getUserWithProperty("key", "valuetest");
- Assert.assertEquals(username, "user1");
+ assertEquals(username, "user1");
}
/**
@@ -447,7 +447,7 @@ public class UserAdminTest {
Mockito.when(user1.getName()).thenReturn("user1");
Mockito.when(userAdmin.getRoles("name=user1")).thenReturn(new Role[] { user1 });
String[] roles = mbean.getUsers("name=user1");
- Assert.assertArrayEquals(new String[] { "user1" }, roles);
+ assertArrayEquals(new String[] { "user1" }, roles);
}
/**
@@ -465,7 +465,7 @@ public class UserAdminTest {
Mockito.when(group2.getName()).thenReturn("group2");
Mockito.when(userAdmin.getRoles(null)).thenReturn(new Role[] { group1, group2 });
String[] groups = mbean.listGroups();
- Assert.assertArrayEquals(new String[] { "group1", "group2" }, groups);
+ assertArrayEquals(new String[] { "group1", "group2" }, groups);
}
/**
@@ -483,7 +483,7 @@ public class UserAdminTest {
Mockito.when(user2.getName()).thenReturn("user2");
Mockito.when(userAdmin.getRoles(null)).thenReturn(new Role[] { user1, user2 });
String[] roles = mbean.listRoles();
- Assert.assertArrayEquals(new String[] { "user1", "user2" }, roles);
+ assertArrayEquals(new String[] { "user1", "user2" }, roles);
}
/**
@@ -501,7 +501,7 @@ public class UserAdminTest {
Mockito.when(user2.getName()).thenReturn("user2");
Mockito.when(userAdmin.getRoles(null)).thenReturn(new Role[] { user1, user2 });
String[] roles = mbean.listUsers();
- Assert.assertArrayEquals(new String[] { "user1", "user2" }, roles);
+ assertArrayEquals(new String[] { "user1", "user2" }, roles);
}
/**
@@ -518,7 +518,7 @@ public class UserAdminTest {
Mockito.when(user1.getType()).thenReturn(Role.USER);
Mockito.when(user1.getCredentials()).thenReturn(cred);
mbean.removeCredential("key", "user1");
- Assert.assertEquals(0, cred.size());
+ assertEquals(0, cred.size());
}
/**
@@ -530,7 +530,7 @@ public class UserAdminTest {
public void testRemoveGroup() throws IOException {
Mockito.when(userAdmin.removeRole("group1")).thenReturn(true);
boolean isRemoved = mbean.removeGroup("group1");
- Assert.assertTrue(isRemoved);
+ assertTrue(isRemoved);
}
/**
@@ -548,7 +548,7 @@ public class UserAdminTest {
Mockito.when(group1.getType()).thenReturn(Role.GROUP);
Mockito.when(group1.removeMember(user1)).thenReturn(true);
boolean isAdded = mbean.removeMember("group1", "user1");
- Assert.assertTrue(isAdded);
+ assertTrue(isAdded);
Mockito.verify(group1).removeMember(user1);
}
@@ -566,7 +566,7 @@ public class UserAdminTest {
Mockito.when(user1.getType()).thenReturn(Role.USER);
Mockito.when(user1.getProperties()).thenReturn(props);
mbean.removeProperty("key", "user1");
- Assert.assertEquals(0, props.size());
+ assertEquals(0, props.size());
}
/**
@@ -578,7 +578,7 @@ public class UserAdminTest {
public void testRemoveRole() throws IOException {
Mockito.when(userAdmin.removeRole("role1")).thenReturn(true);
boolean isRemoved = mbean.removeRole("role1");
- Assert.assertTrue(isRemoved);
+ assertTrue(isRemoved);
}
/**
@@ -590,7 +590,7 @@ public class UserAdminTest {
public void testRemoveUser() throws IOException {
Mockito.when(userAdmin.removeRole("user1")).thenReturn(true);
boolean isRemoved = mbean.removeUser("user1");
- Assert.assertTrue(isRemoved);
+ assertTrue(isRemoved);
}
}
diff --git a/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java b/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java
index 1c4731706..10384bbb8 100644
--- a/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java
+++ b/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/ServiceStateMBeanTest.java
@@ -45,7 +45,6 @@ import org.apache.aries.jmx.AbstractIntegrationTest;
import org.apache.aries.jmx.codec.PropertyData;
import org.apache.aries.jmx.test.bundlea.api.InterfaceA;
import org.apache.aries.jmx.test.bundleb.api.InterfaceB;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.ops4j.pax.exam.Configuration;
diff --git a/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanTest.java b/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanTest.java
index 5f15c9f66..3c43c85fa 100644
--- a/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanTest.java
+++ b/jmx/jmx-itests/src/test/java/org/apache/aries/jmx/framework/wiring/BundleWiringStateMBeanTest.java
@@ -34,7 +34,6 @@ import javax.management.openmbean.TabularData;
import org.apache.aries.jmx.AbstractIntegrationTest;
import org.apache.aries.jmx.codec.PropertyData;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.ops4j.pax.exam.Configuration;
@@ -89,11 +88,11 @@ public class BundleWiringStateMBeanTest extends AbstractIntegrationTest {
List<BundleRequirement> requirements = br.getDeclaredRequirements(BundleRevision.PACKAGE_NAMESPACE);
CompositeData[] jmxRequirements = brsMBean.getCurrentRevisionDeclaredRequirements(a.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
- Assert.assertEquals(requirements.size(), jmxRequirements.length);
+ assertEquals(requirements.size(), jmxRequirements.length);
Map<Map<String, Object>, Map<String, String>> expectedRequirements = requirementsToMap(requirements);
Map<Map<String, Object>, Map<String, String>> actualRequirements = jmxCapReqToMap(jmxRequirements);
- Assert.assertEquals(expectedRequirements, actualRequirements);
+ assertEquals(expectedRequirements, actualRequirements);
}
@Test
@@ -102,21 +101,21 @@ public class BundleWiringStateMBeanTest extends AbstractIntegrationTest {
List<BundleCapability> capabilities = br.getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE);
CompositeData[] jmxCapabilities = brsMBean.getCurrentRevisionDeclaredCapabilities(bundleA.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
- Assert.assertEquals(capabilities.size(), jmxCapabilities.length);
+ assertEquals(capabilities.size(), jmxCapabilities.length);
Map<Map<String, Object>, Map<String, String>> expectedCapabilities = capabilitiesToMap(capabilities);
Map<Map<String, Object>, Map<String, String>> actualCapabilities = jmxCapReqToMap(jmxCapabilities);
- Assert.assertEquals(expectedCapabilities, actualCapabilities);
+ assertEquals(expectedCapabilities, actualCapabilities);
}
@Test
public void testGetRevisionsDeclaredRequirements() throws Exception {
BundleRevisions revisions = (BundleRevisions) bundleA.adapt(BundleRevisions.class);
- Assert.assertEquals("Precondition", 1, revisions.getRevisions().size());
+ assertEquals("Precondition", 1, revisions.getRevisions().size());
TabularData jmxRequirementsTable = brsMBean.getRevisionsDeclaredRequirements(bundleA.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
- Assert.assertEquals(1, jmxRequirementsTable.size());
+ assertEquals(1, jmxRequirementsTable.size());
List<BundleRequirement> requirements = ((BundleRevision) revisions.getRevisions().iterator().next()).getDeclaredRequirements(BundleRevision.PACKAGE_NAMESPACE);
CompositeData jmxRevRequirements = (CompositeData) jmxRequirementsTable.values().iterator().next();
@@ -124,17 +123,17 @@ public class BundleWiringStateMBeanTest extends AbstractIntegrationTest {
Map<Map<String, Object>, Map<String, String>> expectedRequirements = requirementsToMap(requirements);
Map<Map<String, Object>, Map<String, String>> actualRequirements = jmxCapReqToMap(jmxRequirements);
- Assert.assertEquals(expectedRequirements, actualRequirements);
+ assertEquals(expectedRequirements, actualRequirements);
}
@Test
public void testGetRevisionsDeclaredCapabilities() throws Exception {
BundleRevisions revisions = (BundleRevisions) bundleA.adapt(BundleRevisions.class);
- Assert.assertEquals("Precondition", 1, revisions.getRevisions().size());
+ assertEquals("Precondition", 1, revisions.getRevisions().size());
TabularData jmxCapabilitiesTable = brsMBean.getRevisionsDeclaredCapabilities(bundleA.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
- Assert.assertEquals(1, jmxCapabilitiesTable.size());
+ assertEquals(1, jmxCapabilitiesTable.size());
List<BundleCapability> capabilities = ((BundleRevision) revisions.getRevisions().iterator().next()).getDeclaredCapabilities(BundleRevision.PACKAGE_NAMESPACE);
CompositeData jmxRevCapabilities = (CompositeData) jmxCapabilitiesTable.values().iterator().next();
@@ -142,15 +141,15 @@ public class BundleWiringStateMBeanTest extends AbstractIntegrationTest {
Map<Map<String, Object>, Map<String, String>> expectedCapabilities = capabilitiesToMap(capabilities);
Map<Map<String, Object>, Map<String, String>> actualCapabilities = jmxCapReqToMap(jmxCapabilities);
- Assert.assertEquals(expectedCapabilities, actualCapabilities);
+ assertEquals(expectedCapabilities, actualCapabilities);
}
@Test
public void testGetCurrentWiring() throws Exception {
CompositeData jmxWiring = brsMBean.getCurrentWiring(bundleA.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
- Assert.assertEquals(BundleWiringStateMBean.BUNDLE_WIRING_TYPE, jmxWiring.getCompositeType());
- Assert.assertEquals(bundleA.getBundleId(), jmxWiring.get(BundleWiringStateMBean.BUNDLE_ID));
+ assertEquals(BundleWiringStateMBean.BUNDLE_WIRING_TYPE, jmxWiring.getCompositeType());
+ assertEquals(bundleA.getBundleId(), jmxWiring.get(BundleWiringStateMBean.BUNDLE_ID));
BundleWiring bw = (BundleWiring) bundleA.adapt(BundleWiring.class);
assertBundleWiring(bw, jmxWiring);
@@ -160,10 +159,10 @@ public class BundleWiringStateMBeanTest extends AbstractIntegrationTest {
public void testRevisionsWiring() throws Exception {
TabularData jmxWiringTable = brsMBean.getRevisionsWiring(bundleA.getBundleId(), BundleRevision.PACKAGE_NAMESPACE);
- Assert.assertEquals(1, jmxWiringTable.size());
+ assertEquals(1, jmxWiringTable.size());
CompositeData jmxWiring = (CompositeData) jmxWiringTable.values().iterator().next();
- Assert.assertEquals(BundleWiringStateMBean.BUNDLE_WIRING_TYPE, jmxWiring.getCompositeType());
- Assert.assertEquals(bundleA.getBundleId(), jmxWiring.get(BundleWiringStateMBean.BUNDLE_ID));
+ assertEquals(BundleWiringStateMBean.BUNDLE_WIRING_TYPE, jmxWiring.getCompositeType());
+ assertEquals(bundleA.getBundleId(), jmxWiring.get(BundleWiringStateMBean.BUNDLE_ID));
BundleWiring bw = (BundleWiring) bundleA.adapt(BundleWiring.class);
assertBundleWiring(bw, jmxWiring);
@@ -172,23 +171,23 @@ public class BundleWiringStateMBeanTest extends AbstractIntegrationTest {
private void assertBundleWiring(BundleWiring bundleWiring, CompositeData jmxWiring) {
CompositeData[] jmxCapabilities = (CompositeData[]) jmxWiring.get(BundleWiringStateMBean.CAPABILITIES);
List<BundleCapability> capabilities = bundleWiring.getCapabilities(BundleRevision.PACKAGE_NAMESPACE);
- Assert.assertEquals(capabilities.size(), jmxCapabilities.length);
+ assertEquals(capabilities.size(), jmxCapabilities.length);
Map<Map<String, Object>, Map<String, String>> expectedCapabilities = capabilitiesToMap(capabilities);
Map<Map<String, Object>, Map<String, String>> actualCapabilities = jmxCapReqToMap(jmxCapabilities);
- Assert.assertEquals(expectedCapabilities, actualCapabilities);
+ assertEquals(expectedCapabilities, actualCapabilities);
CompositeData[] jmxRequirements = (CompositeData[]) jmxWiring.get(BundleWiringStateMBean.REQUIREMENTS);
List<BundleRequirement> requirements = bundleWiring.getRequirements(BundleRevision.PACKAGE_NAMESPACE);
- Assert.assertEquals(requirements.size(), jmxRequirements.length);
+ assertEquals(requirements.size(), jmxRequirements.length);
Map<Map<String, Object>, Map<String, String>> expectedRequirements = requirementsToMap(requirements);
Map<Map<String, Object>, Map<String, String>> actualRequirements = jmxCapReqToMap(jmxRequirements);
- Assert.assertEquals(expectedRequirements, actualRequirements);
+ assertEquals(expectedRequirements, actualRequirements);
List<BundleWire> requiredWires = bundleWiring.getRequiredWires(BundleRevision.PACKAGE_NAMESPACE);
CompositeData[] jmxRequiredWires = (CompositeData[]) jmxWiring.get(BundleWiringStateMBean.REQUIRED_WIRES);
- Assert.assertEquals(requiredWires.size(), jmxRequiredWires.length);
+ assertEquals(requiredWires.size(), jmxRequiredWires.length);
Set<List<Object>> expectedRequiredWires = new HashSet<List<Object>>();
for (BundleWire wire : requiredWires) {
@@ -215,11 +214,11 @@ public class BundleWiringStateMBeanTest extends AbstractIntegrationTest {
data.add(getJmxDirectives((CompositeData) wire.get(BundleWiringStateMBean.BUNDLE_REQUIREMENT)));
actualRequiredWires.add(data);
}
- Assert.assertEquals(expectedRequiredWires, actualRequiredWires);
+ assertEquals(expectedRequiredWires, actualRequiredWires);
List<BundleWire> providedWires = bundleWiring.getProvidedWires(BundleRevision.PACKAGE_NAMESPACE);
CompositeData[] jmxProvidedWires = (CompositeData []) jmxWiring.get(BundleWiringStateMBean.PROVIDED_WIRES);
- Assert.assertEquals(providedWires.size(), jmxProvidedWires.length);
+ assertEquals(providedWires.size(), jmxProvidedWires.length);
HashSet<List<Object>> expectedProvidedWires = new HashSet<List<Object>>();
for (BundleWire wire : providedWires) {
@@ -244,7 +243,7 @@ public class BundleWiringStateMBeanTest extends AbstractIntegrationTest {
data.add(getJmxDirectives((CompositeData) wire.get(BundleWiringStateMBean.BUNDLE_REQUIREMENT)));
actualProvidedWires.add(data);
}
- Assert.assertEquals(expectedProvidedWires, actualProvidedWires);
+ assertEquals(expectedProvidedWires, actualProvidedWires);
}
@Test
diff --git a/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookGenericCapabilityTest.java b/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookGenericCapabilityTest.java
index 403a67ee1..8d7895129 100644
--- a/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookGenericCapabilityTest.java
+++ b/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookGenericCapabilityTest.java
@@ -49,7 +49,6 @@ import org.apache.aries.spifly.Streams;
import org.easymock.EasyMock;
import org.easymock.IAnswer;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -65,6 +64,12 @@ import org.osgi.framework.wiring.BundleWiring;
import aQute.bnd.header.Parameters;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
public class ClientWeavingHookGenericCapabilityTest {
DynamicWeavingActivator activator;
@@ -97,23 +102,23 @@ public class ClientWeavingHookGenericCapabilityTest {
// Weave the TestClient class.
URL clsUrl = getClass().getResource("TestClient.class");
- Assert.assertNotNull("Precondition", clsUrl);
+ assertNotNull("Precondition", clsUrl);
String clientClassName = "org.apache.aries.spifly.dynamic.TestClient";
WovenClass wc = new MyWovenClass(clsUrl, clientClassName, consumerBundle);
- Assert.assertEquals("Precondition", 0, wc.getDynamicImports().size());
+ assertEquals("Precondition", 0, wc.getDynamicImports().size());
wh.weave(wc);
- Assert.assertEquals(1, wc.getDynamicImports().size());
+ assertEquals(1, wc.getDynamicImports().size());
String di1 = "org.apache.aries.spifly";
String di = wc.getDynamicImports().get(0);
- Assert.assertTrue("Weaving should have added a dynamic import", di1.equals(di));
+ assertEquals("Weaving should have added a dynamic import", di1, di);
// Invoke the woven class and check that it properly sets the TCCL so that the
// META-INF/services/org.apache.aries.mytest.MySPI file from impl1 is visible.
Class<?> cls = wc.getDefinedClass();
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
- Assert.assertEquals(Collections.singleton("olleh"), result);
+ assertEquals(Collections.singleton("olleh"), result);
}
@Test
@@ -132,20 +137,20 @@ public class ClientWeavingHookGenericCapabilityTest {
// Weave the TestClient class.
URL clsUrl = getClass().getResource("TestClient.class");
- Assert.assertNotNull("Precondition", clsUrl);
+ assertNotNull("Precondition", clsUrl);
String clientClassName = "org.apache.aries.spifly.dynamic.TestClient";
WovenClass wc = new MyWovenClass(clsUrl, clientClassName, consumerBundle);
- Assert.assertEquals("Precondition", 0, wc.getDynamicImports().size());
+ assertEquals("Precondition", 0, wc.getDynamicImports().size());
wh.weave(wc);
- Assert.assertEquals(0, wc.getDynamicImports().size());
+ assertEquals(0, wc.getDynamicImports().size());
// Invoke the woven class and check that it properly sets the TCCL so that the
// META-INF/services/org.apache.aries.mytest.MySPI file from impl1 is visible.
Class<?> cls = wc.getDefinedClass();
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
- Assert.assertEquals(Collections.emptySet(), result);
+ assertEquals(Collections.emptySet(), result);
}
@Test
@@ -165,23 +170,23 @@ public class ClientWeavingHookGenericCapabilityTest {
// Weave the TestClient class.
URL clsUrl = getClass().getResource("TestClient.class");
- Assert.assertNotNull("Precondition", clsUrl);
+ assertNotNull("Precondition", clsUrl);
String clientClassName = "org.apache.aries.spifly.dynamic.TestClient";
WovenClass wc = new MyWovenClass(clsUrl, clientClassName, consumerBundle);
- Assert.assertEquals("Precondition", 0, wc.getDynamicImports().size());
+ assertEquals("Precondition", 0, wc.getDynamicImports().size());
wh.weave(wc);
- Assert.assertEquals(1, wc.getDynamicImports().size());
+ assertEquals(1, wc.getDynamicImports().size());
String di1 = "org.apache.aries.spifly";
String di = wc.getDynamicImports().get(0);
- Assert.assertTrue("Weaving should have added a dynamic import", di1.equals(di));
+ assertTrue("Weaving should have added a dynamic import", di1.equals(di));
// Invoke the woven class and check that it properly sets the TCCL so that the
// META-INF/services/org.apache.aries.mytest.MySPI file from impl1 is visible.
Class<?> cls = wc.getDefinedClass();
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
- Assert.assertEquals(Collections.singleton("olleh"), result);
+ assertEquals(Collections.singleton("olleh"), result);
}
@Test
@@ -221,23 +226,23 @@ public class ClientWeavingHookGenericCapabilityTest {
// Weave the TestClient class.
URL clsUrl = getClass().getResource("TestClient.class");
- Assert.assertNotNull("Precondition", clsUrl);
+ assertNotNull("Precondition", clsUrl);
String clientClassName = "org.apache.aries.spifly.dynamic.TestClient";
WovenClass wc = new MyWovenClass(clsUrl, clientClassName, consumerBundle);
- Assert.assertEquals("Precondition", 0, wc.getDynamicImports().size());
+ assertEquals("Precondition", 0, wc.getDynamicImports().size());
wh.weave(wc);
- Assert.assertEquals(1, wc.getDynamicImports().size());
+ assertEquals(1, wc.getDynamicImports().size());
String di1 = "org.apache.aries.spifly";
String di = wc.getDynamicImports().get(0);
- Assert.assertTrue("Weaving should have added a dynamic import", di1.equals(di));
+ assertTrue("Weaving should have added a dynamic import", di1.equals(di));
// Invoke the woven class and check that it properly sets the TCCL so that the
// META-INF/services/org.apache.aries.mytest.MySPI file from impl1 is visible.
Class<?> cls = wc.getDefinedClass();
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
- Assert.assertEquals(Collections.singleton("olleh"), result);
+ assertEquals(Collections.singleton("olleh"), result);
}
@@ -246,7 +251,7 @@ public class ClientWeavingHookGenericCapabilityTest {
public void testTCCLResetting() throws Exception {
ClassLoader cl = new URLClassLoader(new URL [] {});
Thread.currentThread().setContextClassLoader(cl);
- Assert.assertSame("Precondition", cl, Thread.currentThread().getContextClassLoader());
+ assertSame("Precondition", cl, Thread.currentThread().getContextClassLoader());
Dictionary<String, String> consumerHeaders = new Hashtable<String, String>();
consumerHeaders.put(SpiFlyConstants.REQUIRE_CAPABILITY, SpiFlyConstants.CLIENT_REQUIREMENT);
@@ -263,16 +268,16 @@ public class ClientWeavingHookGenericCapabilityTest {
// Weave the TestClient class.
URL clsUrl = getClass().getResource("TestClient.class");
- Assert.assertNotNull("Precondition", clsUrl);
+ assertNotNull("Precondition", clsUrl);
String clientClassName = "org.apache.aries.spifly.dynamic.TestClient";
WovenClass wc = new MyWovenClass(clsUrl, clientClassName, consumerBundle);
- Assert.assertEquals("Precondition", 0, wc.getDynamicImports().size());
+ assertEquals("Precondition", 0, wc.getDynamicImports().size());
wh.weave(wc);
- Assert.assertEquals(1, wc.getDynamicImports().size());
+ assertEquals(1, wc.getDynamicImports().size());
String di1 = "org.apache.aries.spifly";
String di = wc.getDynamicImports().get(0);
- Assert.assertTrue("Weaving should have added a dynamic import", di1.equals(di));
+ assertTrue("Weaving should have added a dynamic import", di1.equals(di));
// Invoke the woven class and check that it properly sets the TCCL so that the
// META-INF/services/org.apache.aries.mytest.MySPI file from impl1 is visible.
@@ -280,7 +285,7 @@ public class ClientWeavingHookGenericCapabilityTest {
Method method = cls.getMethod("test", new Class [] {String.class});
method.invoke(cls.getDeclaredConstructor().newInstance(), "hi there");
- Assert.assertSame(cl, Thread.currentThread().getContextClassLoader());
+ assertSame(cl, Thread.currentThread().getContextClassLoader());
}
@@ -288,7 +293,7 @@ public class ClientWeavingHookGenericCapabilityTest {
public void testTCCLResettingOnException() throws Exception {
ClassLoader cl = new URLClassLoader(new URL [] {});
Thread.currentThread().setContextClassLoader(cl);
- Assert.assertSame("Precondition", cl, Thread.currentThread().getContextClassLoader());
+ assertSame("Precondition", cl, Thread.currentThread().getContextClassLoader());
Dictionary<String, String> headers = new Hashtable<String, String>();
headers.put(SpiFlyConstants.REQUIRE_CAPABILITY, SpiFlyConstants.CLIENT_REQUIREMENT);
@@ -314,14 +319,14 @@ public class ClientWeavingHookGenericCapabilityTest {
// That implementation throws an exception, after which we are making sure that the TCCL is set back appropriately.
try {
method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
- Assert.fail("Invocation should have thrown an exception");
+ fail("Invocation should have thrown an exception");
} catch (InvocationTargetException ite) {
RuntimeException re = (RuntimeException) ite.getCause();
String msg = re.getMessage();
- Assert.assertEquals("Uh-oh: hello", msg);
+ assertEquals("Uh-oh: hello", msg);
// The TCCL should have been reset correctly
- Assert.assertSame(cl, Thread.currentThread().getContextClassLoader());
+ assertSame(cl, Thread.currentThread().getContextClassLoader());
}
}
@@ -337,12 +342,12 @@ public class ClientWeavingHookGenericCapabilityTest {
// Weave the TestClient class.
URL clsUrl = getClass().getResource("UnaffectedTestClient.class");
- Assert.assertNotNull("Precondition", clsUrl);
+ assertNotNull("Precondition", clsUrl);
WovenClass wc = new MyWovenClass(clsUrl, "org.apache.aries.spifly.dynamic.UnaffectedTestClient", consumerBundle);
- Assert.assertEquals("Precondition", 0, wc.getDynamicImports().size());
+ assertEquals("Precondition", 0, wc.getDynamicImports().size());
wh.weave(wc);
- Assert.assertEquals("The client is not affected so no additional imports should have been added",
+ assertEquals("The client is not affected so no additional imports should have been added",
0, wc.getDynamicImports().size());
// ok the weaving is done, now prepare the registry for the call
@@ -354,7 +359,7 @@ public class ClientWeavingHookGenericCapabilityTest {
Class<?> cls = wc.getDefinedClass();
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
- Assert.assertEquals("impl4", result);
+ assertEquals("impl4", result);
}
@Test
@@ -386,7 +391,7 @@ public class ClientWeavingHookGenericCapabilityTest {
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
Set<String> expected = new HashSet<String>(Arrays.asList("olleh", "HELLO", "5"));
- Assert.assertEquals("All three services should be invoked", expected, result);
+ assertEquals("All three services should be invoked", expected, result);
}
/* This is currently not supported in the generic model
@@ -514,7 +519,7 @@ public class ClientWeavingHookGenericCapabilityTest {
Class<?> cls = wc.getDefinedClass();
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
- Assert.assertEquals("No providers should be selected for this one", Collections.emptySet(), result);
+ assertEquals("No providers should be selected for this one", Collections.emptySet(), result);
// Weave the AltTestClient class.
URL cls2Url = getClass().getResource("AltTestClient.class");
@@ -525,7 +530,7 @@ public class ClientWeavingHookGenericCapabilityTest {
Class<?> cls2 = wc2.getDefinedClass();
Method method2 = cls2.getMethod("test", new Class [] {long.class});
Object result2 = method2.invoke(cls2.getDeclaredConstructor().newInstance(), 4096);
- Assert.assertEquals("All Providers should be selected", (4096L*4096L)-4096L, result2);
+ assertEquals("All Providers should be selected", (4096L*4096L)-4096L, result2);
}
@@ -567,7 +572,7 @@ public class ClientWeavingHookGenericCapabilityTest {
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
Set<String> expected = new HashSet<String>(Arrays.asList("olleh", "HELLO", "5", "impl4"));
- Assert.assertEquals("All providers should be selected for this one", expected, result);
+ assertEquals("All providers should be selected for this one", expected, result);
// Weave the AltTestClient class.
URL cls2Url = getClass().getResource("AltTestClient.class");
@@ -578,7 +583,7 @@ public class ClientWeavingHookGenericCapabilityTest {
Class<?> cls2 = wc2.getDefinedClass();
Method method2 = cls2.getMethod("test", new Class [] {long.class});
Object result2 = method2.invoke(cls2.getDeclaredConstructor().newInstance(), 4096);
- Assert.assertEquals("Only the services from bundle impl4 should be selected", -4096L, result2);
+ assertEquals("Only the services from bundle impl4 should be selected", -4096L, result2);
}
@Test
@@ -617,7 +622,7 @@ public class ClientWeavingHookGenericCapabilityTest {
Class<?> cls = wc.getDefinedClass();
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
- Assert.assertEquals("No providers should be selected here", Collections.emptySet(), result);
+ assertEquals("No providers should be selected here", Collections.emptySet(), result);
// Weave the AltTestClient class.
URL cls2Url = getClass().getResource("AltTestClient.class");
@@ -628,7 +633,7 @@ public class ClientWeavingHookGenericCapabilityTest {
Class<?> cls2 = wc2.getDefinedClass();
Method method2 = cls2.getMethod("test", new Class [] {long.class});
Object result2 = method2.invoke(cls2.getDeclaredConstructor().newInstance(), 4096);
- Assert.assertEquals("Only the services from bundle impl4 should be selected", -4096L, result2);
+ assertEquals("Only the services from bundle impl4 should be selected", -4096L, result2);
}
@Test
@@ -665,7 +670,7 @@ public class ClientWeavingHookGenericCapabilityTest {
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
Set<String> expected = new HashSet<String>(Arrays.asList("HELLO", "5"));
- Assert.assertEquals("Only the services from bundle impl2 should be selected", expected, result);
+ assertEquals("Only the services from bundle impl2 should be selected", expected, result);
}
@Test
@@ -703,7 +708,7 @@ public class ClientWeavingHookGenericCapabilityTest {
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
Set<String> expected = new HashSet<String>(Arrays.asList("olleh"));
- Assert.assertEquals(expected, result);
+ assertEquals(expected, result);
}
private Bundle mockSpiFlyBundle(Bundle ... bundles) throws Exception {
diff --git a/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookOSGi43Test.java b/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookOSGi43Test.java
index 26b312af5..2666d6043 100644
--- a/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookOSGi43Test.java
+++ b/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookOSGi43Test.java
@@ -45,7 +45,6 @@ import org.apache.aries.spifly.Streams;
import org.easymock.EasyMock;
import org.easymock.IAnswer;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -57,6 +56,9 @@ import org.osgi.framework.hooks.weaving.WovenClass;
import org.osgi.framework.wiring.BundleRevision;
import org.osgi.framework.wiring.BundleWiring;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
public class ClientWeavingHookOSGi43Test {
DynamicWeavingActivator activator;
@@ -89,23 +91,23 @@ public class ClientWeavingHookOSGi43Test {
// Weave the TestClient class.
URL clsUrl = getClass().getResource("TestClient.class");
- Assert.assertNotNull("Precondition", clsUrl);
+ assertNotNull("Precondition", clsUrl);
String clientClassName = "org.apache.aries.spifly.dynamic.TestClient";
WovenClass wc = new MyWovenClass(clsUrl, clientClassName, consumerBundle);
- Assert.assertEquals("Precondition", 0, wc.getDynamicImports().size());
+ assertEquals("Precondition", 0, wc.getDynamicImports().size());
wh.weave(wc);
- Assert.assertEquals(1, wc.getDynamicImports().size());
+ assertEquals(1, wc.getDynamicImports().size());
String di1 = "org.apache.aries.spifly";
String di = wc.getDynamicImports().get(0);
- Assert.assertTrue("Weaving should have added a dynamic import", di1.equals(di));
+ assertEquals("Weaving should have added a dynamic import", di1, di);
// Invoke the woven class and check that it properly sets the TCCL so that the
// META-INF/services/org.apache.aries.mytest.MySPI file from impl1 is visible.
Class<?> cls = wc.getDefinedClass();
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
- Assert.assertEquals(Collections.singleton("olleh"), result);
+ assertEquals(Collections.singleton("olleh"), result);
}
private Bundle mockSpiFlyBundle(String bsn, Version version, Bundle ... bundles) throws Exception {
diff --git a/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookTest.java b/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookTest.java
index 664c5dc94..693ff1f65 100644
--- a/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookTest.java
+++ b/spi-fly/spi-fly-dynamic-bundle/src/test/java/org/apache/aries/spifly/dynamic/ClientWeavingHookTest.java
@@ -50,7 +50,6 @@ import org.apache.aries.spifly.Streams;
import org.easymock.EasyMock;
import org.easymock.IAnswer;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -62,6 +61,11 @@ import org.osgi.framework.hooks.weaving.WovenClass;
import org.osgi.framework.wiring.BundleRevision;
import org.osgi.framework.wiring.BundleWiring;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
public class ClientWeavingHookTest {
DynamicWeavingActivator activator;
@@ -96,23 +100,23 @@ public class ClientWeavingHookTest {
// Weave the TestClient class.
URL clsUrl = getClass().getResource("TestClient.class");
- Assert.assertNotNull("Precondition", clsUrl);
+ assertNotNull("Precondition", clsUrl);
String clientClassName = "org.apache.aries.spifly.dynamic.TestClient";
WovenClass wc = new MyWovenClass(clsUrl, clientClassName, consumerBundle);
- Assert.assertEquals("Precondition", 0, wc.getDynamicImports().size());
+ assertEquals("Precondition", 0, wc.getDynamicImports().size());
wh.weave(wc);
- Assert.assertEquals(1, wc.getDynamicImports().size());
+ assertEquals(1, wc.getDynamicImports().size());
String di1 = "org.apache.aries.spifly";
String di = wc.getDynamicImports().get(0);
- Assert.assertTrue("Weaving should have added a dynamic import", di1.equals(di));
+ assertEquals("Weaving should have added a dynamic import", di1, di);
// Invoke the woven class and check that it properly sets the TCCL so that the
// META-INF/services/org.apache.aries.mytest.MySPI file from impl1 is visible.
Class<?> cls = wc.getDefinedClass();
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
- Assert.assertEquals(Collections.singleton("olleh"), result);
+ assertEquals(Collections.singleton("olleh"), result);
}
@Test
@@ -132,16 +136,16 @@ public class ClientWeavingHookTest {
// Weave the TestClient class.
URL clsUrl = getClass().getResource("TestClient3$EnumLoader.class");
- Assert.assertNotNull("Precondition", clsUrl);
+ assertNotNull("Precondition", clsUrl);
String clientClassName = "org.apache.aries.spifly.dynamic.TestClient3$EnumLoader";
WovenClass wc = new MyWovenClass(clsUrl, clientClassName, consumerBundle);
- Assert.assertEquals("Precondition", 0, wc.getDynamicImports().size());
+ assertEquals("Precondition", 0, wc.getDynamicImports().size());
wh.weave(wc);
- Assert.assertEquals(1, wc.getDynamicImports().size());
+ assertEquals(1, wc.getDynamicImports().size());
String di1 = "org.apache.aries.spifly";
String di = wc.getDynamicImports().get(0);
- Assert.assertTrue("Weaving should have added a dynamic import", di1.equals(di));
+ assertTrue("Weaving should have added a dynamic import", di1.equals(di));
// Invoke the woven class and check that it properly sets the TCCL so that the
// META-INF/services/org.apache.aries.mytest.MySPI file from impl1 is visible.
@@ -149,10 +153,10 @@ public class ClientWeavingHookTest {
Method method = cls.getMethod("load", new Class [] {Class.class});
@SuppressWarnings({ "unchecked", "rawtypes" })
Object result = method.invoke(Enum.valueOf((Class<? extends Enum>)cls, "INSTANCE"), MySPI.class);
- Assert.assertTrue("Either null or not a MySPI", result instanceof MySPI);
+ assertTrue("Either null or not a MySPI", result instanceof MySPI);
MySPI instance = (MySPI)result;
String someMethod = instance.someMethod("Hello");
- Assert.assertEquals("olleH", someMethod);
+ assertEquals("olleH", someMethod);
}
@Test
@@ -172,23 +176,23 @@ public class ClientWeavingHookTest {
// Weave the TestClient class.
URL clsUrl = getClass().getResource("TestClient.class");
- Assert.assertNotNull("Precondition", clsUrl);
+ assertNotNull("Precondition", clsUrl);
String clientClassName = "org.apache.aries.spifly.dynamic.TestClient";
WovenClass wc = new MyWovenClass(clsUrl, clientClassName, consumerBundle);
- Assert.assertEquals("Precondition", 0, wc.getDynamicImports().size());
+ assertEquals("Precondition", 0, wc.getDynamicImports().size());
wh.weave(wc);
- Assert.assertEquals(1, wc.getDynamicImports().size());
+ assertEquals(1, wc.getDynamicImports().size());
String di1 = "org.apache.aries.spifly";
String di = wc.getDynamicImports().get(0);
- Assert.assertTrue("Weaving should have added a dynamic import", di1.equals(di));
+ assertTrue("Weaving should have added a dynamic import", di1.equals(di));
// Invoke the woven class and check that it properly sets the TCCL so that the
// META-INF/services/org.apache.aries.mytest.MySPI file from impl1 is visible.
Class<?> cls = wc.getDefinedClass();
Method method = cls.getMethod("testService2", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
- Assert.assertEquals(Collections.singleton("olleh"), result);
+ assertEquals(Collections.singleton("olleh"), result);
}
@Test
@@ -208,30 +212,30 @@ public class ClientWeavingHookTest {
// Weave the TestClient class.
URL clsUrl = getClass().getResource("TestClient2.class");
- Assert.assertNotNull("Precondition", clsUrl);
+ assertNotNull("Precondition", clsUrl);
String clientClassName = "org.apache.aries.spifly.dynamic.TestClient2";
WovenClass wc = new MyWovenClass(clsUrl, clientClassName, consumerBundle);
- Assert.assertEquals("Precondition", 0, wc.getDynamicImports().size());
+ assertEquals("Precondition", 0, wc.getDynamicImports().size());
wh.weave(wc);
- Assert.assertEquals(1, wc.getDynamicImports().size());
+ assertEquals(1, wc.getDynamicImports().size());
String di1 = "org.apache.aries.spifly";
String di = wc.getDynamicImports().get(0);
- Assert.assertTrue("Weaving should have added a dynamic import", di1.equals(di));
+ assertTrue("Weaving should have added a dynamic import", di1.equals(di));
// Invoke the woven class and check that it properly sets the TCCL so that the
// META-INF/services/org.apache.aries.mytest.MySPI file from impl1 is visible.
Class<?> cls = wc.getDefinedClass();
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
- Assert.assertEquals(Collections.singleton("olleh"), result);
+ assertEquals(Collections.singleton("olleh"), result);
}
@Test
public void testTCCLResetting() throws Exception {
ClassLoader cl = new URLClassLoader(new URL [] {});
Thread.currentThread().setContextClassLoader(cl);
- Assert.assertSame("Precondition", cl, Thread.currentThread().getContextClassLoader());
+ assertSame("Precondition", cl, Thread.currentThread().getContextClassLoader());
Dictionary<String, String> consumerHeaders = new Hashtable<String, String>();
consumerHeaders.put(SpiFlyConstants.SPI_CONSUMER_HEADER, "*");
@@ -248,16 +252,16 @@ public class ClientWeavingHookTest {
// Weave the TestClient class.
URL clsUrl = getClass().getResource("TestClient.class");
- Assert.assertNotNull("Precondition", clsUrl);
+ assertNotNull("Precondition", clsUrl);
String clientClassName = "org.apache.aries.spifly.dynamic.TestClient";
WovenClass wc = new MyWovenClass(clsUrl, clientClassName, consumerBundle);
- Assert.assertEquals("Precondition", 0, wc.getDynamicImports().size());
+ assertEquals("Precondition", 0, wc.getDynamicImports().size());
wh.weave(wc);
- Assert.assertEquals(1, wc.getDynamicImports().size());
+ assertEquals(1, wc.getDynamicImports().size());
String di1 = "org.apache.aries.spifly";
String di = wc.getDynamicImports().get(0);
- Assert.assertTrue("Weaving should have added a dynamic import", di1.equals(di));
+ assertTrue("Weaving should have added a dynamic import", di1.equals(di));
// Invoke the woven class and check that it properly sets the TCCL so that the
// META-INF/services/org.apache.aries.mytest.MySPI file from impl1 is visible.
@@ -265,7 +269,7 @@ public class ClientWeavingHookTest {
Method method = cls.getMethod("test", new Class [] {String.class});
method.invoke(cls.getDeclaredConstructor().newInstance(), "hi there");
- Assert.assertSame(cl, Thread.currentThread().getContextClassLoader());
+ assertSame(cl, Thread.currentThread().getContextClassLoader());
}
@Test
@@ -285,12 +289,12 @@ public class ClientWeavingHookTest {
// Weave the TestClient class.
URL clsUrl = getClass().getResource("UnaffectedTestClient.class");
- Assert.assertNotNull("Precondition", clsUrl);
+ assertNotNull("Precondition", clsUrl);
WovenClass wc = new MyWovenClass(clsUrl, "org.apache.aries.spifly.dynamic.UnaffectedTestClient", consumerBundle);
- Assert.assertEquals("Precondition", 0, wc.getDynamicImports().size());
+ assertEquals("Precondition", 0, wc.getDynamicImports().size());
wh.weave(wc);
- Assert.assertEquals("The client is not affected so no additional imports should have been added",
+ assertEquals("The client is not affected so no additional imports should have been added",
0, wc.getDynamicImports().size());
// ok the weaving is done, now prepare the registry for the call
@@ -302,7 +306,7 @@ public class ClientWeavingHookTest {
Class<?> cls = wc.getDefinedClass();
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
- Assert.assertEquals("impl4", result);
+ assertEquals("impl4", result);
}
@Test
@@ -334,7 +338,7 @@ public class ClientWeavingHookTest {
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
Set<String> expected = new HashSet<String>(Arrays.asList("olleh", "HELLO", "5"));
- Assert.assertEquals("All three services should be invoked", expected, result);
+ assertEquals("All three services should be invoked", expected, result);
}
@Test
@@ -364,7 +368,7 @@ public class ClientWeavingHookTest {
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
Set<String> expected = new HashSet<String>(Arrays.asList("HELLO", "5"));
- Assert.assertEquals("Only the services from bundle impl2 should be selected", expected, result);
+ assertEquals("Only the services from bundle impl2 should be selected", expected, result);
}
@Test
@@ -394,7 +398,7 @@ public class ClientWeavingHookTest {
Class<?> cls = wc.getDefinedClass();
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
- Assert.assertEquals("Only the services from bundle impl2 should be selected", Collections.singleton("Updated!hello!Updated"), result);
+ assertEquals("Only the services from bundle impl2 should be selected", Collections.singleton("Updated!hello!Updated"), result);
}
@Test
@@ -428,7 +432,7 @@ public class ClientWeavingHookTest {
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
Set<String> expected = new HashSet<String>(Arrays.asList("olleh", "impl4"));
- Assert.assertEquals("All providers should be selected for this one", expected, result);
+ assertEquals("All providers should be selected for this one", expected, result);
}
@Test
@@ -462,7 +466,7 @@ public class ClientWeavingHookTest {
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
Set<String> expected = new HashSet<String>(Arrays.asList("olleh", "impl4"));
- Assert.assertEquals("All providers should be selected for this one", expected, result);
+ assertEquals("All providers should be selected for this one", expected, result);
}
@Test
@@ -498,7 +502,7 @@ public class ClientWeavingHookTest {
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
Set<String> expected = new HashSet<String>(Arrays.asList("olleh", "impl4", "HELLO", "5"));
- Assert.assertEquals("All providers should be selected for this one", expected, result);
+ assertEquals("All providers should be selected for this one", expected, result);
// Weave the AltTestClient class.
URL cls2Url = getClass().getResource("AltTestClient.class");
@@ -509,7 +513,7 @@ public class ClientWeavingHookTest {
Class<?> cls2 = wc2.getDefinedClass();
Method method2 = cls2.getMethod("test", new Class [] {long.class});
Object result2 = method2.invoke(cls2.getDeclaredConstructor().newInstance(), 4096);
- Assert.assertEquals("Only the services from bundle impl4 should be selected", -4096L, result2);
+ assertEquals("Only the services from bundle impl4 should be selected", -4096L, result2);
}
@Test
@@ -568,7 +572,7 @@ public class ClientWeavingHookTest {
Class<?> cls = wc.getDefinedClass();
Method method = cls.getMethod("test", new Class [] {String.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello");
- Assert.assertEquals(testClientResult, result);
+ assertEquals(testClientResult, result);
URL clsUrl2 = getClass().getResource("JaxpClient.class");
WovenClass wc2 = new MyWovenClass(clsUrl2, JaxpClient.class.getName(), consumerBundle);
@@ -577,7 +581,7 @@ public class ClientWeavingHookTest {
Class<?> cls2 = wc2.getDefinedClass();
Method method2 = cls2.getMethod("test", new Class [] {});
Class<?> result2 = (Class<?>) method2.invoke(cls2.getDeclaredConstructor().newInstance());
- Assert.assertEquals(jaxpClientResult, result2.getName());
+ assertEquals(jaxpClientResult, result2.getName());
}
private void testConsumerBundleWeavingNonConst(Bundle consumerBundle, WeavingHook wh, Set<String> testClientResult, String jaxpClientResult) throws Exception {
@@ -591,7 +595,7 @@ public class ClientWeavingHookTest {
Class<?> cls = wc.getDefinedClass();
Method method = cls.getMethod("testService", new Class [] {String.class, Class.class});
Object result = method.invoke(cls.getDeclaredConstructor().newInstance(), "hello", MySPI.class);
- Assert.assertEquals(testClientResult, result);
+ assertEquals(testClientResult, result);
}
@Test
@@ -612,7 +616,7 @@ public class ClientWeavingHookTest {
Class<?> cls = wc.getDefinedClass();
Method method = cls.getMethod("test", new Class [] {});
Class<?> result = (Class<?>) method.invoke(cls.getDeclaredConstructor().newInstance());
- Assert.assertEquals("JAXP implementation from JRE", thisJVMsDBF, result.getName());
+ assertEquals("JAXP implementation from JRE", thisJVMsDBF, result.getName());
}
// If there is an alternate implementation it should always be favoured over the JRE one
@@ -637,7 +641,7 @@ public class ClientWeavingHookTest {
Class<?> cls = wc.getDefinedClass();
Method method = cls.getMethod("test", new Class [] {});
Class<?> result = (Class<?>) method.invoke(cls.getDeclaredConstructor().newInstance());
- Assert.assertEquals("JAXP implementation from JRE", "org.apache.aries.spifly.dynamic.impl3.MyAltDocumentBuilderFactory", result.getName());
+ assertEquals("JAXP implementation from JRE", "org.apache.aries.spifly.dynamic.impl3.MyAltDocumentBuilderFactory", result.getName());
}
@Test
@@ -661,7 +665,7 @@ public class ClientWeavingHookTest {
Class<?> cls = wc.getDefinedClass();
Method method = cls.getMethod("test", new Class [] {});
Class<?> result = (Class<?>) method.invoke(cls.getDeclaredConstructor().newInstance());
- Assert.assertEquals("JAXP implementation from JRE", thisJVMsDBF, result.getName());
+ assertEquals("JAXP implementation from JRE", thisJVMsDBF, result.getName());
}
@Test
@@ -685,7 +689,7 @@ public class ClientWeavingHookTest {
Class<?> cls = wc.getDefinedClass();
Method method = cls.getMethod("test", new Class [] {});
Class<?> result = (Class<?>) method.invoke(cls.getDeclaredConstructor().newInstance());
- Assert.assertEquals("JAXP implementation from alternative bundle", "org.apache.aries.spifly.dynamic.impl3.MyAltDocumentBuilderFactory", result.getName());
+ assertEquals("JAXP implementation from alternative bundle", "org.apache.aries.spifly.dynamic.impl3.MyAltDocumentBuilderFactory", result.getName());
}
private Bundle mockSpiFlyBundle(Bundle ... bundles) throws Exception {
diff --git a/spi-fly/spi-fly-static-tool/src/test/java/org/apache/aries/spifly/statictool/ConsumerTest.java b/spi-fly/spi-fly-static-tool/src/test/java/org/apache/aries/spifly/statictool/ConsumerTest.java
index 021351fb2..e80682b9b 100644
--- a/spi-fly/spi-fly-static-tool/src/test/java/org/apache/aries/spifly/statictool/ConsumerTest.java
+++ b/spi-fly/spi-fly-static-tool/src/test/java/org/apache/aries/spifly/statictool/ConsumerTest.java
@@ -33,9 +33,14 @@ import org.apache.aries.spifly.Streams;
import org.apache.aries.spifly.statictool.bundle.Test2Class;
import org.apache.aries.spifly.statictool.bundle.Test3Class;
import org.apache.aries.spifly.statictool.bundle.TestClass;
-import org.junit.Assert;
import org.junit.Test;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
public class ConsumerTest {
@Test
public void testConsumerBundle() throws Exception {
@@ -70,30 +75,30 @@ public class ConsumerTest {
Main.main(jarFile.getCanonicalPath());
expectedFile = new File(jarFile.getParent(), jarFile.getName().replaceAll("[.]jar", "_spifly.jar"));
- Assert.assertTrue("A processed separate bundle should have been created", expectedFile.exists());
+ assertTrue("A processed separate bundle should have been created", expectedFile.exists());
// Check manifest in generated bundle.
JarFile transformedJarFile = new JarFile(expectedFile);
Manifest expectedMF = transformedJarFile.getManifest();
- Assert.assertEquals("1.0", expectedMF.getMainAttributes().getValue("Manifest-Version"));
- Assert.assertEquals("2.0", expectedMF.getMainAttributes().getValue("Bundle-ManifestVersion"));
- Assert.assertEquals("testbundle", expectedMF.getMainAttributes().getValue("Bundle-SymbolicName"));
- Assert.assertEquals("Bar Bar", expectedMF.getMainAttributes().getValue("Foo"));
- Assert.assertEquals("org.apache.aries.spifly;version=\"[1.1.0,1.2.0)\"", expectedMF.getMainAttributes().getValue("Import-Package"));
- Assert.assertNull(expectedMF.getMainAttributes().get(SpiFlyConstants.SPI_CONSUMER_HEADER));
+ assertEquals("1.0", expectedMF.getMainAttributes().getValue("Manifest-Version"));
+ assertEquals("2.0", expectedMF.getMainAttributes().getValue("Bundle-ManifestVersion"));
+ assertEquals("testbundle", expectedMF.getMainAttributes().getValue("Bundle-SymbolicName"));
+ assertEquals("Bar Bar", expectedMF.getMainAttributes().getValue("Foo"));
+ assertEquals("org.apache.aries.spifly;version=\"[1.1.0,1.2.0)\"", expectedMF.getMainAttributes().getValue("Import-Package"));
+ assertNull(expectedMF.getMainAttributes().get(SpiFlyConstants.SPI_CONSUMER_HEADER));
JarFile initialJarFile = new JarFile(jarFile);
byte[] orgBytes = Streams.suck(initialJarFile.getInputStream(new ZipEntry(testClassFileName)));
byte[] transBytes = Streams.suck(transformedJarFile.getInputStream(new ZipEntry(testClassFileName)));
- Assert.assertFalse("The transformed class should be different", Arrays.equals(orgBytes, transBytes));
+ assertFalse("The transformed class should be different", Arrays.equals(orgBytes, transBytes));
byte[] orgBytes2 = Streams.suck(initialJarFile.getInputStream(new ZipEntry(test2ClassFileName)));
byte[] nonTransBytes2 = Streams.suck(transformedJarFile.getInputStream(new ZipEntry(test2ClassFileName)));
- Assert.assertArrayEquals(orgBytes2, nonTransBytes2);
+ assertArrayEquals(orgBytes2, nonTransBytes2);
byte[] orgBytes3 = Streams.suck(initialJarFile.getInputStream(new ZipEntry(test3ClassFileName)));
byte[] nonTransBytes3 = Streams.suck(transformedJarFile.getInputStream(new ZipEntry(test3ClassFileName)));
- Assert.assertArrayEquals(orgBytes3, nonTransBytes3);
+ assertArrayEquals(orgBytes3, nonTransBytes3);
initialJarFile.close();
transformedJarFile.close();
diff --git a/spi-fly/spi-fly-static-tool/src/test/java/org/apache/aries/spifly/statictool/MainTest.java b/spi-fly/spi-fly-static-tool/src/test/java/org/apache/aries/spifly/statictool/MainTest.java
index deb927a22..3fff7b326 100644
--- a/spi-fly/spi-fly-static-tool/src/test/java/org/apache/aries/spifly/statictool/MainTest.java
+++ b/spi-fly/spi-fly-static-tool/src/test/java/org/apache/aries/spifly/statictool/MainTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.aries.spifly.statictool;
+import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -29,7 +30,6 @@ import java.net.URL;
import java.util.jar.Manifest;
import org.apache.aries.spifly.Streams;
-import org.junit.Assert;
import org.junit.Test;
import org.junit.internal.ArrayComparisonFailure;
@@ -54,8 +54,8 @@ public class MainTest {
"jar:" + jarURL + "!/dir/dir 2/a.txt");
assertStreams(new File(tempDir, "dir/dir 2/b.txt"),
"jar:" + jarURL + "!/dir/dir 2/b.txt");
-
- Assert.assertTrue(new File(tempDir, "dir/dir.3").exists());
+
+ assertTrue(new File(tempDir, "dir/dir.3").exists());
// Create a second jar from the exploded directory
File copiedFile = new File(jarFile.getAbsolutePath() + ".copy");
@@ -109,7 +109,7 @@ public class MainTest {
try {
byte[] bytes1 = Streams.suck(is1);
byte[] bytes2 = Streams.suck(is2);
- Assert.assertArrayEquals("Files not equal", bytes1, bytes2);
+ assertArrayEquals("Files not equal", bytes1, bytes2);
} finally {
is1.close();
is2.close();
diff --git a/spi-fly/spi-fly-static-tool/src/test/java/org/apache/aries/spifly/statictool/RequirementTest.java b/spi-fly/spi-fly-static-tool/src/test/java/org/apache/aries/spifly/statictool/RequirementTest.java
index e3196fae5..8f1e6ee98 100644
--- a/spi-fly/spi-fly-static-tool/src/test/java/org/apache/aries/spifly/statictool/RequirementTest.java
+++ b/spi-fly/spi-fly-static-tool/src/test/java/org/apache/aries/spifly/statictool/RequirementTest.java
@@ -33,9 +33,14 @@ import org.apache.aries.spifly.Streams;
import org.apache.aries.spifly.statictool.bundle.Test2Class;
import org.apache.aries.spifly.statictool.bundle.Test3Class;
import org.apache.aries.spifly.statictool.bundle.TestClass;
-import org.junit.Assert;
import org.junit.Test;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
public class RequirementTest {
@Test
public void testConsumerBundle() throws Exception {
@@ -73,20 +78,20 @@ public class RequirementTest {
Main.main(jarFile.getCanonicalPath());
expectedFile = new File(jarFile.getParent(), jarFile.getName().replaceAll("[.]jar", "_spifly.jar"));
- Assert.assertTrue("A processed separate bundle should have been created", expectedFile.exists());
+ assertTrue("A processed separate bundle should have been created", expectedFile.exists());
// Check manifest in generated bundle.
JarFile transformedJarFile = new JarFile(expectedFile);
Manifest actualMF = transformedJarFile.getManifest();
- Assert.assertEquals("1.0", actualMF.getMainAttributes().getValue("Manifest-Version"));
- Assert.assertEquals("2.0", actualMF.getMainAttributes().getValue("Bundle-ManifestVersion"));
- Assert.assertEquals("testbundle", actualMF.getMainAttributes().getValue("Bundle-SymbolicName"));
- Assert.assertEquals("Bar Bar", actualMF.getMainAttributes().getValue("Foo"));
- Assert.assertEquals("osgi.serviceloader; filter:=\"(osgi.serviceloader=org.apache.aries.spifly.mysvc.SPIProvider)\";cardinality:=multiple",
+ assertEquals("1.0", actualMF.getMainAttributes().getValue("Manifest-Version"));
+ assertEquals("2.0", actualMF.getMainAttributes().getValue("Bundle-ManifestVersion"));
+ assertEquals("testbundle", actualMF.getMainAttributes().getValue("Bundle-SymbolicName"));
+ assertEquals("Bar Bar", actualMF.getMainAttributes().getValue("Foo"));
+ assertEquals("osgi.serviceloader; filter:=\"(osgi.serviceloader=org.apache.aries.spifly.mysvc.SPIProvider)\";cardinality:=multiple",
actualMF.getMainAttributes().getValue(SpiFlyConstants.REQUIRE_CAPABILITY));
- Assert.assertNull("Should not generate this header when processing Require-Capability",
+ assertNull("Should not generate this header when processing Require-Capability",
actualMF.getMainAttributes().getValue(SpiFlyConstants.PROCESSED_SPI_CONSUMER_HEADER));
String importPackage = actualMF.getMainAttributes().getValue("Import-Package");
- Assert.assertTrue(
+ assertTrue(
importPackage,
"org.foo.bar,org.apache.aries.spifly;version=\"[1.1.0,1.2.0)\"".equals(importPackage) ||
"org.apache.aries.spifly;version=\"[1.1.0,1.2.0)\",org.foo.bar".equals(importPackage));
@@ -94,15 +99,15 @@ public class RequirementTest {
JarFile initialJarFile = new JarFile(jarFile);
byte[] orgBytes = Streams.suck(initialJarFile.getInputStream(new ZipEntry(testClassFileName)));
byte[] nonTransBytes = Streams.suck(transformedJarFile.getInputStream(new ZipEntry(testClassFileName)));
- Assert.assertArrayEquals(orgBytes, nonTransBytes);
+ assertArrayEquals(orgBytes, nonTransBytes);
byte[] orgBytes2 = Streams.suck(initialJarFile.getInputStream(new ZipEntry(test2ClassFileName)));
byte[] nonTransBytes2 = Streams.suck(transformedJarFile.getInputStream(new ZipEntry(test2ClassFileName)));
- Assert.assertArrayEquals(orgBytes2, nonTransBytes2);
+ assertArrayEquals(orgBytes2, nonTransBytes2);
byte[] orgBytes3 = Streams.suck(initialJarFile.getInputStream(new ZipEntry(test3ClassFileName)));
byte[] transBytes3 = Streams.suck(transformedJarFile.getInputStream(new ZipEntry(test3ClassFileName)));
- Assert.assertFalse("The transformed class should be different", Arrays.equals(orgBytes3, transBytes3));
+ assertFalse("The transformed class should be different", Arrays.equals(orgBytes3, transBytes3));
initialJarFile.close();
transformedJarFile.close();
diff --git a/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/Aries1453Test.java b/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/Aries1453Test.java
index dfd2a2927..bb432695f 100644
--- a/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/Aries1453Test.java
+++ b/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/Aries1453Test.java
@@ -19,7 +19,6 @@ import java.util.Set;
import org.apache.aries.subsystem.core.capabilityset.CapabilitySet;
import org.apache.aries.subsystem.core.capabilityset.SimpleFilter;
-import org.junit.Assert;
import org.junit.Test;
import org.osgi.framework.namespace.HostNamespace;
import org.osgi.resource.Capability;
@@ -27,6 +26,9 @@ import org.osgi.resource.Namespace;
import org.osgi.resource.Requirement;
import org.osgi.resource.Resource;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
/*
* https://issues.apache.org/jira/browse/ARIES-1453
*
@@ -58,7 +60,7 @@ public class Aries1453Test {
CapabilitySet capabilitySet = new CapabilitySet(Arrays.asList(HostNamespace.HOST_NAMESPACE), true);
capabilitySet.addCapability(capability);
Set<Capability> capabilities = capabilitySet.match(simpleFilter, true);
- Assert.assertTrue(capabilities.size() == 1);
- Assert.assertSame(capabilities.iterator().next(), capability);
+ assertEquals(1, capabilities.size());
+ assertSame(capabilities.iterator().next(), capability);
}
}
diff --git a/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/FeatureTest.java b/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/FeatureTest.java
index 722b133e0..dd0330325 100644
--- a/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/FeatureTest.java
+++ b/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/FeatureTest.java
@@ -23,7 +23,6 @@ import java.util.Collection;
import junit.framework.AssertionFailedError;
import org.apache.aries.subsystem.core.internal.ResourceHelper;
-import org.junit.Assert;
import org.junit.Test;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerMethod;
@@ -33,6 +32,10 @@ import org.osgi.framework.namespace.IdentityNamespace;
import org.osgi.resource.Resource;
import org.osgi.service.subsystem.Subsystem;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
@ExamReactorStrategy(PerMethod.class)
public class FeatureTest extends SubsystemTest {
@@ -169,45 +172,45 @@ public class FeatureTest extends SubsystemTest {
if (ResourceHelper.areEqual(constituent, resource))
return;
}
- Assert.fail("Constituent not found");
+ fail("Constituent not found");
}
private void assertContainsChild(Collection<Subsystem> children, Subsystem child) {
for (Subsystem subsystem : children) {
try {
- assertEquals(child, subsystem);
+ assertSubsystemsEquals(child, subsystem);
return;
}
catch (AssertionError e) {}
}
- Assert.fail("Child not found");
+ fail("Child not found");
}
- private void assertEquals(Subsystem subsystem1, Subsystem subsystem2) {
+ private void assertSubsystemsEquals(Subsystem subsystem1, Subsystem subsystem2) {
assertChildrenEqual(subsystem1.getChildren(), subsystem2.getChildren());
assertConstituentsEqual(subsystem1.getConstituents(), subsystem2.getConstituents());
- Assert.assertEquals("Headers were not equal", subsystem1.getSubsystemHeaders(null), subsystem2.getSubsystemHeaders(null));
- Assert.assertEquals("Locations were not equal", subsystem1.getLocation(), subsystem2.getLocation());
+ assertEquals("Headers were not equal", subsystem1.getSubsystemHeaders(null), subsystem2.getSubsystemHeaders(null));
+ assertEquals("Locations were not equal", subsystem1.getLocation(), subsystem2.getLocation());
assertParentsEqual(subsystem1.getParents(), subsystem2.getParents());
- Assert.assertEquals("States were not equal", subsystem1.getState(), subsystem2.getState());
- Assert.assertEquals("IDs were not equal", subsystem1.getSubsystemId(), subsystem2.getSubsystemId());
- Assert.assertEquals("Symbolic names were not equal", subsystem1.getSymbolicName(), subsystem2.getSymbolicName());
- Assert.assertEquals("Versions were not equal", subsystem1.getVersion(), subsystem2.getVersion());
+ assertEquals("States were not equal", subsystem1.getState(), subsystem2.getState());
+ assertEquals("IDs were not equal", subsystem1.getSubsystemId(), subsystem2.getSubsystemId());
+ assertEquals("Symbolic names were not equal", subsystem1.getSymbolicName(), subsystem2.getSymbolicName());
+ assertEquals("Versions were not equal", subsystem1.getVersion(), subsystem2.getVersion());
}
private void assertParentsEqual(Subsystem parent1, Subsystem parent2) {
if (parent1 == null || parent2 == null) {
- Assert.assertTrue("Parents were not equal", parent1 == null && parent2 == null);
+ assertTrue("Parents were not equal", parent1 == null && parent2 == null);
return;
}
assertConstituentsEqual(parent1.getConstituents(), parent2.getConstituents());
- Assert.assertEquals("Headers were not equal", parent1.getSubsystemHeaders(null), parent2.getSubsystemHeaders(null));
- Assert.assertEquals("Locations were not equal", parent1.getLocation(), parent2.getLocation());
+ assertEquals("Headers were not equal", parent1.getSubsystemHeaders(null), parent2.getSubsystemHeaders(null));
+ assertEquals("Locations were not equal", parent1.getLocation(), parent2.getLocation());
assertParentsEqual(parent1.getParents(), parent2.getParents());
- Assert.assertEquals("States were not equal", parent1.getState(), parent2.getState());
- Assert.assertEquals("IDs were not equal", parent1.getSubsystemId(), parent2.getSubsystemId());
- Assert.assertEquals("Symbolic names were not equal", parent1.getSymbolicName(), parent2.getSymbolicName());
- Assert.assertEquals("Versions were not equal", parent1.getVersion(), parent2.getVersion());
+ assertEquals("States were not equal", parent1.getState(), parent2.getState());
+ assertEquals("IDs were not equal", parent1.getSubsystemId(), parent2.getSubsystemId());
+ assertEquals("Symbolic names were not equal", parent1.getSymbolicName(), parent2.getSymbolicName());
+ assertEquals("Versions were not equal", parent1.getVersion(), parent2.getVersion());
}
private void assertParentsEqual(Subsystem parent1, Collection<Subsystem> parents2) {
@@ -218,25 +221,25 @@ public class FeatureTest extends SubsystemTest {
}
catch (AssertionFailedError e) {}
}
- Assert.fail("Parent not found: " + parent1.getSymbolicName());
+ fail("Parent not found: " + parent1.getSymbolicName());
}
private void assertParentsEqual(Collection<Subsystem> parents1, Collection<Subsystem> parents2) {
- Assert.assertEquals("Size not equal", parents1.size(), parents2.size());
+ assertEquals("Size not equal", parents1.size(), parents2.size());
for (Subsystem parent1 : parents1) {
assertParentsEqual(parent1, parents2);
}
}
private void assertConstituentsEqual(Collection<Resource> resources1, Collection<Resource> resources2) {
- Assert.assertEquals("Constituent size does not match", resources1.size(), resources2.size());
+ assertEquals("Constituent size does not match", resources1.size(), resources2.size());
for (Resource resource : resources1) {
assertContainsConstituent(resources2, resource);
}
}
private void assertChildrenEqual(Collection<Subsystem> subsystems1, Collection<Subsystem> subsystems2) {
- Assert.assertEquals("Children size does not match", subsystems1.size(), subsystems2.size());
+ assertEquals("Children size does not match", subsystems1.size(), subsystems2.size());
for (Subsystem subsystem : subsystems1) {
assertContainsChild(subsystems2, subsystem);
}
diff --git a/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ServiceDependencyTest.java b/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ServiceDependencyTest.java
index 4bc3c604a..74c06a171 100644
--- a/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ServiceDependencyTest.java
+++ b/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/ServiceDependencyTest.java
@@ -28,7 +28,6 @@ import org.apache.aries.subsystem.core.archive.SubsystemImportServiceHeader;
import org.apache.aries.subsystem.itests.util.GenericMetadataWrapper;
import org.apache.aries.util.manifest.ManifestHeaderProcessor;
import org.apache.aries.util.manifest.ManifestHeaderProcessor.GenericMetadata;
-import org.junit.Assert;
import org.junit.Test;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.Version;
@@ -65,7 +64,7 @@ public class ServiceDependencyTest extends SubsystemTest {
/*
* Bundle-SymbolicName: bundle.a.jar
* Bundle-Blueprint: OSGI-INF/blueprint/*.xml
- *
+ *
* <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
* <reference interface="bundle.b" filter="(&(active=true)(mode=shared))"/>
* <service interface="bundle.a" ref="bundle.a"/>
@@ -75,7 +74,7 @@ public class ServiceDependencyTest extends SubsystemTest {
/*
* Bundle-SymbolicName: bundle.b.jar
* Bundle-Blueprint: OSGI-INF/blueprint/*.xml
- *
+ *
* <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
* <reference interface="bundle.a" availability="optional"/>
* <service ref="bundle.b">
@@ -93,47 +92,47 @@ public class ServiceDependencyTest extends SubsystemTest {
* </blueprint>
*/
private static final String BUNDLE_B = "bundle.b.jar";
-
+
private static void createApplicationA() throws IOException {
createApplicationAManifest();
createSubsystem(APPLICATION_A, BUNDLE_A);
}
-
+
private static void createApplicationB() throws IOException {
createApplicationBManifest();
createSubsystem(APPLICATION_B, BUNDLE_B);
}
-
+
private static void createApplicationC() throws IOException {
createApplicationCManifest();
createSubsystem(APPLICATION_C, BUNDLE_A, BUNDLE_B);
}
-
+
private static void createApplicationD() throws IOException {
createApplicationDManifest();
createSubsystem(APPLICATION_D, BUNDLE_A, COMPOSITE_A);
}
-
+
private static void createApplicationAManifest() throws IOException {
createBasicApplicationManifest(APPLICATION_A);
}
-
+
private static void createApplicationBManifest() throws IOException {
createBasicApplicationManifest(APPLICATION_B);
}
-
+
private static void createApplicationCManifest() throws IOException {
createBasicApplicationManifest(APPLICATION_C);
}
-
+
private static void createApplicationDManifest() throws IOException {
createBasicApplicationManifest(APPLICATION_D);
}
-
+
private static void createBasicApplicationManifest(String symbolicName) throws IOException {
createBasicSubsystemManifest(symbolicName, null, null);
}
-
+
private static void createBasicSubsystemManifest(String symbolicName, Version version, String type) throws IOException {
Map<String, String> attributes = new HashMap<String, String>();
attributes.put(SubsystemConstants.SUBSYSTEM_SYMBOLICNAME, symbolicName);
@@ -143,12 +142,12 @@ public class ServiceDependencyTest extends SubsystemTest {
attributes.put(SubsystemConstants.SUBSYSTEM_TYPE, type);
createManifest(symbolicName + ".mf", attributes);
}
-
-
+
+
private static void createBundleA() throws IOException {
createBlueprintBundle(
- BUNDLE_A,
+ BUNDLE_A,
new StringBuilder()
.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
.append("<blueprint ")
@@ -164,10 +163,10 @@ public class ServiceDependencyTest extends SubsystemTest {
.append("</blueprint>")
.toString());
}
-
+
private static void createBundleB() throws IOException {
createBlueprintBundle(
- BUNDLE_B,
+ BUNDLE_B,
new StringBuilder()
.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
.append("<blueprint ")
@@ -191,22 +190,22 @@ public class ServiceDependencyTest extends SubsystemTest {
.append("</blueprint>")
.toString());
}
-
+
private static void createCompositeA() throws IOException {
createCompositeAManifest();
createSubsystem(COMPOSITE_A, BUNDLE_B);
}
-
+
private static void createCompositeAManifest() throws IOException {
Map<String, String> attributes = new HashMap<String, String>();
attributes.put(SubsystemConstants.SUBSYSTEM_SYMBOLICNAME, COMPOSITE_A);
attributes.put(SubsystemConstants.SUBSYSTEM_TYPE, SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE);
attributes.put(
- SubsystemConstants.SUBSYSTEM_EXPORTSERVICE,
+ SubsystemConstants.SUBSYSTEM_EXPORTSERVICE,
"bundle.b;filter:=\"(&(active=true)(mode=shared))\"");
createManifest(COMPOSITE_A + ".mf", attributes);
}
-
+
@Override
public void createApplications() throws Exception {
createBundleA();
@@ -217,7 +216,7 @@ public class ServiceDependencyTest extends SubsystemTest {
createCompositeA();
createApplicationD();
}
-
+
//@Test
public void testImportServiceDependencySatisfiedByChild() throws Exception {
try {
@@ -227,7 +226,7 @@ public class ServiceDependencyTest extends SubsystemTest {
"Generated application Subsystem-ImportService header when dependency satisfied by child",
subsystem.getSubsystemHeaders(null).get(SubsystemConstants.SUBSYSTEM_IMPORTSERVICE));
assertSubsystemExportServiceHeader(
- subsystem.getChildren().iterator().next(),
+ subsystem.getChildren().iterator().next(),
"bundle.b;filter:=\"(&(active=true)(mode=shared))\"");
}
finally {
@@ -239,7 +238,7 @@ public class ServiceDependencyTest extends SubsystemTest {
fail("Installation must succeed if missing service dependency is satisfied");
}
}
-
+
@Test
public void testImportServiceDependencySatisfiedByContent() throws Exception {
try {
@@ -258,7 +257,7 @@ public class ServiceDependencyTest extends SubsystemTest {
fail("Installation must succeed if service dependency is satisfied");
}
}
-
+
@Test
public void testImportServiceDependencySatisfiedByParent() throws Exception {
try {
@@ -285,7 +284,7 @@ public class ServiceDependencyTest extends SubsystemTest {
fail("Installation must succeed if missing service dependency is optional");
}
}
-
+
@Test
public void testMissingImportServiceDependencyMandatory() throws Exception {
try {
@@ -297,7 +296,7 @@ public class ServiceDependencyTest extends SubsystemTest {
// Okay.
}
}
-
+
@Test
public void testMissingImportServiceDependencyOptional() throws Exception {
try {
@@ -314,23 +313,23 @@ public class ServiceDependencyTest extends SubsystemTest {
fail("Installation must succeed if missing service dependency is optional");
}
}
-
+
private void assertSubsystemExportServiceHeader(Subsystem subsystem, String value) throws InvalidSyntaxException {
String header = assertHeaderExists(subsystem, SubsystemConstants.SUBSYSTEM_EXPORTSERVICE);
List<GenericMetadata> actual = ManifestHeaderProcessor.parseRequirementString(header);
List<GenericMetadata> expected = ManifestHeaderProcessor.parseRequirementString(value);
- Assert.assertEquals("Wrong number of clauses", expected.size(), actual.size());
+ assertEquals("Wrong number of clauses", expected.size(), actual.size());
for (int i = 0; i < expected.size(); i++)
assertEquals("Wrong clause", new GenericMetadataWrapper(expected.get(i)), new GenericMetadataWrapper(actual.get(i)));
}
-
+
private void assertSubsystemImportServiceHeader(Subsystem subsystem, String value) throws InvalidSyntaxException {
String header = assertHeaderExists(subsystem, SubsystemConstants.SUBSYSTEM_IMPORTSERVICE);
SubsystemImportServiceHeader actual = new SubsystemImportServiceHeader(header);
SubsystemImportServiceHeader expected = new SubsystemImportServiceHeader(value);
Collection<SubsystemImportServiceHeader.Clause> actualClauses = actual.getClauses();
Collection<SubsystemImportServiceHeader.Clause> expectedClauses = expected.getClauses();
- Assert.assertEquals("Wrong number of clauses", expectedClauses.size(), actualClauses.size());
+ assertEquals("Wrong number of clauses", expectedClauses.size(), actualClauses.size());
Iterator<SubsystemImportServiceHeader.Clause> actualItr = actualClauses.iterator();
Iterator<SubsystemImportServiceHeader.Clause> expectedItr = expectedClauses.iterator();
while (expectedItr.hasNext()) {
diff --git a/subsystem/subsystem-modeller/src/test/java/org/apache/aries/subsystem/modelling/utils/DeployedBundlesTest.java b/subsystem/subsystem-modeller/src/test/java/org/apache/aries/subsystem/modelling/utils/DeployedBundlesTest.java
index d49763d05..a4e2afc25 100644
--- a/subsystem/subsystem-modeller/src/test/java/org/apache/aries/subsystem/modelling/utils/DeployedBundlesTest.java
+++ b/subsystem/subsystem-modeller/src/test/java/org/apache/aries/subsystem/modelling/utils/DeployedBundlesTest.java
@@ -20,6 +20,8 @@ package org.apache.aries.subsystem.modelling.utils;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.Arrays;
@@ -44,7 +46,6 @@ import org.apache.aries.subsystem.modelling.impl.ModelledResourceImpl;
import org.apache.aries.subsystem.modelling.impl.ModellingHelperImpl;
import org.apache.aries.util.manifest.ManifestHeaderProcessor;
import org.apache.aries.util.manifest.ManifestHeaderProcessor.NameValuePair;
-import org.junit.Assert;
import org.junit.Test;
import org.osgi.framework.Constants;
@@ -188,7 +189,7 @@ public final class DeployedBundlesTest
// Check the deployed content entry is correct.
String contentEntry = deployedBundles.getContent();
String expectedResult = "bundle.a;deployed-version=1.0.0,bundle.b;deployed-version=1.0.0";
- Assert.assertTrue("Content=" + contentEntry, isEqual(contentEntry, expectedResult));
+ assertTrue("Content=" + contentEntry, isEqual(contentEntry, expectedResult));
}
@Test
@@ -201,7 +202,7 @@ public final class DeployedBundlesTest
// Check the deployed use bundle entry is correct.
String useBundleEntry = deployedBundles.getUseBundle();
String expectedResult = "bundle.c;deployed-version=1.0.0,bundle.d;deployed-version=1.0.0";
- Assert.assertTrue("UseBundle=" + useBundleEntry, isEqual(useBundleEntry, expectedResult));
+ assertTrue("UseBundle=" + useBundleEntry, isEqual(useBundleEntry, expectedResult));
}
@Test
@@ -212,7 +213,7 @@ public final class DeployedBundlesTest
packagesResolve(deployedBundles);
String provisionBundleEntry = deployedBundles.getProvisionBundle();
String expectedResult = "bundle.e;deployed-version=1.0.0";
- Assert.assertTrue("ProvisionBundle=" + provisionBundleEntry, isEqual(provisionBundleEntry, expectedResult));
+ assertTrue("ProvisionBundle=" + provisionBundleEntry, isEqual(provisionBundleEntry, expectedResult));
}
@Test
@@ -230,7 +231,7 @@ public final class DeployedBundlesTest
catch (ResolverException e)
{
e.printStackTrace();
- Assert.fail(e.toString());
+ fail(e.toString());
}
String expectedResult = "package.c;version=\"1.0.0\";bundle-symbolic-name=\"bundle.c\";bundle-version=\"[1.0.0,1.0.0]\","
@@ -246,7 +247,7 @@ public final class DeployedBundlesTest
+ ",package.e;version=\"[1.0.0,2.0.0)\""
+ ",package.g";
*/
- Assert.assertTrue("ImportPackage=" + importPackageEntry, isEqual(importPackageEntry, expectedResult));
+ assertTrue("ImportPackage=" + importPackageEntry, isEqual(importPackageEntry, expectedResult));
}
@@ -300,10 +301,10 @@ public final class DeployedBundlesTest
catch (ResolverException e)
{
e.printStackTrace();
- Assert.fail(e.toString());
+ fail(e.toString());
}
String expectedResult = "package.d;version=\"[2.0.0,3.0.0)\"";
- Assert.assertTrue("ImportPackage=" + importPackageEntry, isEqual(importPackageEntry, expectedResult));
+ assertTrue("ImportPackage=" + importPackageEntry, isEqual(importPackageEntry, expectedResult));
}
@Test
@@ -328,10 +329,10 @@ public final class DeployedBundlesTest
catch (ResolverException e)
{
e.printStackTrace();
- Assert.fail(e.toString());
+ fail(e.toString());
}
String expectedResult = "package.c;was_internal=\"true\";version=\"2.0.0\"";
- Assert.assertTrue("ImportPackage=" + importPackageEntry, isEqual(importPackageEntry, expectedResult));
+ assertTrue("ImportPackage=" + importPackageEntry, isEqual(importPackageEntry, expectedResult));
}
@Test
@@ -351,7 +352,7 @@ public final class DeployedBundlesTest
try
{
importPackageEntry = deployedBundles.getImportPackage();
- Assert.fail("Expected exception. ImportPackage=" + importPackageEntry);
+ fail("Expected exception. ImportPackage=" + importPackageEntry);
}
catch (ResolverException e)
{
@@ -376,7 +377,7 @@ public final class DeployedBundlesTest
try
{
importPackageEntry = deployedBundles.getImportPackage();
- Assert.fail("Expected exception. ImportPackage=" + importPackageEntry);
+ fail("Expected exception. ImportPackage=" + importPackageEntry);
}
catch (ResolverException e)
{
@@ -404,10 +405,10 @@ public final class DeployedBundlesTest
catch (ResolverException e)
{
e.printStackTrace();
- Assert.fail(e.toString());
+ fail(e.toString());
}
String expectedResult = ""; // All packages are satisfied internally
- Assert.assertTrue("ImportPackage=" + importPackageEntry, isEqual(importPackageEntry, expectedResult));
+ assertTrue("ImportPackage=" + importPackageEntry, isEqual(importPackageEntry, expectedResult));
}
@@ -427,7 +428,7 @@ public final class DeployedBundlesTest
try
{
importPackageEntry = deployedBundles.getImportPackage();
- Assert.fail("Expected exception. ImportPackage=" + importPackageEntry);
+ fail("Expected exception. ImportPackage=" + importPackageEntry);
}
catch (ResolverException e)
{
@@ -451,7 +452,7 @@ public final class DeployedBundlesTest
try
{
importPackageEntry = deployedBundles.getImportPackage();
- Assert.fail("Expected exception. ImportPackage=" + importPackageEntry);
+ fail("Expected exception. ImportPackage=" + importPackageEntry);
}
catch (ResolverException e)
{
@@ -480,10 +481,10 @@ public final class DeployedBundlesTest
catch (ResolverException e)
{
e.printStackTrace();
- Assert.fail(e.toString());
+ fail(e.toString());
}
String expectedResult = "package.c;version=1.0.0";
- Assert.assertTrue("ImportPackage=" + importPackageEntry, isEqual(importPackageEntry, expectedResult));
+ assertTrue("ImportPackage=" + importPackageEntry, isEqual(importPackageEntry, expectedResult));
}
@Test
@@ -512,9 +513,9 @@ public final class DeployedBundlesTest
catch (ResolverException e)
{
e.printStackTrace();
- Assert.fail(e.toString());
+ fail(e.toString());
}
- Assert.assertTrue("RequiredUseBundle=" + requiredUseBundle, requiredUseBundle.size() == 1);
+ assertTrue("RequiredUseBundle=" + requiredUseBundle, requiredUseBundle.size() == 1);
}
@Test
@@ -533,9 +534,9 @@ public final class DeployedBundlesTest
catch (ResolverException e)
{
e.printStackTrace();
- Assert.fail(e.toString());
+ fail(e.toString());
}
- Assert.assertTrue("RequiredUseBundle=" + requiredUseBundle, requiredUseBundle.size() == 2);
+ assertTrue("RequiredUseBundle=" + requiredUseBundle, requiredUseBundle.size() == 2);
}
//Inside cannot bundle-symbolic-name an outside bundle until the new RFC 138!
@@ -555,7 +556,7 @@ public final class DeployedBundlesTest
try
{
importPackageEntry = deployedBundles.getImportPackage();
- Assert.fail("Expected exception. ImportPackage=" + importPackageEntry);
+ fail("Expected exception. ImportPackage=" + importPackageEntry);
}
catch (ResolverException e)
{
diff --git a/subsystem/subsystem-modeller/src/test/java/org/apache/aries/subsystem/modelling/utils/PackageRequirementMergerTest.java b/subsystem/subsystem-modeller/src/test/java/org/apache/aries/subsystem/modelling/utils/PackageRequirementMergerTest.java
index 36402d117..a6c3b17ca 100644
--- a/subsystem/subsystem-modeller/src/test/java/org/apache/aries/subsystem/modelling/utils/PackageRequirementMergerTest.java
+++ b/subsystem/subsystem-modeller/src/test/java/org/apache/aries/subsystem/modelling/utils/PackageRequirementMergerTest.java
@@ -32,10 +32,14 @@ import org.apache.aries.subsystem.modelling.impl.ImportedPackageImpl;
import org.apache.aries.subsystem.modelling.impl.PackageRequirementMerger;
import org.apache.aries.util.VersionRange;
import org.apache.aries.util.manifest.ManifestHeaderProcessor;
-import org.junit.Assert;
import org.junit.Test;
import org.osgi.framework.Constants;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
public final class PackageRequirementMergerTest
{
@@ -126,16 +130,16 @@ public final class PackageRequirementMergerTest
reqs.add(newImportedPackage("c", "1.0.0"));
PackageRequirementMerger merger = new PackageRequirementMerger(reqs);
- Assert.assertTrue(merger.isMergeSuccessful());
+ assertTrue(merger.isMergeSuccessful());
- Assert.assertTrue(merger.getInvalidRequirements().isEmpty());
+ assertTrue(merger.getInvalidRequirements().isEmpty());
Collection<ImportedPackage> result = merger.getMergedRequirements();
Collection<ImportedPackage> expected = new ArrayList<ImportedPackage>();
expected.add(newImportedPackage("a", "3.0.0"));
expected.add(newImportedPackage("b", "2.0.0"));
expected.add(newImportedPackage("c", "1.0.0"));
- Assert.assertTrue(result.toString(), isEqual(result, expected));
+ assertTrue(result.toString(), isEqual(result, expected));
}
@Test
@@ -150,12 +154,12 @@ public final class PackageRequirementMergerTest
reqs.add(newImportedPackage("c", "2.0.0"));
PackageRequirementMerger merger = new PackageRequirementMerger(reqs);
- Assert.assertFalse(merger.isMergeSuccessful());
+ assertFalse(merger.isMergeSuccessful());
try
{
merger.getMergedRequirements();
- Assert.fail("getMergedRequirements should throw IllegalStateException.");
+ fail("getMergedRequirements should throw IllegalStateException.");
}
catch (IllegalStateException e) { }
@@ -163,7 +167,7 @@ public final class PackageRequirementMergerTest
Set<String> expected = new HashSet<String>();
expected.add("a");
expected.add("c");
- Assert.assertEquals(expected, result);
+ assertEquals(expected, result);
}
@Test
@@ -174,14 +178,14 @@ public final class PackageRequirementMergerTest
reqs.add(newImportedPackage("a", "2.0.0", true));
PackageRequirementMerger merger = new PackageRequirementMerger(reqs);
- Assert.assertTrue(merger.isMergeSuccessful());
+ assertTrue(merger.isMergeSuccessful());
- Assert.assertTrue(merger.getInvalidRequirements().isEmpty());
+ assertTrue(merger.getInvalidRequirements().isEmpty());
Collection<ImportedPackage> result = merger.getMergedRequirements();
Collection<ImportedPackage> expected = new ArrayList<ImportedPackage>();
expected.add(newImportedPackage("a", "2.0.0", true));
- Assert.assertTrue(result.toString(), isEqual(result, expected));
+ assertTrue(result.toString(), isEqual(result, expected));
}
@Test
@@ -192,14 +196,14 @@ public final class PackageRequirementMergerTest
reqs.add(newImportedPackage("a", "2.0.0", false));
PackageRequirementMerger merger = new PackageRequirementMerger(reqs);
- Assert.assertTrue(merger.isMergeSuccessful());
+ assertTrue(merger.isMergeSuccessful());
- Assert.assertTrue(merger.getInvalidRequirements().isEmpty());
+ assertTrue(merger.getInvalidRequirements().isEmpty());
Collection<ImportedPackage> result = merger.getMergedRequirements();
Collection<ImportedPackage> expected = new ArrayList<ImportedPackage>();
expected.add(newImportedPackage("a", "2.0.0"));
- Assert.assertTrue(result.toString(), isEqual(result, expected));
+ assertTrue(result.toString(), isEqual(result, expected));
}
@Test
@@ -210,14 +214,14 @@ public final class PackageRequirementMergerTest
reqs.add(newImportedPackage("a", "2.0.0", "foo=bar"));
PackageRequirementMerger merger = new PackageRequirementMerger(reqs);
- Assert.assertTrue(merger.isMergeSuccessful());
+ assertTrue(merger.isMergeSuccessful());
- Assert.assertTrue(merger.getInvalidRequirements().isEmpty());
+ assertTrue(merger.getInvalidRequirements().isEmpty());
Collection<ImportedPackage> result = merger.getMergedRequirements();
Collection<ImportedPackage> expected = new ArrayList<ImportedPackage>();
expected.add(newImportedPackage("a", "2.0.0", "foo=bar"));
- Assert.assertTrue(result.toString(), isEqual(result, expected));
+ assertTrue(result.toString(), isEqual(result, expected));
}
@Test
@@ -229,19 +233,19 @@ public final class PackageRequirementMergerTest
reqs.add(newImportedPackage("b", "1.0.0"));
PackageRequirementMerger merger = new PackageRequirementMerger(reqs);
- Assert.assertFalse(merger.isMergeSuccessful());
+ assertFalse(merger.isMergeSuccessful());
try
{
merger.getMergedRequirements();
- Assert.fail("getMergedRequirements should throw IllegalStateException.");
+ fail("getMergedRequirements should throw IllegalStateException.");
}
catch (IllegalStateException e) { }
Set<String> result = merger.getInvalidRequirements();
Set<String> expected = new HashSet<String>();
expected.add("a");
- Assert.assertEquals(expected, result);
+ assertEquals(expected, result);
}
}
diff --git a/testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/mocks/Skeleton.java b/testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/mocks/Skeleton.java
index cad5b72b9..32e726bd2 100644
--- a/testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/mocks/Skeleton.java
+++ b/testsupport/testsupport-unit/src/main/java/org/apache/aries/unittest/mocks/Skeleton.java
@@ -33,12 +33,14 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import org.junit.Assert;
import junit.framework.AssertionFailedError;
import org.apache.aries.unittest.mocks.annotations.InjectSkeleton;
import org.apache.aries.unittest.mocks.annotations.Singleton;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
/**
* <p>The Skeleton class is an implementation of the
* <code>java.lang.reflect.InvocationHandler</code> that can be used for
@@ -987,7 +989,7 @@ public final class Skeleton implements InvocationHandler
*/
public void assertNotCalled(MethodCall call)
{
- Assert.assertFalse( "The method call " +
+ assertFalse( "The method call " +
call +
" occurred in the skeleton " +
this.toString(), checkCall(call));
@@ -1002,7 +1004,7 @@ public final class Skeleton implements InvocationHandler
*/
public void assertSkeletonNotCalled()
{
- Assert.assertEquals("The skeleton " + this.toString() +
+ assertEquals("The skeleton " + this.toString() +
" has had the following method invoked on it " + getMethodCallsAsString(),
0, _methodCalls.size());
}
diff --git a/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/ComponentTxDataTest.java b/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/ComponentTxDataTest.java
index 92237903b..ca01bac64 100644
--- a/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/ComponentTxDataTest.java
+++ b/transaction/transaction-blueprint/src/test/java/org/apache/aries/transaction/ComponentTxDataTest.java
@@ -18,7 +18,9 @@
*/
package org.apache.aries.transaction;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.lang.reflect.Method;
import java.sql.BatchUpdateException;
@@ -33,7 +35,6 @@ import org.apache.aries.transaction.pojo.ExtendedPojo;
import org.apache.aries.transaction.pojo.ExtendedPojo2;
import org.apache.aries.transaction.pojo.ExtendedPojo3;
import org.apache.aries.transaction.pojo.OnRollbackPojo;
-import org.junit.Assert;
import org.junit.Test;
public class ComponentTxDataTest {
@@ -41,7 +42,7 @@ public class ComponentTxDataTest {
@Test
public void testFindAnnotation() throws NoSuchMethodException, SecurityException {
ComponentTxData txData = new ComponentTxData(AnnotatedPojo.class);
- Assert.assertTrue(txData.isTransactional());
+ assertTrue(txData.isTransactional());
assertEquals(TxType.REQUIRED, getEffectiveType(txData, "increment").getTxType());
assertEquals(TxType.SUPPORTS, getEffectiveType(txData, "checkValue").getTxType());
assertEquals(TxType.MANDATORY, getEffectiveType(txData, "getRealObject").getTxType());
diff --git a/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/AbstractIntegrationTest.java b/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/AbstractIntegrationTest.java
index dd20ee621..a4f119a74 100644
--- a/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/AbstractIntegrationTest.java
+++ b/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/AbstractIntegrationTest.java
@@ -25,8 +25,6 @@ import static org.ops4j.pax.exam.CoreOptions.frameworkProperty;
import static org.ops4j.pax.exam.CoreOptions.junitBundles;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
-import static org.ops4j.pax.exam.CoreOptions.vmOption;
-import static org.ops4j.pax.exam.CoreOptions.when;
import java.sql.SQLException;
@@ -36,7 +34,6 @@ import javax.transaction.UserTransaction;
import org.apache.aries.transaction.test.Counter;
import org.apache.aries.transaction.test.TestBean;
-import org.junit.Assert;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.CoreOptions;
@@ -124,7 +121,7 @@ public abstract class AbstractIntegrationTest extends org.apache.aries.itest.Abs
try {
bean.insertRow("testWithClientTranAndWithRuntimeException", 2, new RuntimeException("Dummy exception"));
} catch (RuntimeException e) {
- Assert.assertEquals("Dummy exception", e.getMessage());
+ assertEquals("Dummy exception", e.getMessage());
}
if (clientTransaction) {
try {
@@ -151,7 +148,7 @@ public abstract class AbstractIntegrationTest extends org.apache.aries.itest.Abs
try {
bean.insertRow("testWithClientTranAndWithAppException", 2, new SQLException("Dummy exception"));
} catch (SQLException e) {
- Assert.assertEquals("Dummy exception", e.getMessage());
+ assertEquals("Dummy exception", e.getMessage());
}
if (clientTransaction) {
tran.commit();
diff --git a/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RollbackOnTest.java b/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RollbackOnTest.java
index acf3ae663..f7a195840 100644
--- a/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RollbackOnTest.java
+++ b/transaction/transaction-itests/src/test/java/org/apache/aries/transaction/itests/RollbackOnTest.java
@@ -20,7 +20,6 @@ package org.apache.aries.transaction.itests;
import org.apache.aries.transaction.test.RollbackOnBean;
import org.apache.aries.transaction.test.TestBean;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.ops4j.pax.exam.util.Filter;
@@ -56,7 +55,7 @@ public class RollbackOnTest extends AbstractIntegrationTest {
}
int txStatus = tran.getStatus();
tran.rollback();
- Assert.assertEquals("tx was rolled back", Status.STATUS_ACTIVE, txStatus);
+ assertEquals("tx was rolled back", Status.STATUS_ACTIVE, txStatus);
}
//default behavior, doesn't rollback on exception
@@ -70,7 +69,7 @@ public class RollbackOnTest extends AbstractIntegrationTest {
}
int txStatus = tran.getStatus();
tran.rollback();
- Assert.assertEquals("tx was rolled back", Status.STATUS_ACTIVE, txStatus);
+ assertEquals("tx was rolled back", Status.STATUS_ACTIVE, txStatus);
}
@Test
@@ -83,7 +82,7 @@ public class RollbackOnTest extends AbstractIntegrationTest {
}
int txStatus = tran.getStatus();
tran.rollback();
- Assert.assertEquals("tx was not rolled back", Status.STATUS_MARKED_ROLLBACK, txStatus);
+ assertEquals("tx was not rolled back", Status.STATUS_MARKED_ROLLBACK, txStatus);
}
@Test
@@ -96,7 +95,7 @@ public class RollbackOnTest extends AbstractIntegrationTest {
}
int txStatus = tran.getStatus();
tran.rollback();
- Assert.assertEquals("tx was not rolled back", Status.STATUS_MARKED_ROLLBACK, txStatus);
+ assertEquals("tx was not rolled back", Status.STATUS_MARKED_ROLLBACK, txStatus);
}
//throw Runtime / handle Exception
diff --git a/util/src/test/java/org/apache/aries/util/log/LoggerTest.java b/util/src/test/java/org/apache/aries/util/log/LoggerTest.java
index 91986b602..a6d15006c 100644
--- a/util/src/test/java/org/apache/aries/util/log/LoggerTest.java
+++ b/util/src/test/java/org/apache/aries/util/log/LoggerTest.java
@@ -25,7 +25,6 @@ import java.util.List;
import org.apache.aries.mocks.BundleContextMock;
import org.apache.aries.unittest.mocks.Skeleton;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.Bundle;
@@ -33,6 +32,9 @@ import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.service.log.LogService;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
@SuppressWarnings("rawtypes")
public class LoggerTest {
private BundleContext ctx;
@@ -57,18 +59,18 @@ public class LoggerTest {
TestLogService tls = new TestLogService();
ctx.registerService(LogService.class.getName(), tls, null);
- Assert.assertEquals("Precondition", 0, tls.logData.size());
+ assertEquals("Precondition", 0, tls.logData.size());
logger.log(LogService.LOG_INFO, "Hi");
- Assert.assertEquals(1, tls.logData.size());
+ assertEquals(1, tls.logData.size());
LogData ld = tls.logData.get(0);
- Assert.assertEquals(LogService.LOG_INFO, ld.level);
- Assert.assertEquals("Hi", ld.message);
+ assertEquals(LogService.LOG_INFO, ld.level);
+ assertEquals("Hi", ld.message);
logger.close();
logger.log(LogService.LOG_INFO, "This message will disappear too");
- Assert.assertEquals("The logger was closed so log messages shouldn't appear in the LogService any more",
+ assertEquals("The logger was closed so log messages shouldn't appear in the LogService any more",
1, tls.logData.size());
}
@@ -79,15 +81,15 @@ public class LoggerTest {
TestLogService tls = new TestLogService();
ctx.registerService(LogService.class.getName(), tls, null);
- Assert.assertEquals("Precondition", 0, tls.logData.size());
+ assertEquals("Precondition", 0, tls.logData.size());
Throwable th = new Throwable();
logger.log(LogService.LOG_INFO, "Hi", th);
- Assert.assertEquals(1, tls.logData.size());
+ assertEquals(1, tls.logData.size());
LogData ld = tls.logData.get(0);
- Assert.assertEquals(LogService.LOG_INFO, ld.level);
- Assert.assertEquals("Hi", ld.message);
- Assert.assertEquals(th, ld.throwable);
+ assertEquals(LogService.LOG_INFO, ld.level);
+ assertEquals("Hi", ld.message);
+ assertEquals(th, ld.throwable);
}
@Test
@@ -97,15 +99,15 @@ public class LoggerTest {
TestLogService tls = new TestLogService();
ctx.registerService(LogService.class.getName(), tls, null);
- Assert.assertEquals("Precondition", 0, tls.logData.size());
+ assertEquals("Precondition", 0, tls.logData.size());
ServiceReference sr = new MockServiceReference();
logger.log(sr, LogService.LOG_INFO, "Hi");
- Assert.assertEquals(1, tls.logData.size());
+ assertEquals(1, tls.logData.size());
LogData ld = tls.logData.get(0);
- Assert.assertSame(sr, ld.serviceReference);
- Assert.assertEquals(LogService.LOG_INFO, ld.level);
- Assert.assertEquals("Hi", ld.message);
+ assertSame(sr, ld.serviceReference);
+ assertEquals(LogService.LOG_INFO, ld.level);
+ assertEquals("Hi", ld.message);
}
@Test
@@ -115,17 +117,17 @@ public class LoggerTest {
TestLogService tls = new TestLogService();
ctx.registerService(LogService.class.getName(), tls, null);
- Assert.assertEquals("Precondition", 0, tls.logData.size());
+ assertEquals("Precondition", 0, tls.logData.size());
ServiceReference sr = new MockServiceReference();
Throwable th = new Throwable();
logger.log(sr, LogService.LOG_INFO, "Hi", th);
- Assert.assertEquals(1, tls.logData.size());
+ assertEquals(1, tls.logData.size());
LogData ld = tls.logData.get(0);
- Assert.assertSame(sr, ld.serviceReference);
- Assert.assertEquals(LogService.LOG_INFO, ld.level);
- Assert.assertEquals("Hi", ld.message);
- Assert.assertEquals(th, ld.throwable);
+ assertSame(sr, ld.serviceReference);
+ assertEquals(LogService.LOG_INFO, ld.level);
+ assertEquals("Hi", ld.message);
+ assertEquals(th, ld.throwable);
}
private class TestLogService implements LogService {