diff --git a/components/api/pom.xml b/components/api/pom.xml index e73089137a..7bc3d10677 100644 --- a/components/api/pom.xml +++ b/components/api/pom.xml @@ -66,12 +66,6 @@ org.hamcrest hamcrest-all - - - org.slf4j - slf4j-api - - diff --git a/components/client/pom.xml b/components/client/pom.xml index 55d52501eb..57eac3690f 100644 --- a/components/client/pom.xml +++ b/components/client/pom.xml @@ -60,12 +60,6 @@ org.hamcrest hamcrest-all - - - org.slf4j - slf4j-api - - diff --git a/components/client/src/main/java/com/hotels/styx/client/netty/eventloop/epoll/EpollClientEventLoopGroupFactory.java b/components/client/src/main/java/com/hotels/styx/client/netty/eventloop/epoll/EpollClientEventLoopGroupFactory.java index f4b4578a02..3cda2bfb38 100644 --- a/components/client/src/main/java/com/hotels/styx/client/netty/eventloop/epoll/EpollClientEventLoopGroupFactory.java +++ b/components/client/src/main/java/com/hotels/styx/client/netty/eventloop/epoll/EpollClientEventLoopGroupFactory.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. @@ -22,8 +22,8 @@ import io.netty.channel.epoll.EpollSocketChannel; import io.netty.channel.socket.SocketChannel; -import static com.hotels.styx.common.MorePreconditions.checkArgument; -import static com.hotels.styx.common.MorePreconditions.checkNotEmpty; +import static com.hotels.styx.common.Preconditions.checkArgument; +import static com.hotels.styx.common.Preconditions.checkNotEmpty; /** * A factory for creating Epoll-based client event loops. diff --git a/components/client/src/test/unit/java/com/hotels/styx/client/OriginsInventoryTest.java b/components/client/src/test/unit/java/com/hotels/styx/client/OriginsInventoryTest.java index 4b213a4049..37dde0718b 100644 --- a/components/client/src/test/unit/java/com/hotels/styx/client/OriginsInventoryTest.java +++ b/components/client/src/test/unit/java/com/hotels/styx/client/OriginsInventoryTest.java @@ -30,7 +30,6 @@ import com.hotels.styx.client.origincommands.DisableOrigin; import com.hotels.styx.client.origincommands.EnableOrigin; import com.hotels.styx.support.matchers.LoggingTestSupport; -import org.hamcrest.Matcher; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -44,7 +43,6 @@ import static com.hotels.styx.api.extension.service.ConnectionPoolSettings.defaultConnectionPoolSettings; import static com.hotels.styx.client.OriginsInventory.OriginState.ACTIVE; import static com.hotels.styx.client.OriginsInventory.OriginState.DISABLED; -import static com.hotels.styx.common.testing.matcher.TransformingMatcher.hasDerivedValue; import static com.hotels.styx.support.matchers.ContainsExactlyOneMatcher.containsExactlyOne; import static com.hotels.styx.support.matchers.IsOptional.isAbsent; import static com.hotels.styx.support.matchers.IsOptional.isValue; @@ -93,7 +91,7 @@ public void stop() { public void startsMonitoringNewOrigins() { inventory.setOrigins(ORIGIN_1, ORIGIN_2); - assertThat(inventory, hasActiveOrigins(2)); + assertThat(inventory.originCount(ACTIVE), is(2)); verify(monitor).monitor(singleton(ORIGIN_1)); verify(monitor).monitor(singleton(ORIGIN_2)); @@ -110,14 +108,14 @@ public void updatesOriginPortNumber() throws Exception { inventory.setOrigins(originV1); - assertThat(inventory, hasActiveOrigins(1)); + assertThat(inventory.originCount(ACTIVE), is(1)); verify(monitor).monitor(singleton(originV1)); assertThat(gaugeValue("origins.generic-app.acme-01.status"), isValue(1)); verify(eventBus).post(any(OriginsSnapshot.class)); inventory.setOrigins(originV2); - assertThat(inventory, hasActiveOrigins(1)); + assertThat(inventory.originCount(ACTIVE), is(1)); verify(monitor).stopMonitoring(singleton(originV1)); verify(monitor).monitor(singleton(originV2)); assertThat(gaugeValue("origins.generic-app.acme-01.status"), isValue(1)); @@ -131,14 +129,14 @@ public void updatesOriginHostName() throws Exception { inventory.setOrigins(originV1); - assertThat(inventory, hasActiveOrigins(1)); + assertThat(inventory.originCount(ACTIVE), is(1)); verify(monitor).monitor(singleton(originV1)); assertThat(gaugeValue("origins.generic-app.acme-01.status"), isValue(1)); verify(eventBus).post(any(OriginsSnapshot.class)); inventory.setOrigins(originV2); - assertThat(inventory, hasActiveOrigins(1)); + assertThat(inventory.originCount(ACTIVE), is(1)); verify(monitor).stopMonitoring(singleton(originV1)); verify(monitor).monitor(singleton(originV2)); assertThat(gaugeValue("origins.generic-app.acme-01.status"), isValue(1)); @@ -187,7 +185,7 @@ public void shutsConnectionPoolForModifiedOrigin() { public void ignoresUnchangedOrigins() throws Exception { inventory.setOrigins(ORIGIN_1, ORIGIN_2); - assertThat(inventory, hasActiveOrigins(2)); + assertThat(inventory.originCount(ACTIVE), is(2)); verify(monitor).monitor(singleton(ORIGIN_1)); verify(monitor).monitor(singleton(ORIGIN_2)); assertThat(gaugeValue("origins.generic-app.app-01.status"), isValue(1)); @@ -196,7 +194,7 @@ public void ignoresUnchangedOrigins() throws Exception { inventory.setOrigins(ORIGIN_1, ORIGIN_2); - assertThat(inventory, hasActiveOrigins(2)); + assertThat(inventory.originCount(ACTIVE), is(2)); verify(monitor, times(1)).monitor(singleton(ORIGIN_1)); verify(monitor, times(1)).monitor(singleton(ORIGIN_2)); verify(eventBus).post(any(OriginsSnapshot.class)); @@ -206,7 +204,7 @@ public void ignoresUnchangedOrigins() throws Exception { public void removesOrigin() throws Exception { inventory.setOrigins(ORIGIN_1, ORIGIN_2); - assertThat(inventory, hasActiveOrigins(2)); + assertThat(inventory.originCount(ACTIVE), is(2)); verify(monitor).monitor(singleton(ORIGIN_1)); verify(monitor).monitor(singleton(ORIGIN_2)); assertThat(gaugeValue("origins.generic-app.app-01.status"), isValue(1)); @@ -215,7 +213,7 @@ public void removesOrigin() throws Exception { inventory.setOrigins(ORIGIN_2); - assertThat(inventory, hasActiveOrigins(1)); + assertThat(inventory.originCount(ACTIVE), is(1)); verify(monitor).stopMonitoring(singleton(ORIGIN_1)); assertThat(gaugeValue("origins.generic-app.app-01.status"), isAbsent()); assertThat(gaugeValue("origins.generic-app.app-02.status"), isValue(1)); @@ -268,7 +266,7 @@ public void willNotDisableOriginsNotBelongingToTheApp() { inventory.onCommand(new DisableOrigin(id("some-other-app"), ORIGIN_1.id())); - assertThat(inventory, hasActiveOrigins(1)); + assertThat(inventory.originCount(ACTIVE), is(1)); verify(eventBus).post(any(OriginsSnapshot.class)); } @@ -279,7 +277,7 @@ public void willNotEnableOriginsNotBelongingToTheApp() { inventory.onCommand(new DisableOrigin(ORIGIN_1.applicationId(), ORIGIN_1.id())); inventory.onCommand(new EnableOrigin(id("some-other-app"), ORIGIN_1.id())); - assertThat(inventory, hasNoActiveOrigins()); + assertThat(inventory.originCount(ACTIVE), is(0)); verify(eventBus, times(2)).post(any(OriginsSnapshot.class)); } @@ -289,8 +287,8 @@ public void disablingAnOriginRemovesItFromActiveSetAndStopsHealthCheckMonitoring inventory.onCommand(new DisableOrigin(ORIGIN_1.applicationId(), ORIGIN_1.id())); - assertThat(inventory, hasNoActiveOrigins()); - assertThat(inventory, hasDisabledOrigins(1)); + assertThat(inventory.originCount(ACTIVE), is(0)); + assertThat(inventory.originCount(DISABLED), is(1)); verify(monitor).stopMonitoring(singleton(ORIGIN_1)); assertThat(gaugeValue("origins.generic-app.app-01.status"), isValue(-1)); @@ -304,8 +302,8 @@ public void disablingAnOriginRemovesItFromInactiveSetAndStopsHealthCheckMonitori inventory.originUnhealthy(ORIGIN_1); inventory.onCommand(new DisableOrigin(ORIGIN_1.applicationId(), ORIGIN_1.id())); - assertThat(inventory, hasNoActiveOrigins()); - assertThat(inventory, hasDisabledOrigins(1)); + assertThat(inventory.originCount(ACTIVE), is(0)); + assertThat(inventory.originCount(DISABLED), is(1)); verify(monitor).stopMonitoring(singleton(ORIGIN_1)); assertThat(gaugeValue("origins.generic-app.app-01.status"), isValue(-1)); @@ -327,11 +325,11 @@ public void enablingAnOriginWillReInitiateHealthCheckMonitoring() { @Test public void removesUnhealthyOriginsFromActiveSet() { inventory.setOrigins(ORIGIN_1); - assertThat(inventory, hasActiveOrigins(1)); + assertThat(inventory.originCount(ACTIVE), is(1)); inventory.originUnhealthy(ORIGIN_1); - assertThat(inventory, hasNoActiveOrigins()); + assertThat(inventory.originCount(ACTIVE), is(0)); assertThat(gaugeValue("origins.generic-app.app-01.status"), isValue(0)); verify(eventBus, times(2)).post(any(OriginsSnapshot.class)); } @@ -339,12 +337,12 @@ public void removesUnhealthyOriginsFromActiveSet() { @Test public void putsHealthyOriginsBackIntoActiveSet() { inventory.setOrigins(ORIGIN_1); - assertThat(inventory, hasActiveOrigins(1)); + assertThat(inventory.originCount(ACTIVE), is(1)); inventory.originUnhealthy(ORIGIN_1); inventory.originHealthy(ORIGIN_1); - assertThat(inventory, hasActiveOrigins(1)); + assertThat(inventory.originCount(ACTIVE), is(1)); assertThat(gaugeValue("origins.generic-app.app-01.status"), isValue(1)); verify(eventBus, times(3)).post(any(OriginsSnapshot.class)); } @@ -352,26 +350,26 @@ public void putsHealthyOriginsBackIntoActiveSet() { @Test public void reportingUpRepeatedlyDoesNotAffectCurrentActiveOrigins() { inventory.setOrigins(ORIGIN_1); - assertThat(inventory, hasActiveOrigins(1)); + assertThat(inventory.originCount(ACTIVE), is(1)); inventory.originHealthy(ORIGIN_1); inventory.originHealthy(ORIGIN_1); inventory.originHealthy(ORIGIN_1); - assertThat(inventory, hasActiveOrigins(1)); + assertThat(inventory.originCount(ACTIVE), is(1)); verify(eventBus, times(1)).post(any(OriginsSnapshot.class)); } @Test public void reportingDownRepeatedlyDoesNotAffectCurrentActiveOrigins() { inventory.setOrigins(ORIGIN_1); - assertThat(inventory, hasActiveOrigins(1)); + assertThat(inventory.originCount(ACTIVE), is(1)); inventory.originUnhealthy(ORIGIN_1); inventory.originUnhealthy(ORIGIN_1); inventory.originUnhealthy(ORIGIN_1); - assertThat(inventory, hasActiveOrigins(0)); + assertThat(inventory.originCount(ACTIVE), is(0)); verify(eventBus, times(2)).post(any(OriginsSnapshot.class)); } @@ -475,22 +473,6 @@ public void stopsMonitoringAndUnregistersWhenClosed() { verify(eventBus).unregister(eq(inventory)); } - private static Matcher hasNoActiveOrigins() { - return hasActiveOrigins(0); - } - - private static Matcher hasActiveOrigins(int numberOfActiveOrigins) { - return hasOrigins(numberOfActiveOrigins, ACTIVE); - } - - private static Matcher hasDisabledOrigins(int numberOfDisabledOrigins) { - return hasOrigins(numberOfDisabledOrigins, DISABLED); - } - - private static Matcher hasOrigins(int numberOfOrigins, OriginsInventory.OriginState state) { - return hasDerivedValue(inventory -> inventory.originCount(state), is(numberOfOrigins)); - } - private Optional gaugeValue(String name) { return gauge(name) .map(Gauge::getValue) diff --git a/components/common/pom.xml b/components/common/pom.xml index 1019ebdfc5..86222dea06 100644 --- a/components/common/pom.xml +++ b/components/common/pom.xml @@ -55,6 +55,11 @@ testng + + org.hamcrest + hamcrest-all + + org.mockito mockito-all diff --git a/components/common/src/main/java/com/hotels/styx/common/MorePreconditions.java b/components/common/src/main/java/com/hotels/styx/common/MorePreconditions.java deleted file mode 100644 index 04ae4960db..0000000000 --- a/components/common/src/main/java/com/hotels/styx/common/MorePreconditions.java +++ /dev/null @@ -1,111 +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 com.google.common.base.Preconditions; -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.StringDescription; - -import static com.google.common.base.Strings.isNullOrEmpty; -import static org.hamcrest.Matchers.allOf; -import static org.hamcrest.Matchers.greaterThanOrEqualTo; -import static org.hamcrest.Matchers.lessThanOrEqualTo; - -/** - * Static convenience methods that help a method or constructor check whether it was invoked - * correctly (whether its preconditions have been met). - */ -public final class MorePreconditions { - /** - * Ensures that the string passed as a parameter to the calling method is not null or empty. - * - * @param value a string - * @return the same string if non-empty - * @throws NullPointerException if {@code value} is null or empty - */ - public static String checkNotEmpty(String value) { - Preconditions.checkArgument(!isNullOrEmpty(value)); - return value; - } - - /** - * Ensures the truth of an expression involving one or more parameters to the calling method. - * - * @param reference a reference to pass through if the {@code expression} is true - * @param expression a boolean expression - * @param reference type - * @return the same reference passed in (if {@code expression} is true) - * @throws IllegalArgumentException if {@code expression} is false - */ - public static T checkArgument(T reference, boolean expression) { - Preconditions.checkArgument(expression); - return reference; - } - - - /** - * Ensures that an object reference passed as a parameter to the calling method satisfies - * the condition specified by the matcher. - * - * @param reference an object reference - * @param condition the condition to be satisfied - * @param reference type - * @return the same reference passed in - * @throws IllegalArgumentException if {@code condition} is false - */ - public static T checkArgument(T reference, Matcher condition) { - return checkArgument(reference, condition, "argument"); - } - - /** - * Ensures that an object reference passed as a parameter to the calling method satisfies - * the condition specified by the matcher. - * - * @param reference an object reference - * @param condition the condition to be satisfied - * @param referenceName the name of the argument to use in the error description - * @param reference type - * @return the same reference passed in - * @throws IllegalArgumentException if {@code condition} is false - */ - public static T checkArgument(T reference, Matcher condition, String referenceName) { - if (!condition.matches(reference)) { - Description description = new StringDescription(); - description.appendText(referenceName) - .appendText("\nExpected: ") - .appendDescriptionOf(condition) - .appendText("\n but: "); - condition.describeMismatch(reference, description); - throw new IllegalArgumentException(description.toString()); - } - return reference; - } - - /** - * A matcher that checks whether an integer is between a given minimum and maximum (inclusive). - * - * @param minimum minimum value (inclusive) - * @param maximum maximum value (inclusive) - * @return the matcher - */ - public static Matcher inRange(int minimum, int maximum) { - return allOf(greaterThanOrEqualTo(minimum), lessThanOrEqualTo(maximum)); - } - - private MorePreconditions() { - } -} diff --git a/components/common/src/main/java/com/hotels/styx/common/Preconditions.java b/components/common/src/main/java/com/hotels/styx/common/Preconditions.java new file mode 100644 index 0000000000..4bf170eba0 --- /dev/null +++ b/components/common/src/main/java/com/hotels/styx/common/Preconditions.java @@ -0,0 +1,57 @@ +/* + 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; + +/** + * Static convenience methods that help a method or constructor check whether it was invoked + * correctly (whether its preconditions have been met). + */ +public final class Preconditions { + /** + * Ensures that the string passed as a parameter to the calling method is not null or empty. + * + * @param value a string + * @return the same string if non-empty + * @throws NullPointerException if {@code value} is null or empty + */ + public static String checkNotEmpty(String value) { + + if (value == null || value.length() == 0) { + throw new IllegalArgumentException(); + } + return value; + } + + /** + * Ensures the truth of an expression involving one or more parameters to the calling method. + * + * @param reference a reference to pass through if the {@code expression} is true + * @param expression a boolean expression + * @param reference type + * @return the same reference passed in (if {@code expression} is true) + * @throws IllegalArgumentException if {@code expression} is false + */ + public static 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