You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by sg...@apache.org on 2015/08/06 22:35:41 UTC
svn commit: r1694570 - in /turbine/fulcrum/trunk/testcontainer: ./
src/java/org/apache/fulcrum/testcontainer/
src/test/org/apache/fulcrum/testcontainer/
Author: sgoeschl
Date: Thu Aug 6 20:35:41 2015
New Revision: 1694570
URL: http://svn.apache.org/r1694570
Log:
Clean up the source code and javadocs.
Modified:
turbine/fulcrum/trunk/testcontainer/pom.xml
turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnit4Test.java
turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnitTest.java
turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/Container.java
turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/YAAFIContainer.java
turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/EcmContainerTest.java
turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/SimpleComponent.java
turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/SimpleComponentImpl.java
turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/YaafiContainerTest.java
Modified: turbine/fulcrum/trunk/testcontainer/pom.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/testcontainer/pom.xml?rev=1694570&r1=1694569&r2=1694570&view=diff
==============================================================================
--- turbine/fulcrum/trunk/testcontainer/pom.xml (original)
+++ turbine/fulcrum/trunk/testcontainer/pom.xml Thu Aug 6 20:35:41 2015
@@ -81,7 +81,7 @@
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
- <version>1.2.15</version>
+ <version>1.2.16</version>
<type>jar</type>
<optional>true</optional>
<exclusions>
Modified: turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnit4Test.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnit4Test.java?rev=1694570&r1=1694569&r2=1694570&view=diff
==============================================================================
--- turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnit4Test.java (original)
+++ turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnit4Test.java Thu Aug 6 20:35:41 2015
@@ -45,7 +45,7 @@ public class BaseUnit4Test
/** Key used in the context for defining the application root */
public static String COMPONENT_APP_ROOT = Container.COMPONENT_APP_ROOT;
- /** Pick the default container to be Yaafi **/
+ /** Pick the default container to be YAAFI **/
public static String containerType = CONTAINER_YAAFI;
/** Use INFO for ConsoleLogger */
@@ -53,20 +53,22 @@ public class BaseUnit4Test
/** Container for the components */
private Container container;
+
/** Setup our default configurationFileName */
private String configurationFileName = "src/test/TestComponentConfig.xml";
+
/** Setup our default roleFileName */
private String roleFileName = "src/test/TestRoleConfig.xml";
+
/** Setup our default parameterFileName */
private String parameterFileName = null;
+
/** Set the log level (only works for YAAFI container) */
private int logLevel = defaultLogLevel;
/**
* Gets the configuration file name for the container should use for this test. By default it
* is src/test/TestComponentConfig.
- *
- * @param configurationFileName
*/
protected void setConfigurationFileName(String configurationFileName)
{
@@ -76,8 +78,6 @@ public class BaseUnit4Test
/**
* Override the role file name for the container should use for this test. By default it is
* src/test/TestRoleConfig.
- *
- * @param roleFileName
*/
protected void setRoleFileName(String roleFileName)
{
@@ -93,8 +93,6 @@ public class BaseUnit4Test
/**
* Constructor for test.
- *
- * @param testName name of the test being executed
*/
public BaseUnit4Test()
{
@@ -112,6 +110,7 @@ public class BaseUnit4Test
}
container = null;
}
+
/**
* Gets the configuration file name for the container should use for this test.
*
@@ -121,6 +120,7 @@ public class BaseUnit4Test
{
return configurationFileName;
}
+
/**
* Gets the role file name for the container should use for this test.
*
@@ -130,6 +130,7 @@ public class BaseUnit4Test
{
return roleFileName;
}
+
/**
* Gets the parameter file name for the container should use for this test.
*
@@ -139,6 +140,7 @@ public class BaseUnit4Test
{
return parameterFileName;
}
+
/**
* Returns an instance of the named component. Starts the container if it hasn't been started.
*
@@ -161,9 +163,9 @@ public class BaseUnit4Test
}
/**
- * Releases the component
+ * Releases the component.
*
- * @param component
+ * @param component component to be released
*/
protected void release(Object component)
{
Modified: turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnitTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnitTest.java?rev=1694570&r1=1694569&r2=1694570&view=diff
==============================================================================
--- turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnitTest.java (original)
+++ turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/BaseUnitTest.java Thu Aug 6 20:35:41 2015
@@ -63,8 +63,6 @@ public class BaseUnitTest extends TestCa
/**
* Gets the configuration file name for the container should use for this test. By default it
* is src/test/TestComponentConfig.
- *
- * @param configurationFileName
*/
protected void setConfigurationFileName(String configurationFileName)
{
@@ -74,8 +72,6 @@ public class BaseUnitTest extends TestCa
/**
* Override the role file name for the container should use for this test. By default it is
* src/test/TestRoleConfig.
- *
- * @param roleFileName
*/
protected void setRoleFileName(String roleFileName)
{
@@ -110,6 +106,7 @@ public class BaseUnitTest extends TestCa
}
container = null;
}
+
/**
* Gets the configuration file name for the container should use for this test.
*
@@ -119,6 +116,7 @@ public class BaseUnitTest extends TestCa
{
return configurationFileName;
}
+
/**
* Gets the role file name for the container should use for this test.
*
@@ -128,6 +126,7 @@ public class BaseUnitTest extends TestCa
{
return roleFileName;
}
+
/**
* Gets the parameter file name for the container should use for this test.
*
@@ -137,6 +136,7 @@ public class BaseUnitTest extends TestCa
{
return parameterFileName;
}
+
/**
* Returns an instance of the named component. Starts the container if it hasn't been started.
*
@@ -160,19 +160,17 @@ public class BaseUnitTest extends TestCa
/**
* Helper method for converting to and from Merlin Unit TestCase.
- * @param roleName
- * @return
- * @throws ComponentException
*/
protected Object resolve(String roleName) throws ComponentException
{
return lookup(roleName);
}
+
/**
- * Releases the component
- *
- * @param component
- */
+ * Releases the component.
+ *
+ * @param component component to be released
+ */
protected void release(Object component)
{
if (container != null)
Modified: turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/Container.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/Container.java?rev=1694570&r1=1694569&r2=1694570&view=diff
==============================================================================
--- turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/Container.java (original)
+++ turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/Container.java Thu Aug 6 20:35:41 2015
@@ -31,19 +31,17 @@ import org.apache.avalon.framework.compo
public interface Container extends Initializable, Disposable
{
/** Key used in the context for defining the application root */
- public static String COMPONENT_APP_ROOT = "componentAppRoot";
+ String COMPONENT_APP_ROOT = "componentAppRoot";
/** Alternate Merlin Friendly Key used in the context for defining the application root */
- public static String URN_AVALON_HOME = "urn:avalon:home";
+ String URN_AVALON_HOME = "urn:avalon:home";
/** Alternate Merlin Friendly Key used in the context for defining the application root */
- public static String URN_AVALON_TEMP = "urn:avalon:temp";
+ String URN_AVALON_TEMP = "urn:avalon:temp";
- public void startup(String configFileName, String roleFileName, String parametersFileName);
-
- public Object lookup(String roleName) throws ComponentException;
-
- public void release(Object component);
+ void startup(String configFileName, String roleFileName, String parametersFileName);
+ Object lookup(String roleName) throws ComponentException;
+ void release(Object component);
}
Modified: turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/YAAFIContainer.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/YAAFIContainer.java?rev=1694570&r1=1694569&r2=1694570&view=diff
==============================================================================
--- turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/YAAFIContainer.java (original)
+++ turbine/fulcrum/trunk/testcontainer/src/java/org/apache/fulcrum/testcontainer/YAAFIContainer.java Thu Aug 6 20:35:41 2015
@@ -19,6 +19,8 @@ package org.apache.fulcrum.testcontainer
* under the License.
*/
+import java.io.File;
+
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
@@ -27,8 +29,6 @@ import org.apache.fulcrum.yaafi.framewor
import org.apache.fulcrum.yaafi.framework.factory.ServiceContainerConfiguration;
import org.apache.fulcrum.yaafi.framework.factory.ServiceContainerFactory;
-import java.io.File;
-
/**
* This is a simple YAAFI based container that can be used in unit test
* of the fulcrum components.
@@ -47,7 +47,7 @@ public class YAAFIContainer extends Abst
private int logLevel = ConsoleLogger.LEVEL_DEBUG;
/**
- * Constructor
+ * Constructor.
*/
public YAAFIContainer()
{
@@ -56,7 +56,9 @@ public class YAAFIContainer extends Abst
}
/**
- * Constructor
+ * Constructor.
+ *
+ * @param logLevel the log level to be used
*/
public YAAFIContainer(int logLevel)
{
@@ -94,7 +96,7 @@ public class YAAFIContainer extends Abst
try
{
initialize();
- getLogger().info("YaffiContainer ready.");
+ getLogger().info("YAFFI Container ready.");
}
catch (Exception e)
{
@@ -108,7 +110,7 @@ public class YAAFIContainer extends Abst
// -------------------------------------------------------------
/**
- * Initializes the container
+ * Initializes the container.
*
* @throws Exception generic exception
*/
@@ -120,7 +122,7 @@ public class YAAFIContainer extends Abst
}
/**
- * Disposes of the container and releases resources
+ * Disposes of the container and releases resources.
*/
public void dispose()
{
@@ -129,11 +131,11 @@ public class YAAFIContainer extends Abst
{
this.manager.dispose();
}
- getLogger().info("YaffiContainer has been disposed.");
+ getLogger().info("YAFFI Container has been disposed.");
}
/**
- * Returns an instance of the named component
+ * Returns an instance of the named component.
*
* @param roleName Name of the role the component fills.
* @throws ComponentException generic exception
@@ -163,9 +165,9 @@ public class YAAFIContainer extends Abst
}
/**
- * Releases the component
+ * Releases the component.
*
- * @param component
+ * @param component component to be released
*/
public void release(Object component)
{
Modified: turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/EcmContainerTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/EcmContainerTest.java?rev=1694570&r1=1694569&r2=1694570&view=diff
==============================================================================
--- turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/EcmContainerTest.java (original)
+++ turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/EcmContainerTest.java Thu Aug 6 20:35:41 2015
@@ -17,13 +17,16 @@ package org.apache.fulcrum.testcontainer
* specific language governing permissions and limitations
* under the License.
*/
-import static org.junit.Assert.*;
-
import java.io.File;
import org.apache.avalon.framework.component.ComponentException;
import org.junit.Before;
import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* Basic testing of the Container
*
@@ -34,8 +37,6 @@ public class EcmContainerTest extends Ba
{
/**
* Constructor for test.
- *
- * @param testName name of the test being executed
*/
public EcmContainerTest()
{
@@ -69,6 +70,7 @@ public class EcmContainerTest extends Ba
assertEquals(sc.getAppRoot(),sc.getAppRoot2());
this.release(sc);
}
+
@Test
public void testAlternativeRoles()
{
@@ -117,13 +119,11 @@ public class EcmContainerTest extends Ba
@Test
public void testLoadingNonExistentFile()
{
- SimpleComponent sc = null;
-
this.setRoleFileName(null);
this.setConfigurationFileName("BogusFile.xml");
try
{
- sc = (SimpleComponent) this.lookup(SimpleComponent.ROLE);
+ this.lookup(SimpleComponent.ROLE);
}
catch(RuntimeException re){
//good
Modified: turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/SimpleComponent.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/SimpleComponent.java?rev=1694570&r1=1694569&r2=1694570&view=diff
==============================================================================
--- turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/SimpleComponent.java (original)
+++ turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/SimpleComponent.java Thu Aug 6 20:35:41 2015
@@ -29,13 +29,9 @@ import org.apache.avalon.framework.compo
*/
public interface SimpleComponent extends Component
{
-
- static final String ROLE = SimpleComponent.class.getName();
-
+ String ROLE = SimpleComponent.class.getName();
void test();
-
- public String getAppRoot();
-
- public String getAppRoot2();
+ String getAppRoot();
+ String getAppRoot2();
}
Modified: turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/SimpleComponentImpl.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/SimpleComponentImpl.java?rev=1694570&r1=1694569&r2=1694570&view=diff
==============================================================================
--- turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/SimpleComponentImpl.java (original)
+++ turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/SimpleComponentImpl.java Thu Aug 6 20:35:41 2015
@@ -21,12 +21,12 @@ package org.apache.fulcrum.testcontainer
import java.io.File;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
/**
* Interface of the component
@@ -62,12 +62,13 @@ public class SimpleComponentImpl
{
appRoot = (String) context.get("componentAppRoot");
if (context.get("urn:avalon:home") instanceof File){
- appRoot2 = ((File)(context.get("urn:avalon:home"))).toString();
+ appRoot2 = (context.get("urn:avalon:home")).toString();
}
else {
appRoot2 = (String)context.get("urn:avalon:home");
}
}
+
/**
* @return Returns the appRoot.
*/
Modified: turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/YaafiContainerTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/YaafiContainerTest.java?rev=1694570&r1=1694569&r2=1694570&view=diff
==============================================================================
--- turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/YaafiContainerTest.java (original)
+++ turbine/fulcrum/trunk/testcontainer/src/test/org/apache/fulcrum/testcontainer/YaafiContainerTest.java Thu Aug 6 20:35:41 2015
@@ -17,13 +17,16 @@ package org.apache.fulcrum.testcontainer
* specific language governing permissions and limitations
* under the License.
*/
-import static org.junit.Assert.*;
+import java.io.File;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.junit.Test;
-import java.io.File;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
* Basic testing of the Container
*
@@ -34,8 +37,6 @@ public class YaafiContainerTest extends
{
/**
* Constructor for test.
- *
- * @param testName name of the test being executed
*/
public YaafiContainerTest()
{
@@ -54,7 +55,6 @@ public class YaafiContainerTest extends
try
{
sc = (SimpleComponent) this.lookup(SimpleComponent.class.getName());
- //sc = (SimpleComponent) this.lookup("SimpleComponent");
}
catch (ComponentException e)
{
@@ -66,6 +66,7 @@ public class YaafiContainerTest extends
assertEquals(sc.getAppRoot(),sc.getAppRoot2());
this.release(sc);
}
+
@Test
public void testAlternativeRoles()
{
@@ -87,14 +88,17 @@ public class YaafiContainerTest extends
sc.test();
this.release(sc);
}
+
@Test
public void testLoadingContainerWithNoRolesfileFails()
{
- SimpleComponent sc = null;
+ this.setLogLevel(ConsoleLogger.LEVEL_DISABLED);
+
this.setRoleFileName(null);
+
try
{
- sc = (SimpleComponent) this.lookup(SimpleComponent.class.getName());
+ this.lookup(SimpleComponent.class.getName());
fail("We should fail");
}
catch (ComponentException e)