T checkArgument(T reference, boolean expression) {
+ if (!expression) {
+ throw new IllegalArgumentException();
+ }
+ return reference;
+ }
+
+
+ private Preconditions() {
+ }
+}
diff --git a/components/common/src/main/java/com/hotels/styx/common/testing/matcher/TransformingMatcher.java b/components/common/src/main/java/com/hotels/styx/common/testing/matcher/TransformingMatcher.java
deleted file mode 100644
index 65d41bbf0c..0000000000
--- a/components/common/src/main/java/com/hotels/styx/common/testing/matcher/TransformingMatcher.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- Copyright (C) 2013-2018 Expedia Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-package com.hotels.styx.common.testing.matcher;
-
-import org.hamcrest.Description;
-import org.hamcrest.Matcher;
-import org.hamcrest.TypeSafeMatcher;
-
-import java.util.function.Function;
-
-import static java.util.Objects.requireNonNull;
-
-/**
- * A matcher that transforms a value and then applies another matcher to it when used.
- *
- * The advantage of this over transforming the value inside the test code is that it can be re-used while maintaining
- * the familiar syntax of hamcrest assertThat.
- *
- * @param type to match against
- * @param post-transformation type of delegate matcher
- */
-public class TransformingMatcher extends TypeSafeMatcher {
- private final Function transformation;
- private final Matcher matcher;
-
- protected TransformingMatcher(Function transformation, Matcher matcher) {
- this.transformation = requireNonNull(transformation);
- this.matcher = requireNonNull(matcher);
- }
-
- public static TransformingMatcher hasDerivedValue(Function transformation, Matcher matcher) {
- return new TransformingMatcher<>(transformation, matcher);
- }
-
- @Override
- protected boolean matchesSafely(E e) {
- return matcher.matches(transformation.apply(e));
- }
-
- @Override
- public void describeTo(Description description) {
- matcher.describeTo(description);
- }
-
- @Override
- protected void describeMismatchSafely(E item, Description mismatchDescription) {
- matcher.describeMismatch(transformation.apply(item), mismatchDescription);
- }
-}
diff --git a/components/common/src/test/java/com/hotels/styx/common/MorePreconditionsTest.java b/components/common/src/test/java/com/hotels/styx/common/MorePreconditionsTest.java
deleted file mode 100644
index fb18a43f5a..0000000000
--- a/components/common/src/test/java/com/hotels/styx/common/MorePreconditionsTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- Copyright (C) 2013-2018 Expedia Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-package com.hotels.styx.common;
-
-import org.testng.annotations.Test;
-
-import static com.hotels.styx.common.MorePreconditions.checkArgument;
-import static com.hotels.styx.common.MorePreconditions.inRange;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.greaterThan;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.core.StringContains.containsString;
-import static org.testng.Assert.fail;
-
-public class MorePreconditionsTest {
-
- @Test
- public void checkArgumentSimpleMessageFailure() {
- try {
- checkArgument(0, greaterThan(0));
- fail("no exception thrown");
- } catch (IllegalArgumentException expected) {
- assertThat(expected.getMessage(), containsString("argument\n" +
- "Expected: a value greater than <0>\n" +
- " but: <0> was equal to <0>"));
- }
- }
-
- @Test
- public void checkArgumentFullMessageFailure() {
- try {
- checkArgument(0, greaterThan(0), "healthy count threshold");
- fail("no exception thrown");
- } catch (IllegalArgumentException expected) {
- assertThat(expected.getMessage(), containsString("healthy count threshold\n" +
- "Expected: a value greater than <0>\n" +
- " but: <0> was equal to <0>"));
- }
- }
-
- @Test
- public void checkArgumentInRange() {
- assertThat(checkArgument(0, inRange(-3, 3)), is(0));
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void checkArgumentInRangeFailure() {
- checkArgument(0, inRange(3, 4));
- }
-
-}
-
-
diff --git a/components/common/src/test/java/com/hotels/styx/common/PreconditionsTest.java b/components/common/src/test/java/com/hotels/styx/common/PreconditionsTest.java
new file mode 100644
index 0000000000..17bab516e0
--- /dev/null
+++ b/components/common/src/test/java/com/hotels/styx/common/PreconditionsTest.java
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 2013-2019 Expedia Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+package com.hotels.styx.common;
+
+import org.testng.annotations.Test;
+
+import static com.hotels.styx.common.Preconditions.checkArgument;
+import static com.hotels.styx.common.Preconditions.checkNotEmpty;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+
+public class PreconditionsTest {
+
+ @Test
+ public void isNotEmptyString() {
+ assertThat(checkNotEmpty(" "), is(" ") );
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void isEmptyString() {
+ checkNotEmpty(null);
+ }
+
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void checkArgumentFailure() {
+ checkArgument(0, false);
+ }
+
+ @Test
+ public void checkArgumentSuccess() {
+ assertThat(checkArgument(0, true), is(0));
+ }
+
+}
diff --git a/components/server/pom.xml b/components/server/pom.xml
index d47bb8ced0..2ca9365cfd 100644
--- a/components/server/pom.xml
+++ b/components/server/pom.xml
@@ -86,12 +86,6 @@
org.hamcrest
hamcrest-all
-
-
- org.slf4j
- slf4j-api
-
-
diff --git a/components/server/src/main/java/com/hotels/styx/server/netty/eventloop/epoll/EpollServerEventLoopGroupFactory.java b/components/server/src/main/java/com/hotels/styx/server/netty/eventloop/epoll/EpollServerEventLoopGroupFactory.java
index 014b268940..8d0127458c 100644
--- a/components/server/src/main/java/com/hotels/styx/server/netty/eventloop/epoll/EpollServerEventLoopGroupFactory.java
+++ b/components/server/src/main/java/com/hotels/styx/server/netty/eventloop/epoll/EpollServerEventLoopGroupFactory.java
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013-2018 Expedia Inc.
+ Copyright (C) 2013-2019 Expedia Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@
import io.netty.channel.ServerChannel;
import io.netty.channel.epoll.EpollServerSocketChannel;
-import static com.hotels.styx.common.MorePreconditions.checkArgument;
+import static com.hotels.styx.common.Preconditions.checkArgument;
import static com.hotels.styx.server.netty.eventloop.epoll.EpollEventLoopGroups.newEventLoopGroup;
import static java.util.Objects.requireNonNull;
diff --git a/plugin-examples/pom.xml b/plugin-examples/pom.xml
index 393b66a636..fb0a26fcbf 100644
--- a/plugin-examples/pom.xml
+++ b/plugin-examples/pom.xml
@@ -11,53 +11,65 @@
1.0-SNAPSHOT
- ${project.parent.basedir}
+ ${project.basedir}${file.separator}..
1.8
1.8
true
1.1.6
- 2.9.10
6.14.3
+
+
+
+ com.hotels.styx
+ styx-bom
+ 1.0-SNAPSHOT
+ pom
+ import
+
+
+
+
com.hotels.styx
styx-api
- 1.0-SNAPSHOT
provided
io.reactivex
rxjava
- ${rxjava.version}
provided
com.fasterxml.jackson.core
jackson-core
- ${jackson.version}
+ provided
com.fasterxml.jackson.core
jackson-databind
- 2.9.9.3
+ provided
com.fasterxml.jackson.core
jackson-annotations
- ${jackson.version}
org.testng
testng
- ${testng.version}
+
+
+
+ org.hamcrest
+ hamcrest-all
diff --git a/pom.xml b/pom.xml
index 201613ea72..819817ec14 100755
--- a/pom.xml
+++ b/pom.xml
@@ -326,18 +326,36 @@
io.dropwizard.metrics
metrics-core
${metrics.version}
+
+
+ org.slf4j
+ slf4j-api
+
+
io.dropwizard.metrics
metrics-jvm
${metrics.version}
+
+
+ org.slf4j
+ slf4j-api
+
+
io.dropwizard.metrics
metrics-json
${metrics.version}
+
+
+ org.slf4j
+ slf4j-api
+
+
@@ -457,6 +475,7 @@
org.hamcrest
hamcrest-all
${hamcrest.all.version}
+ test
org.slf4j
diff --git a/support/api-testsupport/pom.xml b/support/api-testsupport/pom.xml
index 038d019f53..c4bbcf8c56 100755
--- a/support/api-testsupport/pom.xml
+++ b/support/api-testsupport/pom.xml
@@ -54,6 +54,12 @@
+
+ org.hamcrest
+ hamcrest-all
+ compile
+
+
com.github.tomakehurst
wiremock
diff --git a/support/testsupport/pom.xml b/support/testsupport/pom.xml
index 395d82bd60..16b8f93528 100755
--- a/support/testsupport/pom.xml
+++ b/support/testsupport/pom.xml
@@ -45,12 +45,7 @@
org.hamcrest
hamcrest-all
-
-
- org.slf4j
- slf4j-api
-
-
+ compile