001: /*
002: * Copyright (C) 2006 Methodhead Software LLC. All rights reserved.
003: *
004: * This file is part of TransferCM.
005: *
006: * TransferCM is free software; you can redistribute it and/or modify it under the
007: * terms of the GNU General Public License as published by the Free Software
008: * Foundation; either version 2 of the License, or (at your option) any later
009: * version.
010: *
011: * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
012: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
013: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
014: * details.
015: *
016: * You should have received a copy of the GNU General Public License along with
017: * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
018: * Fifth Floor, Boston, MA 02110-1301 USA
019: */
020:
021: package com.methodhead.transfer;
022:
023: import java.util.*;
024: import java.sql.*;
025: import java.io.*;
026: import junit.framework.*;
027: import org.apache.log4j.*;
028: import com.methodhead.persistable.*;
029: import com.methodhead.test.*;
030: import com.methodhead.auth.*;
031: import com.methodhead.aikp.*;
032: import com.methodhead.sitecontext.*;
033: import com.methodhead.*;
034: import com.methodhead.transfer.*;
035: import servletunit.struts.*;
036: import org.apache.struts.action.*;
037: import org.apache.cactus.*;
038:
039: public class SiteContextFormTest extends CactusStrutsTestCase {
040:
041: DynaActionForm form = null;
042: List list = null;
043: Extension[] extensions = null;
044: SiteExtension siteExtension = null;
045:
046: static {
047: TestUtils.initLogger();
048: }
049:
050: public SiteContextFormTest(String name) {
051: super (name);
052: }
053:
054: public void setUp() throws Exception {
055: super .setUp();
056:
057: ConnectionSingleton.runBatchUpdate(new FileReader(
058: "webapp/WEB-INF/db/transfer-reset.sql"));
059: }
060:
061: public void tearDown() throws Exception {
062: super .tearDown();
063: }
064:
065: public void beginReset(WebRequest webRequest) {
066: }
067:
068: public void testReset() throws Exception {
069: TestData.createSiteExtensions();
070: AuthUtil.setUser(request, TestData.user1);
071:
072: setRequestPathInfo("/siteContext");
073: addRequestParameter("action", "edit");
074: addRequestParameter("id", "1");
075: actionPerform();
076:
077: verifyInputForward();
078:
079: //
080: // installedExtensions should be set
081: //
082: form = (DynaActionForm) getActionForm();
083:
084: extensions = (Extension[]) form.get("installedExtensions");
085: assertEquals(2, extensions.length);
086:
087: assertEquals("MockExtension", extensions[0].getName());
088: assertEquals("MockExtension2", extensions[1].getName());
089:
090: //
091: // extensions should be set
092: //
093: list = (List) form.get("extensions");
094: assertEquals(1, list.size());
095:
096: siteExtension = (SiteExtension) list.get(0);
097: assertEquals("com.methodhead.transfer.MockExtension",
098: siteExtension.getString("class_name"));
099: }
100: }
|