Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimone Bordet2015-10-07 17:10:11 -0400
committerSimone Bordet2015-10-07 17:10:11 -0400
commit29e64f5b1ce4d0e0322497feb10c8ce3cf93a9b1 (patch)
tree8a8881a73b0917012866e0dfb7df5e8960c3bdac
parent0ca40b59c613704d81258af0b0dde6da0a83981e (diff)
downloadorg.eclipse.jetty.project-29e64f5b1ce4d0e0322497feb10c8ce3cf93a9b1.tar.gz
org.eclipse.jetty.project-29e64f5b1ce4d0e0322497feb10c8ce3cf93a9b1.tar.xz
org.eclipse.jetty.project-29e64f5b1ce4d0e0322497feb10c8ce3cf93a9b1.zip
Fixed test.
-rw-r--r--jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherForwardTest.java33
1 files changed, 31 insertions, 2 deletions
diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherForwardTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherForwardTest.java
index 825a4ae60b..51e9f0d910 100644
--- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherForwardTest.java
+++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DispatcherForwardTest.java
@@ -21,6 +21,8 @@ package org.eclipse.jetty.servlet;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import javax.servlet.ServletException;
import javax.servlet.ServletInputStream;
@@ -88,6 +90,7 @@ public class DispatcherForwardTest
// 2. assert query => a=1 one
// 1. assert query => a=1 one
+ CountDownLatch latch = new CountDownLatch(1);
final String query1 = "a=1%20one";
servlet1 = new HttpServlet()
{
@@ -100,6 +103,7 @@ public class DispatcherForwardTest
checkThat(req.getQueryString(),Matchers.equalTo(query1));
checkThat(req.getParameter("a"),Matchers.equalTo("1 one"));
+ latch.countDown();
}
};
servlet2 = new HttpServlet()
@@ -120,6 +124,7 @@ public class DispatcherForwardTest
"Connection: close\r\n" +
"\r\n";
String response = connector.getResponses(request);
+ Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
Assert.assertTrue(response, response.startsWith("HTTP/1.1 200"));
}
@@ -131,7 +136,8 @@ public class DispatcherForwardTest
// 2. assert query => a=2
// 1. assert query => a=1
- final String query1 = "a=1$20one&b=2%20two";
+ CountDownLatch latch = new CountDownLatch(1);
+ final String query1 = "a=1%20one&b=2%20two";
final String query2 = "a=3%20three";
final String query3 = "a=3%20three&b=2%20two";
servlet1 = new HttpServlet()
@@ -143,9 +149,10 @@ public class DispatcherForwardTest
req.getRequestDispatcher("/two?" + query2).forward(req, resp);
- checkThat(req.getQueryString(),Matchers.equalTo(query1));
+ checkThat(req.getQueryString(), Matchers.equalTo(query1));
checkThat(req.getParameter("a"),Matchers.equalTo("1 one"));
checkThat(req.getParameter("b"),Matchers.equalTo("2 two"));
+ latch.countDown();
}
};
servlet2 = new HttpServlet()
@@ -167,6 +174,7 @@ public class DispatcherForwardTest
"Connection: close\r\n" +
"\r\n";
String response = connector.getResponses(request);
+ Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
Assert.assertTrue(response, response.startsWith("HTTP/1.1 200"));
}
@@ -178,6 +186,7 @@ public class DispatcherForwardTest
// 2. assert query => a=1&b=2
// 1. assert query => a=1
+ CountDownLatch latch = new CountDownLatch(1);
final String query1 = "a=1%20one";
final String query2 = "b=2%20two";
final String query3 = "b=2%20two&a=1%20one";
@@ -192,6 +201,7 @@ public class DispatcherForwardTest
checkThat(req.getQueryString(),Matchers.equalTo(query1));
checkThat(req.getParameter("a"),Matchers.equalTo("1 one"));
+ latch.countDown();
}
};
servlet2 = new HttpServlet()
@@ -213,6 +223,7 @@ public class DispatcherForwardTest
"Connection: close\r\n" +
"\r\n";
String response = connector.getResponses(request);
+ Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
Assert.assertTrue(response, response.startsWith("HTTP/1.1 200"));
}
@@ -224,6 +235,7 @@ public class DispatcherForwardTest
// 2. assert query => a=1 + params => a=1,2
// 1. assert query => a=1 + params => a=1,2
+ CountDownLatch latch = new CountDownLatch(1);
final String query1 = "a=1%20one";
final String form = "a=2%20two";
servlet1 = new HttpServlet()
@@ -240,6 +252,7 @@ public class DispatcherForwardTest
checkThat(values, Matchers.notNullValue());
checkThat(2, Matchers.equalTo(values.length));
checkThat(values, Matchers.arrayContainingInAnyOrder("1 one", "2 two"));
+ latch.countDown();
}
};
servlet2 = new HttpServlet()
@@ -266,6 +279,7 @@ public class DispatcherForwardTest
"\r\n" +
form;
String response = connector.getResponses(request);
+ Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
Assert.assertTrue(response, response.startsWith("HTTP/1.1 200"));
}
@@ -277,6 +291,7 @@ public class DispatcherForwardTest
// 2. assert query => a=3 + params => a=3,2,1
// 1. assert query => a=1 + params => a=1,2
+ CountDownLatch latch = new CountDownLatch(1);
final String query1 = "a=1%20one";
final String query2 = "a=3%20three";
final String form = "a=2%20two";
@@ -294,6 +309,7 @@ public class DispatcherForwardTest
checkThat(values, Matchers.notNullValue());
checkThat(2, Matchers.equalTo(values.length));
checkThat(values, Matchers.arrayContainingInAnyOrder("1 one", "2 two"));
+ latch.countDown();
}
};
servlet2 = new HttpServlet()
@@ -320,6 +336,7 @@ public class DispatcherForwardTest
"\r\n" +
form;
String response = connector.getResponses(request);
+ Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
Assert.assertTrue(response, response.startsWith("HTTP/1.1 200"));
}
@@ -331,6 +348,7 @@ public class DispatcherForwardTest
// 2. assert query => a=1&c=3 + params => a=1&b=2&c=3
// 1. assert query => a=1 + params => a=1&b=2
+ CountDownLatch latch = new CountDownLatch(1);
final String query1 = "a=1%20one";
final String query2 = "c=3%20three";
final String query3 = "c=3%20three&a=1%20one";
@@ -348,6 +366,7 @@ public class DispatcherForwardTest
checkThat(req.getParameter("a"),Matchers.equalTo("1 one"));
checkThat(req.getParameter("b"),Matchers.equalTo("2 two"));
checkThat(req.getParameter("c"), Matchers.nullValue());
+ latch.countDown();
}
};
servlet2 = new HttpServlet()
@@ -373,6 +392,7 @@ public class DispatcherForwardTest
"\r\n" +
form;
String response = connector.getResponses(request);
+ Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
Assert.assertTrue(response, response.startsWith("HTTP/1.1 200"));
}
@@ -385,6 +405,7 @@ public class DispatcherForwardTest
// 2. assert query => a=1&c=3 + params => a=1&b=2&c=3
// 1. assert query => a=1 + params => a=1&b=2
+ CountDownLatch latch = new CountDownLatch(1);
final String query1 = "a=1%20one";
final String query2 = "c=3%20three";
final String query3 = "c=3%20three&a=1%20one";
@@ -404,6 +425,7 @@ public class DispatcherForwardTest
checkThat(req.getParameter("a"),Matchers.equalTo("1 one"));
checkThat(req.getParameter("b"),Matchers.equalTo("2 two"));
checkThat(req.getParameter("c"), Matchers.nullValue());
+ latch.countDown();
}
};
servlet2 = new HttpServlet()
@@ -429,12 +451,14 @@ public class DispatcherForwardTest
"\r\n" +
form;
String response = connector.getResponses(request);
+ Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
Assert.assertTrue(response, response.startsWith("HTTP/1.1 200"));
}
@Test
public void testContentCanBeReadViaInputStreamAfterForwardWithoutQuery() throws Exception
{
+ CountDownLatch latch = new CountDownLatch(1);
final String query1 = "a=1%20one";
final String form = "c=3%20three";
servlet1 = new HttpServlet()
@@ -448,6 +472,7 @@ public class DispatcherForwardTest
checkThat(req.getQueryString(),Matchers.equalTo(query1));
checkThat(req.getParameter("c"), Matchers.nullValue());
+ latch.countDown();
}
};
servlet2 = new HttpServlet()
@@ -473,12 +498,14 @@ public class DispatcherForwardTest
"\r\n" +
form;
String response = connector.getResponses(request);
+ Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
Assert.assertTrue(response, response.startsWith("HTTP/1.1 200"));
}
@Test
public void testContentCanBeReadViaInputStreamAfterForwardWithQuery() throws Exception
{
+ CountDownLatch latch = new CountDownLatch(1);
final String query1 = "a=1%20one";
final String query2 = "b=2%20two";
final String query3 = "b=2%20two&a=1%20one";
@@ -494,6 +521,7 @@ public class DispatcherForwardTest
checkThat(req.getQueryString(),Matchers.equalTo(query1));
checkThat(req.getParameter("c"), Matchers.nullValue());
+ latch.countDown();
}
};
servlet2 = new HttpServlet()
@@ -520,6 +548,7 @@ public class DispatcherForwardTest
"\r\n" +
form;
String response = connector.getResponses(request);
+ Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
Assert.assertTrue(response, response.startsWith("HTTP/1.1 200"));
}

Back to the top