-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#18] Factor out conversation form REST-assured requests to curl-logg…
…er-restassured module
- Loading branch information
Showing
19 changed files
with
531 additions
and
364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>curl-logger</artifactId> | ||
<groupId>com.github.dzieciou.testing</groupId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>curl-logger-core</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
<version>4.5.3</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.rest-assured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
</dependency> | ||
|
||
<!-- Test scope --> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hamcrest</groupId> | ||
<artifactId>hamcrest-all</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
<version>23.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
curl-logger-core/src/main/java/com/github/dzieciou/testing/curl/core/Http2Curl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.github.dzieciou.testing.curl.core; | ||
|
||
import java.io.IOException; | ||
import org.apache.http.HttpRequest; | ||
|
||
|
||
public abstract class Http2Curl<RequestT> { | ||
|
||
protected final Options options; | ||
|
||
public Http2Curl(Options options) { | ||
this.options = options; | ||
} | ||
|
||
/** | ||
* Generates single-line CURL command for a given HTTP request. | ||
* | ||
* @param request HTTP request | ||
* @return CURL command | ||
* @throws Exception if failed to generate CURL command | ||
*/ | ||
public String generateCurl(RequestT request) throws Exception { | ||
|
||
CurlCommand curl = http2curl(request); | ||
options.getCurlUpdater().ifPresent(updater -> updater.accept(curl)); | ||
return curl | ||
.asString(options.getTargetPlatform(), options.useShortForm(), options.printMultiliner()); | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
protected abstract CurlCommand http2curl(RequestT request) | ||
throws NoSuchFieldException, IllegalAccessException, IOException; | ||
} |
2 changes: 1 addition & 1 deletion
2
...github/dzieciou/testing/curl/Options.java → ...b/dzieciou/testing/curl/core/Options.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ithub/dzieciou/testing/curl/Platform.java → .../dzieciou/testing/curl/core/Platform.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.github.dzieciou.testing.curl; | ||
package com.github.dzieciou.testing.curl.core; | ||
|
||
|
||
public enum Platform { | ||
|
2 changes: 1 addition & 1 deletion
2
...zieciou/testing/curl/CurlCommandTest.java → ...ou/testing/curl/core/CurlCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>curl-logger</artifactId> | ||
<groupId>com.github.dzieciou.testing</groupId> | ||
<version>2.0.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>curl-logger-restassured</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.github.dzieciou.testing</groupId> | ||
<artifactId>curl-logger-core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.rest-assured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
</dependency> | ||
|
||
<!-- Test scope --> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hamcrest</groupId> | ||
<artifactId>hamcrest-all</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-all</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>uk.org.lidalia</groupId> | ||
<artifactId>slf4j-test</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mock-server</groupId> | ||
<artifactId>mockserver-netty</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
</dependency> | ||
<dependency> | ||
<artifactId>jackson-databind</artifactId> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.