webwork/src/test/webwork/action/factory ReloadingTestCase.java,NONE,1.1
[email protected] Sat, 08 Nov 2003 08:30:57 -0800
| Newsgroups | gmane.comp.java.open-symphony.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/opensymphony/webwork/src/test/webwork/action/factory
In directory sc8-pr-cvs1:/tmp/cvs-serv31476/webwork/action/factory
Added Files:
ReloadingTestCase.java
Log Message:
Testcase for action reloading
--- NEW FILE: ReloadingTestCase.java ---
package webwork.action.factory;
import java.io.*;
import java.net.URL;
import webwork.TestCaseSupport;
import webwork.action.Action;
/**
* User: hani
* Date: Nov 7, 2003
* Time: 10:14:48 AM
*/
public class ReloadingTestCase extends TestCaseSupport
{
private static final String ORIG = "/reload.orig.xml";
private static final String NEW = "/reload.new.xml";
private File actions;
public void setUp() throws IOException
{
URL url = getClass().getResource(ORIG);
assertNotNull("Cannot find " + ORIG + " in classpath", url);
File orig = new File(url.getFile());
assertTrue("Cannot find file " + url.getFile() + " for " + ORIG, orig.exists());
actions = new File(orig.getParentFile(), "actions.xml");
pipe(new FileInputStream(orig), new FileOutputStream(actions));
//we set the actions file to be modified in the past to ensure the modification will be picked up.
actions.setLastModified(System.currentTimeMillis() - 2000);
}
protected void tearDown() throws Exception
{
actions.delete();
}
public void testXMLReload() throws Exception
{
assertNotNull("Could not find test action", ActionFactory.getAction("test"));
try
{
Action a = ActionFactory.getAction("foo");
fail("foo action should not be available");
}
catch(Exception ex)
{
//good.
}
URL url = getClass().getResource(NEW);
assertNotNull("Cannot find " + NEW + " in classpath", url);
File newFile = new File(url.getFile());
assertTrue("Cannot find file " + url.getFile() + " for " + NEW, newFile.exists());
pipe(new FileInputStream(newFile), new FileOutputStream(actions));
System.out.println("lastModified=" + actions.lastModified());
actions.setLastModified(System.currentTimeMillis()+2000);
System.out.println("fileModified=" + actions.lastModified());
try
{
Action a = ActionFactory.getAction("foo");
}
catch(IllegalArgumentException ex)
{
fail("Cannot find new action foo, reload failed");
}
try
{
Action a = ActionFactory.getAction("test");
fail("Old test action should have been removed but wasn't");
}
catch(Exception ex)
{
//good
}
}
}
-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/