summaryrefslogtreecommitdiff
path: root/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java')
-rw-r--r--qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java
index 469e6ce52b..31d148a529 100644
--- a/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java
+++ b/qpid/java/systests/src/main/java/org/apache/qpid/systest/rest/RestTestHelper.java
@@ -31,10 +31,12 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLDecoder;
+import java.net.URLEncoder;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.util.Collections;
@@ -575,4 +577,20 @@ public class RestTestHelper
}
}
+ public String encode(String value, String encoding) throws UnsupportedEncodingException
+ {
+ return URLEncoder.encode(value, encoding).replace("+", "%20");
+ }
+
+ public String encodeAsUTF(String value)
+ {
+ try
+ {
+ return encode(value, "UTF8");
+ }
+ catch(UnsupportedEncodingException e)
+ {
+ throw new RuntimeException("Unsupported encoding UTF8", e);
+ }
+ }
}