diff --git a/containers/pax-exam-container-remote/src/main/java/org/ops4j/pax/exam/container/remote/Parser.java b/containers/pax-exam-container-remote/src/main/java/org/ops4j/pax/exam/container/remote/Parser.java index db39d724c..9759ad168 100644 --- a/containers/pax-exam-container-remote/src/main/java/org/ops4j/pax/exam/container/remote/Parser.java +++ b/containers/pax-exam-container-remote/src/main/java/org/ops4j/pax/exam/container/remote/Parser.java @@ -15,6 +15,8 @@ */ package org.ops4j.pax.exam.container.remote; +import java.util.Objects; + import static org.ops4j.pax.exam.OptionUtils.filter; import org.ops4j.pax.exam.Option; @@ -35,8 +37,8 @@ public class Parser { public Parser(Option[] options) { extractArguments(filter(RBCPortOption.class, options)); extractArguments(filter(RBCLookupTimeoutOption.class, options)); - assert port != null : "Port should never be null."; - assert host != null : "Host should never be null."; + Objects.requireNonNull(host, "Host must not be be null."); + Objects.requireNonNull(port, "Port must not be be null."); } diff --git a/containers/pax-exam-container-remote/src/main/java/org/ops4j/pax/exam/container/remote/options/RBCPortOption.java b/containers/pax-exam-container-remote/src/main/java/org/ops4j/pax/exam/container/remote/options/RBCPortOption.java index f56dba773..3dcfe1a9a 100644 --- a/containers/pax-exam-container-remote/src/main/java/org/ops4j/pax/exam/container/remote/options/RBCPortOption.java +++ b/containers/pax-exam-container-remote/src/main/java/org/ops4j/pax/exam/container/remote/options/RBCPortOption.java @@ -17,6 +17,8 @@ */ package org.ops4j.pax.exam.container.remote.options; +import java.util.Objects; + import org.ops4j.pax.exam.Option; /** @@ -29,8 +31,8 @@ public class RBCPortOption implements Option { private String host; public RBCPortOption(String host, Integer port) { - assert host != null : "Host should never be null."; - assert port != null : "Port should never be null."; + Objects.requireNonNull(host, "Host must not be be null."); + Objects.requireNonNull(port, "Port must not be be null."); this.host = host; this.port = port; diff --git a/containers/pax-exam-container-remote/src/test/java/org/ops4j/pax/exam/container/remote/ParserTest.java b/containers/pax-exam-container-remote/src/test/java/org/ops4j/pax/exam/container/remote/ParserTest.java index ffb0e8eb5..fde20d058 100644 --- a/containers/pax-exam-container-remote/src/test/java/org/ops4j/pax/exam/container/remote/ParserTest.java +++ b/containers/pax-exam-container-remote/src/test/java/org/ops4j/pax/exam/container/remote/ParserTest.java @@ -27,7 +27,7 @@ */ public class ParserTest { - @Test(expected = AssertionError.class) + @Test(expected = NullPointerException.class) public void testDefaults() { Option[] options = CoreOptions.options(); new Parser(options); diff --git a/core/pax-exam-container-rbc-client/src/main/java/org/ops4j/pax/exam/rbc/client/intern/RemoteBundleContextClientImpl.java b/core/pax-exam-container-rbc-client/src/main/java/org/ops4j/pax/exam/rbc/client/intern/RemoteBundleContextClientImpl.java index 17a63675d..3a8b4d872 100644 --- a/core/pax-exam-container-rbc-client/src/main/java/org/ops4j/pax/exam/rbc/client/intern/RemoteBundleContextClientImpl.java +++ b/core/pax-exam-container-rbc-client/src/main/java/org/ops4j/pax/exam/rbc/client/intern/RemoteBundleContextClientImpl.java @@ -28,6 +28,7 @@ import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; +import java.util.Objects; import java.util.Stack; import org.ops4j.io.StreamUtils; @@ -79,7 +80,7 @@ public class RemoteBundleContextClientImpl implements RemoteBundleContextClient */ public RemoteBundleContextClientImpl(final String name, final Integer registry, final RelativeTimeout timeout) { - assert registry != null : "registry should not be null"; + Objects.requireNonNull(registry, "Registry must not be null."); this.registry = registry; this.name = name; diff --git a/core/pax-exam-spi/src/main/java/org/ops4j/pax/exam/spi/reactors/AllConfinedStagedReactor.java b/core/pax-exam-spi/src/main/java/org/ops4j/pax/exam/spi/reactors/AllConfinedStagedReactor.java index d01239ccb..b809f0c12 100644 --- a/core/pax-exam-spi/src/main/java/org/ops4j/pax/exam/spi/reactors/AllConfinedStagedReactor.java +++ b/core/pax-exam-spi/src/main/java/org/ops4j/pax/exam/spi/reactors/AllConfinedStagedReactor.java @@ -18,6 +18,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import org.ops4j.pax.exam.TestAddress; @@ -69,7 +70,7 @@ public void setUp() { } public void invoke(TestAddress address) throws Exception { - assert (address != null) : "TestAddress must not be null."; + Objects.requireNonNull(address, "TestAddress must not be null."); // you can directly invoke: TestContainer container = map.get(address); if (container == null) { diff --git a/core/pax-exam-spi/src/main/java/org/ops4j/pax/exam/spi/reactors/EagerSingleStagedReactor.java b/core/pax-exam-spi/src/main/java/org/ops4j/pax/exam/spi/reactors/EagerSingleStagedReactor.java index bd42659d5..6c9466c10 100644 --- a/core/pax-exam-spi/src/main/java/org/ops4j/pax/exam/spi/reactors/EagerSingleStagedReactor.java +++ b/core/pax-exam-spi/src/main/java/org/ops4j/pax/exam/spi/reactors/EagerSingleStagedReactor.java @@ -21,6 +21,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import org.ops4j.pax.exam.TestAddress; @@ -99,7 +100,7 @@ public void setUp() { } public void invoke(TestAddress address) throws Exception { - assert (address != null) : "TestAddress must not be null."; + Objects.requireNonNull(address, "TestAddress must not be null."); TestContainer testContainer = map.get(address); if (testContainer == null) { diff --git a/core/pax-exam-spi/src/main/java/org/ops4j/pax/exam/spi/reactors/SingletonStagedReactor.java b/core/pax-exam-spi/src/main/java/org/ops4j/pax/exam/spi/reactors/SingletonStagedReactor.java index 8f9b897cf..b91e5b664 100644 --- a/core/pax-exam-spi/src/main/java/org/ops4j/pax/exam/spi/reactors/SingletonStagedReactor.java +++ b/core/pax-exam-spi/src/main/java/org/ops4j/pax/exam/spi/reactors/SingletonStagedReactor.java @@ -21,6 +21,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import org.ops4j.pax.exam.TestAddress; @@ -104,7 +105,7 @@ public static synchronized StagedExamReactor getInstance(List con } public void invoke(TestAddress address) throws Exception { - assert (address != null) : "TestAddress must not be null."; + Objects.requireNonNull(address, "TestAddress must not be null."); TestContainer testContainer = testToContainerMap.get(address); if (testContainer == null) { diff --git a/core/pax-exam-spi/src/test/java/org/ops4j/pax/exam/spi/reactors/BaseStagedReactorTest.java b/core/pax-exam-spi/src/test/java/org/ops4j/pax/exam/spi/reactors/BaseStagedReactorTest.java index 10229c5a9..9515fbb96 100644 --- a/core/pax-exam-spi/src/test/java/org/ops4j/pax/exam/spi/reactors/BaseStagedReactorTest.java +++ b/core/pax-exam-spi/src/test/java/org/ops4j/pax/exam/spi/reactors/BaseStagedReactorTest.java @@ -48,7 +48,7 @@ public void testEmptyContainersAndBuilders() throws IOException { assertThat(reactor.getTargets().size(), is(0)); } - @Test(expected = AssertionError.class) + @Test(expected = NullPointerException.class) public void testInvokeNull() throws Exception { List containers = new ArrayList(); List providers = new ArrayList();