Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Excavator: Upgrades Baseline to the latest version
  • Loading branch information
svc-excavator-bot committed Sep 17, 2019
commit 735fc3093756e02bec1658714d88b45acf771a5f
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
classpath 'com.netflix.nebula:gradle-dependency-lock-plugin:7.0.1'
classpath 'com.netflix.nebula:nebula-publishing-plugin:13.5.1'
classpath 'com.palantir.baseline:gradle-baseline-java:2.5.0'
classpath 'com.palantir.baseline:gradle-baseline-java:2.6.0'
classpath 'com.palantir.gradle.gitversion:gradle-git-version:0.12.2'
classpath 'gradle.plugin.org.inferred:gradle-processors:3.1.0'
classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:1.12.4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

package com.palantir.conjure.java.client.jaxrs;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.assertj.core.api.Assertions.fail;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

import com.google.common.collect.Lists;
import com.palantir.conjure.java.client.config.ClientConfiguration;
Expand All @@ -35,6 +35,7 @@
import java.util.concurrent.Future;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import org.assertj.core.api.HamcrestCondition;
import org.junit.Test;
import org.junit.experimental.theories.DataPoints;
import org.junit.experimental.theories.FromDataPoints;
Expand Down Expand Up @@ -86,7 +87,7 @@ public void testConnectionError_performsFailover(
failoverTestCase.server1.shutdown();
failoverTestCase.server2.enqueue(new MockResponse().setBody("\"foo\""));

assertThat(proxy.string(), is("foo"));
assertThat(proxy.string()).is(new HamcrestCondition<>(is("foo")));
}

@Test
Expand All @@ -107,7 +108,7 @@ public void testConnectionError_performsFailover_concurrentRequests(
things.add(executorService.submit(() -> proxy.string()));
}
for (int i = 0; i < 10; i++) {
assertThat(things.get(i).get(), is("foo"));
assertThat(things.get(i).get()).is(new HamcrestCondition<>(is("foo")));
}
}

Expand All @@ -123,16 +124,16 @@ public void testConnectionError_whenOneCallFailsThenSubsequentNewCallsCanStillSu

try {
proxy.string();
fail();
fail("fail");
} catch (RetryableException e) {
assertThat(e.getMessage(), startsWith("Failed to complete the request due to an IOException"));
assertThat(e.getMessage()).is(new HamcrestCondition<>(startsWith("Failed to complete the request due to an IOException")));
}

// Subsequent call (with the same proxy instance) succeeds.
MockWebServer anotherServer1 = new MockWebServer(); // Not a @Rule so we can control start/stop/port explicitly
anotherServer1.start(failoverTestCase.server1.getPort());
anotherServer1.enqueue(new MockResponse().setBody("\"foo\""));
assertThat(proxy.string(), is("foo"));
assertThat(proxy.string()).is(new HamcrestCondition<>(is("foo")));
anotherServer1.shutdown();
}

Expand All @@ -146,7 +147,7 @@ public void testQosError_performsFailover(
failoverTestCase.server1.enqueue(new MockResponse().setBody("\"foo\""));
failoverTestCase.server2.enqueue(new MockResponse().setBody("\"bar\""));

assertThat(proxy.string(), is("bar"));
assertThat(proxy.string()).is(new HamcrestCondition<>(is("bar")));
}

@Test
Expand All @@ -163,8 +164,8 @@ public void testConnectionError_performsFailoverOnDnsFailure(
"http://localhost:" + failoverTestCase.server1.getPort()))
.maxNumRetries(2)
.build());
assertThat(bogusHostProxy.string(), is("foo"));
assertThat(failoverTestCase.server1.getRequestCount(), is(1));
assertThat(bogusHostProxy.string()).is(new HamcrestCondition<>(is("foo")));
assertThat(failoverTestCase.server1.getRequestCount()).is(new HamcrestCondition<>(is(1)));
}

@Test
Expand All @@ -182,7 +183,7 @@ public void testQosError_performsRetryWithOneNode() throws Exception {
.maxNumRetries(2)
.build());

assertThat(anotherProxy.string(), is("foo"));
assertThat(anotherProxy.string()).is(new HamcrestCondition<>(is("foo")));
}

@Test
Expand All @@ -201,7 +202,7 @@ public void testQosError_performsRetryWithOneNodeAndCache() throws Exception {
.failedUrlCooldown(Duration.ofMillis(CACHE_DURATION))
.build());

assertThat(anotherProxy.string(), is("foo"));
assertThat(anotherProxy.string()).is(new HamcrestCondition<>(is("foo")));
}

@Test
Expand Down Expand Up @@ -231,7 +232,7 @@ public void testCache_recovery() throws Exception {

anotherServer1.enqueue(new MockResponse().setResponseCode(503));
anotherServer1.enqueue(new MockResponse().setBody("\"foo\""));
assertThat(anotherProxy.string(), is("foo"));
assertThat(anotherProxy.string()).is(new HamcrestCondition<>(is("foo")));
anotherServer1.shutdown();
}

Expand All @@ -249,8 +250,8 @@ public void testPerformsRoundRobin() throws Exception {
proxy.string();
proxy.string();

assertThat(failoverTestCase.server1.getRequestCount(), is(1));
assertThat(failoverTestCase.server2.getRequestCount(), is(1));
assertThat(failoverTestCase.server1.getRequestCount()).is(new HamcrestCondition<>(is(1)));
assertThat(failoverTestCase.server2.getRequestCount()).is(new HamcrestCondition<>(is(1)));
}

private static class FailoverTestCase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package com.palantir.conjure.java.client.jaxrs;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;

import com.palantir.conjure.java.okhttp.HostMetricsRegistry;
import javax.ws.rs.GET;
Expand All @@ -29,6 +29,7 @@
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import org.assertj.core.api.HamcrestCondition;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -79,65 +80,64 @@ public void testCannotDecorateInterfaceWithOptionalPathParam() {
AGENT,
new HostMetricsRegistry(),
createTestConfig("http://localhost:" + server.getPort()));
fail();
fail("fail");
} catch (RuntimeException e) {
assertThat(e.getMessage(),
is("Cannot use Guava Optionals with PathParams. (Class: com.palantir.conjure"
assertThat(e.getMessage()).is(new HamcrestCondition<>(is("Cannot use Guava Optionals with PathParams. (Class: com.palantir.conjure"
+ ".java.client.jaxrs.JaxRsClientGuavaOptionalHandlingTest$CannotDecorateInterface,"
+ " Method: path, Param: arg0)"));
+ " Method: path, Param: arg0)")));
}
}

@Test
public void testRegularPathParam() throws Exception {
proxy.path("str2");
RecordedRequest takeRequest = server.takeRequest();
assertThat(takeRequest.getPath(), is("/foo/str2"));
assertThat(takeRequest.getPath()).is(new HamcrestCondition<>(is("/foo/str2")));
}

@Test
public void testAbsentQuery() throws Exception {
proxy.query(com.google.common.base.Optional.absent(), "str2");
RecordedRequest takeRequest = server.takeRequest();
assertThat(takeRequest.getRequestLine(), is("GET /foo?req=str2 HTTP/1.1"));
assertThat(takeRequest.getRequestLine()).is(new HamcrestCondition<>(is("GET /foo?req=str2 HTTP/1.1")));
}

@Test
public void testEmptyStringQuery() throws Exception {
proxy.query(com.google.common.base.Optional.of(""), "str2");
RecordedRequest takeRequest = server.takeRequest();
assertThat(takeRequest.getRequestLine(), is("GET /foo?opt=&req=str2 HTTP/1.1"));
assertThat(takeRequest.getRequestLine()).is(new HamcrestCondition<>(is("GET /foo?opt=&req=str2 HTTP/1.1")));
}

@Test
public void testStringQuery() throws Exception {
proxy.query(com.google.common.base.Optional.of("str"), "str2");
RecordedRequest takeRequest = server.takeRequest();
assertThat(takeRequest.getRequestLine(), is("GET /foo?opt=str&req=str2 HTTP/1.1"));
assertThat(takeRequest.getRequestLine()).is(new HamcrestCondition<>(is("GET /foo?opt=str&req=str2 HTTP/1.1")));
}

@Test
public void testAbsentHeader() throws Exception {
proxy.header(com.google.common.base.Optional.absent(), "str2");
RecordedRequest takeRequest = server.takeRequest();
assertThat(takeRequest.getHeader("opt"), is(""));
assertThat(takeRequest.getHeader("req"), is("str2"));
assertThat(takeRequest.getHeader("opt")).is(new HamcrestCondition<>(is("")));
assertThat(takeRequest.getHeader("req")).is(new HamcrestCondition<>(is("str2")));
}

@Test
public void testEmptyStringHeader() throws Exception {
proxy.header(com.google.common.base.Optional.of(""), "str2");
RecordedRequest takeRequest = server.takeRequest();
assertThat(takeRequest.getHeader("opt"), is(""));
assertThat(takeRequest.getHeader("req"), is("str2"));
assertThat(takeRequest.getHeader("opt")).is(new HamcrestCondition<>(is("")));
assertThat(takeRequest.getHeader("req")).is(new HamcrestCondition<>(is("str2")));
}

@Test
public void testStringHeader() throws Exception {
proxy.header(com.google.common.base.Optional.of("str"), "str2");
RecordedRequest takeRequest = server.takeRequest();
assertThat(takeRequest.getHeader("opt"), is("str"));
assertThat(takeRequest.getHeader("req"), is("str2"));
assertThat(takeRequest.getHeader("opt")).is(new HamcrestCondition<>(is("str")));
assertThat(takeRequest.getHeader("req")).is(new HamcrestCondition<>(is("str2")));
}

}
Loading