- Update Fulcrum Testcontainer 1.0.9 and Turbine Parent 7
- Fix Mock Encoding in Fulcrum Update Test
- Format Yaafi Tests
- Remove JUnitPlatform in json, crypto module
git-svn-id: https://svn.apache.org/repos/asf/turbine/fulcrum/trunk/yaafi@1887964 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
index f592697..75c4808 100644
--- a/pom.xml
+++ b/pom.xml
@@ -19,7 +19,7 @@
<parent>
<artifactId>turbine-parent</artifactId>
<groupId>org.apache.turbine</groupId>
- <version>6</version>
+ <version>7</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -94,7 +94,7 @@
<dependency>
<groupId>org.apache.fulcrum</groupId>
<artifactId>fulcrum-yaafi-crypto</artifactId>
- <version>1.0.7</version>
+ <version>2.0.1</version>
<optional>true</optional>
</dependency>
<dependency>
@@ -119,9 +119,15 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.13.1</version>
+ <version>4.13.2</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.fulcrum</groupId>
+ <artifactId>fulcrum-testcontainer</artifactId>
+ <version>1.0.9</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/src/java/org/apache/fulcrum/yaafi/interceptor/util/StopWatch.java b/src/java/org/apache/fulcrum/yaafi/interceptor/util/StopWatch.java
index 930c3a3..fa9aee9 100644
--- a/src/java/org/apache/fulcrum/yaafi/interceptor/util/StopWatch.java
+++ b/src/java/org/apache/fulcrum/yaafi/interceptor/util/StopWatch.java
@@ -59,7 +59,7 @@
* @author Henri Yandell
* @author Stephen Colebourne
* @since 2.0
- * @version $Id: StopWatch.java,v 1.1 2005/09/29 13:18:37 sigi Exp $
+ * @version $Id$
*/
public class StopWatch {
diff --git a/src/test/org/apache/fulcrum/yaafi/DependentTestComponentTest.java b/src/test/org/apache/fulcrum/yaafi/DependentTestComponentTest.java
index d141bb0..d0aa0dd 100644
--- a/src/test/org/apache/fulcrum/yaafi/DependentTestComponentTest.java
+++ b/src/test/org/apache/fulcrum/yaafi/DependentTestComponentTest.java
@@ -1,5 +1,7 @@
package org.apache.fulcrum.yaafi;
+import org.apache.fulcrum.testcontainer.BaseUnit5Test;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -19,8 +21,7 @@
* under the License.
*/
-
-import org.apache.fulcrum.yaafi.testcontainer.BaseUnitTest;
+import org.junit.jupiter.api.Test;
/**
* Test suite for ensuring that a dependent test component
@@ -30,16 +31,8 @@
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
*/
-public class DependentTestComponentTest extends BaseUnitTest
+public class DependentTestComponentTest extends BaseUnit5Test
{
- /**
- * Constructor
- * @param name the name of the test case
- */
- public DependentTestComponentTest( String name )
- {
- super(name);
- }
/**
* DependentTestComponentImpl uses a TestComponent which. Make
@@ -47,6 +40,7 @@
*
* @throws Exception generic exception
*/
+ @Test
public void testDependentTestComponent() throws Exception
{
DependentTestComponent dependentTestComponent = (DependentTestComponent) this.lookup(
diff --git a/src/test/org/apache/fulcrum/yaafi/TestComponentTest.java b/src/test/org/apache/fulcrum/yaafi/TestComponentTest.java
index dcd8739..42e326f 100644
--- a/src/test/org/apache/fulcrum/yaafi/TestComponentTest.java
+++ b/src/test/org/apache/fulcrum/yaafi/TestComponentTest.java
@@ -1,5 +1,12 @@
package org.apache.fulcrum.yaafi;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.apache.fulcrum.yaafi.testcontainer.BaseUnit5Test;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -20,7 +27,7 @@
*/
-import org.apache.fulcrum.yaafi.testcontainer.BaseUnitTest;
+import org.junit.jupiter.api.Test;
/**
* Test suite for the project
@@ -28,17 +35,10 @@
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
*/
-public class TestComponentTest extends BaseUnitTest
+public class TestComponentTest extends BaseUnit5Test
{
- /**
- * Constructor
- * @param name the name of the test case
- */
- public TestComponentTest( String name )
- {
- super(name);
- }
+ @Test
public void testTestComponent() throws Exception
{
TestComponent testComponent = (TestComponent) this.lookup(
diff --git a/src/test/org/apache/fulcrum/yaafi/baseservice/DerivedServiceTest.java b/src/test/org/apache/fulcrum/yaafi/baseservice/DerivedServiceTest.java
index aeb73c0..4c0fc56 100644
--- a/src/test/org/apache/fulcrum/yaafi/baseservice/DerivedServiceTest.java
+++ b/src/test/org/apache/fulcrum/yaafi/baseservice/DerivedServiceTest.java
@@ -1,5 +1,7 @@
package org.apache.fulcrum.yaafi.baseservice;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -19,10 +21,10 @@
* under the License.
*/
-
import java.io.File;
-import org.apache.fulcrum.yaafi.testcontainer.BaseUnitTest;
+import org.apache.fulcrum.testcontainer.BaseUnit5Test;
+import org.junit.jupiter.api.Test;
/**
* Test suite for the project
@@ -30,26 +32,18 @@
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
*/
-public class DerivedServiceTest extends BaseUnitTest
+public class DerivedServiceTest extends BaseUnit5Test
{
- /**
- * Constructor
- * @param name the name of the test case
- */
- public DerivedServiceTest( String name )
- {
- super(name);
- }
/**
* Lookup the service and invoke the test() method
+ *
* @throws Exception invocation failed
*/
+ @Test
public void testDerivedService() throws Exception
{
- DerivedService derivedService = (DerivedService) this.lookup(
- DerivedService.class.getName()
- );
+ DerivedService derivedService = (DerivedService) this.lookup( DerivedService.class.getName() );
// invoke the test() method on the service
@@ -58,12 +52,12 @@
// determine absolute paths and files
String fileName = "./src/test/TestRoleConfig.xml";
- String absolutePath = derivedService.createAbsolutePath(fileName);
- File absoluteFile = derivedService.createAbsoluteFile(fileName);
+ String absolutePath = derivedService.createAbsolutePath( fileName );
+ File absoluteFile = derivedService.createAbsoluteFile( fileName );
- assertTrue(absoluteFile.isAbsolute());
- assertTrue(absoluteFile.exists());
- assertTrue(new File(absolutePath).isAbsolute());
- assertTrue(new File(absolutePath).exists());
+ assertTrue( absoluteFile.isAbsolute() );
+ assertTrue( absoluteFile.exists() );
+ assertTrue( new File( absolutePath ).isAbsolute() );
+ assertTrue( new File( absolutePath ).exists() );
}
}
diff --git a/src/test/org/apache/fulcrum/yaafi/cli/MainTest.java b/src/test/org/apache/fulcrum/yaafi/cli/MainTest.java
index 953a397..aec4574 100644
--- a/src/test/org/apache/fulcrum/yaafi/cli/MainTest.java
+++ b/src/test/org/apache/fulcrum/yaafi/cli/MainTest.java
@@ -23,6 +23,8 @@
import org.apache.avalon.framework.service.ServiceException;
import org.apache.fulcrum.yaafi.TestComponent;
+import org.junit.After;
+import org.junit.jupiter.api.Test;
/**
* Test suite for exercising the command line integration.
@@ -34,18 +36,11 @@
{
private Main main;
- /**
- * Constructor
- * @param name the name of the test case
- */
- public MainTest( String name )
- {
- super(name);
- }
/* (non-Javadoc)
* @see junit.framework.TestCase#tearDown()
*/
+ @After
protected void tearDown() throws Exception
{
this.main.dispose();
@@ -67,6 +62,7 @@
* Initialize the CLI using a valid container configuration
* @throws Exception generic exception
*/
+ @Test
public void testValidContainerConfiguration() throws Exception
{
String[] args = {
@@ -84,6 +80,7 @@
* Test the toString() method provding diagnostic information
* @throws Exception generic exception
*/
+ @Test
public void testToString() throws Exception
{
String[] args = {
@@ -102,6 +99,7 @@
* Initialize the CLI using an invalid container configuration
* @throws Exception generic exception
*/
+ @Test
public void testInvlidContainerConfiguration() throws Exception
{
String[] args = {
diff --git a/src/test/org/apache/fulcrum/yaafi/framework/container/ServiceLifecycleManagerTest.java b/src/test/org/apache/fulcrum/yaafi/framework/container/ServiceLifecycleManagerTest.java
index e4865d0..9d07793 100644
--- a/src/test/org/apache/fulcrum/yaafi/framework/container/ServiceLifecycleManagerTest.java
+++ b/src/test/org/apache/fulcrum/yaafi/framework/container/ServiceLifecycleManagerTest.java
@@ -1,5 +1,9 @@
package org.apache.fulcrum.yaafi.framework.container;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.apache.fulcrum.yaafi.TestComponent;
@@ -7,6 +11,9 @@
import org.apache.fulcrum.yaafi.framework.factory.ServiceContainerFactory;
import org.apache.fulcrum.yaafi.framework.role.RoleEntry;
import org.apache.fulcrum.yaafi.service.reconfiguration.ReconfigurationService;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -27,221 +34,215 @@
* under the License.
*/
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
/**
* Test suite for the ServiceLifecycleManager.
*
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
*/
-public class ServiceLifecycleManagerTest extends TestCase {
- private ServiceLifecycleManager lifecycleManager;
- private ServiceContainer container;
+public class ServiceLifecycleManagerTest
+{
+ private ServiceLifecycleManager lifecycleManager;
+ private ServiceContainer container;
- /**
- * Constructor
- *
- * @param name the name of the test case
- */
- public ServiceLifecycleManagerTest(String name) {
- super(name);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#setUp()
+ */
+ @BeforeEach
+ protected void setUp() throws Exception
+ {
+ ServiceContainerConfiguration config = new ServiceContainerConfiguration();
+ config.loadContainerConfiguration( "./src/test/TestYaafiContainerConfig.xml" );
+ this.container = ServiceContainerFactory.create( config );
+ this.lifecycleManager = this.container;
+ }
- /*
- * (non-Javadoc)
- *
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- ServiceContainerConfiguration config = new ServiceContainerConfiguration();
- config.loadContainerConfiguration("./src/test/TestYaafiContainerConfig.xml");
- this.container = ServiceContainerFactory.create(config);
- this.lifecycleManager = this.container;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see junit.framework.TestCase#tearDown()
+ */
+ @AfterEach
+ protected void tearDown() throws Exception
+ {
+ ServiceContainerFactory.dispose( this.container );
+ }
- /*
- * (non-Javadoc)
- *
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- ServiceContainerFactory.dispose(this.container);
- super.tearDown();
- }
+ /**
+ * Check our TestComponent.
+ *
+ * @throws Exception generic exception
+ */
+ private void checkTestComponent() throws Exception
+ {
+ TestComponent testComponent = (TestComponent) container.lookup( TestComponent.ROLE );
- public static Test suite() {
- TestSuite suite = new TestSuite();
+ testComponent.test();
- suite.addTest(new ServiceLifecycleManagerTest("testGetServiceComponents"));
- suite.addTest(new ServiceLifecycleManagerTest("testGeneralReconfiguration"));
- suite.addTest(new ServiceLifecycleManagerTest("testGeneralDecommision"));
- suite.addTest(new ServiceLifecycleManagerTest("testGeneralReconfigurationAndDecommision"));
- suite.addTest(new ServiceLifecycleManagerTest("testIndividualDecommission"));
- suite.addTest(new ServiceLifecycleManagerTest("testException"));
+ assertEquals( testComponent.getBar(), "BAR" );
+ assertEquals( testComponent.getFoo(), "FOO" );
- return suite;
- }
+ assertNotNull( testComponent.getUrnAvalonClassLoader() );
+ assertNotNull( testComponent.getUrnAvaloneHome() );
+ assertNotNull( testComponent.getUrnAvaloneTemp() );
+ assertNotNull( testComponent.getUrnAvalonName() );
+ assertNotNull( testComponent.getUrnAvalonPartition() );
+ }
- /**
- * Check our TestComponent.
- *
- * @throws Exception generic exception
- */
- private void checkTestComponent() throws Exception {
- TestComponent testComponent = (TestComponent) container.lookup(TestComponent.ROLE);
+ /**
+ * Gets a list of all available services and dumps them on System.out.
+ *
+ * @throws Exception generic exception
+ */
+ @Test
+ public void testGetServiceComponents() throws Exception
+ {
+ RoleEntry[] list = this.lifecycleManager.getRoleEntries();
+ assertNotNull( list );
+ assertTrue( list.length > 0 );
+ for (RoleEntry entry : list)
+ System.out.println( entry.toString() );
+ }
- testComponent.test();
+ /**
+ * Reconfigure the all services
+ *
+ * @throws Exception generic exception
+ */
+ @Test
+ public void testGeneralReconfiguration() throws Exception
+ {
+ RoleEntry[] list = this.lifecycleManager.getRoleEntries();
- assertEquals(testComponent.getBar(), "BAR");
- assertEquals(testComponent.getFoo(), "FOO");
+ for (int i = 0; i < list.length; i++)
+ {
+ String serviceName = list[i].getName();
+ System.out.println( "Reconfiguring " + serviceName + " ..." );
- assertNotNull(testComponent.getUrnAvalonClassLoader());
- assertNotNull(testComponent.getUrnAvaloneHome());
- assertNotNull(testComponent.getUrnAvaloneTemp());
- assertNotNull(testComponent.getUrnAvalonName());
- assertNotNull(testComponent.getUrnAvalonPartition());
- }
+ String[] serviceNames = { list[i].getName() };
+ this.lifecycleManager.reconfigure( serviceNames );
+ assertTrue( this.container.hasService( serviceName ) );
+ assertNotNull( this.container.lookup( serviceName ) );
+ }
+ }
- /**
- * Gets a list of all available services and dumps them on System.out.
- *
- * @throws Exception generic exception
- */
- public void testGetServiceComponents() throws Exception {
- RoleEntry[] list = this.lifecycleManager.getRoleEntries();
- assertNotNull(list);
- assertTrue(list.length > 0);
- for (RoleEntry entry : list)
- System.out.println(entry.toString());
- }
+ /**
+ * Decommission and resurrect all services
+ *
+ * @throws Exception generic exception
+ */
+ @Test
+ public void testGeneralDecommision() throws Exception
+ {
+ String serviceName = null;
+ RoleEntry[] list = this.lifecycleManager.getRoleEntries();
- /**
- * Reconfigure the all services
- *
- * @throws Exception generic exception
- */
- public void testGeneralReconfiguration() throws Exception {
- RoleEntry[] list = this.lifecycleManager.getRoleEntries();
+ for (int i = 0; i < list.length; i++)
+ {
+ serviceName = list[i].getName();
+ System.out.println( "Decommissiong " + serviceName + " ..." );
- for (int i = 0; i < list.length; i++) {
- String serviceName = list[i].getName();
- System.out.println("Reconfiguring " + serviceName + " ...");
+ assertTrue( this.container.hasService( serviceName ) );
+ this.lifecycleManager.decommission( serviceName );
+ assertTrue( this.container.hasService( serviceName ) );
+ this.container.lookup( serviceName );
+ assertTrue( this.container.hasService( serviceName ) );
+ this.lifecycleManager.decommission( serviceName );
+ assertTrue( this.container.hasService( serviceName ) );
+ }
+ }
- String[] serviceNames = { list[i].getName() };
- this.lifecycleManager.reconfigure(serviceNames);
- assertTrue(this.container.hasService(serviceName));
- assertNotNull(this.container.lookup(serviceName));
- }
- }
+ /**
+ * Decommission and resurrect all services
+ *
+ * @throws Exception generic exception
+ */
+ @Test
+ public void testGeneralReconfigurationAndDecommision() throws Exception
+ {
+ String serviceName = null;
+ RoleEntry[] list = this.lifecycleManager.getRoleEntries();
+ DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+ Configuration configuration = builder.buildFromFile( "./src/test/TestReconfigurationConfig.xml" );
- /**
- * Decommission and resurrect all services
- *
- * @throws Exception generic exception
- */
- public void testGeneralDecommision() throws Exception {
- String serviceName = null;
- RoleEntry[] list = this.lifecycleManager.getRoleEntries();
+ for (int i = 0; i < list.length; i++)
+ {
+ serviceName = list[i].getName();
+ String[] serviceNames = { list[i].getName() };
+ System.out.println( "Processing " + serviceName + " ..." );
- for (int i = 0; i < list.length; i++) {
- serviceName = list[i].getName();
- System.out.println("Decommissiong " + serviceName + " ...");
+ // reconfigure/decommission/reconfigure the service
+ this.lifecycleManager.reconfigure( serviceNames );
+ this.lifecycleManager.decommission( serviceName );
+ this.lifecycleManager.reconfigure( serviceNames );
- assertTrue(this.container.hasService(serviceName));
- this.lifecycleManager.decommission(serviceName);
- assertTrue(this.container.hasService(serviceName));
- this.container.lookup(serviceName);
- assertTrue(this.container.hasService(serviceName));
- this.lifecycleManager.decommission(serviceName);
- assertTrue(this.container.hasService(serviceName));
- }
- }
+ // run a reconfiguration over all services
+ this.container.reconfigure( configuration );
- /**
- * Decommission and resurrect all services
- *
- * @throws Exception generic exception
- */
- public void testGeneralReconfigurationAndDecommision() throws Exception {
- String serviceName = null;
- RoleEntry[] list = this.lifecycleManager.getRoleEntries();
- DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
- Configuration configuration = builder.buildFromFile("./src/test/TestReconfigurationConfig.xml");
+ // reconfigure/decommission/reconfigure the service
+ this.container.lookup( serviceName );
+ this.lifecycleManager.reconfigure( serviceNames );
+ this.lifecycleManager.decommission( serviceName );
+ this.lifecycleManager.reconfigure( serviceNames );
+ }
+ }
- for (int i = 0; i < list.length; i++) {
- serviceName = list[i].getName();
- String[] serviceNames = { list[i].getName() };
- System.out.println("Processing " + serviceName + " ...");
+ /**
+ * Decommissions the TestComponent and ReconfigurationService to start them again.
+ *
+ * @throws Exception generic exception
+ */
+ @Test
+ public void testIndividualDecommission() throws Exception
+ {
+ String serviceName = null;
- // reconfigure/decommission/reconfigure the service
- this.lifecycleManager.reconfigure(serviceNames);
- this.lifecycleManager.decommission(serviceName);
- this.lifecycleManager.reconfigure(serviceNames);
+ // teminate the TestComponent and run it again
- // run a reconfiguration over all services
- this.container.reconfigure(configuration);
+ serviceName = TestComponent.class.getName();
- // reconfigure/decommission/reconfigure the service
- this.container.lookup(serviceName);
- this.lifecycleManager.reconfigure(serviceNames);
- this.lifecycleManager.decommission(serviceName);
- this.lifecycleManager.reconfigure(serviceNames);
- }
- }
+ this.checkTestComponent();
+ this.lifecycleManager.decommission( serviceName );
+ this.checkTestComponent();
- /**
- * Decommissions the TestComponent and ReconfigurationService to start them
- * again.
- *
- * @throws Exception generic exception
- */
- public void testIndividualDecommission() throws Exception {
- String serviceName = null;
+ // terminate the ReconfigurationService which is currently
+ // not instantiated and resurrect it. The moment the
+ // ReconfigurationService is instantiated it is starting to
+ // work
- // teminate the TestComponent and run it again
+ serviceName = ReconfigurationService.class.getName();
- serviceName = TestComponent.class.getName();
+ this.lifecycleManager.decommission( ReconfigurationService.class.getName() );
+ this.container.lookup( ReconfigurationService.class.getName() );
- this.checkTestComponent();
- this.lifecycleManager.decommission(serviceName);
- this.checkTestComponent();
+ // now we should see that the service is starting up
- // terminate the ReconfigurationService which is currently
- // not instantiated and resurrect it. The moment the
- // ReconfigurationService is instantiated it is starting to
- // work
+ Thread.sleep( 5000 );
- serviceName = ReconfigurationService.class.getName();
+ // and terminate it again
- this.lifecycleManager.decommission(ReconfigurationService.class.getName());
- this.container.lookup(ReconfigurationService.class.getName());
+ this.lifecycleManager.decommission( ReconfigurationService.class.getName() );
+ }
- // now we should see that the service is starting up
+ /**
+ * Create an exception which should be handled by the JAMon interceptor.
+ *
+ * @throws Exception generic exception
+ */
+ @Test
+ public void testException() throws Exception
+ {
+ TestComponent testComponent = (TestComponent) container.lookup( TestComponent.ROLE );
- Thread.sleep(5000);
+ try
+ {
+ testComponent.createException( "testException", this );
+ } catch (Exception e)
+ {
+ return;
+ }
- // and terminate it again
-
- this.lifecycleManager.decommission(ReconfigurationService.class.getName());
- }
-
- /**
- * Create an exception which should be handled by the JAMon interceptor.
- *
- * @throws Exception generic exception
- */
- public void testException() throws Exception {
- TestComponent testComponent = (TestComponent) container.lookup(TestComponent.ROLE);
-
- try {
- testComponent.createException("testException", this);
- } catch (Exception e) {
- return;
- }
-
- }
+ }
}
diff --git a/src/test/org/apache/fulcrum/yaafi/framework/factory/ServiceContainerFactoryTest.java b/src/test/org/apache/fulcrum/yaafi/framework/factory/ServiceContainerFactoryTest.java
index 68c9201..6d78a64 100644
--- a/src/test/org/apache/fulcrum/yaafi/framework/factory/ServiceContainerFactoryTest.java
+++ b/src/test/org/apache/fulcrum/yaafi/framework/factory/ServiceContainerFactoryTest.java
@@ -1,5 +1,9 @@
package org.apache.fulcrum.yaafi.framework.factory;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -29,8 +33,8 @@
import org.apache.avalon.framework.service.ServiceException;
import org.apache.fulcrum.yaafi.TestComponent;
import org.apache.fulcrum.yaafi.framework.container.ServiceContainer;
-
-import junit.framework.TestCase;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
/**
* Test suite for the ServiceContainerFactory.
@@ -38,194 +42,201 @@
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
*/
-public class ServiceContainerFactoryTest extends TestCase {
- private ServiceContainer container = null;
+public class ServiceContainerFactoryTest
+{
+ private ServiceContainer container = null;
- /**
- * Constructor
- *
- * @param name the name of the test case
- */
- public ServiceContainerFactoryTest(String name) {
- super(name);
- }
+ @AfterEach
+ protected void tearDown() throws Exception
+ {
+ ServiceContainerFactory.dispose( this.container );
+ }
- /*
- * (non-Javadoc)
- *
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- ServiceContainerFactory.dispose(this.container);
- super.tearDown();
- }
+ /**
+ * @throws Exception generic exception
+ */
+ private void checkTestComponent() throws Exception
+ {
+ TestComponent testComponent = this.getTestComponent();
- /**
- * @throws Exception generic exception
- */
- private void checkTestComponent() throws Exception {
- TestComponent testComponent = this.getTestComponent();
+ testComponent.test();
- testComponent.test();
+ assertEquals( testComponent.getBar(), "BAR" );
+ assertEquals( testComponent.getFoo(), "FOO" );
- assertEquals(testComponent.getBar(), "BAR");
- assertEquals(testComponent.getFoo(), "FOO");
+ assertNotNull( testComponent.getUrnAvalonClassLoader() );
+ assertNotNull( testComponent.getUrnAvaloneHome() );
+ assertNotNull( testComponent.getUrnAvaloneTemp() );
+ assertNotNull( testComponent.getUrnAvalonName() );
+ assertNotNull( testComponent.getUrnAvalonPartition() );
- assertNotNull(testComponent.getUrnAvalonClassLoader());
- assertNotNull(testComponent.getUrnAvaloneHome());
- assertNotNull(testComponent.getUrnAvaloneTemp());
- assertNotNull(testComponent.getUrnAvalonName());
- assertNotNull(testComponent.getUrnAvalonPartition());
+ try
+ {
+ testComponent.createException( "enforce exception", this );
+ } catch (Exception e)
+ {
+ // nothing to do
+ }
+ }
- try {
- testComponent.createException("enforce exception", this);
- } catch (Exception e) {
- // nothing to do
- }
- }
+ /**
+ * @return get our simple test component
+ * @throws ServiceException if service not found
+ */
+ private TestComponent getTestComponent() throws ServiceException
+ {
+ return (TestComponent) container.lookup( TestComponent.ROLE );
+ }
- /**
- * @return get our simple test component
- * @throws ServiceException if service not found
- */
- private TestComponent getTestComponent() throws ServiceException {
- return (TestComponent) container.lookup(TestComponent.ROLE);
- }
+ /**
+ * Creates a YAAFI container using a container configuration file which already contains
+ * most of the required settings
+ *
+ * @throws Exception generic exception
+ */
+ @Test
+ public void testCreationWithContainerConfiguration() throws Exception
+ {
+ ServiceContainerConfiguration config = new ServiceContainerConfiguration();
+ config.loadContainerConfiguration( "./src/test/TestYaafiContainerConfig.xml" );
+ this.container = ServiceContainerFactory.create( config );
+ this.checkTestComponent();
+ System.out.println( this.container.toString() );
+ return;
+ }
- /**
- * Creates a YAAFI container using a container configuration file which already
- * contains most of the required settings
- *
- * @throws Exception generic exception
- */
- public void testCreationWithContainerConfiguration() throws Exception {
- ServiceContainerConfiguration config = new ServiceContainerConfiguration();
- config.loadContainerConfiguration("./src/test/TestYaafiContainerConfig.xml");
- this.container = ServiceContainerFactory.create(config);
- this.checkTestComponent();
- System.out.println(this.container.toString());
- return;
- }
+ /**
+ * Creates a YAAFI container using a non-existent container configuration file. Therefore
+ * the creation should fail.
+ *
+ * @throws Exception generic exception
+ */
+ @Test
+ public void testCreationWithMissingContainerConfiguration() throws Exception
+ {
+ ServiceContainerConfiguration config = new ServiceContainerConfiguration();
- /**
- * Creates a YAAFI container using a non-existent container configuration file.
- * Therefore the creation should fail.
- *
- * @throws Exception generic exception
- */
- public void testCreationWithMissingContainerConfiguration() throws Exception {
- ServiceContainerConfiguration config = new ServiceContainerConfiguration();
+ try
+ {
+ config.loadContainerConfiguration( "./src/test/MissingTestContainerConfig.xml" );
+ this.container = ServiceContainerFactory.create( config );
+ fail( "The creation of the YAAFI container must fail" );
+ } catch (IOException e)
+ {
+ // nothing to do
+ } catch (Exception e)
+ {
+ fail( "We are expecting an IOException" );
+ }
+ }
- try {
- config.loadContainerConfiguration("./src/test/MissingTestContainerConfig.xml");
- this.container = ServiceContainerFactory.create(config);
- fail("The creation of the YAAFI container must fail");
- } catch (IOException e) {
- // nothing to do
- } catch (Exception e) {
- fail("We are expecting an IOException");
- }
- }
+ /**
+ * Creates a YAAFI container providing all required settings manually
+ *
+ * @throws Exception generic exception
+ */
+ @Test
+ public void testCreationWithManualSettings() throws Exception
+ {
+ ServiceContainerConfiguration config = new ServiceContainerConfiguration();
+ config.setComponentRolesLocation( "./src/test/TestRoleConfig.xml" );
+ config.setComponentConfigurationLocation( "./src/test/TestComponentConfig.xml" );
+ config.setParametersLocation( "./src/test/TestParameters.properties" );
+ this.container = ServiceContainerFactory.create( config );
+ this.checkTestComponent();
+ }
- /**
- * Creates a YAAFI container providing all required settings manually
- *
- * @throws Exception generic exception
- */
- public void testCreationWithManualSettings() throws Exception {
- ServiceContainerConfiguration config = new ServiceContainerConfiguration();
- config.setComponentRolesLocation("./src/test/TestRoleConfig.xml");
- config.setComponentConfigurationLocation("./src/test/TestComponentConfig.xml");
- config.setParametersLocation("./src/test/TestParameters.properties");
- this.container = ServiceContainerFactory.create(config);
- this.checkTestComponent();
- }
+ /**
+ * Creates a YAAFI container providing a Phoenix context
+ *
+ * @throws Exception generic exception
+ */
+ @Test
+ public void testCreationWithPhoenixContext() throws Exception
+ {
+ ServiceContainerConfiguration config = new ServiceContainerConfiguration();
+ DefaultContext context = new DefaultContext();
- /**
- * Creates a YAAFI container providing a Phoenix context
- *
- * @throws Exception generic exception
- */
- public void testCreationWithPhoenixContext() throws Exception {
- ServiceContainerConfiguration config = new ServiceContainerConfiguration();
- DefaultContext context = new DefaultContext();
+ // use an existing container configuration
- // use an existing container configuration
+ config.loadContainerConfiguration( "./src/test/TestPhoenixContainerConfig.xml" );
- config.loadContainerConfiguration("./src/test/TestPhoenixContainerConfig.xml");
+ // fill the context with Phoenix settings
- // fill the context with Phoenix settings
+ context.put( "app.name", "ServiceContainerFactoryTest" );
+ context.put( "block.name", "fulcrum-yaafi" );
+ context.put( "app.home", new File( new File( "" ).getAbsolutePath() ) );
- context.put("app.name", "ServiceContainerFactoryTest");
- context.put("block.name", "fulcrum-yaafi");
- context.put("app.home", new File(new File("").getAbsolutePath()));
+ // create an instance
- // create an instance
+ this.container = ServiceContainerFactory.create( config, context );
- this.container = ServiceContainerFactory.create(config, context);
+ // execute the test component
- // execute the test component
+ this.checkTestComponent();
+ }
- this.checkTestComponent();
- }
+ /**
+ * Creates a YAAFI container providing a Fortress context
+ *
+ * @throws Exception generic exception
+ */
+ @Test
+ public void testCreationWithFortressContext() throws Exception
+ {
+ ServiceContainerConfiguration config = new ServiceContainerConfiguration();
+ DefaultContext context = new DefaultContext();
- /**
- * Creates a YAAFI container providing a Fortress context
- *
- * @throws Exception generic exception
- */
- public void testCreationWithFortressContext() throws Exception {
- ServiceContainerConfiguration config = new ServiceContainerConfiguration();
- DefaultContext context = new DefaultContext();
+ // use an existing container configuration
- // use an existing container configuration
+ config.loadContainerConfiguration( "./src/test/TestFortressContainerConfig.xml" );
- config.loadContainerConfiguration("./src/test/TestFortressContainerConfig.xml");
+ // fill the context with Fortress settings
- // fill the context with Fortress settings
+ context.put( "component.id", "ServiceContainerFactoryTest" );
+ context.put( "component.logger", "fulcrum-yaafi" );
+ context.put( "context-root", new File( new File( "" ).getAbsolutePath() ) );
+ context.put( "impl.workDir", new File( new File( "" ).getAbsolutePath() ) );
- context.put("component.id", "ServiceContainerFactoryTest");
- context.put("component.logger", "fulcrum-yaafi");
- context.put("context-root", new File(new File("").getAbsolutePath()));
- context.put("impl.workDir", new File(new File("").getAbsolutePath()));
+ // create an instance
- // create an instance
+ this.container = ServiceContainerFactory.create( config, context );
- this.container = ServiceContainerFactory.create(config, context);
+ // execute the test component
- // execute the test component
+ this.checkTestComponent();
+ }
- this.checkTestComponent();
- }
+ /**
+ * Reconfigures the YAAFI container with the "TestReconfigurationConfig.xml"
+ *
+ * @throws Exception generic exception
+ */
+ @Test
+ public void testReconfiguration() throws Exception
+ {
+ // create a YAAFI instance
- /**
- * Reconfigures the YAAFI container with the "TestReconfigurationConfig.xml"
- *
- * @throws Exception generic exception
- */
- public void testReconfiguration() throws Exception {
- // create a YAAFI instance
+ ServiceContainerConfiguration config = new ServiceContainerConfiguration();
+ config.loadContainerConfiguration( "./src/test/TestYaafiContainerConfig.xml" );
+ this.container = ServiceContainerFactory.create( config );
+ this.checkTestComponent();
- ServiceContainerConfiguration config = new ServiceContainerConfiguration();
- config.loadContainerConfiguration("./src/test/TestYaafiContainerConfig.xml");
- this.container = ServiceContainerFactory.create(config);
- this.checkTestComponent();
+ // load a different configuration and reconfigure YAAFI
- // load a different configuration and reconfigure YAAFI
+ DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+ Configuration configuration = builder.buildFromFile( "./src/test/TestReconfigurationConfig.xml" );
+ System.out.println( ConfigurationUtil.toString( configuration ) );
- DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
- Configuration configuration = builder.buildFromFile("./src/test/TestReconfigurationConfig.xml");
- System.out.println(ConfigurationUtil.toString(configuration));
+ this.container.reconfigure( configuration );
+ TestComponent testComponent = this.getTestComponent();
+ testComponent.test();
- this.container.reconfigure(configuration);
- TestComponent testComponent = this.getTestComponent();
- testComponent.test();
+ // the TestReconfigurationConfig.xml overwrites the
+ // TestComponentImpl.foo and the SystemProperty.FOO
- // the TestReconfigurationConfig.xml overwrites the
- // TestComponentImpl.foo and the SystemProperty.FOO
+ assertEquals( System.getProperty( "FOO" ), "YAAFI" );
+ assertEquals( testComponent.getFoo(), "YAAFI" );
- assertEquals(System.getProperty("FOO"), "YAAFI");
- assertEquals(testComponent.getFoo(), "YAAFI");
-
- }
+ }
}
diff --git a/src/test/org/apache/fulcrum/yaafi/interceptor/util/ArgumentToStringBuilderTest.java b/src/test/org/apache/fulcrum/yaafi/interceptor/util/ArgumentToStringBuilderTest.java
index 3fc9b18..12b5ba8 100644
--- a/src/test/org/apache/fulcrum/yaafi/interceptor/util/ArgumentToStringBuilderTest.java
+++ b/src/test/org/apache/fulcrum/yaafi/interceptor/util/ArgumentToStringBuilderTest.java
@@ -24,7 +24,9 @@
import java.util.Hashtable;
import java.util.Properties;
-import junit.framework.TestCase;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Test suite for the SmartToStringBuilderImpl.
@@ -32,259 +34,269 @@
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
*/
-public class ArgumentToStringBuilderTest extends TestCase
+public class ArgumentToStringBuilderTest
{
private String result;
private ArgumentToStringBuilderImpl toStringBuilder;
private int maxArgLength = 100;
int mode = 3;
-
- /**
- * Constructor
- * @param name the name of the test case
- */
- public ArgumentToStringBuilderTest( String name )
- {
- super(name);
- }
-
/**
* @see junit.framework.TestCase#setUp()
*/
+ @BeforeEach
protected void setUp() throws Exception
{
- super.setUp();
this.toStringBuilder = new ArgumentToStringBuilderImpl();
- this.toStringBuilder.setMaxArgLength(this.maxArgLength);
- this.toStringBuilder.setMode(this.mode);
- System.out.println( "=== " + this.getName() + " ====================================");
+ this.toStringBuilder.setMaxArgLength( this.maxArgLength );
+ this.toStringBuilder.setMode( this.mode );
+ System.out.println( "=== " + this.getClass().getName() + " ====================================" );
}
/**
* @see junit.framework.TestCase#setUp()
*/
+ @AfterEach
protected void tearDown() throws Exception
{
- System.out.println(this.result);
- super.tearDown();
+ System.out.println( this.result );
}
/**
* Test with a simple String
*/
+ @Test
public void testString()
{
String target = "In vino veritas";
- this.toStringBuilder.setTarget(target);
+ this.toStringBuilder.setTarget( target );
result = toStringBuilder.toString();
}
/**
* Test with a simple Integer
*/
+ @Test
public void testInteger()
{
- Integer target = new Integer(69);
- this.toStringBuilder.setTarget(target);
+ Integer target = new Integer( 69 );
+ this.toStringBuilder.setTarget( target );
result = toStringBuilder.toString();
}
/**
* Test with an empty array
*/
+ @Test
public void testEmptyArray()
{
String[] target = {};
- this.toStringBuilder.setTarget(target);
+ this.toStringBuilder.setTarget( target );
result = toStringBuilder.toString();
}
/**
* Test with a simple String[]
*/
+ @Test
public void testStringArray()
{
- String[] target = {"foo","bar"};
- this.toStringBuilder.setTarget(target);
+ String[] target = { "foo", "bar" };
+ this.toStringBuilder.setTarget( target );
result = toStringBuilder.toString();
}
/**
* Test with a simple Integer[]
*/
+ @Test
public void testIntegerArray()
{
- Integer[] target = {new Integer(4711), new Integer(815)};
- this.toStringBuilder.setTarget(target);
+ Integer[] target = { new Integer( 4711 ), new Integer( 815 ) };
+ this.toStringBuilder.setTarget( target );
result = toStringBuilder.toString();
}
/**
* Test with an Exception
*/
+ @Test
public void testException()
{
- Exception target = new RuntimeException(this.getName());
- this.toStringBuilder.setTarget(target);
+ Exception target = new RuntimeException( this.getClass().getName() );
+ this.toStringBuilder.setTarget( target );
result = toStringBuilder.toString();
}
/**
* Test with an NULL object
*/
+ @Test
public void testNull()
{
Object target = null;
- this.toStringBuilder.setTarget(target);
+ this.toStringBuilder.setTarget( target );
result = toStringBuilder.toString();
}
/**
* Test with an array containing NULL values
*/
+ @Test
public void testWithANullArray()
{
Object target = new String[] { "foo", null, "bar" };
- this.toStringBuilder.setTarget(target);
+ this.toStringBuilder.setTarget( target );
result = toStringBuilder.toString();
}
/**
* Create a plain vanilla Java object
+ *
* @throws Exception generic exception
*/
+ @Test
public void testPlainVanillaObject() throws Exception
{
- File target = new File("./LICENSE.txt");
- this.toStringBuilder.setTarget(target);
+ File target = new File( "./LICENSE.txt" );
+ this.toStringBuilder.setTarget( target );
result = toStringBuilder.toString();
}
/**
* Test with a char[]
*/
+ @Test
public void testCharArray()
{
- char[] target = this.getName().toCharArray();
- this.toStringBuilder.setTarget(target);
+ char[] target = this.getClass().getName().toCharArray();
+ this.toStringBuilder.setTarget( target );
result = toStringBuilder.toString();
}
/**
* Test with a long char[] which will be truncated
*/
+ @Test
public void testLongCharArray()
{
char[] target = System.getProperties().toString().toCharArray();
- this.toStringBuilder.setTarget(target);
+ this.toStringBuilder.setTarget( target );
result = toStringBuilder.toString();
}
/**
* Test with a byte[]
*/
+ @Test
public void testByteArray()
{
- Exception target = new RuntimeException(this.getName());
- this.toStringBuilder.setTarget(target.toString().getBytes());
+ Exception target = new RuntimeException( this.getClass().getName() );
+ this.toStringBuilder.setTarget( target.toString().getBytes() );
result = toStringBuilder.toString();
}
/**
* Test with a multidimensional array
*/
- public void testMultiDimensionalArray()
+ @Test
+ public void testMultiDimensionalArray()
{
- String[] row1 = {"r1.1", "1.2", "r1.3" };
+ String[] row1 = { "r1.1", "1.2", "r1.3" };
int[] row2 = { 1, 2, 3 };
- String[] row3 = {"r3.1" };
- Object[] target = { row1, row2, row3, this.getName().toCharArray() };
+ String[] row3 = { "r3.1" };
+ Object[] target = { row1, row2, row3, this.getClass().getName().toCharArray() };
- this.toStringBuilder.setTarget(target);
+ this.toStringBuilder.setTarget( target );
result = toStringBuilder.toString();
}
/**
* Test with a hashtable
*/
+ @Test
public void testHashtable()
{
Hashtable target = new Hashtable();
- target.put("foo","foo");
- target.put("bar","bar");
+ target.put( "foo", "foo" );
+ target.put( "bar", "bar" );
- this.toStringBuilder.setTarget(target);
+ this.toStringBuilder.setTarget( target );
result = toStringBuilder.toString();
}
/**
* Test with a java.util.Properties
*/
+ @Test
public void testProperties()
{
Properties target = System.getProperties();
- this.toStringBuilder.setTarget(target);
+ this.toStringBuilder.setTarget( target );
result = toStringBuilder.toString();
}
/**
* Test with an ArrayList
*/
+ @Test
public void testArrayList()
{
ArrayList<String> target = new ArrayList<>();
- target.add("foo");
- target.add("bar");
+ target.add( "foo" );
+ target.add( "bar" );
- this.toStringBuilder.setTarget(target);
+ this.toStringBuilder.setTarget( target );
result = toStringBuilder.toString();
}
/**
* Test with a non-empty int[]
*/
+ @Test
public void testIntArray()
{
int[] target = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- this.toStringBuilder.setTarget(target);
+ this.toStringBuilder.setTarget( target );
result = toStringBuilder.toString();
}
/**
* Test with an empty int[]
*/
+ @Test
public void testEmptyIntArray()
{
int[] target = {};
- this.toStringBuilder.setTarget(target);
+ this.toStringBuilder.setTarget( target );
result = toStringBuilder.toString();
}
/**
* Test with an boolean[]
*/
+ @Test
public void testBooleanArray()
{
boolean[] target = { true, false };
- this.toStringBuilder.setTarget(target);
+ this.toStringBuilder.setTarget( target );
result = toStringBuilder.toString();
}
/**
* Test with an File[]
*/
+ @Test
public void testFileArray()
{
- File[] target = { new File("foo"), new File("bar") };
+ File[] target = { new File( "foo" ), new File( "bar" ) };
- this.toStringBuilder.setTarget(target);
+ this.toStringBuilder.setTarget( target );
result = toStringBuilder.toString();
}
-
}
diff --git a/src/test/org/apache/fulcrum/yaafi/service/AdviceServiceTest.java b/src/test/org/apache/fulcrum/yaafi/service/AdviceServiceTest.java
index dbc89af..1e3768d 100644
--- a/src/test/org/apache/fulcrum/yaafi/service/AdviceServiceTest.java
+++ b/src/test/org/apache/fulcrum/yaafi/service/AdviceServiceTest.java
@@ -1,5 +1,8 @@
package org.apache.fulcrum.yaafi.service;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -19,9 +22,6 @@
* under the License.
*/
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.fulcrum.yaafi.DependentTestComponent;
@@ -30,6 +30,9 @@
import org.apache.fulcrum.yaafi.framework.factory.ServiceContainerFactory;
import org.apache.fulcrum.yaafi.interceptor.logging.LoggingInterceptorService;
import org.apache.fulcrum.yaafi.service.advice.AdviceService;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Test suite for the ServiceManagereService.
@@ -37,60 +40,33 @@
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
*/
-public class AdviceServiceTest extends TestCase implements DependentTestComponent
+public class AdviceServiceTest implements DependentTestComponent
{
private AdviceService service;
private DependentTestComponent advisedThis;
private ServiceContainer container;
- /**
- * Constructor
- * @param name the name of the test case
- */
- public AdviceServiceTest( String name )
- {
- super(name);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
+ @BeforeEach
protected void setUp() throws Exception
{
- super.setUp();
ServiceContainerConfiguration config = new ServiceContainerConfiguration();
config.loadContainerConfiguration( "./src/test/TestYaafiContainerConfig.xml" );
this.container = ServiceContainerFactory.create( config );
service = (AdviceService) this.container.lookup(AdviceService.class.getName());
}
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
+ @AfterEach
protected void tearDown() throws Exception
{
ServiceContainerFactory.dispose(this.container);
- super.tearDown();
- }
-
- public static Test suite()
- {
- TestSuite suite= new TestSuite();
-
- suite.addTest( new AdviceServiceTest("testSimpleObject") );
- suite.addTest( new AdviceServiceTest("testDefaultAdvice") );
- suite.addTest( new AdviceServiceTest("testChainedAdvices") );
- suite.addTest( new AdviceServiceTest("testMultipleProxies") );
-
-
- return suite;
}
/**
* Advice a StringBuilder based on the CharSequence interface
* @throws Exception generic exception
*/
+ @Test
public void testSimpleAdvice() throws Exception
{
String[] interceptorList = { LoggingInterceptorService.class.getName() };
@@ -107,6 +83,7 @@
* Advice a StringBuilder based on the CharSequence interface
* @throws Exception generic exception
*/
+ @Test
public void testSimpleObject() throws Exception
{
String[] interceptorList = { LoggingInterceptorService.class.getName() };
@@ -123,6 +100,7 @@
* Advice a StringBuilder based on the CharSequenceInterface with default interceptors
* @throws Exception generic exception
*/
+ @Test
public void testDefaultAdvice() throws Exception
{
StringBuilder unadvicedObject = new StringBuilder("foo");
@@ -137,6 +115,7 @@
* another advised component.
* @throws Exception generic exception
*/
+ @Test
public void testChainedAdvices() throws Exception
{
String[] interceptorList = { LoggingInterceptorService.class.getName() };
@@ -148,6 +127,7 @@
* Advice a StringBuilder based on the CharSequenceInterface
* @throws Exception generic exception
*/
+ @Test
public void testMultipleProxies() throws Exception
{
String[] interceptorList = { LoggingInterceptorService.class.getName() };
@@ -163,6 +143,7 @@
* Advice a StringBuilder based on the CharSequenceInterface
* @see org.apache.fulcrum.yaafi.DependentTestComponent#test()
*/
+ @Test
public void test()
{
try
diff --git a/src/test/org/apache/fulcrum/yaafi/service/ServiceManagerServiceTest.java b/src/test/org/apache/fulcrum/yaafi/service/ServiceManagerServiceTest.java
index 64fc1e9..6b5018b 100644
--- a/src/test/org/apache/fulcrum/yaafi/service/ServiceManagerServiceTest.java
+++ b/src/test/org/apache/fulcrum/yaafi/service/ServiceManagerServiceTest.java
@@ -1,5 +1,8 @@
package org.apache.fulcrum.yaafi.service;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -19,7 +22,6 @@
* under the License.
*/
-import junit.framework.TestCase;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.fulcrum.yaafi.framework.container.ServiceContainer;
@@ -27,6 +29,9 @@
import org.apache.fulcrum.yaafi.framework.factory.ServiceContainerFactory;
import org.apache.fulcrum.yaafi.service.servicemanager.ServiceManagerService;
import org.apache.fulcrum.yaafi.service.servicemanager.ServiceManagerServiceImpl;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
* Test suite for the ServiceManagereService.
@@ -34,43 +39,31 @@
* @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
*/
-public class ServiceManagerServiceTest extends TestCase
-{
+public class ServiceManagerServiceTest {
+
private ServiceContainer container = null;
- /**
- * Constructor
- * @param name the name of the test case
- */
- public ServiceManagerServiceTest( String name )
- {
- super(name);
- }
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
+
+ @BeforeEach
protected void setUp() throws Exception
{
- super.setUp();
ServiceContainerConfiguration config = new ServiceContainerConfiguration();
config.loadContainerConfiguration( "./src/test/TestYaafiContainerConfig.xml" );
this.container = ServiceContainerFactory.create( config );
}
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
+ @AfterEach
protected void tearDown() throws Exception
{
ServiceContainerFactory.dispose(this.container);
- super.tearDown();
}
/**
* Access the ServiceManagerService
* @throws Exception if service manager not found
*/
+ @Test
public void testServiceManagerService() throws Exception
{
ServiceManagerService serviceManagerService = ServiceManagerServiceImpl.getInstance();
diff --git a/src/test/org/apache/fulcrum/yaafi/testcontainer/BaseUnitTest.java b/src/test/org/apache/fulcrum/yaafi/testcontainer/BaseUnit5Test.java
similarity index 93%
rename from src/test/org/apache/fulcrum/yaafi/testcontainer/BaseUnitTest.java
rename to src/test/org/apache/fulcrum/yaafi/testcontainer/BaseUnit5Test.java
index f51f8c8..d7ab956 100644
--- a/src/test/org/apache/fulcrum/yaafi/testcontainer/BaseUnitTest.java
+++ b/src/test/org/apache/fulcrum/yaafi/testcontainer/BaseUnit5Test.java
@@ -1,177 +1,165 @@
-package org.apache.fulcrum.yaafi.testcontainer;
-
-/*
- * 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 org.apache.avalon.framework.component.Component;
-import org.apache.avalon.framework.component.ComponentException;
-import org.apache.avalon.framework.service.ServiceException;
-
-import junit.framework.TestCase;
-
-/**
- * Base class for unit tests for components. This version doesn't load the
- * container until the first request for a component. This allows the tester to
- * populate the configurationFileName and roleFileName, possible one per test.
- *
- * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
- * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
- */
-public abstract class BaseUnitTest extends TestCase {
-
- /** YaffiContainer 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 paramterFileName */
- private String parameterFileName = "src/test/TestParameters.properties";
-
- /**
- * Gets the configuration file name for the container should use for this test.
- * By default it is src/test/TestComponentConfig.
- *
- * @param configurationFileName config file name
- */
- protected void setConfigurationFileName(String configurationFileName) {
- this.configurationFileName = configurationFileName;
- }
-
- /**
- * Override the role file name for the container should use for this test. By
- * default it is src/test/TestRoleConfig.
- *
- * @param roleFileName role file name
- */
- protected void setRoleFileName(String roleFileName) {
- this.roleFileName = roleFileName;
- }
-
- /**
- * Override the parameter file name for the container should use for this test.
- * By default it is src/test/TestRoleConfig.
- *
- * @param parameterFileName the name of the parameter file
- */
- protected void setParameterFileName(String parameterFileName) {
- this.parameterFileName = parameterFileName;
- }
-
- /**
- * Constructor for test.
- *
- * @param testName name of the test being executed
- */
- public BaseUnitTest(String testName) {
- super(testName);
- }
-
- /*
- * (non-Javadoc) Clean up after each test is run.
- *
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- if (this.container != null) {
- this.container.dispose();
- }
- this.container = null;
- }
-
- /**
- * Gets the configuration file name for the container should use for this test.
- *
- * @return The filename of the configuration file
- */
- protected String getConfigurationFileName() {
- return this.configurationFileName;
- }
-
- /**
- * Gets the role file name for the container should use for this test.
- *
- * @return The filename of the role configuration file
- */
- protected String getRoleFileName() {
- return this.roleFileName;
- }
-
- /**
- * Gets the parameter file name for the container should use for this test.
- *
- * @return The filename of the parameter file
- */
- protected String getParameterFileName() {
- return this.parameterFileName;
- }
-
- /**
- * Returns an instance of the named component. Starts the container if it hasn't
- * been started.
- *
- * @param roleName Name of the role the component fills.
- * @return Object representing the named component
- * @throws ComponentException if the component is not found
- */
- protected Object lookup(String roleName) throws ComponentException {
- if (this.container == null) {
- this.container = new Container();
- this.container.startup(getConfigurationFileName(), getRoleFileName(), getParameterFileName());
- }
- return this.container.lookup(roleName);
- }
-
- /**
- * Releases the component
- *
- * @param component the component to be released
- */
- protected void release(Component component) {
- if (this.container != null) {
- this.container.release(component);
- }
- }
-
- /**
- * Releases the component
- *
- * @param component the component to be released
- */
- protected void release(Object component) {
- if (this.container != null) {
- this.container.release(component);
- }
- }
-
- /**
- * Decommision the service
- *
- * @param name the name of the service
- * @throws ServiceException if the service is not found
- */
- protected void decommision(String name) throws ServiceException {
- if (this.container != null) {
- this.container.decommission(name);
- }
- }
-}
+package org.apache.fulcrum.yaafi.testcontainer;
+
+/*
+ * 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 org.apache.avalon.framework.component.Component;
+import org.apache.avalon.framework.component.ComponentException;
+import org.apache.avalon.framework.service.ServiceException;
+import org.junit.jupiter.api.AfterEach;
+
+import junit.framework.TestCase;
+
+/**
+ * Base class for unit tests for components. This version doesn't load the
+ * container until the first request for a component. This allows the tester to
+ * populate the configurationFileName and roleFileName, possible one per test.
+ *
+ * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
+ * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
+ */
+public abstract class BaseUnit5Test {
+
+ /** YaffiContainer 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 paramterFileName */
+ private String parameterFileName = "src/test/TestParameters.properties";
+
+ /**
+ * Gets the configuration file name for the container should use for this test.
+ * By default it is src/test/TestComponentConfig.
+ *
+ * @param configurationFileName config file name
+ */
+ protected void setConfigurationFileName(String configurationFileName) {
+ this.configurationFileName = configurationFileName;
+ }
+
+ /**
+ * Override the role file name for the container should use for this test. By
+ * default it is src/test/TestRoleConfig.
+ *
+ * @param roleFileName role file name
+ */
+ protected void setRoleFileName(String roleFileName) {
+ this.roleFileName = roleFileName;
+ }
+
+ /**
+ * Override the parameter file name for the container should use for this test.
+ * By default it is src/test/TestRoleConfig.
+ *
+ * @param parameterFileName the name of the parameter file
+ */
+ protected void setParameterFileName(String parameterFileName) {
+ this.parameterFileName = parameterFileName;
+ }
+
+ @AfterEach
+ protected void tearDown() throws Exception {
+ if (this.container != null) {
+ this.container.dispose();
+ }
+ this.container = null;
+ }
+
+ /**
+ * Gets the configuration file name for the container should use for this test.
+ *
+ * @return The filename of the configuration file
+ */
+ protected String getConfigurationFileName() {
+ return this.configurationFileName;
+ }
+
+ /**
+ * Gets the role file name for the container should use for this test.
+ *
+ * @return The filename of the role configuration file
+ */
+ protected String getRoleFileName() {
+ return this.roleFileName;
+ }
+
+ /**
+ * Gets the parameter file name for the container should use for this test.
+ *
+ * @return The filename of the parameter file
+ */
+ protected String getParameterFileName() {
+ return this.parameterFileName;
+ }
+
+ /**
+ * Returns an instance of the named component. Starts the container if it hasn't
+ * been started.
+ *
+ * @param roleName Name of the role the component fills.
+ * @return Object representing the named component
+ * @throws ComponentException if the component is not found
+ */
+ protected Object lookup(String roleName) throws ComponentException {
+ if (this.container == null) {
+ this.container = new Container();
+ this.container.startup(getConfigurationFileName(), getRoleFileName(), getParameterFileName());
+ }
+ return this.container.lookup(roleName);
+ }
+
+ /**
+ * Releases the component
+ *
+ * @param component the component to be released
+ */
+ protected void release(Component component) {
+ if (this.container != null) {
+ this.container.release(component);
+ }
+ }
+
+ /**
+ * Releases the component
+ *
+ * @param component the component to be released
+ */
+ protected void release(Object component) {
+ if (this.container != null) {
+ this.container.release(component);
+ }
+ }
+
+ /**
+ * Decommision the service
+ *
+ * @param name the name of the service
+ * @throws ServiceException if the service is not found
+ */
+ protected void decommision(String name) throws ServiceException {
+ if (this.container != null) {
+ this.container.decommission(name);
+ }
+ }
+}