[jboss-cvs] JBossAS SVN: r68159 - in branches/JBPAPP_4_2/testsuite/src/main/org/jboss/test: util/test and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Dec 11 17:58:23 EST 2007
Author: rrajesh
Date: 2007-12-11 17:58:23 -0500 (Tue, 11 Dec 2007)
New Revision: 68159
Modified:
branches/JBPAPP_4_2/testsuite/src/main/org/jboss/test/jmx/xmbean/XMLAttributePersistenceManagerTestService.java
branches/JBPAPP_4_2/testsuite/src/main/org/jboss/test/util/test/FileURLListerUnitTestCase.java
Log:
JBPAPP-496 Refactor tests that use .dir in directory names for OpenVMS
Modified: branches/JBPAPP_4_2/testsuite/src/main/org/jboss/test/jmx/xmbean/XMLAttributePersistenceManagerTestService.java
===================================================================
--- branches/JBPAPP_4_2/testsuite/src/main/org/jboss/test/jmx/xmbean/XMLAttributePersistenceManagerTestService.java 2007-12-11 22:57:52 UTC (rev 68158)
+++ branches/JBPAPP_4_2/testsuite/src/main/org/jboss/test/jmx/xmbean/XMLAttributePersistenceManagerTestService.java 2007-12-11 22:58:23 UTC (rev 68159)
@@ -40,9 +40,9 @@
* A test service that wraps an XMLAttributePersistenceManager
* configured to write to a random directory containing a space
* in its name, e.g. "./tmp/XmlApmXXXXXTest .dir"
- *
+ *
* @see org.jboss.test.jmx.test.MLAttributePersistenceManagerUnitTestCase
- *
+ *
* @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
* @version $Revision$
*/
@@ -51,33 +51,33 @@
{
private AttributePersistenceManager apm;
private File storeDir;
-
+
protected void startService()
throws Exception
{
File tmpDir = ServerConfigLocator.locate().getServerTempDir();
boolean result;
-
+
// Get a temporary file in the server tmp dir, with a space in its name
- storeDir = File.createTempFile("XmlApm", "Test .dir", tmpDir);
-
+ storeDir = File.createTempFile("XmlApm", "Test .directory", tmpDir);
+
// Remove the tmp file
result = storeDir.delete();
// Recreate it as directory
result = storeDir.mkdir();
log.info("Created 'bad' store dir: " + storeDir + ", " + result);
-
+
String dirURL = storeDir.toURL().toString();
- log.info("Dir URL: " + dirURL);
-
+ log.info("Dir URL: " + dirURL);
+
apm = new XMLAttributePersistenceManager();
// Initialize an XMLAttributePeristenceManager and
// configure it to point to the "bad" directory
apm.create(null, prepareConfig(dirURL));
}
-
+
protected void stopService()
throws Exception
{
@@ -93,33 +93,33 @@
log.info("Removed: " + storeDir + ", " + result);
}
}
-
+
public void store(String id, AttributeList atlist) throws Exception
{
apm.store(id, atlist);
}
-
+
public AttributeList load(String id) throws Exception
{
return apm.load(id);
}
-
+
public void selftest() throws Exception
{
// Store some attributes under an id
AttributeList alist = new AttributeList();
String storeId = "bananarama";
-
+
Integer anInteger = new Integer(666);
String aString = new String("Evil Test");
alist.add(new Attribute("Attr1", anInteger));
alist.add(new Attribute("Attr2", aString));
apm.store(storeId, alist);
-
+
// Read them back
- AttributeList alist2 = apm.load(storeId);
+ AttributeList alist2 = apm.load(storeId);
}
-
+
private Element prepareConfig(String dir) throws Exception
{
// build the config XML Element in memory using DOM
@@ -128,13 +128,13 @@
// Create config element
Element config = doc.createElement(XMLAttributePersistenceManager.DATA_DIR_ELEMENT);
-
+
// Insert a text node with the directory name
Node text = doc.createTextNode(dir);
-
+
config.appendChild(text);
-
+
// Return the config
return config;
- }
+ }
}
Modified: branches/JBPAPP_4_2/testsuite/src/main/org/jboss/test/util/test/FileURLListerUnitTestCase.java
===================================================================
--- branches/JBPAPP_4_2/testsuite/src/main/org/jboss/test/util/test/FileURLListerUnitTestCase.java 2007-12-11 22:57:52 UTC (rev 68158)
+++ branches/JBPAPP_4_2/testsuite/src/main/org/jboss/test/util/test/FileURLListerUnitTestCase.java 2007-12-11 22:58:23 UTC (rev 68159)
@@ -30,7 +30,7 @@
/**
* FileURLLister tests
- *
+ *
* @author <a href="dimitris at jboss.org">Dimitris Andreadis</a>
* @version $Revision$
**/
@@ -44,87 +44,87 @@
public void testListDeployLikeDirStructureDontRecurse() throws Exception
{
getLog().debug("+++ testListDeployLikeDirStructureDontRecurse");
-
+
String baseUrlString = super.getResourceURL("util/fileurllister/deploy/");
URL baseUrl = new URL(baseUrlString);
-
+
FileURLLister lister = new FileURLLister();
Collection files = lister.listMembers(baseUrl, "*", false);
-
+
logResult(files);
-
+
String[] expected = new String[] {
- "dotted.sub.dir/",
+ "dotted.subdir/",
"nondottedsubdir/",
"one.xml",
"two.xml"
};
-
+
checkResult(files, baseUrlString, expected);
}
-
+
public void testListDeployLikeDirStructureRecurse() throws Exception
{
getLog().debug("+++ testListDeployLikeDirStructureRecurse");
-
+
String baseUrlString = super.getResourceURL("util/fileurllister/deploy/");
URL baseUrl = new URL(baseUrlString);
-
+
FileURLLister lister = new FileURLLister();
Collection files = lister.listMembers(baseUrl, "*", true);
-
+
logResult(files);
-
+
String[] expected = new String[] {
- "dotted.sub.dir/",
+ "dotted.subdir/",
"nondottedsubdir/three.xml",
"one.xml",
"two.xml",
};
-
+
checkResult(files, baseUrlString, expected);
}
-
+
public void testListDeployLikeDirStructureDontRecurseWithFilter() throws Exception
{
getLog().debug("+++ testListDeployLikeDirStructureDontRecurseWithFilter");
-
+
String baseUrlString = super.getResourceURL("util/fileurllister/deploy/");
URL baseUrl = new URL(baseUrlString);
-
+
FileURLLister lister = new FileURLLister();
Collection files = lister.listMembers(baseUrl, "one.xml,nondottedsubdir,three.xml", false);
-
+
logResult(files);
-
+
String[] expected = new String[] {
"nondottedsubdir/",
"one.xml"
};
-
+
checkResult(files, baseUrlString, expected);
}
-
+
public void testListDeployLikeDirStructureRecurseWithFilter() throws Exception
{
getLog().debug("+++ testListDeployLikeDirStructureRecurseWithFilter");
-
+
String baseUrlString = super.getResourceURL("util/fileurllister/deploy/");
URL baseUrl = new URL(baseUrlString);
-
+
FileURLLister lister = new FileURLLister();
Collection files = lister.listMembers(baseUrl, "one.xml,nondottedsubdir,three.xml", true);
-
+
logResult(files);
-
+
String[] expected = new String[] {
"nondottedsubdir/three.xml",
"one.xml"
};
-
+
checkResult(files, baseUrlString, expected);
}
-
+
private void logResult(Collection result)
{
for (Iterator i = result.iterator(); i.hasNext(); )
@@ -133,12 +133,12 @@
getLog().debug(url.toString());
}
}
-
+
private void checkResult(Collection result, String baseUrlString, String[] expected) throws Exception
{
assertTrue("result.size(" + result.size() + ") != expected.length(" + expected.length + ")",
result.size() == expected.length);
-
+
for (int i = 0; i < expected.length; i++)
{
URL excepted = new URL(baseUrlString + expected[i]);
More information about the jboss-cvs-commits
mailing list