YARN-1728. Regression test for guice-undecoded pathInfo in YARN WebApp. (Yuanbo Liu via gera)
This commit is contained in:
parent
d269b488a7
commit
480b4dd574
@ -27,12 +27,12 @@ import static org.apache.hadoop.yarn.webapp.view.JQueryUI._TH;
|
|||||||
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.initID;
|
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.initID;
|
||||||
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.tableInit;
|
import static org.apache.hadoop.yarn.webapp.view.JQueryUI.tableInit;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
@ -263,6 +263,35 @@ public class TestWebApp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test public void testEncodedUrl() throws Exception {
|
||||||
|
WebApp app =
|
||||||
|
WebApps.$for("test", TestWebApp.class, this, "ws").start(new WebApp() {
|
||||||
|
@Override
|
||||||
|
public void setup() {
|
||||||
|
bind(MyTestJAXBContextResolver.class);
|
||||||
|
bind(MyTestWebService.class);
|
||||||
|
|
||||||
|
route("/:foo", FooController.class);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
String baseUrl = baseUrl(app);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Test encoded url
|
||||||
|
String rawPath = "localhost:8080";
|
||||||
|
String encodedUrl = baseUrl + "test/" +
|
||||||
|
URLEncoder.encode(rawPath, "UTF-8");
|
||||||
|
assertEquals("foo" + rawPath, getContent(encodedUrl).trim());
|
||||||
|
|
||||||
|
rawPath = "@;%$";
|
||||||
|
encodedUrl = baseUrl + "test/" +
|
||||||
|
URLEncoder.encode(rawPath, "UTF-8");
|
||||||
|
assertEquals("foo" + rawPath, getContent(encodedUrl).trim());
|
||||||
|
} finally {
|
||||||
|
app.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test public void testRobotsText() throws Exception {
|
@Test public void testRobotsText() throws Exception {
|
||||||
WebApp app =
|
WebApp app =
|
||||||
WebApps.$for("test", TestWebApp.class, this, "ws").start(new WebApp() {
|
WebApps.$for("test", TestWebApp.class, this, "ws").start(new WebApp() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user