Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
33 changes: 22 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<jackson-bind.version>2.14.2</jackson-bind.version>

<okhttp.version>3.14.9</okhttp.version>
<hamcrest.version>2.2</hamcrest.version>

<surefire.version>3.2.2</surefire.version>
<javadoc-plugin.version>3.7.0</javadoc-plugin.version>
Expand All @@ -82,6 +83,18 @@
</repository>
</repositories>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.10.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.msgpack</groupId>
Expand All @@ -96,12 +109,6 @@
<version>${okhttp.version}</version>
</dependency>

<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp-urlconnection</artifactId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okhttp-urlconnection is no longer used.

~/I/td-client-java ❯❯❯ mvn dependency:analyze-only
[INFO] Scanning for projects...
[INFO] 
[INFO] -----------------< com.treasuredata.client:td-client >------------------
[INFO] Building Treasure Data Client for Java 1.1.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-dependency-plugin:3.6.1:analyze-only (default-cli) @ td-client ---
[WARNING] Used undeclared dependencies found:
[WARNING]    com.google.code.findbugs:jsr305:jar:3.0.2:compile
[WARNING] Unused declared dependencies found:
[WARNING]    javax.annotation:javax.annotation-api:jar:1.3.2:compile
[WARNING]    com.squareup.okhttp3:okhttp-urlconnection:jar:3.14.9:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.280 s
[INFO] Finished at: 2024-03-14T16:15:03+09:00
[INFO] ------------------------------------------------------------------------

<version>${okhttp.version}</version>
</dependency>

<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
Expand Down Expand Up @@ -182,9 +189,13 @@
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -228,13 +239,13 @@
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>2.2</version>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>2.2</version>
<version>${hamcrest.version}</version>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.time.Instant;
import java.util.Date;
import java.util.Optional;

import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertFalse;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertFalse;

/**
*
Expand All @@ -29,14 +29,14 @@ public class TDRequestErrorHandlerTest
private static Logger logger = LoggerFactory.getLogger(TestTDHttpClient.class);
private TDHttpClient client;

@Before
@BeforeEach
public void setUp()
throws Exception
{
client = TDClient.newClient().httpClient;
}

@After
@AfterEach
public void tearDown()
throws Exception
{
Expand Down
25 changes: 16 additions & 9 deletions src/test/java/com/treasuredata/client/TestBackoff.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,36 @@
*/
package com.treasuredata.client;

import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class TestBackoff
{
@Test(expected = IllegalArgumentException.class)
@Test
public void invalidBaseIntervalArgument()
{
new ExponentialBackOff(-1, 10000, -1);
Assertions.assertThrows(IllegalArgumentException.class, () -> {
new ExponentialBackOff(-1, 10000, -1);
});
}

@Test(expected = IllegalArgumentException.class)
@Test
public void invalidMaxIntervalArgument()
{
new ExponentialBackOff(1000, -1, 1);
Assertions.assertThrows(IllegalArgumentException.class, () -> {
new ExponentialBackOff(1000, -1, 1);
});
}

@Test(expected = IllegalArgumentException.class)
@Test
public void invalidMultiplierArgument()
{
new FullJitterBackOff(1000, 10000, -1);
Assertions.assertThrows(IllegalArgumentException.class, () -> {
new FullJitterBackOff(1000, 10000, -1);
});
}

@Test
Expand Down
19 changes: 10 additions & 9 deletions src/test/java/com/treasuredata/client/TestProxyAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import com.treasuredata.client.model.TDTable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.HttpRequest;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.littleshoot.proxy.HttpFilters;
import org.littleshoot.proxy.HttpFiltersSourceAdapter;
import org.littleshoot.proxy.HttpProxyServer;
Expand All @@ -46,9 +46,10 @@
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

public class TestProxyAccess
{
Expand All @@ -69,7 +70,7 @@ static int findAvailablePort()
private static final String PROXY_PASS = "helloproxy";
private AtomicInteger proxyAccessCount = new AtomicInteger(0);

@Before
@BeforeEach
public void setUp()
throws Exception
{
Expand Down Expand Up @@ -106,7 +107,7 @@ public HttpFilters filterRequest(HttpRequest httpRequest, ChannelHandlerContext
}).start();
}

@After
@AfterEach
public void tearDown()
throws Exception
{
Expand Down Expand Up @@ -167,7 +168,7 @@ public void proxyApiAccess()
assertTrue(tableList.size() >= 2);

TDJobList jobList = client.listJobs();
assertTrue(jobList.getJobs().size() > 0);
assertFalse(jobList.getJobs().isEmpty());

logger.debug("proxy access count: {}", proxyAccessCount);
assertEquals(1, proxyAccessCount.get());
Expand Down
16 changes: 8 additions & 8 deletions src/test/java/com/treasuredata/client/TestSSLProxyAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import com.treasuredata.client.model.TDTable;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.HttpRequest;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.littleshoot.proxy.HttpFilters;
import org.littleshoot.proxy.HttpFiltersSourceAdapter;
import org.littleshoot.proxy.HttpProxyServer;
Expand All @@ -35,9 +35,9 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
*
Expand All @@ -51,7 +51,7 @@ public class TestSSLProxyAccess
private static final String PROXY_PASS = "helloproxy";
private AtomicInteger proxyAccessCount = new AtomicInteger(0);

@Before
@BeforeEach
public void setUp()
throws Exception
{
Expand Down Expand Up @@ -87,7 +87,7 @@ public HttpFilters filterRequest(HttpRequest httpRequest, ChannelHandlerContext
}).start();
}

@After
@AfterEach
public void tearDown()
throws Exception
{
Expand Down
18 changes: 9 additions & 9 deletions src/test/java/com/treasuredata/client/TestServerFailures.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -39,12 +39,12 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.anyOf;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

/**
*
Expand All @@ -58,15 +58,15 @@ public class TestServerFailures
private MockWebServer server;
private int port;

@Before
@BeforeEach
public void setUp()
throws Exception
{
port = TestProxyAccess.findAvailablePort();
server = new MockWebServer();
}

@After
@AfterEach
public void tearDown()
throws Exception
{
Expand Down
Loading