Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New http client #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
41 changes: 30 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<description>A simple rest client, used by the RestFixture</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mave.compiler.target>1.8</mave.compiler.target>
<mave.compiler.source>1.8</mave.compiler.source>
</properties>
<licenses>
<license>
Expand Down Expand Up @@ -53,14 +55,25 @@
</issueManagement>
<dependencies>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<version>5.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -76,8 +89,14 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.0</version>
<artifactId>mockito-core</artifactId>
<version>3.9.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>3.9.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -93,8 +112,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -149,7 +168,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.12.2</version>
<version>2.12.4</version>
<configuration>
<!-- place your configuration here -->
</configuration>
Expand Down
222 changes: 107 additions & 115 deletions src/main/java/smartrics/rest/client/RestClientImpl.java

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/main/java/smartrics/rest/client/RestData.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public String toString() {
}
}

private final List<Header> headers = new ArrayList<Header>();
private byte raw[];
private final List<Header> headers = new ArrayList<>();
private byte[] raw;
private String resource;
private Long transactionId;

Expand Down Expand Up @@ -170,7 +170,7 @@ public List<Header> getHeaders() {
* @return the sub-list of headers with the same name
*/
public List<Header> getHeader(String name) {
List<Header> headersWithTheSameName = new ArrayList<Header>();
List<Header> headersWithTheSameName = new ArrayList<>();
for (Header h : headers) {
if (h.getName().equalsIgnoreCase(name)) {
headersWithTheSameName.add(h);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/smartrics/rest/client/RestMultipart.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public enum RestMultipartType {
* @param stringValue The String content or the file Path
*/
public RestMultipart(RestMultipartType type, String stringValue) {
this(type, stringValue, (String)null, (String)null);
this(type, stringValue, null, null);
}

public RestMultipart(RestMultipartType type,String stringValue, String contentType) {
this(type, stringValue, contentType, (String)null);
this(type, stringValue, contentType, null);
}

public RestMultipart(RestMultipartType type, String stringValue, String contentType, String charset) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/smartrics/rest/client/RestRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class RestRequest extends RestData {
* An http verb (those supported).
*/
public enum Method {
Get, Post, Put, Delete, Head, Options, Trace
Get, Post, Put, Delete, Head, Options, Trace, Patch
}

private static final String FILE = "file";
Expand All @@ -41,7 +41,7 @@ public enum Method {
private String multipartFileName;
@Deprecated
private String multipartFileParameterName = FILE;
private Map<String,RestMultipart> multipartFileByParamName = new LinkedHashMap<String, RestMultipart>();
private final Map<String,RestMultipart> multipartFileByParamName = new LinkedHashMap<>();
private String query;
private Method method;
private boolean followRedirect = true;
Expand Down
51 changes: 0 additions & 51 deletions src/test/java/smartrics/rest/client/MockHttpClient.java

This file was deleted.

82 changes: 0 additions & 82 deletions src/test/java/smartrics/rest/client/MockHttpMethod.java

This file was deleted.

66 changes: 0 additions & 66 deletions src/test/java/smartrics/rest/client/MockRestClient.java

This file was deleted.

Loading