Skip to content

Commit

Permalink
CARGO-1634 (Upgrade to JUnit 5.x): cargo-sample-java done, let's give…
Browse files Browse the repository at this point in the history
… it to the CI
  • Loading branch information
alitokmen committed Jan 20, 2025
1 parent f02e804 commit 457efd0
Show file tree
Hide file tree
Showing 61 changed files with 1,010 additions and 4,141 deletions.
5 changes: 3 additions & 2 deletions core/documentation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${cargo.archetypes-junit.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
import org.codehaus.cargo.generic.configuration.DefaultConfigurationFactory;
import org.codehaus.cargo.generic.deployer.DefaultDeployerFactory;
import org.codehaus.cargo.generic.deployer.DeployerFactory;
import org.codehaus.cargo.sample.java.CargoTestSuite;
import org.codehaus.cargo.sample.java.EnvironmentTestData;
import org.codehaus.cargo.sample.java.JmsQueueResourceOnStandaloneConfigurationTest;
import org.codehaus.cargo.sample.java.JmsTopicResourceOnStandaloneConfigurationTest;
Expand Down Expand Up @@ -367,67 +366,30 @@ public String generateDatasourceDocumentation() throws Exception
if (properties.keySet().contains(ResourcePropertySet.RESOURCE))
{
output.append("/)");
String containerId = System.getProperty(
CargoTestSuite.SYSTEM_PROPERTY_CONTAINER_IDS);
String deployables = System.getProperty("cargo.testdata.deployables");
String targetDir = System.getProperty("cargo.target.dir");
try
File dummy = new File(System.getProperty("java.io.tmpdir"), "cargo-dummy");
dummy.mkdirs();
dummy.deleteOnExit();
File dummyDeployables = new File(dummy, "deployables");
dummyDeployables.mkdirs();
dummyDeployables.deleteOnExit();
File dummyJakartaEeDeployables = new File(dummy, "deployables-jakarta-ee");
dummyJakartaEeDeployables.mkdirs();
dummyJakartaEeDeployables.deleteOnExit();

if (!new JmsQueueResourceOnStandaloneConfigurationTest().isSupported(
container.getId(), ContainerType.INSTALLED, null))
{
File dummy = new File(System.getProperty("java.io.tmpdir"), "cargo-dummy");
dummy.mkdirs();
dummy.deleteOnExit();
File dummyDeployables = new File(dummy, "deployables");
dummyDeployables.mkdirs();
dummyDeployables.deleteOnExit();
File dummyJakartaEeDeployables = new File(dummy, "deployables-jakarta-ee");
dummyJakartaEeDeployables.mkdirs();
dummyJakartaEeDeployables.deleteOnExit();

System.setProperty(
CargoTestSuite.SYSTEM_PROPERTY_CONTAINER_IDS, container.getId());
System.setProperty(
"cargo.testdata.deployables", dummyDeployables.getAbsolutePath());
System.setProperty("cargo.target.dir", System.getProperty("java.io.tmpdir"));
if (JmsQueueResourceOnStandaloneConfigurationTest.suite().countTestCases() == 0)
{
output.append("^Q^");
}
if (JmsTopicResourceOnStandaloneConfigurationTest.suite().countTestCases() == 0)
{
output.append("^T^");
}
if (MailResourceOnStandaloneConfigurationTest.suite().countTestCases() == 0)
{
output.append("^M^");
}
output.append("^Q^");
}
finally
if (!new JmsTopicResourceOnStandaloneConfigurationTest().isSupported(
container.getId(), ContainerType.INSTALLED, null))
{
if (containerId == null)
{
System.clearProperty(CargoTestSuite.SYSTEM_PROPERTY_CONTAINER_IDS);
}
else
{
System.setProperty(
CargoTestSuite.SYSTEM_PROPERTY_CONTAINER_IDS, containerId);
}
if (deployables == null)
{
System.clearProperty("cargo.testdata.deployables");
}
else
{
System.setProperty("cargo.testdata.deployables", deployables);
}
if (targetDir == null)
{
System.clearProperty("cargo.target.dir");
}
else
{
System.setProperty("cargo.target.dir", targetDir);
}
output.append("^T^");
}
if (!new MailResourceOnStandaloneConfigurationTest().isSupported(
container.getId(), ContainerType.INSTALLED, null))
{
output.append("^M^");
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import java.util.Map;
import java.util.Set;

import junit.framework.TestCase;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import org.codehaus.cargo.container.ContainerType;
import org.codehaus.cargo.generic.ContainerFactory;
Expand All @@ -34,17 +36,17 @@
/**
* Unit tests for {@link ConfluenceContainerDocumentationGenerator}
*/
public class ConfluenceContainerDocumentationGeneratorTest extends TestCase
public class ConfluenceContainerDocumentationGeneratorTest
{
/**
* Documentation generator.
*/
private ConfluenceContainerDocumentationGenerator generator;

/**
* {@inheritDoc}
* Creates the {@link ConfluenceProjectStructureDocumentationGenerator}
*/
@Override
@BeforeEach
protected void setUp() throws Exception
{
this.generator = new ConfluenceContainerDocumentationGenerator();
Expand All @@ -53,16 +55,18 @@ protected void setUp() throws Exception
/**
* Test computed qualified class name.
*/
@Test
public void testComputedFQCN()
{
assertEquals("o.c.c.c.myc.MyContainerIsTheBest",
Assertions.assertEquals("o.c.c.c.myc.MyContainerIsTheBest",
this.generator.computedFQCN("org.codehaus.cargo.container.myc.MyContainerIsTheBest"));
}

/**
* Generate datasource documentation.
* @throws Exception If anything goes wrong.
*/
@Test
public void testGenerateDatasourceDocumentation() throws Exception
{
try (Writer writer =
Expand All @@ -76,6 +80,7 @@ public void testGenerateDatasourceDocumentation() throws Exception
* Generate documentation for all containers.
* @throws Exception If anything goes wrong.
*/
@Test
public void testGenerateDocumentationForAllContainers() throws Exception
{
try (Writer writer =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,24 @@
import java.io.FileWriter;
import java.io.Writer;

import junit.framework.TestCase;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* Generates project structure documentation using ConfluenceProjectStructureDocumentationGenerator.
*/
public class ConfluenceProjectStructureDocumentationGeneratorTest extends TestCase
public class ConfluenceProjectStructureDocumentationGeneratorTest
{
/**
* The doc generator under test.
*/
private ConfluenceProjectStructureDocumentationGenerator generator;

/**
* {@inheritDoc}
* Creates the {@link ConfluenceProjectStructureDocumentationGenerator}
*/
@Override
@BeforeEach
protected void setUp()
{
this.generator = new ConfluenceProjectStructureDocumentationGenerator();
Expand All @@ -48,6 +50,7 @@ protected void setUp()
* Tests for the creation of the project structure markup.
* @throws Exception if something goes wrong with the markup generation.
*/
@Test
public void testDocGeneration() throws Exception
{
File projectStructureMarkup = new File(System.getProperty("basedir")
Expand All @@ -57,7 +60,7 @@ public void testDocGeneration() throws Exception
writer.write(this.generator.generateDocumentation());
}

assertTrue(projectStructureMarkup.exists());
Assertions.assertTrue(projectStructureMarkup.exists());
}

}
45 changes: 23 additions & 22 deletions core/samples/java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
<description>Sample application that exercises the Cargo Java API</description>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${cargo.archetypes-junit.version}</version>
</dependency>
</dependencies>
<build>
Expand All @@ -50,26 +51,26 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includeJUnit5Engines>
<engine>junit-jupiter</engine>
</includeJUnit5Engines>
<excludeJUnit5Engines>
<engine>junit-vintage</engine>
</excludeJUnit5Engines>
<!--
Show the CargoTestCase DisplayName, so that the XML test reports differentiate between
the containers and container types the test instances were run on
-->
<statelessTestsetReporter
implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5Xml30StatelessReporter">
<usePhrasedTestCaseMethodName>true</usePhrasedTestCaseMethodName>
</statelessTestsetReporter>
</configuration>
</plugin>
</plugins>
</build>
<!--
Re-running failing tests with the Maven Surefire plugin requires JUnit 4+.
-->
<profiles>
<profile>
<id>surefire.rerunFailingTestsCount</id>
<activation>
<property>
<name>surefire.rerunFailingTestsCount</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
Loading

0 comments on commit 457efd0

Please sign in to comment.