-
Notifications
You must be signed in to change notification settings - Fork 615
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISPN-12075 Remove alternative http clients from the testsuite
- Loading branch information
Showing
31 changed files
with
526 additions
and
1,030 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
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
36 changes: 36 additions & 0 deletions
36
...-client/src/main/java/org/infinispan/client/rest/impl/okhttp/InputStreamEntityOkHttp.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,36 @@ | ||
package org.infinispan.client.rest.impl.okhttp; | ||
|
||
import java.io.InputStream; | ||
|
||
import org.infinispan.client.rest.RestEntity; | ||
import org.infinispan.commons.dataconversion.MediaType; | ||
|
||
import okhttp3.RequestBody; | ||
|
||
/** | ||
* @since 12.0 | ||
*/ | ||
public class InputStreamEntityOkHttp implements RestEntity, RestEntityAdaptorOkHttp { | ||
private final MediaType contentType; | ||
private final InputStream inputStream; | ||
|
||
public InputStreamEntityOkHttp(MediaType contentType, InputStream inputStream) { | ||
this.contentType = contentType; | ||
this.inputStream = inputStream; | ||
} | ||
|
||
@Override | ||
public String getBody() { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public MediaType contentType() { | ||
return contentType; | ||
} | ||
|
||
@Override | ||
public RequestBody toRequestBody() { | ||
return new StreamRequestBody(okhttp3.MediaType.get(contentType.toString()), inputStream); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...t/rest-client/src/main/java/org/infinispan/client/rest/impl/okhttp/StreamRequestBody.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,36 @@ | ||
package org.infinispan.client.rest.impl.okhttp; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import okhttp3.MediaType; | ||
import okhttp3.RequestBody; | ||
import okio.BufferedSink; | ||
import okio.Okio; | ||
import okio.Source; | ||
|
||
/** | ||
* Support for {@link java.io.InputStream} to be used in POST and PUT {@link okhttp3.RequestBody}. | ||
* @since 12.0 | ||
*/ | ||
public class StreamRequestBody extends RequestBody { | ||
private final MediaType contentType; | ||
private final InputStream inputStream; | ||
|
||
public StreamRequestBody(MediaType contentType, InputStream inputStream) { | ||
this.contentType = contentType; | ||
this.inputStream = inputStream; | ||
} | ||
|
||
@Override | ||
public MediaType contentType() { | ||
return contentType; | ||
} | ||
|
||
@Override | ||
public void writeTo(BufferedSink sink) throws IOException { | ||
try (Source source = Okio.source(inputStream)) { | ||
sink.writeAll(source); | ||
} | ||
} | ||
} |
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
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.