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 2003/10/24 15:01:19 UTC
cvs commit: jakarta-turbine-2/conf/test fulcrumRoleConfiguration.xml fulcrumComponentConfiguration.xml
epugh 2003/10/24 06:01:19
Modified: src/test/org/apache/turbine/services/crypto
CryptoDefaultTest.java
conf/test fulcrumRoleConfiguration.xml
fulcrumComponentConfiguration.xml
Removed: src/test/org/apache/turbine/services/crypto CryptoTest.java
Log:
Cleanup Unit test for CryptoService.
Revision Changes Path
1.4 +72 -91 jakarta-turbine-2/src/test/org/apache/turbine/services/crypto/CryptoDefaultTest.java
Index: CryptoDefaultTest.java
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/src/test/org/apache/turbine/services/crypto/CryptoDefaultTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CryptoDefaultTest.java 7 Jun 2003 11:46:11 -0000 1.3
+++ CryptoDefaultTest.java 24 Oct 2003 13:01:19 -0000 1.4
@@ -1,57 +1,46 @@
package org.apache.turbine.services.crypto;
-/* ====================================================================
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
- * reserved.
- *
+/*
+ * ==================================================================== 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.
+ * 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/>.
+ *
+ * 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;
@@ -59,51 +48,28 @@
import org.apache.commons.configuration.BaseConfiguration;
import org.apache.commons.configuration.Configuration;
+import org.apache.fulcrum.crypto.CryptoAlgorithm;
+import org.apache.fulcrum.crypto.CryptoService;
import org.apache.turbine.services.ServiceManager;
import org.apache.turbine.services.TurbineServices;
+import org.apache.turbine.services.avaloncomponent.AvalonComponentService;
import org.apache.turbine.services.factory.FactoryService;
import org.apache.turbine.services.factory.TurbineFactoryService;
import org.apache.turbine.test.BaseTestCase;
+import org.apache.turbine.util.TurbineConfig;
-public class CryptoDefaultTest
- extends BaseTestCase
+public class CryptoDefaultTest extends BaseTestCase
{
- private static final String PREFIX = "services." +
- CryptoService.SERVICE_NAME + '.';
-
private static final String preDefinedInput = "Oeltanks";
+ private static TurbineConfig tc = null;
+ private CryptoService cryptoService;
- public CryptoDefaultTest(String name)
- throws Exception
+ public CryptoDefaultTest(String name) throws Exception
{
super(name);
- ServiceManager serviceManager = TurbineServices.getInstance();
- serviceManager.setApplicationRoot(".");
-
- Configuration cfg = new BaseConfiguration();
- cfg.setProperty(PREFIX + "classname",
- TurbineCryptoService.class.getName());
-
- /* No providers configured. Should be "java" then */
-
- /* Ugh */
-
- cfg.setProperty("services." + FactoryService.SERVICE_NAME + ".classname",
- TurbineFactoryService.class.getName());
-
- serviceManager.setConfiguration(cfg);
-
- try
- {
- serviceManager.init();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- fail();
- }
+
}
public static Test suite()
@@ -117,15 +83,13 @@
try
{
- CryptoAlgorithm ca = TurbineCrypto.getCryptoAlgorithm("default");
+ CryptoAlgorithm ca =cryptoService.getCryptoAlgorithm("default");
ca.setCipher("MD5");
String output = ca.encrypt(preDefinedInput);
- assertEquals("MD5 Encryption failed ",
- preDefinedResult,
- output);
+ assertEquals("MD5 Encryption failed ", preDefinedResult, output);
}
catch (Exception e)
@@ -137,25 +101,42 @@
public void testSha1()
{
- String preDefinedResult = "uVDiJHaavRYX8oWt5ctkaa7j1cw=";
+ String preDefinedResult = "uVDiJHaavRYX8oWt5ctkaa7j1cw=";
try
{
- CryptoAlgorithm ca = TurbineCrypto.getCryptoAlgorithm("default");
+ CryptoAlgorithm ca = cryptoService.getCryptoAlgorithm("default");
ca.setCipher("SHA1");
String output = ca.encrypt(preDefinedInput);
- assertEquals("SHA1 Encryption failed ",
- preDefinedResult,
- output);
+ 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.2 +5 -0 jakarta-turbine-2/conf/test/fulcrumRoleConfiguration.xml
Index: fulcrumRoleConfiguration.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/conf/test/fulcrumRoleConfiguration.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- fulcrumRoleConfiguration.xml 24 Oct 2003 12:50:58 -0000 1.1
+++ fulcrumRoleConfiguration.xml 24 Oct 2003 13:01:19 -0000 1.2
@@ -13,5 +13,10 @@
name="org.apache.fulcrum.mimetype.MimeTypeService"
shorthand="mimetype"
default-class="org.apache.fulcrum.mimetype.DefaultMimeTypeService"/>
+
+ <role
+ name="org.apache.fulcrum.crypto.CryptoService"
+ shorthand="crypto"
+ default-class="org.apache.fulcrum.crypto.DefaultCryptoService"/>
</role-list>
1.2 +9 -0 jakarta-turbine-2/conf/test/fulcrumComponentConfiguration.xml
Index: fulcrumComponentConfiguration.xml
===================================================================
RCS file: /home/cvs/jakarta-turbine-2/conf/test/fulcrumComponentConfiguration.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- fulcrumComponentConfiguration.xml 24 Oct 2003 12:50:58 -0000 1.1
+++ fulcrumComponentConfiguration.xml 24 Oct 2003 13:01:19 -0000 1.2
@@ -6,4 +6,13 @@
<componentConfig>
<cache cacheInitialSize="20" cacheCheckFrequency="5"/>
<mimetype/>
+ <crypto>
+ <algorithm>
+ <unix>org.apache.fulcrum.crypto.provider.UnixCrypt</unix>
+ <clear>org.apache.fulcrum.crypto.provider.ClearCrypt</clear>
+ <java>org.apache.fulcrum.crypto.provider.JavaCrypt</java>
+ <oldjava>org.apache.fulcrum.crypto.provider.OldJavaCrypt</oldjava>
+
+ </algorithm>
+ </crypto>
</componentConfig>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org