You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by ep...@apache.org on 2004/02/16 08:10:10 UTC
cvs commit: jakarta-turbine-2/src/test/org/apache/turbine/services LoadingComponentsTest.java
epugh 2004/02/15 23:10:10
Modified: src/test/org/apache/turbine TorqueLoadTest.java
Added: src/test/org/apache/turbine/services/crypto
CryptoRunningInMerlinTest.java
CryptoRunningInECMTest.java
src/test/org/apache/turbine/services
LoadingComponentsTest.java
Removed: src/test/org/apache/turbine/services/crypto
CryptoDefaultTest.java
Log:
Update tests for components running in containers
Revision Changes Path
1.1 jakarta-turbine-2/src/test/org/apache/turbine/services/crypto/CryptoRunningInMerlinTest.java
Index: CryptoRunningInMerlinTest.java
===================================================================
package org.apache.turbine.services.crypto;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* AintakeToolernately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.fulcrum.crypto.CryptoAlgorithm;
import org.apache.fulcrum.crypto.CryptoService;
import org.apache.turbine.services.TurbineServices;
import org.apache.turbine.services.avaloncomponent.MerlinComponentService;
import org.apache.turbine.test.BaseTestCase;
import org.apache.turbine.util.TurbineConfig;
/**
* Verifies the Fulcrum Crypto Service works properly in Turbine.
* <br>
*
* @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
* @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
* @version $Id: CryptoRunningInMerlinTest.java,v 1.1 2004/02/16 07:10:10 epugh Exp $
*/
public class CryptoRunningInMerlinTest extends BaseTestCase
{
private static final String preDefinedInput = "Oeltanks";
private static TurbineConfig tc = null;
private CryptoService cryptoService;
public CryptoRunningInMerlinTest(String name) throws Exception
{
super(name);
}
public static Test suite()
{
return new TestSuite(CryptoRunningInMerlinTest.class);
}
public void testMd5()
{
String preDefinedResult = "XSop0mncK19Ii2r2CUe29w==";
try
{
CryptoAlgorithm ca =cryptoService.getCryptoAlgorithm("default");
ca.setCipher("MD5");
String output = ca.encrypt(preDefinedInput);
assertEquals("MD5 Encryption failed ", preDefinedResult, output);
}
catch (Exception e)
{
e.printStackTrace();
fail();
}
}
public void testSha1()
{
String preDefinedResult = "uVDiJHaavRYX8oWt5ctkaa7j1cw=";
try
{
CryptoAlgorithm ca = cryptoService.getCryptoAlgorithm("default");
ca.setCipher("SHA1");
String output = ca.encrypt(preDefinedInput);
assertEquals("SHA1 Encryption failed ", preDefinedResult, output);
}
catch (Exception e)
{
e.printStackTrace();
fail();
}
}
public void setUp() throws Exception
{
tc =
new TurbineConfig(
".",
"/conf/test/TestFulcrumComponents.properties");
tc.initialize();
MerlinComponentService acs =
(MerlinComponentService) TurbineServices.getInstance().getService(
MerlinComponentService.SERVICE_NAME);
cryptoService = (CryptoService) acs.lookup("/fulcrum/crypto");
}
public void tearDown() throws Exception
{
if (tc != null)
{
tc.dispose();
}
}
}
1.1 jakarta-turbine-2/src/test/org/apache/turbine/services/crypto/CryptoRunningInECMTest.java
Index: CryptoRunningInECMTest.java
===================================================================
package org.apache.turbine.services.crypto;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* AintakeToolernately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.fulcrum.crypto.CryptoAlgorithm;
import org.apache.fulcrum.crypto.CryptoService;
import org.apache.turbine.services.TurbineServices;
import org.apache.turbine.services.avaloncomponent.AvalonComponentService;
import org.apache.turbine.test.BaseTestCase;
import org.apache.turbine.util.TurbineConfig;
/**
* Verifies the Fulcrum Crypto Service works properly in Turbine.
* <br>
*
* @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
* @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
* @version $Id: CryptoRunningInECMTest.java,v 1.1 2004/02/16 07:10:10 epugh Exp $
*/
public class CryptoRunningInECMTest extends BaseTestCase
{
private static final String preDefinedInput = "Oeltanks";
private static TurbineConfig tc = null;
private CryptoService cryptoService;
public CryptoRunningInECMTest(String name) throws Exception
{
super(name);
}
public static Test suite()
{
return new TestSuite(CryptoRunningInECMTest.class);
}
public void testMd5()
{
String preDefinedResult = "XSop0mncK19Ii2r2CUe29w==";
try
{
CryptoAlgorithm ca =cryptoService.getCryptoAlgorithm("default");
ca.setCipher("MD5");
String output = ca.encrypt(preDefinedInput);
assertEquals("MD5 Encryption failed ", preDefinedResult, output);
}
catch (Exception e)
{
e.printStackTrace();
fail();
}
}
public void testSha1()
{
String preDefinedResult = "uVDiJHaavRYX8oWt5ctkaa7j1cw=";
try
{
CryptoAlgorithm ca = cryptoService.getCryptoAlgorithm("default");
ca.setCipher("SHA1");
String output = ca.encrypt(preDefinedInput);
assertEquals("SHA1 Encryption failed ", preDefinedResult, output);
}
catch (Exception e)
{
e.printStackTrace();
fail();
}
}
public void setUp() throws Exception
{
tc =
new TurbineConfig(
".",
"/conf/test/TestFulcrumComponents.properties");
tc.initialize();
AvalonComponentService acs =
(AvalonComponentService) TurbineServices.getInstance().getService(
AvalonComponentService.SERVICE_NAME);
cryptoService = (CryptoService) acs.lookup(CryptoService.ROLE);
}
public void tearDown() throws Exception
{
if (tc != null)
{
tc.dispose();
}
}
}
1.4 +13 -23 jakarta-turbine-2/src/test/org/apache/turbine/TorqueLoadTest.java
Index: TorqueLoadTest.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/test/org/apache/turbine/TorqueLoadTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TorqueLoadTest.java 14 Oct 2003 11:50:04 -0000 1.3
+++ TorqueLoadTest.java 16 Feb 2004 07:10:10 -0000 1.4
@@ -100,9 +100,7 @@
Torque.init("conf/test/TorqueTest.properties");
assertTrue("Torque must be initialized!", Torque.isInit());
Torque.shutdown();
- // Uncomment once we get a torque 3.1 release post alpha-2
- // Everything up to alpha-2 does not shut down Torque properly.
- // assertFalse("Torque did not shut down properly!", Torque.isInit());
+ assertFalse("Torque did not shut down properly!", Torque.isInit());
}
/**
@@ -152,28 +150,20 @@
TurbineConfig tc =
new TurbineConfig(
".",
- "/conf/test/TurbineAvalonService.properties");
+ "/conf/test/TestFulcrumComponents.properties");
- try
- {
- tc.initialize();
- assertTrue("Torque must be initialized!", Torque.isInit());
+ tc.initialize();
+ assertTrue("Torque must be initialized!", Torque.isInit());
- TorqueComponent toc =
- (TorqueComponent) getService().lookup(
- "org.apache.torque.avalon.Torque");
- assertTrue("TorqueComponent must be initialized!", toc.isInit());
+ TorqueComponent toc =
+ (TorqueComponent) getService().lookup(
+ "org.apache.torque.avalon.Torque");
+ assertTrue("TorqueComponent must be initialized!", toc.isInit());
+
+ getService().release(toc);
+
+ tc.dispose();
- getService().release(toc);
- }
- catch (Exception e)
- {
- throw e;
- }
- finally
- {
- tc.dispose();
- }
assertFalse("Torque did not shut down properly!", Torque.isInit());
}
}
1.1 jakarta-turbine-2/src/test/org/apache/turbine/services/LoadingComponentsTest.java
Index: LoadingComponentsTest.java
===================================================================
package org.apache.turbine.services;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Turbine" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Turbine", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import java.util.Vector;
import javax.servlet.ServletConfig;
import javax.servlet.http.HttpServletResponse;
import org.apache.fulcrum.cache.DefaultGlobalCacheService;
import org.apache.fulcrum.crypto.CryptoService;
import org.apache.fulcrum.factory.FactoryService;
import org.apache.fulcrum.intake.IntakeService;
import org.apache.fulcrum.localization.LocalizationService;
import org.apache.fulcrum.mimetype.MimeTypeService;
import org.apache.turbine.om.security.User;
import org.apache.turbine.services.TurbineServices;
import org.apache.turbine.services.avaloncomponent.AvalonComponentService;
import org.apache.turbine.services.rundata.RunDataService;
import org.apache.turbine.test.BaseTestCase;
import org.apache.turbine.test.EnhancedMockHttpServletRequest;
import org.apache.turbine.util.RunData;
import org.apache.turbine.util.TurbineConfig;
import com.mockobjects.servlet.MockHttpServletResponse;
import com.mockobjects.servlet.MockHttpSession;
import com.mockobjects.servlet.MockServletConfig;
/**
* Unit test for verifing that we can load all the appropriate components from the
* appropriate Container. For now that is just ECM (AvalonComponentService)
* but in the future with mixed containers there could be multiple.
*
* @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
* @version $Id: LoadingComponentsTest.java,v 1.1 2004/02/16 07:10:10 epugh Exp $
*/
public class LoadingComponentsTest extends BaseTestCase
{
private static TurbineConfig tc = null;
public LoadingComponentsTest(String name) throws Exception
{
super(name);
}
public void testLoading() throws Exception
{
AvalonComponentService ecm =
(AvalonComponentService) TurbineServices.getInstance().getService(
AvalonComponentService.SERVICE_NAME);
DefaultGlobalCacheService dgcs = (DefaultGlobalCacheService)ecm.lookup(DefaultGlobalCacheService.ROLE);
assertNotNull(dgcs);
CryptoService cs = (CryptoService)ecm.lookup(CryptoService.ROLE);
assertNotNull(cs);
LocalizationService ls = (LocalizationService)ecm.lookup(LocalizationService.ROLE);
assertNotNull(ls);
IntakeService intake = (IntakeService)ecm.lookup(IntakeService.ROLE);
assertNotNull(intake);
FactoryService fs = (FactoryService)ecm.lookup(FactoryService.ROLE);
assertNotNull(fs);
MimeTypeService mimetype = (MimeTypeService)ecm.lookup(MimeTypeService.ROLE);
assertNotNull(mimetype);
}
public void setUp() throws Exception
{
tc = new TurbineConfig(".", "/conf/test/TestFulcrumComponents.properties");
tc.initialize();
}
public void tearDown() throws Exception
{
if (tc != null)
{
tc.dispose();
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org