[jboss-cvs] JBossAS SVN: r68360 - in trunk/testsuite/src/main/org/jboss/test/deployers: seam/test and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Dec 17 22:21:40 EST 2007
Author: alesj
Date: 2007-12-17 22:21:40 -0500 (Mon, 17 Dec 2007)
New Revision: 68360
Modified:
trunk/testsuite/src/main/org/jboss/test/deployers/AbstractDeploymentTest.java
trunk/testsuite/src/main/org/jboss/test/deployers/seam/test/SeamExampleTestCase.java
trunk/testsuite/src/main/org/jboss/test/deployers/seam/test/SeamNumberguessExampleTestCase.java
Log:
Seam examples test case - testing http request access.
Modified: trunk/testsuite/src/main/org/jboss/test/deployers/AbstractDeploymentTest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/deployers/AbstractDeploymentTest.java 2007-12-18 03:02:50 UTC (rev 68359)
+++ trunk/testsuite/src/main/org/jboss/test/deployers/AbstractDeploymentTest.java 2007-12-18 03:21:40 UTC (rev 68360)
@@ -30,6 +30,8 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployment.MainDeployerMBean;
import org.jboss.test.JBossTestCase;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VFS;
/**
* Abstract deployment test.
@@ -112,12 +114,19 @@
protected boolean isDeployed(String deployment) throws Exception
{
- URL deployURL = getDeployURL(deployment);
+ URL deployURL = getVFSDeployURL(deployment);
String[] sig = { URL.class.getName() };
Object[] args = {deployURL};
return invokeMainDeployer("isDeployed", args, sig, Boolean.class);
}
+ protected URL getVFSDeployURL(String deployment) throws Exception
+ {
+ URL url = getDeployURL(deployment);
+ VirtualFile vf = VFS.getRoot(url);
+ return vf.toURL();
+ }
+
protected void assertNoChildContexts(String deployment) throws Exception
{
DeploymentUnit unit = getDeploymentUnit(deployment);
Modified: trunk/testsuite/src/main/org/jboss/test/deployers/seam/test/SeamExampleTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/deployers/seam/test/SeamExampleTestCase.java 2007-12-18 03:02:50 UTC (rev 68359)
+++ trunk/testsuite/src/main/org/jboss/test/deployers/seam/test/SeamExampleTestCase.java 2007-12-18 03:21:40 UTC (rev 68360)
@@ -23,9 +23,11 @@
import java.util.HashSet;
import java.util.Set;
+import java.net.URL;
+import junit.framework.Test;
import org.jboss.test.deployers.AbstractDeploymentTest;
-import junit.framework.Test;
+import org.jboss.test.util.web.HttpUtils;
/**
* Test Seam example.
@@ -35,13 +37,21 @@
public abstract class SeamExampleTestCase extends AbstractDeploymentTest
{
// Example libs
- public static final String exampleEar = "jboss-seam-%1$s.ear";
- public static final String exampleJar = "jboss-seam-%1$s.jar";
- public static final String exampleWar = "jboss-seam-%1$s.war";
- public static final String exampleDS = "jboss-seam-%1$s-ds.xml";
+ public static final String JBoss = "jboss-";
+ public static final String simpleName = "seam-%1$s";
+ public static final String exampleName = JBoss + simpleName;
+ public static final String exampleEar = exampleName + ".ear";
+ public static final String exampleJar = exampleName + ".jar";
+ public static final String exampleWar = exampleName + ".war";
+ public static final String exampleDS = exampleName + "-ds.xml";
// Seam libs
public static final String seamJar = "jboss-seam.jar";
+ private boolean testExpected;
+ private boolean useAuthentification;
+ private String username;
+ private String password;
+
protected SeamExampleTestCase(String test)
{
super(test);
@@ -86,11 +96,37 @@
log.info("Testing Seam " + exampleName + " example.");
String topLevelDeployment = getTopLevelDeployment(exampleName);
- final Set<String> expected = getExpectedDeployments(topLevelDeployment, exampleName);
+ assertTrue(isDeployed(topLevelDeployment));
- assertDeployed(topLevelDeployment, expected);
+ if (testExpected)
+ {
+ final Set<String> expected = getExpectedDeployments(topLevelDeployment, exampleName);
+ assertDeployed(topLevelDeployment, expected);
+ }
+
+ URL testURL = getBaseURL();
+ log.info("Accessing test URL: " + testURL);
+ HttpUtils.accessURL(testURL);
}
+ protected String getBaseURLString()
+ {
+ if (useAuthentification)
+ {
+ if (username != null && password != null)
+ return HttpUtils.getBaseURL(username, password);
+ else
+ return HttpUtils.getBaseURL();
+ }
+ return HttpUtils.getBaseURLNoAuth();
+ }
+
+ protected URL getBaseURL() throws Exception
+ {
+ String example = String.format(simpleName, getExampleName());
+ return new URL(getBaseURLString() + example);
+ }
+
protected Set<String> getExpectedDeployments(String topLevelDeployment, String exampleName)
{
final Set<String> expected = new HashSet<String>();
@@ -100,4 +136,24 @@
expected.add(seamJar);
return expected;
}
+
+ public void setTestExpected(boolean testExpected)
+ {
+ this.testExpected = testExpected;
+ }
+
+ public void setUseAuthentification(boolean useAuthentification)
+ {
+ this.useAuthentification = useAuthentification;
+ }
+
+ public void setUsername(String username)
+ {
+ this.username = username;
+ }
+
+ public void setPassword(String password)
+ {
+ this.password = password;
+ }
}
Modified: trunk/testsuite/src/main/org/jboss/test/deployers/seam/test/SeamNumberguessExampleTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/deployers/seam/test/SeamNumberguessExampleTestCase.java 2007-12-18 03:02:50 UTC (rev 68359)
+++ trunk/testsuite/src/main/org/jboss/test/deployers/seam/test/SeamNumberguessExampleTestCase.java 2007-12-18 03:21:40 UTC (rev 68360)
@@ -33,6 +33,7 @@
public SeamNumberguessExampleTestCase(String test)
{
super(test);
+ setTestExpected(true);
}
public static Test suite() throws Exception
More information about the jboss-cvs-commits
mailing list