summaryrefslogtreecommitdiffstats
path: root/simple/simple-http/src/test/java/org/simpleframework/http/message/MockBody.java
diff options
context:
space:
mode:
Diffstat (limited to 'simple/simple-http/src/test/java/org/simpleframework/http/message/MockBody.java')
-rw-r--r--simple/simple-http/src/test/java/org/simpleframework/http/message/MockBody.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/simple/simple-http/src/test/java/org/simpleframework/http/message/MockBody.java b/simple/simple-http/src/test/java/org/simpleframework/http/message/MockBody.java
new file mode 100644
index 0000000..4a4ee75
--- /dev/null
+++ b/simple/simple-http/src/test/java/org/simpleframework/http/message/MockBody.java
@@ -0,0 +1,47 @@
+package org.simpleframework.http.message;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+
+import org.simpleframework.http.Part;
+import org.simpleframework.http.message.PartData;
+
+
+public class MockBody implements Body {
+
+ protected PartData list;
+
+ protected String body;
+
+ public MockBody() {
+ this("");
+ }
+
+ public MockBody(String body) {
+ this.list = new PartData();
+ this.body = body;
+ }
+
+ public List<Part> getParts() {
+ return list.getParts();
+ }
+
+ public Part getPart(String name) {
+ return list.getPart(name);
+ }
+
+ public String getContent(String charset) {
+ return body;
+ }
+
+ public InputStream getInputStream() throws IOException {
+ return new ByteArrayInputStream(body.getBytes("UTF-8"));
+ }
+
+ public String getContent() throws IOException {
+ return body;
+ }
+
+}