-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simple unit test to verify (parts of) #33
- Loading branch information
1 parent
85cc17a
commit ddf256f
Showing
8 changed files
with
220 additions
and
35 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
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
48 changes: 48 additions & 0 deletions
48
json/src/test/java/com/fasterxml/jackson/jaxrs/json/ResourceTestBase.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,48 @@ | ||
package com.fasterxml.jackson.jaxrs.json; | ||
|
||
import java.io.*; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import javax.ws.rs.core.Application; | ||
|
||
public class ResourceTestBase extends JaxrsTestBase | ||
{ | ||
protected static abstract class JsonApplication extends Application | ||
{ | ||
protected final Object _resource; | ||
|
||
protected JsonApplication(Object r) { _resource = r; } | ||
|
||
@Override | ||
public Set<Object> getSingletons() { | ||
HashSet<Object> singletons = new HashSet<Object>(); | ||
singletons.add(new JacksonJsonProvider()); | ||
singletons.add(_resource); | ||
return singletons; | ||
} | ||
} | ||
|
||
protected String aposToQuotes(String json) { | ||
return json.replace("'", "\""); | ||
} | ||
|
||
protected String readUTF8(InputStream in) throws IOException | ||
{ | ||
return new String(readAll(in), "UTF-8"); | ||
} | ||
|
||
protected byte[] readAll(InputStream in) throws IOException | ||
{ | ||
ByteArrayOutputStream bytes = new ByteArrayOutputStream(100); | ||
byte[] buffer = new byte[500]; | ||
int count; | ||
|
||
while ((count = in.read(buffer)) > 0) { | ||
bytes.write(buffer, 0, count); | ||
} | ||
in.close(); | ||
return bytes.toByteArray(); | ||
} | ||
} |
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.