Skip to content

Commit

Permalink
Merge pull request #30 from yammer/dropwizard_110
Browse files Browse the repository at this point in the history
Dropwizard 110
  • Loading branch information
chrisgray authored Apr 11, 2017
2 parents b6e3df5 + 314c98f commit 88de1fd
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 92 deletions.
8 changes: 7 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
Next
0.6.0 - Apr. 11, 2017
---
* [Dropwizard 1.1.0](http://www.dropwizard.io/1.1.0/docs/about/release-notes.html)
* [Tenacity 1.1.0](https://github.com/yammer/tenacity/blob/master/CHANGES.md)
* Dropped dependency on PowerMock
* Mockito 2.7.22

---
* [Dropwizard 1.0.6](http://www.dropwizard.io/1.0.6/docs/about/release-notes.html)
* PostgreSQL 42.0.0
Expand Down
5 changes: 5 additions & 0 deletions breakerbox-azure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,10 @@
<artifactId>dropwizard-testing</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.yammer.breakerbox.azure.healthchecks.tests;

import com.codahale.metrics.health.HealthCheck;
import com.google.common.collect.ImmutableList;
import com.yammer.breakerbox.azure.TableClient;
import com.yammer.breakerbox.azure.core.TableId;
Expand All @@ -19,7 +18,7 @@ public void healthy() throws Exception {
final TableClientHealthcheck tableClientHealthcheck = new TableClientHealthcheck(mockTableClient);

when(mockTableClient.listTables()).thenReturn(ImmutableList.of(TableId.SERVICE.toString()));
assertThat(tableClientHealthcheck.check()).isEqualTo(HealthCheck.Result.healthy());
assertThat(tableClientHealthcheck.check().isHealthy()).isTrue();
}

@Test
Expand All @@ -28,6 +27,6 @@ public void unhealthy() throws Exception {
final TableClientHealthcheck tableClientHealthcheck = new TableClientHealthcheck(mockTableClient);

when(mockTableClient.listTables()).thenReturn(ImmutableList.<String>of());
assertThat(tableClientHealthcheck.check()).isEqualTo(HealthCheck.Result.unhealthy("Could not list tables"));
assertThat(tableClientHealthcheck.check().isHealthy()).isFalse();
}
}
18 changes: 1 addition & 17 deletions breakerbox-turbine/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@
<groupId>io.dropwizard</groupId>
<artifactId>dropwizard-testing</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>mockito-core</artifactId>
<groupId>org.mockito</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.yammer.tenacity</groupId>
Expand All @@ -42,19 +36,9 @@
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-api</artifactId>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
package com.yammer.breakerbox.turbine;

import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import javax.ws.rs.core.Response;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
Expand All @@ -21,15 +9,29 @@
import com.netflix.turbine.discovery.InstanceDiscovery;
import com.yammer.breakerbox.turbine.client.RancherClient;
import com.yammer.breakerbox.turbine.config.RancherInstanceConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.ws.rs.core.Response;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public class RancherInstanceDiscovery implements InstanceDiscovery {
private static final Logger LOGGER = LoggerFactory.getLogger(RancherInstanceDiscovery.class);
private RancherClient rancherClient;
private ObjectMapper mapper;
private final RancherClient rancherClient;
private final ObjectMapper mapper;

public RancherInstanceDiscovery(RancherInstanceConfiguration instanceConfiguration,
ObjectMapper mapper) {
this.rancherClient = new RancherClient(instanceConfiguration);
this(new RancherClient(instanceConfiguration), mapper);
}

public RancherInstanceDiscovery(RancherClient rancherClient, ObjectMapper mapper) {
this.rancherClient = rancherClient;
this.mapper = mapper;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,50 +1,37 @@
package com.yammer.breakerbox.turbine.tests;

import java.util.Arrays;
import java.util.Collection;

import javax.ws.rs.core.Response;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.netflix.turbine.discovery.Instance;
import com.yammer.breakerbox.turbine.RancherInstanceDiscovery;
import com.yammer.breakerbox.turbine.client.RancherClient;
import com.yammer.breakerbox.turbine.config.RancherInstanceConfiguration;

import io.dropwizard.jackson.Jackson;
import io.dropwizard.testing.FixtureHelpers;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import javax.ws.rs.core.Response;
import java.util.Arrays;
import java.util.Collection;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@RunWith(PowerMockRunner.class)
@PrepareForTest( {RancherInstanceDiscovery.class})
public class RancherInstanceDiscoveryTest {
private static final ObjectMapper MAPPER = new ObjectMapper();
private static final ObjectMapper MAPPER = Jackson.newObjectMapper();

@Mock
private RancherInstanceConfiguration rancherInstanceConfiguration;
@Mock
private RancherClient rancherClient;
@Mock
private Response response;
private RancherClient rancherClient = mock(RancherClient.class);
private Response response = mock(Response.class);

private RancherInstanceDiscovery rancherInstanceDiscovery;

@Before
public void setUp() throws Exception {
PowerMockito.whenNew(RancherClient.class).withAnyArguments().thenReturn(rancherClient);
Mockito.when(rancherClient.getServiceInstanceDetails()).thenReturn(response);
Mockito.when(response.getStatus()).thenReturn(200);
Mockito.when(response.readEntity(String.class))
when(rancherClient.getServiceInstanceDetails()).thenReturn(response);
when(response.getStatus()).thenReturn(Response.Status.OK.getStatusCode());
when(response.readEntity(String.class))
.thenReturn(FixtureHelpers.fixture("fixtures/rancherClientResponse.json"));
this.rancherInstanceDiscovery = new RancherInstanceDiscovery(rancherInstanceConfiguration, MAPPER);
rancherInstanceDiscovery = new RancherInstanceDiscovery(rancherClient, MAPPER);
}

@Test
Expand Down
11 changes: 11 additions & 0 deletions breakerbox-turbine/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<outputPatternAsHeader>false</outputPatternAsHeader>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="warn">
<appender-ref ref="STDOUT"/>
</root>
</configuration>
31 changes: 6 additions & 25 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,15 @@
</issueManagement>

<properties>
<dropwizard.version>1.0.6</dropwizard.version>
<dropwizard.version>1.1.0</dropwizard.version>
<windowsazure.version>0.4.6</windowsazure.version>
<tenacity.version>1.0.5</tenacity.version>
<tenacity.version>1.1.1</tenacity.version>
<turbine.version>1.0.0</turbine.version>
<dropwizard-auth-ldap.version>1.0.4</dropwizard-auth-ldap.version>
<postgresql.version>42.0.0</postgresql.version>
<h2.version>1.4.194</h2.version>
<kubernetes.version>2.2.144</kubernetes.version>
<powermock.version>1.6.6</powermock.version>
<mockito-all.version>1.10.19</mockito-all.version>
<mockito-core.version>2.7.22</mockito-core.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -141,28 +140,10 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>mockito-core</artifactId>
<groupId>org.mockito</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${mockito-all.version}</version>
<artifactId>mockito-core</artifactId>
<version>${mockito-core.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -272,7 +253,7 @@
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>2.0.18</version>
<version>2.0.19</version>
</dependency>
</dependencies>
</plugin>
Expand Down

0 comments on commit 88de1fd

Please sign in to comment.