Skip to content

Commit c5bc4d8

Browse files
authored
Merge pull request Kong#169 from wtetsu/fix/uncompilable_java_asynchttp_code
Fix uncompilable code of Java asynchttp
2 parents d2203fb + 5350ca8 commit c5bc4d8

16 files changed

+16
-16
lines changed

src/targets/java/asynchttp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = function (source, options) {
2121

2222
code.push('AsyncHttpClient client = new DefaultAsyncHttpClient();')
2323

24-
code.push(`client.prepare${source.method[0].toUpperCase()}${source.method.substring(1).toLowerCase()}("${source.fullUrl}")`)
24+
code.push(`client.prepare("${source.method.toUpperCase()}", "${source.fullUrl}")`)
2525

2626
// Add headers, including the cookies
2727
var headers = Object.keys(source.allHeaders)

test/fixtures/output/java/asynchttp/application-form-encoded.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AsyncHttpClient client = new DefaultAsyncHttpClient();
2-
client.preparePost("http://mockbin.com/har")
2+
client.prepare("POST", "http://mockbin.com/har")
33
.setHeader("content-type", "application/x-www-form-urlencoded")
44
.setBody("foo=bar&hello=world")
55
.execute()

test/fixtures/output/java/asynchttp/application-json.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AsyncHttpClient client = new DefaultAsyncHttpClient();
2-
client.preparePost("http://mockbin.com/har")
2+
client.prepare("POST", "http://mockbin.com/har")
33
.setHeader("content-type", "application/json")
44
.setBody("{\"number\":1,\"string\":\"f\\\"oo\",\"arr\":[1,2,3],\"nested\":{\"a\":\"b\"},\"arr_mix\":[1,\"a\",{\"arr_mix_nested\":{}}],\"boolean\":false}")
55
.execute()

test/fixtures/output/java/asynchttp/cookies.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AsyncHttpClient client = new DefaultAsyncHttpClient();
2-
client.preparePost("http://mockbin.com/har")
2+
client.prepare("POST", "http://mockbin.com/har")
33
.setHeader("cookie", "foo=bar; bar=baz")
44
.execute()
55
.toCompletableFuture()

test/fixtures/output/java/asynchttp/custom-method.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AsyncHttpClient client = new DefaultAsyncHttpClient();
2-
client.preparePropfind("http://mockbin.com/har")
2+
client.prepare("PROPFIND", "http://mockbin.com/har")
33
.execute()
44
.toCompletableFuture()
55
.thenAccept(System.out::println)

test/fixtures/output/java/asynchttp/full.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AsyncHttpClient client = new DefaultAsyncHttpClient();
2-
client.preparePost("http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value")
2+
client.prepare("POST", "http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value")
33
.setHeader("cookie", "foo=bar; bar=baz")
44
.setHeader("accept", "application/json")
55
.setHeader("content-type", "application/x-www-form-urlencoded")

test/fixtures/output/java/asynchttp/headers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AsyncHttpClient client = new DefaultAsyncHttpClient();
2-
client.prepareGet("http://mockbin.com/har")
2+
client.prepare("GET", "http://mockbin.com/har")
33
.setHeader("accept", "application/json")
44
.setHeader("x-foo", "Bar")
55
.execute()

test/fixtures/output/java/asynchttp/https.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AsyncHttpClient client = new DefaultAsyncHttpClient();
2-
client.prepareGet("https://mockbin.com/har")
2+
client.prepare("GET", "https://mockbin.com/har")
33
.execute()
44
.toCompletableFuture()
55
.thenAccept(System.out::println)

test/fixtures/output/java/asynchttp/jsonObj-multiline.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AsyncHttpClient client = new DefaultAsyncHttpClient();
2-
client.preparePost("http://mockbin.com/har")
2+
client.prepare("POST", "http://mockbin.com/har")
33
.setHeader("content-type", "application/json")
44
.setBody("{\n \"foo\": \"bar\"\n}")
55
.execute()

test/fixtures/output/java/asynchttp/jsonObj-null-value.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AsyncHttpClient client = new DefaultAsyncHttpClient();
2-
client.preparePost("http://mockbin.com/har")
2+
client.prepare("POST", "http://mockbin.com/har")
33
.setHeader("content-type", "application/json")
44
.setBody("{\"foo\":null}")
55
.execute()

0 commit comments

Comments
 (0)