Improve styles for test webapps

This commit is contained in:
Jan Bartel 2013-05-06 19:13:41 +10:00
parent b89de0346d
commit 143b387727
15 changed files with 93 additions and 79 deletions

View File

@ -2,6 +2,7 @@
<HEAD>
<META http-equiv="Pragma" content="no-cache">
<META http-equiv="Cache-Control" content="no-cache,no-store">
<link rel="stylesheet" type="text/css" href="stylesheet.css"/>
</HEAD>
<BODY>

View File

@ -1,6 +1,7 @@
<html>
<head>
<title>Authentication Failure</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css"/>
</head>
<body>
<h1>Authentication Failure</h1>

View File

@ -3,12 +3,7 @@
<TITLE>JAAS Authentication and Authorization Test</TITLE>
<META http-equiv="Pragma" content="no-cache">
<META http-equiv="Cache-Control" content="no-cache,no-store">
<style>
body {color: #2E2E2E; font-family:sans-serif; font-size:90%;}
h1 {font-variant: small-caps; font-size:130%; letter-spacing: 0.1em;}
h2 {font-variant: small-caps; font-size:100%; letter-spacing: 0.1em;}
</style>
<link rel="stylesheet" type="text/css" href="stylesheet.css"/>
</HEAD>
<BODY>
<A HREF="http://www.eclipse.org/jetty"><IMG SRC="images/jetty_banner.gif"></A>

View File

@ -1,5 +1,8 @@
<HTML><HEAD><TITLE>JAAS Authentication and Authorization Test</TITLE></HEAD>
<HTML>
<HEAD><TITLE>JAAS Authentication and Authorization Test</TITLE>
<link rel="stylesheet" type="text/css" href="stylesheet.css"/>
</HEAD>
<BODY>
<H1> Enter your username and password to login </H1>
<I> Enter login=me and password=me in order to authenticate successfully</I>

View File

@ -0,0 +1,7 @@
body {color: #2E2E2E; font-family:sans-serif; font-size:90%;}
h1 {font-variant: small-caps; font-size:130%; letter-spacing: 0.1em;}
h2 {font-variant: small-caps; font-size:100%; letter-spacing: 0.1em;}
h3 {font-size:100%; letter-spacing: 0.1em;}
span.pass { color: green; }
span.fail { color:red; }

View File

@ -55,8 +55,8 @@ public class JNDITest extends HttpServlet
private String resourceNameMappingInjectionResult;
private String envEntryOverrideResult;
private String postConstructResult = "PostConstruct method called: FALSE";
private String preDestroyResult = "PreDestroy method called: NOT YET";
private String postConstructResult = "PostConstruct method called: <span class=\"fail\">FALSE</span>";
private String preDestroyResult = "PreDestroy method called: <span class=\"pass\">NOT YET</span>";
private String envEntryGlobalScopeResult;
private String envEntryWebAppScopeResult;
private String userTransactionResult;
@ -71,15 +71,14 @@ public class JNDITest extends HttpServlet
private void postConstruct ()
{
String tmp = (myDS == null?"":myDS.toString());
resourceNameMappingInjectionResult= "Injection of resource to locally mapped name (java:comp/env/mydatasource as java:comp/env/mydatasource1): "+String.valueOf(myDS);
envEntryOverrideResult = "Override of EnvEntry in jetty-env.xml (java:comp/env/wiggle): "+(wiggle==55.0?"PASS":"FAIL(expected 55.0, got "+wiggle+")");
postConstructResult = "PostConstruct method called: PASS";
resourceNameMappingInjectionResult= "Injection of resource to locally mapped name (java:comp/env/mydatasource as java:comp/env/mydatasource1): "+(myDS!=null?"<span class=\"pass\">PASS</span>":"<span class=\"fail\">FAIL</span>");
envEntryOverrideResult = "Override of EnvEntry in jetty-env.xml (java:comp/env/wiggle): "+(wiggle==55.0?"<span class=\"pass\">PASS":"<span class=\"fail\">FAIL(expected 55.0, got "+wiggle+")")+"</span>";
postConstructResult = "PostConstruct method called: <span class=\"pass\">PASS</span>";
}
private void preDestroy()
{
preDestroyResult = "PreDestroy method called: PASS";
preDestroyResult = "PreDestroy method called: <span class=\"pass\">PASS</span>";
}
@ -90,13 +89,13 @@ public class JNDITest extends HttpServlet
{
InitialContext ic = new InitialContext();
woggle = (Integer)ic.lookup("java:comp/env/woggle");
envEntryGlobalScopeResult = "EnvEntry defined in context xml lookup result (java:comp/env/woggle): "+(woggle==4000?"PASS":"FAIL(expected 4000, got "+woggle+")");
envEntryGlobalScopeResult = "EnvEntry defined in context xml lookup result (java:comp/env/woggle): "+(woggle==4000?"<span class=\"pass\">PASS":"<span class=\"fail\">FAIL(expected 4000, got "+woggle+")")+"</span>";
gargle = (Double)ic.lookup("java:comp/env/gargle");
envEntryWebAppScopeResult = "EnvEntry defined in jetty-env.xml lookup result (java:comp/env/gargle): "+(gargle==100.0?"PASS":"FAIL(expected 100, got "+gargle+")");
envEntryWebAppScopeResult = "EnvEntry defined in jetty-env.xml lookup result (java:comp/env/gargle): "+(gargle==100.0?"<span class=\"pass\">PASS":"<span class=\"fail\">FAIL(expected 100, got "+gargle+")")+"</span>";
UserTransaction utx = (UserTransaction)ic.lookup("java:comp/UserTransaction");
userTransactionResult = "UserTransaction lookup result (java:comp/UserTransaction): "+(utx!=null?"PASS":"FAIL");
userTransactionResult = "UserTransaction lookup result (java:comp/UserTransaction): "+(utx!=null?"<span class=\"pass\">PASS":"<span class=\"fail\">FAIL")+"</span>";
myMailSession = (Session)ic.lookup("java:comp/env/mail/Session");
mailSessionResult = "Mail Session lookup result (java:comp/env/mail/Session): "+(myMailSession!=null?"PASS": "FAIL");
mailSessionResult = "Mail Session lookup result (java:comp/env/mail/Session): "+(myMailSession!=null?"<span class=\"pass\">PASS": "<span class=\"fail\">FAIL")+"</span>";
}
catch (Exception e)
{
@ -129,6 +128,7 @@ public class JNDITest extends HttpServlet
response.setContentType("text/html");
ServletOutputStream out = response.getOutputStream();
out.println("<html>");
out.println("<head><link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheet.css\"/></head>");
out.println("<h1>Jetty JNDI Tests</h1>");
out.println("<body>");

View File

@ -3,12 +3,7 @@
<TITLE>JNDI Test WebApp</TITLE>
<META http-equiv="Pragma" content="no-cache">
<META http-equiv="Cache-Control" content="no-cache,no-store">
<style>
body {color: #2E2E2E; font-family:sans-serif; font-size:90%;}
h1 {font-variant: small-caps; font-size:130%; letter-spacing: 0.1em;}
h2 {font-variant: small-caps; font-size:100%; letter-spacing: 0.1em;}
h3 {font-size:100%; letter-spacing: 0.1em;}
</style>
<link rel="stylesheet" type="text/css" href="stylesheet.css"/>
</HEAD>
<BODY>
<A HREF="http://www.eclipse.org/jetty"><IMG SRC="images/jetty_banner.gif"></A>

View File

@ -0,0 +1,7 @@
body {color: #2E2E2E; font-family:sans-serif; font-size:90%;}
h1 {font-variant: small-caps; font-size:130%; letter-spacing: 0.1em;}
h2 {font-variant: small-caps; font-size:100%; letter-spacing: 0.1em;}
h3 {font-size:100%; letter-spacing: 0.1em;}
span.pass { color: green; }
span.fail { color:red; }

View File

@ -94,18 +94,18 @@ public class AnnotationTest extends HttpServlet
@PostConstruct
private void myPostConstructMethod ()
{
postConstructResult = "Called";
postConstructResult = "<span class=\"pass\">PASS</span>";
try
{
dsResult = (myDS==null?"FAIL":"myDS="+myDS.toString());
dsResult = (myDS==null?"<span class=\"fail\">FAIL</span>":"<span class=\"pass\">myDS="+myDS.toString()+"</span>");
}
catch (Exception e)
{
dsResult = "FAIL: "+e;
dsResult = "<span class=\"fail\">FAIL:</span> "+e;
}
envResult = (maxAmount==null?"FAIL":"maxAmount="+maxAmount.toString());
envResult = (maxAmount==null?"FAIL</span>":"<span class=\"pass\">maxAmount="+maxAmount.toString()+"</span>");
try
{
@ -114,10 +114,10 @@ public class AnnotationTest extends HttpServlet
}
catch (Exception e)
{
envLookupResult = "FAIL: "+e;
envLookupResult = "<span class=\"fail\">FAIL:</span> "+e;
}
envResult2 = (minAmount==null?"FAIL":"minAmount="+minAmount.toString());
envResult2 = (minAmount==null?"<span class=\"fail\">FAIL</span>":"<span class=\"pass\">minAmount="+minAmount.toString()+"</span>");
try
{
InitialContext ic = new InitialContext();
@ -125,9 +125,9 @@ public class AnnotationTest extends HttpServlet
}
catch (Exception e)
{
envLookupResult2 = "FAIL: "+e;
envLookupResult2 = "<span class=\"fail\">FAIL:</span> "+e;
}
envResult3 = (minAmount==null?"FAIL":"avgAmount="+avgAmount.toString());
envResult3 = (minAmount==null?"<span class=\"fail\">FAIL</span>":"<span class=\"pass\">avgAmount="+avgAmount.toString()+"</span>");
try
{
InitialContext ic = new InitialContext();
@ -135,7 +135,7 @@ public class AnnotationTest extends HttpServlet
}
catch (Exception e)
{
envLookupResult3 = "FAIL: "+e;
envLookupResult3 = "<span class=\"fail\">FAIL:</span> "+e;
}
@ -147,10 +147,10 @@ public class AnnotationTest extends HttpServlet
}
catch (Exception e)
{
dsLookupResult = "FAIL: "+e;
dsLookupResult = "<span class=\"fail\">FAIL:</span> "+e;
}
txResult = (myUserTransaction==null?"FAIL":"myUserTransaction="+myUserTransaction);
txResult = (myUserTransaction==null?"<span class=\"fail\">FAIL</span>":"<span class=\"pass\">myUserTransaction="+myUserTransaction+"</span>");
try
{
InitialContext ic = new InitialContext();
@ -158,7 +158,7 @@ public class AnnotationTest extends HttpServlet
}
catch (Exception e)
{
txLookupResult = "FAIL: "+e;
txLookupResult = "<span class=\"fail\">FAIL:</span> "+e;
}
}
@ -189,6 +189,7 @@ public class AnnotationTest extends HttpServlet
response.setContentType("text/html");
ServletOutputStream out = response.getOutputStream();
out.println("<html>");
out.println("<HEAD><link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheet.css\"/></HEAD>");
out.println("<body>");
out.println("<h1>Results</h1>");
@ -196,14 +197,14 @@ public class AnnotationTest extends HttpServlet
out.println("<pre>");
out.println("initParams={@WebInitParam(name=\"fromAnnotation\", value=\"xyz\")}");
out.println("</pre>");
out.println("<br/><b>Result: "+("xyz".equals(config.getInitParameter("fromAnnotation"))? "PASS": "FAIL"));
out.println("<br/><b>Result: "+("xyz".equals(config.getInitParameter("fromAnnotation"))? "<span class=\"pass\">PASS": "<span class=\"fail\">FAIL")+"</span>");
out.println("<h2>Init Params from web-fragment</h2>");
out.println("<pre>");
out.println("extra1=123, extra2=345");
out.println("</pre>");
boolean fragInitParamResult = "123".equals(config.getInitParameter("extra1")) && "345".equals(config.getInitParameter("extra2"));
out.println("<br/><b>Result: "+(fragInitParamResult? "PASS": "FAIL"));
out.println("<br/><b>Result: "+(fragInitParamResult? "<span class=\"pass\">PASS": "<span class=\"fail\">FAIL")+"</span>");
__HandlesTypes = Arrays.asList( "javax.servlet.GenericServlet",
@ -231,27 +232,27 @@ public class AnnotationTest extends HttpServlet
}
if (classNames.size() != __HandlesTypes.size())
out.println("<br/>FAIL");
out.println("<br/><span class=\"fail\">FAIL</span>");
else if (!classNames.containsAll(__HandlesTypes))
out.println("<br/>FAIL");
out.println("<br/><span class=\"fail\">FAIL</span>");
else
out.println("<br/>PASS");
out.println("<br/><span class=\"pass\">PASS</span>");
}
else
out.print("<br/>FAIL (No such attribute com.acme.Foo)");
out.print("<br/><span class=\"fail\">FAIL</span> (No such attribute com.acme.Foo)");
out.println("</b>");
out.println("<h2>Complete Servlet Registration</h2>");
Boolean complete = (Boolean)config.getServletContext().getAttribute("com.acme.AnnotationTest.complete");
out.println("<br/><b>Result: "+(complete.booleanValue()?"PASS":"FAIL")+"</b>");
out.println("<br/><b>Result: "+(complete.booleanValue()?"<span class=\"pass\">PASS":"<span class=\"fail\">FAIL")+"</span></b>");
out.println("<h2>ServletContextListener Programmatic Registration from ServletContainerInitializer</h2>");
Boolean programmaticListener = (Boolean)config.getServletContext().getAttribute("com.acme.AnnotationTest.listenerTest");
out.println("<br/><b>Result: "+(programmaticListener.booleanValue()?"PASS":"FAIL")+"</b>");
out.println("<br/><b>Result: "+(programmaticListener.booleanValue()?"<span class=\"pass\">PASS":"<span class=\"fail\">FAIL")+"</span></b>");
out.println("<h2>ServletContextListener Programmatic Registration Prevented from ServletContextListener</h2>");
Boolean programmaticListenerPrevention = (Boolean)config.getServletContext().getAttribute("com.acme.AnnotationTest.listenerRegoTest");
out.println("<br/><b>Result: "+(programmaticListenerPrevention.booleanValue()?"PASS":"FAIL")+"</b>");
out.println("<br/><b>Result: "+(programmaticListenerPrevention.booleanValue()?"<span class=\"pass\">PASS":"<span class=\"fail\">FAIL")+"</span></b>");
out.println("<h2>@PostConstruct Callback</h2>");
out.println("<pre>");
@ -281,11 +282,11 @@ public class AnnotationTest extends HttpServlet
out.println("@Resource(name=\"minAmount\")");
out.println("private Double minAmount;");
out.println("</pre>");
out.println("<br/><b>Result: "+envResult+": "+(maxAmount.compareTo(new Double(55))==0?" PASS":" FAIL")+"</b>");
out.println("<br/><b>Result: "+envResult+": "+(maxAmount.compareTo(new Double(55))==0?" <span class=\"pass\">PASS":" <span class=\"fail\">FAIL")+"</span></b>");
out.println("<br/><b>JNDI Lookup Result: "+envLookupResult+"</b>");
out.println("<br/><b>Result: "+envResult2+": "+(minAmount.compareTo(new Double("0.99"))==0?" PASS":" FAIL")+"</b>");
out.println("<br/><b>Result: "+envResult2+": "+(minAmount.compareTo(new Double("0.99"))==0?" <span class=\"pass\">PASS":" <span class=\"fail\">FAIL")+"</span></b>");
out.println("<br/><b>JNDI Lookup Result: "+envLookupResult2+"</b>");
out.println("<br/><b>Result: "+envResult3+": "+(avgAmount.compareTo(new Double("1.25"))==0?" PASS":" FAIL")+"</b>");
out.println("<br/><b>Result: "+envResult3+": "+(avgAmount.compareTo(new Double("1.25"))==0?" <span class=\"pass\">PASS":" <span class=\"fail\">FAIL")+"</span></b>");
out.println("<br/><b>JNDI Lookup Result: "+envLookupResult3+"</b>");
out.println("<h2>@Resource Injection for UserTransaction </h2>");
out.println("<pre>");
@ -294,22 +295,6 @@ public class AnnotationTest extends HttpServlet
out.println("</pre>");
out.println("<br/><b>Result: "+txResult+"</b>");
out.println("<br/><b>JNDI Lookup Result: "+txLookupResult+"</b>");
out.println("<h2>DeclaresRoles</h2>");
out.println("<p>Login as user \"admin\" with password \"admin\" when prompted after clicking the button below to test @DeclareRoles annotation</p>");
String context = request.getContextPath();
if (!context.endsWith("/"))
context += "/";
context += "role/";
out.println("<form action="+context+" method=\"post\"><button type=\"submit\">Test Role Annotations</button></form>");
out.println("<h2>ServletSecurity</h2>");
out.println("<p>Login as user \"admin\" with password \"admin\" when prompted after clicking the button below to test @ServletSecurity annotation</p>");
context = request.getContextPath();
if (!context.endsWith("/"))
context += "/";
context += "sec/foo";
out.println("<form action="+context+" method=\"post\"><button type=\"submit\">Test ServletSecurity Annotation</button></form>");
out.println("</body>");
out.println("</html>");

View File

@ -62,8 +62,9 @@ public class MultiPartTest extends HttpServlet
response.setContentType("text/html");
ServletOutputStream out = response.getOutputStream();
out.println("<html>");
out.println("<h1>Results</h1>");
out.println("<HEAD><link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheet.css\"/></HEAD>");
out.println("<body>");
out.println("<h1>Results</h1>");
out.println("<p>");
Collection<Part> parts = request.getParts();

View File

@ -64,17 +64,18 @@ public class RoleAnnotationTest extends HttpServlet
response.setContentType("text/html");
ServletOutputStream out = response.getOutputStream();
out.println("<html>");
out.println("<HEAD><link rel=\"stylesheet\" type=\"text/css\" href=\"stylesheet.css\"/></HEAD>");
out.println("<h1>Jetty DeclareRoles Annotation Results</h1>");
out.println("<body>");
out.println("<h2>Roles</h2>");
boolean result = request.isUserInRole("other");
out.println("<br/><b>Result: isUserInRole(\"other\")="+result+":"+ (result==false?" PASS":" FAIL")+"</b>");
out.println("<br/><b>Result: isUserInRole(\"other\")="+result+":"+ (result==false?" <span class=\"pass\">PASS":" <span class=\"fail\">FAIL")+"</span></b>");
result = request.isUserInRole("manager");
out.println("<br/><b>Result: isUserInRole(\"manager\")="+result+":"+ (result?" PASS":" FAIL")+"</b>");
out.println("<br/><b>Result: isUserInRole(\"manager\")="+result+":"+ (result?" <span class=\"pass\">PASS":" <span class=\"fail\">FAIL")+"</span></b>");
result = request.isUserInRole("user");
out.println("<br/><b>Result: isUserInRole(\"user\")="+result+":"+ (result==false?" PASS":" FAIL")+"</b>");
out.println("<br/><b>Result: isUserInRole(\"user\")="+result+":"+ (result==false?" <span class=\"pass\">PASS":" <span class=\"fail\">FAIL")+"</span></b>");
String context = _config.getServletContext().getContextPath();
if (!context.endsWith("/"))
context += "/";

View File

@ -40,13 +40,14 @@ public class SecuredServlet extends HttpServlet
{
PrintWriter writer = resp.getWriter();
writer.println( "<html>");
writer.println( "<body>");
writer.println("<h1>@ServletSecurity</h2>");
writer.println("<HEAD><link rel=\"stylesheet\" type=\"text/css\" href=\"../stylesheet.css\"/></HEAD>");
writer.println("<h1>@ServletSecurity</h1>");
writer.println("<body>");
writer.println("<pre>");
writer.println("@ServletSecurity");
writer.println("public class SecuredServlet");
writer.println("</pre>");
writer.println("<br/><b>Result: "+true+"</b>");
writer.println("<p><b>Result: <span class=\"pass\">PASS</span></b></p>");
String context = getServletConfig().getServletContext().getContextPath();
if (!context.endsWith("/"))
context += "/";

View File

@ -3,13 +3,7 @@
<TITLE>Test Specification WebApp</TITLE>
<META http-equiv="Pragma" content="no-cache">
<META http-equiv="Cache-Control" content="no-cache,no-store">
<style>
body {color: #2E2E2E; font-family:sans-serif; font-size:90%;}
h1 {font-variant: small-caps; font-size:130%; letter-spacing: 0.1em;}
h2 {font-variant: small-caps; font-size:100%; letter-spacing: 0.1em;}
h3 {font-size:100%; letter-spacing: 0.1em;}
</style>
<link rel="stylesheet" type="text/css" href="stylesheet.css"/>
</HEAD>
<BODY >
<A HREF="http://www.eclipse.org/jetty"><IMG SRC="images/jetty_banner.gif"></A>
@ -38,6 +32,18 @@ The source repository for this test is available <a href="http://git.eclipse.org
<button type="submit">Test</button>
</form>
<h3>DeclaresRoles</h3>
<p>Login as user <code>admin</code> with password <code>admin</code> when prompted after clicking the button below to test @DeclareRoles annotation</p>
<form action="role" method="post">
<button type="submit">Test Role Annotations</button>
</form>
<h3>ServletSecurity</h3>
<p>Login as user <code>admin</code> with password <code>admin</code> when prompted after clicking the button below to test @ServletSecurity annotation</p>
<form action="sec/foo" method="post">
<button type="submit">Test ServletSecurity Annotation</button>
</form>
<h3>Test Servlet 3.0 Multipart Mime</h3>
Test of the annotation:
<pre>

View File

@ -1,5 +1,9 @@
<HTML><HEAD><TITLE>Annotation Test</TITLE></HEAD>
<HTML>
<HEAD>
<TITLE>Annotation Test</TITLE>
<link rel="stylesheet" type="text/css" href="stylesheet.css"/>
</HEAD>
<BODY>
<H1> Enter your username and password to login </H1>
<I> Enter login=admin and password=admin in order to authenticate successfully</I>

View File

@ -0,0 +1,7 @@
body {color: #2E2E2E; font-family:sans-serif; font-size:90%;}
h1 {font-variant: small-caps; font-size:130%; letter-spacing: 0.1em;}
h2 {font-variant: small-caps; font-size:100%; letter-spacing: 0.1em;}
h3 {font-size:100%; letter-spacing: 0.1em;}
span.pass { color: green; }
span.fail { color:red; }