KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > methodhead > transfer > SiteContextFormTest


1 /*
2  * Copyright (C) 2006 Methodhead Software LLC. All rights reserved.
3  *
4  * This file is part of TransferCM.
5  *
6  * TransferCM is free software; you can redistribute it and/or modify it under the
7  * terms of the GNU General Public License as published by the Free Software
8  * Foundation; either version 2 of the License, or (at your option) any later
9  * version.
10  *
11  * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
18  * Fifth Floor, Boston, MA 02110-1301 USA
19  */

20
21 package com.methodhead.transfer;
22
23 import java.util.*;
24 import java.sql.*;
25 import java.io.*;
26 import junit.framework.*;
27 import org.apache.log4j.*;
28 import com.methodhead.persistable.*;
29 import com.methodhead.test.*;
30 import com.methodhead.auth.*;
31 import com.methodhead.aikp.*;
32 import com.methodhead.sitecontext.*;
33 import com.methodhead.*;
34 import com.methodhead.transfer.*;
35 import servletunit.struts.*;
36 import org.apache.struts.action.*;
37 import org.apache.cactus.*;
38
39 public class SiteContextFormTest extends CactusStrutsTestCase {
40
41   DynaActionForm form = null;
42   List list = null;
43   Extension[] extensions = null;
44   SiteExtension siteExtension = null;
45
46   static {
47     TestUtils.initLogger();
48   }
49
50   public SiteContextFormTest( String JavaDoc name ) {
51     super( name );
52   }
53
54   public void setUp() throws Exception JavaDoc {
55     super.setUp();
56
57     ConnectionSingleton.runBatchUpdate( new FileReader( "webapp/WEB-INF/db/transfer-reset.sql" ) );
58   }
59
60   public void tearDown() throws Exception JavaDoc {
61     super.tearDown();
62   }
63
64   public void beginReset( WebRequest webRequest ) {
65   }
66
67   public void testReset() throws Exception JavaDoc {
68     TestData.createSiteExtensions();
69     AuthUtil.setUser( request, TestData.user1 );
70
71     setRequestPathInfo( "/siteContext" );
72     addRequestParameter( "action", "edit" );
73     addRequestParameter( "id", "1" );
74     actionPerform();
75
76     verifyInputForward();
77
78     //
79
// installedExtensions should be set
80
//
81
form = ( DynaActionForm )getActionForm();
82
83     extensions = ( Extension[] )form.get( "installedExtensions" );
84     assertEquals( 2, extensions.length );
85
86     assertEquals( "MockExtension", extensions[ 0 ].getName() );
87     assertEquals( "MockExtension2", extensions[ 1 ].getName() );
88
89     //
90
// extensions should be set
91
//
92
list = ( List )form.get( "extensions" );
93     assertEquals( 1, list.size() );
94
95     siteExtension = ( SiteExtension )list.get( 0 );
96     assertEquals( "com.methodhead.transfer.MockExtension", siteExtension.getString( "class_name" ) );
97   }
98 }
99
Popular Tags