324601 replace asserts with junit asserts

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@2259 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Greg Wilkins 2010-09-08 06:09:21 +00:00
parent ee2d8e635e
commit 3c4a816760
10 changed files with 51 additions and 36 deletions

View File

@ -27,6 +27,8 @@ import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.http.HttpMethods; import org.eclipse.jetty.http.HttpMethods;
import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/** /**
@ -65,9 +67,9 @@ public abstract class AbstractClientCrossContextSessionTest
exchangeA.setURL("http://localhost:" + port + contextA + servletMapping); exchangeA.setURL("http://localhost:" + port + contextA + servletMapping);
client.send(exchangeA); client.send(exchangeA);
exchangeA.waitForDone(); exchangeA.waitForDone();
assert exchangeA.getResponseStatus() == HttpServletResponse.SC_OK; assertEquals(HttpServletResponse.SC_OK,exchangeA.getResponseStatus());
String sessionCookie = exchangeA.getResponseFields().getStringField("Set-Cookie"); String sessionCookie = exchangeA.getResponseFields().getStringField("Set-Cookie");
assert sessionCookie != null; assertTrue(sessionCookie != null);
// Mangle the cookie, replacing Path with $Path, etc. // Mangle the cookie, replacing Path with $Path, etc.
sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
@ -78,7 +80,7 @@ public abstract class AbstractClientCrossContextSessionTest
exchangeB.getRequestFields().add("Cookie", sessionCookie); exchangeB.getRequestFields().add("Cookie", sessionCookie);
client.send(exchangeB); client.send(exchangeB);
exchangeB.waitForDone(); exchangeB.waitForDone();
assert exchangeB.getResponseStatus() == HttpServletResponse.SC_OK; assertEquals(HttpServletResponse.SC_OK,exchangeB.getResponseStatus());
} }
finally finally
{ {
@ -104,7 +106,7 @@ public abstract class AbstractClientCrossContextSessionTest
// Check that we don't see things put in session by contextB // Check that we don't see things put in session by contextB
Object objectB = session.getAttribute("B"); Object objectB = session.getAttribute("B");
assert objectB == null; assertTrue(objectB == null);
System.out.println("A: session.getAttributeNames() = " + Collections.list(session.getAttributeNames())); System.out.println("A: session.getAttributeNames() = " + Collections.list(session.getAttributeNames()));
} }
} }
@ -122,7 +124,7 @@ public abstract class AbstractClientCrossContextSessionTest
// Check that we don't see things put in session by contextA // Check that we don't see things put in session by contextA
Object objectA = session.getAttribute("A"); Object objectA = session.getAttribute("A");
assert objectA == null; assertTrue(objectA == null);
System.out.println("B: session.getAttributeNames() = " + Collections.list(session.getAttributeNames())); System.out.println("B: session.getAttributeNames() = " + Collections.list(session.getAttributeNames()));
} }
} }

View File

@ -27,6 +27,8 @@ import org.eclipse.jetty.client.ContentExchange;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.http.HttpMethods; import org.eclipse.jetty.http.HttpMethods;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/** /**
@ -61,14 +63,14 @@ public abstract class AbstractImmortalSessionTest
exchange.setURL("http://localhost:" + port + contextPath + servletMapping + "?action=set&value=" + value); exchange.setURL("http://localhost:" + port + contextPath + servletMapping + "?action=set&value=" + value);
client.send(exchange); client.send(exchange);
exchange.waitForDone(); exchange.waitForDone();
assert exchange.getResponseStatus() == HttpServletResponse.SC_OK; assertEquals(HttpServletResponse.SC_OK,exchange.getResponseStatus());
String sessionCookie = exchange.getResponseFields().getStringField("Set-Cookie"); String sessionCookie = exchange.getResponseFields().getStringField("Set-Cookie");
assert sessionCookie != null; assertTrue(sessionCookie != null);
// Mangle the cookie, replacing Path with $Path, etc. // Mangle the cookie, replacing Path with $Path, etc.
sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
String response = exchange.getResponseContent(); String response = exchange.getResponseContent();
assert response.trim().equals(String.valueOf(value)); assertEquals(response.trim(),String.valueOf(value));
// Let's wait for the scavenger to run, waiting 2.5 times the scavenger period // Let's wait for the scavenger to run, waiting 2.5 times the scavenger period
Thread.sleep(scavengePeriod * 2500L); Thread.sleep(scavengePeriod * 2500L);
@ -80,9 +82,9 @@ public abstract class AbstractImmortalSessionTest
exchange.getRequestFields().add("Cookie", sessionCookie); exchange.getRequestFields().add("Cookie", sessionCookie);
client.send(exchange); client.send(exchange);
exchange.waitForDone(); exchange.waitForDone();
assert exchange.getResponseStatus() == HttpServletResponse.SC_OK; assertEquals(HttpServletResponse.SC_OK,exchange.getResponseStatus());
response = exchange.getResponseContent(); response = exchange.getResponseContent();
assert response.trim().equals(String.valueOf(value)); assertEquals(response.trim(),String.valueOf(value));
} }
finally finally
{ {

View File

@ -31,6 +31,8 @@ import org.eclipse.jetty.client.ContentExchange;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.http.HttpMethods; import org.eclipse.jetty.http.HttpMethods;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/** /**
@ -78,9 +80,9 @@ public abstract class AbstractLightLoadTest
exchange1.setURL( urls[0] + "?action=init" ); exchange1.setURL( urls[0] + "?action=init" );
client.send( exchange1 ); client.send( exchange1 );
exchange1.waitForDone(); exchange1.waitForDone();
assert exchange1.getResponseStatus() == HttpServletResponse.SC_OK; assertEquals(HttpServletResponse.SC_OK,exchange1.getResponseStatus());
String sessionCookie = exchange1.getResponseFields().getStringField( "Set-Cookie" ); String sessionCookie = exchange1.getResponseFields().getStringField( "Set-Cookie" );
assert sessionCookie != null; assertTrue(sessionCookie != null);
// Mangle the cookie, replacing Path with $Path, etc. // Mangle the cookie, replacing Path with $Path, etc.
sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
@ -116,10 +118,10 @@ public abstract class AbstractLightLoadTest
exchange2.getRequestFields().add( "Cookie", sessionCookie ); exchange2.getRequestFields().add( "Cookie", sessionCookie );
client.send( exchange2 ); client.send( exchange2 );
exchange2.waitForDone(); exchange2.waitForDone();
assert exchange2.getResponseStatus() == HttpServletResponse.SC_OK; assertEquals(HttpServletResponse.SC_OK,exchange2.getResponseStatus());
String response = exchange2.getResponseContent(); String response = exchange2.getResponseContent();
System.out.println( "get = " + response ); System.out.println( "get = " + response );
assert response.trim().equals( String.valueOf( clientsCount * requestsCount ) ); assertEquals(response.trim(), String.valueOf( clientsCount * requestsCount ) );
} }
finally finally
{ {
@ -192,7 +194,7 @@ public abstract class AbstractLightLoadTest
exchange.getRequestFields().add( "Cookie", sessionCookie ); exchange.getRequestFields().add( "Cookie", sessionCookie );
client.send( exchange ); client.send( exchange );
exchange.waitForDone(); exchange.waitForDone();
assert exchange.getResponseStatus() == HttpServletResponse.SC_OK; assertEquals(HttpServletResponse.SC_OK,exchange.getResponseStatus());
} }
// Wait for all workers to be done // Wait for all workers to be done

View File

@ -163,7 +163,7 @@ public abstract class AbstractLocalSessionScavengingTest
else if ("check".equals(action)) else if ("check".equals(action))
{ {
HttpSession session = request.getSession(false); HttpSession session = request.getSession(false);
assert session == null; assertTrue(session == null);
} }
} }
} }

View File

@ -26,6 +26,8 @@ import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.http.HttpMethods; import org.eclipse.jetty.http.HttpMethods;
import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/** /**
* AbstractNewSessionTest * AbstractNewSessionTest
@ -71,9 +73,9 @@ public abstract class AbstractNewSessionTest
exchange.setURL("http://localhost:" + port + contextPath + servletMapping + "?action=create"); exchange.setURL("http://localhost:" + port + contextPath + servletMapping + "?action=create");
client.send(exchange); client.send(exchange);
exchange.waitForDone(); exchange.waitForDone();
assert exchange.getResponseStatus() == HttpServletResponse.SC_OK; assertEquals(HttpServletResponse.SC_OK,exchange.getResponseStatus());
String sessionCookie = exchange.getResponseFields().getStringField("Set-Cookie"); String sessionCookie = exchange.getResponseFields().getStringField("Set-Cookie");
assert sessionCookie != null; assertTrue(sessionCookie != null);
// Mangle the cookie, replacing Path with $Path, etc. // Mangle the cookie, replacing Path with $Path, etc.
sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
@ -88,7 +90,7 @@ public abstract class AbstractNewSessionTest
exchange.getRequestFields().add("Cookie", sessionCookie); exchange.getRequestFields().add("Cookie", sessionCookie);
client.send(exchange); client.send(exchange);
exchange.waitForDone(); exchange.waitForDone();
assert exchange.getResponseStatus() == HttpServletResponse.SC_OK; assertEquals(HttpServletResponse.SC_OK,exchange.getResponseStatus());
} }
finally finally
{ {
@ -117,7 +119,7 @@ public abstract class AbstractNewSessionTest
} }
else else
{ {
assert false; assertTrue(false);
} }
} }
} }

View File

@ -27,6 +27,8 @@ import org.eclipse.jetty.client.ContentExchange;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.http.HttpMethods; import org.eclipse.jetty.http.HttpMethods;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/** /**
* AbstractOrphanedSessionTest * AbstractOrphanedSessionTest
@ -73,9 +75,9 @@ public abstract class AbstractOrphanedSessionTest
exchange1.setURL("http://localhost:" + port1 + contextPath + servletMapping + "?action=init"); exchange1.setURL("http://localhost:" + port1 + contextPath + servletMapping + "?action=init");
client.send(exchange1); client.send(exchange1);
exchange1.waitForDone(); exchange1.waitForDone();
assert exchange1.getResponseStatus() == HttpServletResponse.SC_OK; assertEquals(HttpServletResponse.SC_OK,exchange1.getResponseStatus());
String sessionCookie = exchange1.getResponseFields().getStringField("Set-Cookie"); String sessionCookie = exchange1.getResponseFields().getStringField("Set-Cookie");
assert sessionCookie != null; assertTrue(sessionCookie != null);
// Mangle the cookie, replacing Path with $Path, etc. // Mangle the cookie, replacing Path with $Path, etc.
sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
@ -94,7 +96,7 @@ public abstract class AbstractOrphanedSessionTest
exchange2.getRequestFields().add("Cookie", sessionCookie); exchange2.getRequestFields().add("Cookie", sessionCookie);
client.send(exchange2); client.send(exchange2);
exchange2.waitForDone(); exchange2.waitForDone();
assert exchange2.getResponseStatus() == HttpServletResponse.SC_OK; assertEquals(HttpServletResponse.SC_OK,exchange2.getResponseStatus());
} }
finally finally
{ {
@ -126,7 +128,7 @@ public abstract class AbstractOrphanedSessionTest
else if ("check".equals(action)) else if ("check".equals(action))
{ {
HttpSession session = request.getSession(false); HttpSession session = request.getSession(false);
assert session == null; assertTrue(session == null);
} }
} }
} }

View File

@ -26,6 +26,8 @@ import org.eclipse.jetty.client.ContentExchange;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.http.HttpMethods; import org.eclipse.jetty.http.HttpMethods;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/** /**
@ -58,7 +60,7 @@ public abstract class AbstractReentrantRequestSessionTest
exchange.setURL("http://localhost:" + port + contextPath + servletMapping + "?action=reenter&port=" + port + "&path=" + contextPath + servletMapping); exchange.setURL("http://localhost:" + port + contextPath + servletMapping + "?action=reenter&port=" + port + "&path=" + contextPath + servletMapping);
client.send(exchange); client.send(exchange);
exchange.waitForDone(); exchange.waitForDone();
assert exchange.getResponseStatus() == HttpServletResponse.SC_OK; assertEquals(HttpServletResponse.SC_OK,exchange.getResponseStatus());
} }
finally finally
{ {
@ -106,7 +108,7 @@ public abstract class AbstractReentrantRequestSessionTest
exchange.setURL("http://localhost:" + port + path + "?action=none"); exchange.setURL("http://localhost:" + port + path + "?action=none");
client.send(exchange); client.send(exchange);
exchange.waitForDone(); exchange.waitForDone();
assert exchange.getResponseStatus() == HttpServletResponse.SC_OK; assertEquals(HttpServletResponse.SC_OK,exchange.getResponseStatus());
} }
finally finally
{ {

View File

@ -30,6 +30,8 @@ import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.http.HttpMethods; import org.eclipse.jetty.http.HttpMethods;
import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/** /**
* AbstractServerCrossContextSessionTest * AbstractServerCrossContextSessionTest
@ -67,7 +69,7 @@ public abstract class AbstractServerCrossContextSessionTest
exchange.setURL("http://localhost:" + port + contextA + servletMapping); exchange.setURL("http://localhost:" + port + contextA + servletMapping);
client.send(exchange); client.send(exchange);
exchange.waitForDone(); exchange.waitForDone();
assert exchange.getResponseStatus() == HttpServletResponse.SC_OK; assertEquals(HttpServletResponse.SC_OK,exchange.getResponseStatus());
} }
finally finally
{ {
@ -100,7 +102,7 @@ public abstract class AbstractServerCrossContextSessionTest
// Check that we don't see things put in session by contextB // Check that we don't see things put in session by contextB
Object objectB = session.getAttribute("B"); Object objectB = session.getAttribute("B");
assert objectB == null; assertTrue(objectB == null);
System.out.println("A: session.getAttributeNames() = " + Collections.list(session.getAttributeNames())); System.out.println("A: session.getAttributeNames() = " + Collections.list(session.getAttributeNames()));
} }
} }
@ -115,7 +117,7 @@ public abstract class AbstractServerCrossContextSessionTest
// Be sure nothing from contextA is present // Be sure nothing from contextA is present
Object objectA = session.getAttribute("A"); Object objectA = session.getAttribute("A");
assert objectA == null; assertTrue(objectA == null);
// Add something, so in contextA we can check if it is visible (it must not). // Add something, so in contextA we can check if it is visible (it must not).
session.setAttribute("B", "B"); session.setAttribute("B", "B");

View File

@ -27,6 +27,8 @@ import org.eclipse.jetty.client.ContentExchange;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.http.HttpMethods; import org.eclipse.jetty.http.HttpMethods;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/** /**
* AbstractSessionMigrationTest * AbstractSessionMigrationTest
@ -66,9 +68,9 @@ public abstract class AbstractSessionMigrationTest
exchange1.setURL("http://localhost:" + port1 + contextPath + servletMapping + "?action=set&value=" + value); exchange1.setURL("http://localhost:" + port1 + contextPath + servletMapping + "?action=set&value=" + value);
client.send(exchange1); client.send(exchange1);
exchange1.waitForDone(); exchange1.waitForDone();
assert exchange1.getResponseStatus() == HttpServletResponse.SC_OK; assertEquals(HttpServletResponse.SC_OK,exchange1.getResponseStatus());
String sessionCookie = exchange1.getResponseFields().getStringField("Set-Cookie"); String sessionCookie = exchange1.getResponseFields().getStringField("Set-Cookie");
assert sessionCookie != null; assertTrue(sessionCookie != null);
// Mangle the cookie, replacing Path with $Path, etc. // Mangle the cookie, replacing Path with $Path, etc.
sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path="); sessionCookie = sessionCookie.replaceFirst("(\\W)(P|p)ath=", "$1\\$Path=");
@ -80,10 +82,9 @@ public abstract class AbstractSessionMigrationTest
exchange2.getRequestFields().add("Cookie", sessionCookie); exchange2.getRequestFields().add("Cookie", sessionCookie);
client.send(exchange2); client.send(exchange2);
exchange2.waitForDone(); exchange2.waitForDone();
assert exchange2.getResponseStatus() == HttpServletResponse.SC_OK; assertEquals(HttpServletResponse.SC_OK,exchange2.getResponseStatus());
String response = exchange2.getResponseContent(); String response = exchange2.getResponseContent();
assert response.trim().equals(String.valueOf(value)); assertEquals(response.trim(),String.valueOf(value)); }
}
finally finally
{ {
client.stop(); client.stop();

View File

@ -54,9 +54,9 @@ public class WebAppObjectInSessionServlet extends HttpServlet
Object staticAttribute = session.getAttribute("staticAttribute"); Object staticAttribute = session.getAttribute("staticAttribute");
Assert.assertTrue(staticAttribute instanceof TestSharedStatic); Assert.assertTrue(staticAttribute instanceof TestSharedStatic);
// Object objectAttribute = session.getAttribute("objectAttribute"); // Object objectAttribute = session.getAttribute("objectAttribute");
// assert objectAttribute instanceof TestSharedNonStatic; // assertTrue(objectAttribute instanceof TestSharedNonStatic);
// Object sessionAttribute = session.getAttribute("sessionAttribute"); // Object sessionAttribute = session.getAttribute("sessionAttribute");
// assert sessionAttribute instanceof HttpSession; // assertTrue(sessionAttribute instanceof HttpSession);
} }
} }
catch (Exception e) catch (Exception e)