Source Code Cross Referenced for ZipFilePluginLoaderTest.java in  » ERP-CRM-Financial » Kuali-Financial-System » edu » iu » uis » eden » plugin » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Kuali Financial System » edu.iu.uis.eden.plugin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2007 The Kuali Foundation.
003:         * 
004:         * 
005:         * Licensed under the Educational Community License, Version 1.0 (the "License");
006:         * you may not use this file except in compliance with the License.
007:         * You may obtain a copy of the License at
008:         * 
009:         * http://www.opensource.org/licenses/ecl1.php
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package edu.iu.uis.eden.plugin;
018:
019:        import java.io.File;
020:
021:        import javax.xml.namespace.QName;
022:
023:        import org.apache.commons.io.FileUtils;
024:        import org.junit.After;
025:        import org.junit.Before;
026:        import org.junit.Test;
027:        import org.kuali.rice.config.Config;
028:        import org.kuali.rice.config.SimpleConfig;
029:        import org.kuali.rice.core.Core;
030:        import org.kuali.rice.test.LoggableTestCase;
031:
032:        import edu.iu.uis.eden.test.TestUtilities;
033:        import edu.iu.uis.eden.util.ClassLoaderUtils;
034:
035:        /**
036:         * Tests the ZipFilePluginLoader.  The zip file which is checked in has the following format:
037:         *
038:         * <pre>
039:         * classes/
040:         * |---> test-classes.txt
041:         * |---> workflow2.xml
042:         * lib/
043:         * |---> test.jar
044:         * META-INF/
045:         * |---> workflow.xml
046:         * </pre>
047:         *
048:         * <p>The test.jar which is in the zip file has one resource in it which is named test-lib.txt.
049:         *
050:         * <p>The workflow.xml file has 2 params in it and includes the workflow2.xml file.
051:         *
052:         * @author Eric Westfall
053:         */
054:        public class ZipFilePluginLoaderTest extends LoggableTestCase {
055:
056:            private Plugin plugin;
057:            private File pluginDir;
058:
059:            @Before
060:            public void setUp() throws Exception {
061:                SimpleConfig config = new SimpleConfig();
062:                config.getProperties().put(Config.MESSAGE_ENTITY, "KEW");
063:                Core.init(config);
064:            }
065:
066:            @After
067:            public void tearDown() throws Exception {
068:                try {
069:                    plugin.stop();
070:                } catch (Exception e) {
071:                    e.printStackTrace();
072:                }
073:                try {
074:                    FileUtils.deleteDirectory(pluginDir);
075:                } catch (Exception e) {
076:                }
077:
078:            }
079:
080:            @Test
081:            public void testLoad() throws Exception {
082:                File pluginZipFile = new File(
083:                        "test/src/edu/iu/uis/eden/plugin/ziptest.zip");
084:                assertTrue(pluginZipFile.exists());
085:                assertTrue(pluginZipFile.isFile());
086:
087:                // create a temp directory to copy the zip file into
088:                pluginDir = TestUtilities.createTempDir();
089:
090:                // copy the zip file
091:                FileUtils.copyFileToDirectory(pluginZipFile, pluginDir);
092:                pluginZipFile = new File(pluginDir, pluginZipFile.getName());
093:                assertTrue(pluginZipFile.exists());
094:                pluginZipFile.deleteOnExit();
095:
096:                // create the ZipFilePluginLoader and load the plugin
097:                ZipFilePluginLoader loader = new ZipFilePluginLoader(
098:                        pluginZipFile, null, ClassLoaderUtils
099:                                .getDefaultClassLoader(), Core.getRootConfig(),
100:                        false);
101:                this .plugin = loader.load();
102:                assertNotNull("Plugin should have been successfully loaded.",
103:                        plugin);
104:                // check the plugin name, it's QName should be '{KEW}ziptest', it's plugin name should be 'ziptest'
105:                assertEquals("Plugin QName should be '{KEW}ziptest'",
106:                        new QName("KEW", "ziptest"), plugin.getName());
107:
108:                // start the plugin
109:                this .plugin.start();
110:
111:                // verify that the plugin was extracted, should be in a directory named the same as the local part of the QName
112:                File extractedDirectory = new File(pluginDir, plugin.getName()
113:                        .getLocalPart());
114:                assertTrue("Plugin should have been extracted.",
115:                        extractedDirectory.exists());
116:                assertTrue(extractedDirectory.isDirectory());
117:                File[] files = extractedDirectory.listFiles();
118:                assertEquals("Should be 3 files", 3, files.length);
119:
120:                // try loading some classes and checking that things got loaded properly
121:                assertNotNull("Resource should exist.", plugin.getClassLoader()
122:                        .getResource("lib-test.txt"));
123:                assertNotNull("Resource should exist.", plugin.getClassLoader()
124:                        .getResource("classes-test.txt"));
125:
126:                // check the config values
127:                assertEquals(plugin.getConfig().getProperty("test.param.1"),
128:                        "test.value.1");
129:                assertEquals(plugin.getConfig().getProperty("test.param.2"),
130:                        "test.value.2");
131:                assertEquals(plugin.getConfig().getProperty("test.param.3"),
132:                        "test.value.3");
133:
134:                // verify the modification checks on the plugin which drive hot deployment
135:                assertFalse("Plugin should not be modifed at this point.",
136:                        loader.isModified());
137:                // record the last modified date of the extracted directory
138:                long lastModified = pluginDir.lastModified();
139:
140:                // sleep for a milliseconds before touching the file, this will help our last modified check so we don't
141:                // get the same value
142:                Thread.sleep(1000);
143:
144:                // touch the zip file
145:                FileUtils.touch(pluginZipFile);
146:                assertTrue(
147:                        "Plugin should be modifed after zip file is touched.",
148:                        loader.isModified());
149:                plugin.stop();
150:
151:                // reload the plugin
152:                this .plugin = loader.load();
153:                this .plugin.start();
154:                assertFalse(
155:                        "After reload, plugin should no longer be modifed.",
156:                        loader.isModified());
157:
158:                // check the last modified date of the extracted directory
159:                assertTrue(
160:                        "The extracted directory should have been modified.",
161:                        pluginDir.lastModified() > lastModified);
162:
163:            }
164:
165:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.