⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reloadingtestcase.java

📁 webwork source
💻 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));    actions.setLastModified(System.currentTimeMillis()+2000);    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    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -