Skip to content

Commit

Permalink
Used the commons library api where possible
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@1466100 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mcucchiara committed Apr 9, 2013
1 parent 23bd008 commit 1d64a3e
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions plugins/json/src/test/java/org/apache/struts2/json/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
*/
package org.apache.struts2.json;

import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.junit.Assert;

import java.io.InputStream;
import java.net.URL;
import java.util.StringTokenizer;

/**
* Utility methods for test classes
Expand All @@ -42,14 +42,7 @@ public class TestUtils {
* @return the normalized string
*/
public static String normalize(Object obj, boolean appendSpace) {
StringTokenizer st = new StringTokenizer(obj.toString().trim(), " \t\r\n");
StringBuffer buffer = new StringBuffer(128);

while (st.hasMoreTokens()) {
buffer.append(st.nextToken());
}

return buffer.toString();
return StringUtils.normalizeSpace(obj.toString());
}

public static String normalize(URL url) throws Exception {
Expand Down Expand Up @@ -87,17 +80,6 @@ public static String readContent(URL url) throws Exception {
if (url == null)
throw new Exception("unable to verify a null URL");

StringBuffer buffer = new StringBuffer(128);
InputStream in = url.openStream();
byte[] buf = new byte[4096];
int nbytes;

while ((nbytes = in.read(buf)) > 0) {
buffer.append(new String(buf, 0, nbytes));
}

in.close();

return buffer.toString();
return IOUtils.toString(url.openStream());
}
}

0 comments on commit 1d64a3e

Please sign in to comment.