Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions modello-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,21 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-testing</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<reporting>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@

import org.codehaus.plexus.util.xml.Xpp3Dom;

import junit.framework.TestCase;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;

public class CloneTest
extends TestCase
{

@Test
public void testNullSafe()
throws Exception
{
Expand All @@ -20,7 +24,7 @@ public void testNullSafe()
assertNotNull( copy );
assertNotSame( orig, copy );
}

@Test
public void testClone()
throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@

import org.codehaus.plexus.util.xml.Xpp3Dom;

import junit.framework.TestCase;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;

public class CloneTest
extends TestCase
{

@Test
public void testNullSafe()
throws Exception
{
Expand All @@ -20,7 +24,7 @@ public void testNullSafe()
assertNotNull( copy );
assertNotSame( orig, copy );
}

@Test
public void testClone()
throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,44 @@
* SOFTWARE.
*/

import javax.inject.Inject;

import java.io.File;
import java.util.Arrays;

import org.apache.maven.project.MavenProject;
import org.codehaus.modello.core.ModelloCore;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.build.BuildContext;
import org.codehaus.plexus.testing.PlexusExtension;
import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.testing.PlexusTestConfiguration;
import org.codehaus.plexus.util.FileUtils;
import org.junit.jupiter.api.Test;

import static org.codehaus.plexus.testing.PlexusExtension.getTestFile;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* @author <a href="mailto:[email protected]">Brett Porter</a>
*/
public class ModelloConvertersMojoTest extends PlexusTestCase {
public void testModelloConvertersMojo() throws Exception {
ModelloCore modelloCore = (ModelloCore) lookup(ModelloCore.ROLE);
@PlexusTest
public class ModelloConvertersMojoTest implements PlexusTestConfiguration {

@Inject
private ModelloCore modelloCore;

BuildContext buildContext = (BuildContext) lookup(BuildContext.class);
@Inject
private BuildContext buildContext;

@Override
public void customizeConfiguration(ContainerConfiguration containerConfiguration) {
containerConfiguration.setClassPathScanning("cache");
}

@Test
public void testModelloConvertersMojo() throws Exception {
ModelloConvertersMojo mojo = new ModelloConvertersMojo();

File outputDirectory = getTestFile("target/converters-test");
Expand All @@ -54,7 +73,7 @@ public void testModelloConvertersMojo() throws Exception {
mojo.setOutputDirectory(outputDirectory);

String models[] = new String[1];
models[0] = getTestPath("src/test/resources/java-model.mdo");
models[0] = PlexusExtension.getTestPath("src/test/resources/java-model.mdo");
mojo.setModels(models);

mojo.setVersion("1.0.0");
Expand All @@ -78,33 +97,28 @@ public void testModelloConvertersMojo() throws Exception {
File javaFile =
new File(outputDirectory, "org/codehaus/mojo/modello/javatest/v1_0_0/convert/VersionConverter.java");

assertTrue("The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.", javaFile.exists());
assertTrue(javaFile.exists(), "The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.");

javaFile = new File(
outputDirectory, "org/codehaus/mojo/modello/javatest/v1_0_0/convert/BasicVersionConverter.java");

assertTrue("The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.", javaFile.exists());
assertTrue(javaFile.exists(), "The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.");

javaFile = new File(outputDirectory, "org/codehaus/mojo/modello/javatest/v0_9_0/convert/VersionConverter.java");

assertTrue("The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.", javaFile.exists());
assertTrue(javaFile.exists(), "The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.");

javaFile = new File(
outputDirectory, "org/codehaus/mojo/modello/javatest/v0_9_0/convert/BasicVersionConverter.java");

assertTrue("The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.", javaFile.exists());
assertTrue(javaFile.exists(), "The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.");

javaFile = new File(outputDirectory, "org/codehaus/mojo/modello/javatest/convert/VersionConverter.java");

assertFalse("The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.", javaFile.exists());
assertFalse(javaFile.exists(), "The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.");

javaFile = new File(outputDirectory, "org/codehaus/mojo/modello/javatest/convert/BasicVersionConverter.java");

assertFalse("The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.", javaFile.exists());
}

@Override
protected void customizeContainerConfiguration(ContainerConfiguration containerConfiguration) {
containerConfiguration.setClassPathScanning("cache");
assertFalse(javaFile.exists(), "The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,38 @@
* SOFTWARE.
*/

import javax.inject.Inject;

import java.io.File;
import java.util.Arrays;

import org.apache.maven.project.MavenProject;
import org.codehaus.modello.core.ModelloCore;
import org.codehaus.plexus.ContainerConfiguration;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.build.BuildContext;
import org.codehaus.plexus.testing.PlexusTest;
import org.codehaus.plexus.testing.PlexusTestConfiguration;
import org.codehaus.plexus.util.FileUtils;
import org.junit.jupiter.api.Test;

import static org.codehaus.plexus.testing.PlexusExtension.getTestFile;
import static org.codehaus.plexus.testing.PlexusExtension.getTestPath;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* @author <a href="mailto:[email protected]">Trygve Laugst&oslash;l</a>
*/
public class ModelloJavaMojoTest extends PlexusTestCase {
public void testModelloJavaMojo() throws Exception {
ModelloCore modelloCore = (ModelloCore) lookup(ModelloCore.ROLE);
@PlexusTest
public class ModelloJavaMojoTest implements PlexusTestConfiguration {
@Inject
private BuildContext buildContext;

BuildContext buildContext = (BuildContext) lookup(BuildContext.class);
@Inject
private ModelloCore modelloCore;

@Test
public void testModelloJavaMojo() throws Exception {

ModelloJavaMojo mojo = new ModelloJavaMojo();

Expand Down Expand Up @@ -76,32 +90,32 @@ public void testModelloJavaMojo() throws Exception {

File javaFile = new File(outputDirectory, "org/codehaus/mojo/modello/javatest/Model.java");

assertTrue("The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.", javaFile.exists());
assertTrue(javaFile.exists(), "The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.");

javaFile = new File(outputDirectory, "org/codehaus/mojo/modello/javatest/NewModel.java");

assertTrue("The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.", javaFile.exists());
assertTrue(javaFile.exists(), "The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.");

javaFile = new File(outputDirectory, "org/codehaus/mojo/modello/javatest/v1_0_0/Model.java");

assertTrue("The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.", javaFile.exists());
assertTrue(javaFile.exists(), "The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.");

javaFile = new File(outputDirectory, "org/codehaus/mojo/modello/javatest/v1_0_0/NewModel.java");

assertTrue("The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.", javaFile.exists());
assertTrue(javaFile.exists(), "The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.");

javaFile = new File(outputDirectory, "org/codehaus/mojo/modello/javatest/v0_9_0/Model.java");

assertTrue("The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.", javaFile.exists());
assertTrue(javaFile.exists(), "The generated java file doesn't exist: '" + javaFile.getAbsolutePath() + "'.");

javaFile = new File(outputDirectory, "org/codehaus/mojo/modello/javatest/v0_9_0/NewModel.java");

assertFalse(
"The generated java file shouldn't exist: '" + javaFile.getAbsolutePath() + "'.", javaFile.exists());
javaFile.exists(), "The generated java file shouldn't exist: '" + javaFile.getAbsolutePath() + "'.");
}

@Override
protected void customizeContainerConfiguration(ContainerConfiguration containerConfiguration) {
public void customizeConfiguration(ContainerConfiguration containerConfiguration) {
containerConfiguration.setClassPathScanning("cache");
}
}
6 changes: 6 additions & 0 deletions modello-plugins/modello-plugin-converters/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
<version>7.1.1</version>
<scope>test</scope>
</dependency>
<!-- needed for modello compiler test(inside)-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* SOFTWARE.
*/

import javax.inject.Inject;

import java.io.Reader;
import java.util.HashMap;
import java.util.Map;
Expand All @@ -31,14 +33,22 @@
import org.codehaus.modello.ModelloParameterConstants;
import org.codehaus.modello.core.ModelloCore;
import org.codehaus.modello.model.Model;
import org.codehaus.plexus.testing.PlexusTest;
import org.junit.jupiter.api.Test;

/**
*/
@PlexusTest
public class ConverterGeneratorTest extends AbstractModelloJavaGeneratorTest {

@Inject
private ModelloCore modello;

public ConverterGeneratorTest() {
super("converters");
}

@Test
public void testConverterGenerator() throws Throwable {
generateConverterClasses(getXmlResourceReader("/models/maven.mdo"), "3.0.0", "4.0.0");

Expand All @@ -53,8 +63,6 @@ public void testConverterGenerator() throws Throwable {
}

private void generateConverterClasses(Reader modelReader, String fromVersion, String toVersion) throws Throwable {
ModelloCore modello = (ModelloCore) lookup(ModelloCore.ROLE);

Model model = modello.loadModel(modelReader);

Map<String, Object> parameters = new HashMap<>();
Expand Down
6 changes: 6 additions & 0 deletions modello-plugins/modello-plugin-dom4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
<artifactId>xmlunit-core</artifactId>
<scope>test</scope>
</dependency>
<!-- needed for modello compiler test(inside)-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* SOFTWARE.
*/

import javax.inject.Inject;

import java.util.List;
import java.util.Map;

Expand All @@ -32,20 +34,27 @@
import org.codehaus.modello.model.ModelField;
import org.codehaus.modello.model.Version;
import org.codehaus.modello.plugins.xml.metadata.XmlFieldMetadata;
import org.codehaus.plexus.testing.PlexusTest;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

/**
* Test the generators.
*
* @author <a href="mailto:[email protected]">Brett Porter</a>
*/
@PlexusTest
public class Dom4jGeneratorTest extends AbstractModelloJavaGeneratorTest {
@Inject
private ModelloCore modello;

public Dom4jGeneratorTest() {
super("dom4j");
}

@Test
public void testDom4jGenerator() throws Throwable {
ModelloCore modello = (ModelloCore) lookup(ModelloCore.ROLE);

Model model = modello.loadModel(getXmlResourceReader("/maven.mdo"));

List<ModelClass> classesList = model.getClasses(new Version("4.0.0"));
Expand Down
Loading