From: Olivier Lamy Date: Mon, 9 Apr 2012 20:25:36 +0000 (+0000) Subject: other repackaging to o.a.a.r X-Git-Tag: redback-2.0~172 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=36556ca46f20ea7a23b2d0d257109567c593ab7f;p=archiva.git other repackaging to o.a.a.r git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1311417 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/redback-configuration/src/test/java/org/apache/archiva/redback/configuration/UserConfigurationTest.java b/redback-configuration/src/test/java/org/apache/archiva/redback/configuration/UserConfigurationTest.java new file mode 100644 index 000000000..f79670d5b --- /dev/null +++ b/redback-configuration/src/test/java/org/apache/archiva/redback/configuration/UserConfigurationTest.java @@ -0,0 +1,109 @@ +package org.apache.archiva.redback.configuration; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.TestCase; +import org.apache.archiva.redback.configuration.UserConfiguration; +import org.codehaus.plexus.util.StringUtils; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; + +import javax.inject.Inject; +import javax.inject.Named; + +/** + * UserConfigurationTest + * + * @author Joakim Erdfelt + * @version $Id$ + */ +@RunWith( SpringJUnit4ClassRunner.class ) +@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } ) +public class UserConfigurationTest + extends TestCase +{ + + @Inject @Named(value = "test") + UserConfiguration config; + + private void assertEmpty( String str ) + { + if ( StringUtils.isNotEmpty( str ) ) + { + fail( "Expected String to be empty." ); + } + } + + @Test + public void testLoad() + throws Exception + { + assertNotNull( config ); + // check that the configuration loaded correctly - if this fails, maybe you aren't in the right basedir + assertNotNull( config.getString( "test.value" ) ); + } + + @Test + public void testGetString() + throws Exception + { + // Test default configuration entry + assertEquals( "25", config.getString( "email.smtp.port" ) ); + // Test overlaid configuration entry + assertEquals( "127.0.2.2", config.getString( "email.smtp.host" ) ); + // Test default value + assertEquals( "127.0.0.1", config.getString( "email.smtp.host.bad", "127.0.0.1" ) ); +/* Requires commons-configuration 1.4 + // Test expressions + assertEquals( "jdbc:derby:" + System.getProperty( "plexus.home" ) + "/database;create=true", + config.getString( "jdbc.url" ) ); + assertEquals( "foo/bar", config.getString( "test.expression" ) ); +*/ + + assertEmpty( config.getString( "email.smtp.foo.foo" ) ); + } + + @Test + public void testGetBoolean() + throws Exception + { + assertFalse( config.getBoolean( "email.smtp.ssl.enabled" ) ); + assertFalse( config.getBoolean( "email.smtp.tls.enabled" ) ); + } + + @Test + public void testGetInt() + throws Exception + { + assertEquals( 25, config.getInt( "email.smtp.port" ) ); + assertEquals( 8080, config.getInt( "email.smtp.port.bad", 8080 ) ); + } + + @Test + public void testConcatenatedList() + { + assertEquals( "uid=brett,dc=codehaus,dc=org", config.getConcatenatedList( "ldap.bind.dn", null ) ); + assertEquals( "dc=codehaus,dc=org", config.getConcatenatedList( "ldap.base.dn", null ) ); + assertEquals( "foo", config.getConcatenatedList( "short.list", null ) ); + assertEquals( "bar,baz", config.getConcatenatedList( "no.list", "bar,baz" ) ); + } +} diff --git a/redback-configuration/src/test/java/org/codehaus/plexus/redback/configuration/UserConfigurationTest.java b/redback-configuration/src/test/java/org/codehaus/plexus/redback/configuration/UserConfigurationTest.java deleted file mode 100644 index 02bbf7237..000000000 --- a/redback-configuration/src/test/java/org/codehaus/plexus/redback/configuration/UserConfigurationTest.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.codehaus.plexus.redback.configuration; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import junit.framework.TestCase; -import org.apache.archiva.redback.configuration.UserConfiguration; -import org.codehaus.plexus.util.StringUtils; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; - -import javax.inject.Inject; -import javax.inject.Named; - -/** - * UserConfigurationTest - * - * @author Joakim Erdfelt - * @version $Id$ - */ -@RunWith( SpringJUnit4ClassRunner.class ) -@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } ) -public class UserConfigurationTest - extends TestCase -{ - - @Inject @Named(value = "test") - UserConfiguration config; - - private void assertEmpty( String str ) - { - if ( StringUtils.isNotEmpty( str ) ) - { - fail( "Expected String to be empty." ); - } - } - - @Test - public void testLoad() - throws Exception - { - assertNotNull( config ); - // check that the configuration loaded correctly - if this fails, maybe you aren't in the right basedir - assertNotNull( config.getString( "test.value" ) ); - } - - @Test - public void testGetString() - throws Exception - { - // Test default configuration entry - assertEquals( "25", config.getString( "email.smtp.port" ) ); - // Test overlaid configuration entry - assertEquals( "127.0.2.2", config.getString( "email.smtp.host" ) ); - // Test default value - assertEquals( "127.0.0.1", config.getString( "email.smtp.host.bad", "127.0.0.1" ) ); -/* Requires commons-configuration 1.4 - // Test expressions - assertEquals( "jdbc:derby:" + System.getProperty( "plexus.home" ) + "/database;create=true", - config.getString( "jdbc.url" ) ); - assertEquals( "foo/bar", config.getString( "test.expression" ) ); -*/ - - assertEmpty( config.getString( "email.smtp.foo.foo" ) ); - } - - @Test - public void testGetBoolean() - throws Exception - { - assertFalse( config.getBoolean( "email.smtp.ssl.enabled" ) ); - assertFalse( config.getBoolean( "email.smtp.tls.enabled" ) ); - } - - @Test - public void testGetInt() - throws Exception - { - assertEquals( 25, config.getInt( "email.smtp.port" ) ); - assertEquals( 8080, config.getInt( "email.smtp.port.bad", 8080 ) ); - } - - @Test - public void testConcatenatedList() - { - assertEquals( "uid=brett,dc=codehaus,dc=org", config.getConcatenatedList( "ldap.bind.dn", null ) ); - assertEquals( "dc=codehaus,dc=org", config.getConcatenatedList( "ldap.base.dn", null ) ); - assertEquals( "foo", config.getConcatenatedList( "short.list", null ) ); - assertEquals( "bar,baz", config.getConcatenatedList( "no.list", "bar,baz" ) ); - } -}