Java tutorial
/* * Copyright (c) 2007 NTT DATA Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jp.terasoluna.fw.web.struts.plugins; import java.io.IOException; import java.net.MalformedURLException; import java.util.Map; import javax.servlet.ServletContext; import javax.servlet.ServletException; import jp.terasoluna.fw.util.ClassLoadException; import jp.terasoluna.fw.web.struts.reset.ActionReset; import jp.terasoluna.fw.web.struts.reset.FieldReset; import jp.terasoluna.fw.web.struts.reset.ResetterImpl; import jp.terasoluna.fw.web.struts.reset.ResetterResources; import jp.terasoluna.utlib.LogUTUtil; import jp.terasoluna.utlib.UTUtil; import junit.framework.TestCase; import org.apache.commons.digester.xmlrules.XmlLoadException; import org.apache.struts.config.ModuleConfig; import org.apache.struts.config.impl.ModuleConfigImpl; import org.xml.sax.SAXException; /** * {@link jp.terasoluna.fw.web.struts.plugins.ResetterPlugIn} NXubN{bNXeXg?B * * <p> * <h4>?yNXTv?z</h4> * tH?[Zbg???[hvOC?B<br> * PlugIn@\gp?AT?[ubg?tH?[Zbg@\???AT?[ubgReLXg?B * <p> * * @see jp.terasoluna.fw.web.struts.plugins.ResetterPlugIn */ public class ResetterPlugInTest extends TestCase { /** * t@CpXv?peB */ private static final String RESET_FILE_NAME = ResetterPlugInTest.class .getResource("ResetterPlugInTest-reset.xml").getPath(); /** * t@CpXv?peB */ private static final String RESET_FILE_NAME2 = ResetterPlugInTest.class .getResource("ResetterPlugInTest-reset2.xml").getPath(); /** * t@CpXv?peB */ private static final String RESET_FILE_NAME3 = ResetterPlugInTest.class .getResource("ResetterPlugInTest-reset3.xml").getPath(); /** * t@CpXv?peB */ private static final String RESET_RULES_FILE_NAME = ResetterPlugInTest.class .getResource("ResetterPlugInTest-reset-rules.xml").getPath(); /** * ResetterPlugIn?B */ private ResetterPlugIn plugin = null; /** * eXgP?[X?s * GUI AvP?[VN?B * * @param args java R}h?p??[^ */ public static void main(String[] args) { junit.swingui.TestRunner.run(ResetterPlugInTest.class); } /** * ????s?B * * @throws Exception ?\bh?O * @see junit.framework.TestCase#setUp() */ @Override protected void setUp() throws Exception { super.setUp(); plugin = new ResetterPlugIn(); UTUtil.setPrivateField(ResetterPlugIn.class, "digester", null); } /** * ?I???s?B * * @throws Exception ?\bh?O * @see junit.framework.TestCase#tearDown() */ @Override protected void tearDown() throws Exception { super.tearDown(); } /** * RXgN^?B * * @param name eXgP?[XO?B */ public ResetterPlugInTest(String name) { super(name); } /** * testInit01() * <br><br> * * (??n) * <br> * _?FA * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)=""<br> * (?) this.resetter:ResetterPlugIn_ResetterStub01?i?NX?j<br> * (?) this.resourcePath:"ResetterPlugInTest-reset.xml"?i?t@C?j<br> * * <br> * l?F(?) RESETTER_RESOURCES:T?[ubgReLXg"RESETTER_RESOURCES"L?[ResetterResourcesCX^Xi[?B<br> * (?) RESETTER:T?[ubgReLXg"RESETTER"L?[ResetterPlugIn_ResetterStub01CX^Xi[?B<br> * * <br> * ??????smF?B * <br> * * @throws Exception ?\bh?O */ public void testInit01() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl(""); // Zb^?[NXS?C?NX? UTUtil.setPrivateField(plugin, "resetter", "jp.terasoluna.fw.web.struts.plugins." + "ResetterPlugIn_ResetterStub01"); // Zb^?[NXS?C?NX? UTUtil.setPrivateField(plugin, "resourcesPath", RESET_FILE_NAME); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); // Zbg?[w UTUtil.setPrivateField(plugin, "digesterRules", RESET_RULES_FILE_NAME); // eXg?s plugin.init(servlet, conf); // mF // T?[ubgReLXg ServletContext ctx = servlet.getServletContext(); assertEquals("jp.terasoluna.fw.web.struts.plugins.ResetterPlugIn_ResetterStub01", ((ResetterImpl) ctx.getAttribute("RESETTER")).getClass().getName()); assertEquals("jp.terasoluna.fw.web.struts.reset.ResetterResources", ((ResetterResources) ctx.getAttribute("RESETTER_RESOURCES")).getClass().getName()); } /** * testInitResetter01() * <br><br> * * (??n) * <br> * _?FA * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)=""<br> * (?) this.resetter:null<br> * * <br> * l?F(?) RESETTER:T?[ubgReLXg"RESETTER"L?[ResetterCX^Xi[?B<br> * (?) O:?|<br> * (?) ?O:?|<br> * * <br> * this.resetternull?A??ftHgresetterT?[ubgReLXgmF?B * <br> * * @throws Exception ?\bh?O */ public void testInitResetter01() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl(""); // Zb^?[NXS?C?NX? UTUtil.setPrivateField(plugin, "resetter", null); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); // eXg?s plugin.initResetter(servlet, conf); // mF // T?[ubgReLXg ServletContext ctx = servlet.getServletContext(); assertEquals("jp.terasoluna.fw.web.struts.reset.ResetterImpl", ((ResetterImpl) ctx.getAttribute("RESETTER")).getClass().getName()); } /** * testInitResetter02() * <br><br> * * (??n) * <br> * _?FA * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)=""<br> * (?) this.resetter:""<br> * * <br> * l?F(?) RESETTER:T?[ubgReLXg"RESETTER"L?[ResetterCX^Xi[?B<br> * (?) O:?|<br> * (?) ?O:?|<br> * * <br> * this.resetter?A??ftHgresetterT?[ubgReLXgmF?B * <br> * * @throws Exception ?\bh?O */ public void testInitResetter02() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl(""); // Zb^?[NXS?C?NX? UTUtil.setPrivateField(plugin, "resetter", ""); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); // eXg?s plugin.initResetter(servlet, conf); // mF // T?[ubgReLXg ServletContext ctx = servlet.getServletContext(); assertEquals("jp.terasoluna.fw.web.struts.reset.ResetterImpl", ((ResetterImpl) ctx.getAttribute("RESETTER")).getClass().getName()); } /** * testInitResetter03() * <br><br> * * (?n) * <br> * _?FG * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)=""<br> * (?) this.resetter:Nothing?i?NX?j<br> * * <br> * l?F(?) RESETTER:?|<br> * (?) O:ServletException<br> * bvO?FClassLoadException(ClassNotFoundException)<br> * (?) ?O:??O?<br> * G?[?O?F""<br> * O?FClassLoadException<br> * * <br> * this.resetter?NX?AServletException?mF?B * <br> * * @throws Exception ?\bh?O */ public void testInitResetter03() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl(""); // Zb^?[NXS?C?NX? UTUtil.setPrivateField(plugin, "resetter", "Nothing"); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); try { // eXg?s plugin.initResetter(servlet, conf); fail(); } catch (ServletException e) { // mF assertEquals(ClassLoadException.class.getName(), e.getRootCause().getClass().getName()); assertEquals(ClassNotFoundException.class.getName(), e.getRootCause().getCause().getClass().getName()); assertTrue(LogUTUtil.checkError("", e.getRootCause())); } } /** * testInitResetter04() * <br><br> * * (??n) * <br> * _?FA * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)=""<br> * (?) this.resetter:ResetterPlugIn_ResetterStub01?i?NX?j<br> * * <br> * l?F(?) RESETTER:T?[ubgReLXg"RESETTER"L?[ResetterPlugIn_ResetterStub01CX^Xi[?B<br> * (?) O:?|<br> * (?) ?O:?|<br> * * <br> * this.resetter?NX?A??resetterT?[ubgReLXgmF?B * <br> * * @throws Exception ?\bh?O */ public void testInitResetter04() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl(""); // Zb^?[NXS?C?NX? UTUtil.setPrivateField(plugin, "resetter", "jp.terasoluna.fw.web.struts.plugins." + "ResetterPlugIn_ResetterStub01"); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); // eXg?s plugin.initResetter(servlet, conf); // mF // T?[ubgReLXg ServletContext ctx = servlet.getServletContext(); assertEquals("jp.terasoluna.fw.web.struts.plugins.ResetterPlugIn_ResetterStub01", ((ResetterImpl) ctx.getAttribute("RESETTER")).getClass().getName()); } /** * testInitResetter05() * <br><br> * * (??n) * <br> * _?FA * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)="test1"<br> * (?) this.resetter:ResetterPlugIn_ResetterStub01?i?NX?j<br> * * <br> * l?F(?) RESETTER:T?[ubgReLXg"RESETTER/test1"L?[ResetterPlugIn_ResetterStub01CX^Xi[?B<br> * (?) O:?|<br> * (?) ?O:?|<br> * * <br> * W?[O?AT?[ubgReLXgo^L?[?AW?[mF?B * <br> * * @throws Exception ?\bh?O */ public void testInitResetter05() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl("/test1"); // Zb^?[NXS?C?NX? UTUtil.setPrivateField(plugin, "resetter", "jp.terasoluna.fw.web.struts.plugins." + "ResetterPlugIn_ResetterStub01"); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); // eXg?s plugin.initResetter(servlet, conf); // mF // T?[ubgReLXg ServletContext ctx = servlet.getServletContext(); assertEquals("jp.terasoluna.fw.web.struts.plugins.ResetterPlugIn_ResetterStub01", ((ResetterImpl) ctx.getAttribute("RESETTER/test1")).getClass().getName()); } /** * testInitResources01() * <br><br> * * (?n) * <br> * _?FG * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)=""<br> * (?) this.resourcePath:null<br> * (?) digesterRules:?|<br> * (?) ServletContext#getResource():?|<br> * * <br> * l?F(?) RESETTER_RESOURCES:?|<br> * (?) digesterRules:?|<br> * (?) O:ServletException<br> * ?bZ?[W?F"resources file location is not specified"<br> * (?) ?O:??O?<br> * G?[?O?F"resources file location is not specified"<br> * * <br> * this.resourcesPathnullServletException?mF?B * <br> * * @throws Exception ?\bh?O */ public void testInitResources01() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl(""); // reset.xmlpX? UTUtil.setPrivateField(plugin, "resourcesPath", null); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); // eXg?s try { plugin.initResources(servlet, conf); fail(); } catch (ServletException e) { assertEquals("resources file location is not specified", e.getMessage()); assertTrue(LogUTUtil.checkError("resources file location is not specified")); } } /** * testInitResources02() * <br><br> * * (?n) * <br> * _?FG * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)=""<br> * (?) this.resourcePath:""<br> * (?) digesterRules:?|<br> * (?) ServletContext#getResource():?|<br> * * <br> * l?F(?) RESETTER_RESOURCES:?|<br> * (?) digesterRules:?|<br> * (?) O:ServletException<br> * ?bZ?[W?F"resources file location is not specified"<br> * (?) ?O:??O?<br> * G?[?O?F"resources file location is not specified"<br> * * <br> * this.resourcesPathServletException?mF?B * <br> * * @throws Exception ?\bh?O */ public void testInitResources02() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl(""); // reset.xmlpX? UTUtil.setPrivateField(plugin, "resourcesPath", ""); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); // eXg?s try { plugin.initResources(servlet, conf); fail(); } catch (ServletException e) { assertEquals("resources file location is not specified", e.getMessage()); assertTrue(LogUTUtil.checkError("resources file location is not specified")); } } /** * testInitResources03() * <br><br> * * (?n) * <br> * _?FG * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)=""<br> * (?) this.resourcePath:"ResetterPlugInTest-reset.xml"<br> * (?) digesterRules:null<br> * (?) ServletContext#getResource():?|<br> * * <br> * l?F(?) RESETTER_RESOURCES:?|<br> * (?) digesterRules:"/WEB-INF/reset-rules.xml"<br> * (?) O:ServletException<br> * bvO?FXmlLoadException<br> * (?) ?O:??O?<br> * G?[?O?F""<br> * O?FXmlLoadException<br> * * <br> * digesterRulesw???AftHgt@Ci[mF?B?AdigesterRulest@C?t@CServletException?mF?B * <br> * * @throws Exception ?\bh?O */ public void testInitResources03() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl(""); // reset.xmlpX? UTUtil.setPrivateField(plugin, "resourcesPath", RESET_FILE_NAME); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); try { // eXg?s plugin.initResources(servlet, conf); fail(); } catch (ServletException e) { assertEquals(XmlLoadException.class.getName(), e.getRootCause().getClass().getName()); assertTrue(LogUTUtil.checkError("", e.getRootCause())); assertEquals("/WEB-INF/reset-rules.xml", UTUtil.getPrivateField(plugin, "digesterRules")); } } /** * testInitResources04() * <br><br> * * (?n) * <br> * _?FG * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)=""<br> * (?) this.resourcePath:"ResetterPlugInTest-reset.xml"<br> * (?) digesterRules:"ResetterPlugInTest-reset-rules.xml"<br> * (?) ServletContext#getResource():MalformedURLException?<br> * * <br> * l?F(?) RESETTER_RESOURCES:?|<br> * (?) digesterRules:"ResetterPlugInTest-reset-rules.xml"<br> * (?) O:ServletException<br> * bvO?FMalformedURLException<br> * (?) ?O:??O?<br> * G?[?O?F""<br> * O?FMalformedURLException<br> * * <br> * ServletContext#getResource()MalformedURLException??AServletExceptionbvmF?B * <br> * * @throws Exception ?\bh?O */ public void testInitResources04() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl(""); // reset.xmlpX? UTUtil.setPrivateField(plugin, "resourcesPath", RESET_FILE_NAME); // reset-rules.xmlpX? UTUtil.setPrivateField(plugin, "digesterRules", RESET_RULES_FILE_NAME); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub02 servlet = new ResetterPlugIn_ActionServletStub02(); try { // eXg?s plugin.initResources(servlet, conf); fail(); } catch (ServletException e) { assertEquals(MalformedURLException.class.getName(), e.getRootCause().getClass().getName()); assertTrue(LogUTUtil.checkError("", e.getRootCause())); assertEquals(RESET_RULES_FILE_NAME, UTUtil.getPrivateField(plugin, "digesterRules")); } } /** * testInitResources05() * <br><br> * * (??n) * <br> * _?FA * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)=""<br> * (?) this.resourcePath:"ResetterPlugInTest-reset.xml"<br> * (?) digesterRules:"ResetterPlugInTest-reset-rules.xml"<br> * (?) ServletContext#getResource():?|<br> * * <br> * l?F(?) RESETTER_RESOURCES:T?[ubgReLXg"RESETTER_RESOURCES"L?[ResetterResourcesCX^Xi[?B<br> * (?) digesterRules:?|<br> * (?) O:?|<br> * (?) ?O:?|<br> * * <br> * RESETTER_RESOURCESL?[?A??T?[ubgReLXgmF?B * <br> * * @throws Exception ?\bh?O */ public void testInitResources05() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl(""); // reset.xmlpX? UTUtil.setPrivateField(plugin, "resourcesPath", RESET_FILE_NAME); // reset-rules.xmlpX? UTUtil.setPrivateField(plugin, "digesterRules", RESET_RULES_FILE_NAME); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); // eXg?s plugin.initResources(servlet, conf); // mF // T?[ubgReLXg ServletContext ctx = servlet.getServletContext(); assertEquals("jp.terasoluna.fw.web.struts.reset.ResetterResources", ((ResetterResources) ctx.getAttribute("RESETTER_RESOURCES")).getClass().getName()); } /** * testInitResources06() * <br><br> * * (??n) * <br> * _?FA * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)="/test2"<br> * (?) this.resourcePath:"ResetterPlugInTest-reset.xml"<br> * (?) digesterRules:"ResetterPlugInTest-reset-rules.xml"<br> * (?) ServletContext#getResource():?|<br> * * <br> * l?F(?) RESETTER_RESOURCES:T?[ubgReLXg"RESETTER_RESOURCES/test2"L?[ResetterResourcesCX^Xi[?B<br> * (?) digesterRules:?|<br> * (?) O:?|<br> * (?) ?O:?|<br> * * <br> * W?[O?AT?[ubgReLXgo^L?[?AW?[mF?B * <br> * * @throws Exception ?\bh?O */ public void testInitResources06() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl("/test2"); // reset.xmlpX? UTUtil.setPrivateField(plugin, "resourcesPath", RESET_FILE_NAME); // reset-rules.xmlpX? UTUtil.setPrivateField(plugin, "digesterRules", RESET_RULES_FILE_NAME); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); // eXg?s plugin.initResources(servlet, conf); // mF // T?[ubgReLXg ServletContext ctx = servlet.getServletContext(); assertEquals("jp.terasoluna.fw.web.struts.reset.ResetterResources", ((ResetterResources) ctx.getAttribute("RESETTER_RESOURCES/test2")).getClass().getName()); } /** * testInitResources07() * <br><br> * * (?n) * <br> * _?FG * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)=""<br> * (?) this.resourcePath:"nothing.xml"?i?t@C?j<br> * (?) digesterRules:"ResetterPlugInTest-reset-rules.xml"<br> * (?) ServletContext#getResource():?|<br> * * <br> * l?F(?) RESETTER_RESOURCES:?|<br> * (?) digesterRules:?|<br> * (?) O:ServletException<br> * bvO?FIOException<br> * (?) ?O:??O?<br> * G?[?O?F""<br> * O?FIOException<br> * * <br> * this.resourcePath?t@Cw???AServletException?mF?B * <br> * * @throws Exception ?\bh?O */ public void testInitResources07() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl(""); // reset.xmlpX? UTUtil.setPrivateField(plugin, "resourcesPath", "nothing.xml"); // reset-rules.xmlpX? UTUtil.setPrivateField(plugin, "digesterRules", RESET_RULES_FILE_NAME); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); // eXg?s try { plugin.initResources(servlet, conf); fail(); } catch (ServletException e) { // mF // ????AMalformedURLException??AcatchIOExceptioninstanceof`FbN assertTrue(e.getRootCause() instanceof IOException); assertTrue(LogUTUtil.checkError("", e.getRootCause())); } } /** * testInitResources08() * <br><br> * * (?n) * <br> * _?FG * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)=""<br> * (?) this.resourcePath:"ResetterPlugInTest-error-reset.xml"(p?[XG?[?t@C)<br> * (?) digesterRules:"ResetterPlugInTest-reset-rules.xml"<br> * (?) ServletContext#getResource():?|<br> * * <br> * l?F(?) RESETTER_RESOURCES:?|<br> * (?) digesterRules:?|<br> * (?) O:ServletException<br> * bvO?FSAXException<br> * (?) ?O:??O?<br> * G?[?O?F""<br> * O?FSAXException<br> * * <br> * this.resourcesPathp?[XG?[?t@Cw?AServletException?mF?B * <br> * * @throws Exception ?\bh?O */ public void testInitResources08() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl(""); // reset.xmlpX? UTUtil.setPrivateField(plugin, "resourcesPath", ResetterPlugInTest.class.getResource("ResetterPlugInTest-error-reset.xml").getPath()); // reset-rules.xmlpX? UTUtil.setPrivateField(plugin, "digesterRules", RESET_RULES_FILE_NAME); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); // eXg?s try { plugin.init(servlet, conf); fail(); } catch (ServletException e) { // mF // ????ASAXParseException??AcatchSAXExceptioninstanceof`FbN assertTrue(e.getRootCause() instanceof SAXException); assertTrue(LogUTUtil.checkError("", e.getRootCause())); } } /** * testInitResources09() * <br><br> * * (??n) * <br> * _?FA * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)=""<br> * (?) this.resourcePath:"ResetterPlugInTest-reset.xml","ResetterPlugInTest-reset2.xml","ResetterPlugInTest-reset3.xml"<br> * (?) digesterRules:"ResetterPlugInTest-reset-rules.xml"<br> * (?) ServletContext#getResource():?|<br> * * <br> * l?F(?) RESETTER_RESOURCES:T?[ubgReLXg"RESETTER_RESOURCES"L?[ResetterResourcesCX^Xi[?B?iResetterResources?gmF?s?j<br> * (?) digesterRules:?|<br> * (?) O:?|<br> * (?) ?O:?|<br> * * <br> * this.resourcesPath?t@Cw?ARESETTER_RESOURCESL?[?A??T?[ubgReLXgmF?B * <br> * * @throws Exception ?\bh?O */ public void testInitResources09() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl(""); // reset.xmlpX? UTUtil.setPrivateField(plugin, "resourcesPath", RESET_FILE_NAME + "," + RESET_FILE_NAME2 + "," + RESET_FILE_NAME3); // reset-rules.xmlpX? UTUtil.setPrivateField(plugin, "digesterRules", RESET_RULES_FILE_NAME); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); // eXg?s plugin.initResources(servlet, conf); // mF // T?[ubgReLXg ServletContext ctx = servlet.getServletContext(); assertEquals("jp.terasoluna.fw.web.struts.reset.ResetterResources", ((ResetterResources) ctx.getAttribute("RESETTER_RESOURCES")).getClass().getName()); // XMLp?[X ResetterResources resource = (ResetterResources) ctx.getAttribute("RESETTER_RESOURCES"); Map actionResets = (Map) UTUtil.getPrivateField(resource, "actionResets"); // Pt@Cresett@C??? ActionReset actionReset1_1 = (ActionReset) actionResets.get("/changePage"); // fieldReset`FbN Map fieldResets1_1 = (Map) UTUtil.getPrivateField(actionReset1_1, "fieldResets"); assertEquals(1, fieldResets1_1.size()); FieldReset fieldReset1_1 = (FieldReset) fieldResets1_1.get("field1-1"); assertEquals("field1-1", fieldReset1_1.getFieldName()); assertFalse(fieldReset1_1.isSelect()); ActionReset actionReset1_2 = (ActionReset) actionResets.get("/bbb/BBB"); // fieldReset`FbN Map fieldResets1_2 = (Map) UTUtil.getPrivateField(actionReset1_2, "fieldResets"); assertEquals(3, fieldResets1_2.size()); FieldReset fieldReset1_2 = (FieldReset) fieldResets1_2.get("field1-1"); assertEquals("field1-1", fieldReset1_2.getFieldName()); assertFalse(fieldReset1_2.isSelect()); FieldReset fieldReset1_3 = (FieldReset) fieldResets1_2.get("field1-2"); assertEquals("field1-2", fieldReset1_3.getFieldName()); assertTrue(fieldReset1_3.isSelect()); FieldReset fieldReset1_4 = (FieldReset) fieldResets1_2.get("field1-3"); assertEquals("field1-3", fieldReset1_4.getFieldName()); assertTrue(fieldReset1_4.isSelect()); ActionReset actionReset1_3 = (ActionReset) actionResets.get("/ccc/CCC"); // fieldReset`FbN Map fieldResets1_3 = (Map) UTUtil.getPrivateField(actionReset1_3, "fieldResets"); assertEquals(2, fieldResets1_3.size()); FieldReset fieldReset1_5 = (FieldReset) fieldResets1_3.get("field1-1"); assertEquals("field1-1", fieldReset1_5.getFieldName()); assertFalse(fieldReset1_5.isSelect()); FieldReset fieldReset1_6 = (FieldReset) fieldResets1_3.get("field1-2"); assertEquals("field1-2", fieldReset1_6.getFieldName()); assertFalse(fieldReset1_6.isSelect()); // Qt@Cresett@C??? ActionReset actionReset2_1 = (ActionReset) actionResets.get("/aaa/AAA2"); // fieldReset`FbN Map fieldResets2_1 = (Map) UTUtil.getPrivateField(actionReset2_1, "fieldResets"); assertEquals(1, fieldResets2_1.size()); FieldReset fieldReset2_1 = (FieldReset) fieldResets2_1.get("field2-1"); assertEquals("field2-1", fieldReset2_1.getFieldName()); assertFalse(fieldReset2_1.isSelect()); ActionReset actionReset2_2 = (ActionReset) actionResets.get("/bbb/BBB2"); // fieldReset`FbN Map fieldResets2_2 = (Map) UTUtil.getPrivateField(actionReset2_2, "fieldResets"); assertEquals(3, fieldResets2_2.size()); FieldReset fieldReset2_2 = (FieldReset) fieldResets2_2.get("field2-1"); assertEquals("field2-1", fieldReset2_2.getFieldName()); assertFalse(fieldReset2_2.isSelect()); FieldReset fieldReset2_3 = (FieldReset) fieldResets2_2.get("field2-2"); assertEquals("field2-2", fieldReset2_3.getFieldName()); assertTrue(fieldReset2_3.isSelect()); FieldReset fieldReset2_4 = (FieldReset) fieldResets2_2.get("field2-3"); assertEquals("field2-3", fieldReset2_4.getFieldName()); assertTrue(fieldReset2_4.isSelect()); ActionReset actionReset2_3 = (ActionReset) actionResets.get("/ccc/CCC2"); // fieldReset`FbN Map fieldResets2_3 = (Map) UTUtil.getPrivateField(actionReset2_3, "fieldResets"); assertEquals(2, fieldResets2_3.size()); FieldReset fieldReset2_5 = (FieldReset) fieldResets2_3.get("field2-1"); assertEquals("field2-1", fieldReset2_5.getFieldName()); assertFalse(fieldReset2_5.isSelect()); FieldReset fieldReset2_6 = (FieldReset) fieldResets2_3.get("field2-2"); assertEquals("field2-2", fieldReset2_6.getFieldName()); assertFalse(fieldReset2_6.isSelect()); // Rt@Cresett@C??? ActionReset actionReset3_1 = (ActionReset) actionResets.get("/aaa/AAA3"); // fieldReset`FbN Map fieldResets3_1 = (Map) UTUtil.getPrivateField(actionReset3_1, "fieldResets"); assertEquals(1, fieldResets3_1.size()); FieldReset fieldReset3_1 = (FieldReset) fieldResets3_1.get("field3-1"); assertEquals("field3-1", fieldReset3_1.getFieldName()); assertFalse(fieldReset3_1.isSelect()); ActionReset actionReset3_2 = (ActionReset) actionResets.get("/bbb/BBB3"); // fieldReset`FbN Map fieldResets3_2 = (Map) UTUtil.getPrivateField(actionReset3_2, "fieldResets"); assertEquals(3, fieldResets3_2.size()); FieldReset fieldReset3_2 = (FieldReset) fieldResets3_2.get("field3-1"); assertEquals("field3-1", fieldReset3_2.getFieldName()); assertFalse(fieldReset3_2.isSelect()); FieldReset fieldReset3_3 = (FieldReset) fieldResets3_2.get("field3-2"); assertEquals("field3-2", fieldReset3_3.getFieldName()); assertTrue(fieldReset3_3.isSelect()); FieldReset fieldReset3_4 = (FieldReset) fieldResets3_2.get("field3-3"); assertEquals("field3-3", fieldReset3_4.getFieldName()); assertTrue(fieldReset3_4.isSelect()); ActionReset actionReset3_3 = (ActionReset) actionResets.get("/ccc/CCC3"); // fieldReset`FbN Map fieldResets3_3 = (Map) UTUtil.getPrivateField(actionReset3_3, "fieldResets"); assertEquals(2, fieldResets3_3.size()); FieldReset fieldReset3_5 = (FieldReset) fieldResets3_3.get("field3-1"); assertEquals("field3-1", fieldReset3_5.getFieldName()); assertFalse(fieldReset3_5.isSelect()); FieldReset fieldReset3_6 = (FieldReset) fieldResets3_3.get("field3-2"); assertEquals("field3-2", fieldReset3_6.getFieldName()); assertFalse(fieldReset3_6.isSelect()); // Qt@CRt@Cresett@C?dpX????A // ?t@C?? ActionReset actionResetDuplicate = (ActionReset) actionResets.get("/duplicate"); // fieldReset`FbN Map duplicate = (Map) UTUtil.getPrivateField(actionResetDuplicate, "fieldResets"); assertEquals(1, duplicate.size()); FieldReset fieldReset1 = (FieldReset) duplicate.get("duplicate1"); assertNull(fieldReset1); FieldReset fieldReset2 = (FieldReset) duplicate.get("duplicate2"); assertEquals("duplicate2", fieldReset2.getFieldName()); assertFalse(fieldReset2.isSelect()); } /** * testInitResources10() * <br><br> * * (?n) * <br> * _?FG * <br><br> * l?F(?) servlet:not null<br> * (?) config:W?[(?)=""<br> * (?) this.resourcePath:"ResetterPlugInTest-reset.xml","ResetterPlugInTest-reset2.xml","ResetterPlugInTest-reset3.xml"<br> * (?) digesterRules:"ResetterPlugInTest-reset-rules.xml"<br> * (?) ServletContext#getResource():?|<br> * * <br> * l?F(?) RESETTER_RESOURCES:?|<br> * (?) digesterRules:?|<br> * (?) O:ServletException<br> * bvO?FIOException<br> * (?) ?O:??O?<br> * G?[?O?F""<br> * O?FIOException<br> * * <br> * getPublicIdentifier()?AURLIuWFNg???? * <br> * * @throws Exception ?\bh?O */ public void testInitResources10() throws Exception { // W?[?? ModuleConfig conf = new ModuleConfigImpl(""); plugin = new ResetterPlugIn() { @Override public String getPublicIdentifier() { return ""; } }; // reset.xmlpX? UTUtil.setPrivateField(plugin, "resourcesPath", RESET_FILE_NAME + "," + RESET_FILE_NAME2 + "," + RESET_FILE_NAME3); // reset-rules.xmlpX? UTUtil.setPrivateField(plugin, "digesterRules", RESET_RULES_FILE_NAME); // ANVT?[ubg?? ResetterPlugIn_ActionServletStub01 servlet = new ResetterPlugIn_ActionServletStub01(); // eXg?s try { plugin.initResources(servlet, conf); fail("eXgs"); } catch (ServletException e) { assertTrue(e.getRootCause() instanceof IOException); assertTrue(LogUTUtil.checkError("", e.getRootCause())); } } /** * testSetResetter01() * <br><br> * * (??n) * <br> * _?FA * <br><br> * l?F(?) string:"string"<br> * (?) resetter:null<br> * * <br> * l?F(?) resetter:"string"<br> * * <br> * ?string?i[ * <br> * * @throws Exception ?\bh?O */ public void testSetResetter01() throws Exception { // ?? ResetterPlugIn rpi = new ResetterPlugIn(); // eXg?s rpi.setResetter("string"); // mF assertEquals("string", UTUtil.getPrivateField(rpi, "resetter")); } /** * testSetResources01() * <br><br> * * (??n) * <br> * _?FA * <br><br> * l?F(?) string:"string"<br> * (?) resourcesPath:null<br> * * <br> * l?F(?) resourcesPath:"string"<br> * * <br> * ?string?i[ * <br> * * @throws Exception ?\bh?O */ public void testSetResources01() throws Exception { // ?? ResetterPlugIn rpi = new ResetterPlugIn(); // eXg?s rpi.setResources("string"); // mF assertEquals("string", UTUtil.getPrivateField(rpi, "resourcesPath")); } /** * testSetDigesterRules01() * <br><br> * * (??n) * <br> * _?FA * <br><br> * l?F(?) digesterRules:"string"<br> * (?) digesterRules:null<br> * * <br> * l?F(?) digesterRules:"string"<br> * * <br> * ?digesterRules?i[ * <br> * * @throws Exception ?\bh?O */ public void testSetDigesterRules01() throws Exception { // ?? ResetterPlugIn rpi = new ResetterPlugIn(); // eXg?s rpi.setDigesterRules("string"); // mF assertEquals("string", UTUtil.getPrivateField(rpi, "digesterRules")); } /** * testSetPublicIdentifier01() * <br><br> * * (??n) * <br> * _?FA * <br><br> * l?F(?) publicIdentifier:"publicIdentifier"<br> * (?) publicIdentifier:not null?iftHgl?j<br> * * <br> * l?F(?) publicIdentifier:"publicIdentifier"<br> * * <br> * ?publicIdentifier?i[ * <br> * * @throws Exception ?\bh?O */ public void testSetPublicIdentifier01() throws Exception { // eXg{ plugin.setPublicIdentifier("publicIdentifier"); // assertEquals("publicIdentifier", UTUtil.getPrivateField(plugin, "publicIdentifier")); } /** * testSetDtdUrl01() * <br><br> * * (??n) * <br> * _?FA * <br><br> * l?F(?) dtdUrl:"dtdUrl"<br> * (?) dtdUrl:not null?iftHgl?j<br> * * <br> * l?F(?) dtdUrl:"dtdUrl"<br> * * <br> * ?dtdUrl?i[ * <br> * * @throws Exception ?\bh?O */ public void testSetDtdUrl01() throws Exception { // eXg{ plugin.setDtdUrl("dtdUrl"); // assertEquals("dtdUrl", UTUtil.getPrivateField(plugin, "dtdUrl")); } }