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
5 changes: 0 additions & 5 deletions plexus-compiler-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,5 @@
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class CompilerConfigurationTest {
private CompilerConfiguration configuration;
Expand All @@ -22,21 +21,21 @@ public void testCustomArguments() {
configuration.addCompilerCustomArgument("--add-exports", "FROM-MOD/package1=OTHER-MOD");
configuration.addCompilerCustomArgument("--add-exports", "FROM-MOD/package2=OTHER-MOD");

assertThat(configuration.getCustomCompilerArgumentsAsMap().size(), is(1));
assertThat(
configuration.getCustomCompilerArgumentsAsMap().get("--add-exports"),
is("FROM-MOD/package2=OTHER-MOD"));
assertEquals(1, configuration.getCustomCompilerArgumentsAsMap().size());
assertEquals(
"FROM-MOD/package2=OTHER-MOD",
configuration.getCustomCompilerArgumentsAsMap().get("--add-exports"));

assertThat(configuration.getCustomCompilerArgumentsEntries().size(), is(2));
assertEquals(2, configuration.getCustomCompilerArgumentsEntries().size());
Iterator<Map.Entry<String, String>> entries =
configuration.getCustomCompilerArgumentsEntries().iterator();
Map.Entry<String, String> entry;

entry = entries.next();
assertThat(entry.getKey(), is("--add-exports"));
assertThat(entry.getValue(), is("FROM-MOD/package1=OTHER-MOD"));
assertEquals("--add-exports", entry.getKey());
assertEquals("FROM-MOD/package1=OTHER-MOD", entry.getValue());
entry = entries.next();
assertThat(entry.getKey(), is("--add-exports"));
assertThat(entry.getValue(), is("FROM-MOD/package2=OTHER-MOD"));
assertEquals("--add-exports", entry.getKey());
assertEquals("FROM-MOD/package2=OTHER-MOD", entry.getValue());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@
import org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping;
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.io.FileMatchers.anExistingFile;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Tests for all the implementations of <code>SourceInclusionScanner</code>
Expand Down Expand Up @@ -59,10 +57,10 @@ public void testGetIncludedSources() throws Exception {

Set<File> includedSources = scanner.getIncludedSources(base, base);

assertThat("no sources were included", includedSources, not(empty()));
assertFalse(includedSources.isEmpty(), "no sources were included");

for (File file : includedSources) {
assertThat("file included does not exist", file, anExistingFile());
assertTrue(file.exists(), "file included does not exist");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,11 @@
import org.codehaus.plexus.compiler.util.scan.mapping.SingleTargetSourceMapping;
import org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping;
import org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* @author jdcasey
Expand Down Expand Up @@ -68,9 +64,9 @@ public void testWithDefaultConstructorShouldFindOneStaleSource() throws Exceptio

Set<File> result = scanner.getIncludedSources(base, base);

assertThat("wrong number of stale sources returned.", result.size(), is(1));
assertEquals(1, result.size(), "wrong number of stale sources returned.");

assertThat("expected stale source file not found in result", result, Matchers.contains(sourceFile));
assertTrue(result.contains(sourceFile), "expected stale source file not found in result");
}

@Test
Expand All @@ -97,9 +93,9 @@ public void testWithDefaultConstructorShouldNotFindStaleSources() throws Excepti

Set<File> result = scanner.getIncludedSources(base, base);

assertThat("wrong number of stale sources returned.", result.size(), is(0));
assertEquals(0, result.size(), "wrong number of stale sources returned.");

assertThat("expected stale source file not found in result", result, empty());
assertTrue(result.isEmpty(), "expected stale source file not found in result");
}

@Test
Expand All @@ -116,9 +112,9 @@ public void testWithDefaultConstructorShouldFindStaleSourcesBecauseOfMissingTarg

Set<File> result = scanner.getIncludedSources(base, base);

assertThat("wrong number of stale sources returned.", result.size(), is(1));
assertEquals(1, result.size(), "wrong number of stale sources returned.");

assertThat("expected stale source file not found in result", result, contains(sourceFile));
assertTrue(result.contains(sourceFile), "expected stale source file not found in result");
}

@Test
Expand Down Expand Up @@ -150,10 +146,12 @@ public void testWithDefaultConstructorShouldFindStaleSourcesOneBecauseOfMissingT

Set<File> result = scanner.getIncludedSources(base, base);

assertThat("wrong number of stale sources returned.", result.size(), is(2));
assertEquals(2, result.size(), "wrong number of stale sources returned.");

assertThat(
"expected stale source file not found in result", result, containsInAnyOrder(sourceFile, sourceFile2));
assertEquals(2, result.size());
assertTrue(
result.contains(sourceFile) && result.contains(sourceFile2),
"expected stale source file not found in result");
}

@Test
Expand Down Expand Up @@ -203,9 +201,9 @@ public void testWithDefaultConstructorShouldFindOneStaleSourcesWithStaleTargetAn

Set<File> result = scanner.getIncludedSources(base, base);

assertThat("wrong number of stale sources returned.", result.size(), is(1));
assertEquals(1, result.size(), "wrong number of stale sources returned.");

assertThat("expected stale source file not found in result", result, contains(sourceFile));
assertTrue(result.contains(sourceFile), "expected stale source file not found in result");
}

@Test
Expand Down Expand Up @@ -249,9 +247,9 @@ public void testConstructedWithMsecsShouldReturnOneSourceFileOfTwoDueToLastMod()

Set<File> result = scanner.getIncludedSources(base, base);

assertThat("wrong number of stale sources returned.", result.size(), is(1));
assertEquals(1, result.size(), "wrong number of stale sources returned.");

assertThat("expected stale source file not found in result", result, contains(sourceFile2));
assertTrue(result.contains(sourceFile2), "expected stale source file not found in result");
}

@Test
Expand Down Expand Up @@ -309,9 +307,9 @@ public void testConstructedWithMsecsIncludesAndExcludesShouldReturnOneSourceFile

Set<File> result = scanner.getIncludedSources(base, base);

assertThat("wrong number of stale sources returned.", result.size(), is(1));
assertEquals(1, result.size(), "wrong number of stale sources returned.");

assertThat("expected stale source file not found in result", result, contains(sourceFile3));
assertTrue(result.contains(sourceFile3), "expected stale source file not found in result");
}

@Test
Expand Down Expand Up @@ -369,10 +367,12 @@ public void testConstructedWithMsecsIncludesAndExcludesShouldReturnTwoSourceFile

Set<File> result = scanner.getIncludedSources(base, base);

assertThat("wrong number of stale sources returned.", result.size(), is(2));
assertEquals(2, result.size(), "wrong number of stale sources returned.");

assertThat(
"expected stale source file not found in result", result, containsInAnyOrder(sourceFile2, sourceFile3));
assertEquals(2, result.size());
assertTrue(
result.contains(sourceFile2) && result.contains(sourceFile3),
"expected stale source file not found in result");
}

@Test
Expand Down Expand Up @@ -401,9 +401,9 @@ public void testSingleFileSourceMapping() throws Exception {

Set<File> result = scanner.getIncludedSources(src, target);

assertThat(result.size(), is(1));
assertEquals(1, result.size());

assertThat(result, contains(fooCs));
assertTrue(result.contains(fooCs));

// ----------------------------------------------------------------------
// Add another source file
Expand All @@ -417,9 +417,10 @@ public void testSingleFileSourceMapping() throws Exception {

result = scanner.getIncludedSources(src, target);

assertThat(result.size(), is(2));
assertEquals(2, result.size());

assertThat(result, containsInAnyOrder(fooCs, barCs));
assertEquals(2, result.size());
assertTrue(result.contains(fooCs) && result.contains(barCs));

// ----------------------------------------------------------------------
// Now add the result file
Expand All @@ -433,7 +434,7 @@ public void testSingleFileSourceMapping() throws Exception {

result = scanner.getIncludedSources(src, target);

assertThat(result, empty());
assertTrue(result.isEmpty());

// ----------------------------------------------------------------------
// Make Application.exe older than the Foo.cs
Expand All @@ -443,8 +444,8 @@ public void testSingleFileSourceMapping() throws Exception {

result = scanner.getIncludedSources(src, target);

assertThat(result.size(), is(1));
assertEquals(1, result.size());

assertThat(result, contains(fooCs));
assertTrue(result.contains(fooCs));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@

import org.junit.jupiter.api.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* @author jdcasey
Expand All @@ -42,9 +40,9 @@ public void testShouldReturnSingleClassFileForSingleJavaFile() {

Set<File> results = mapping.getTargetFiles(basedir, base + ".java");

assertThat("Returned wrong number of target files.", results.size(), is(1));
assertEquals(1, results.size(), "Returned wrong number of target files.");

assertThat("Target file is wrong.", results.iterator().next(), is(new File(basedir, base + ".class")));
assertEquals(new File(basedir, base + ".class"), results.iterator().next(), "Target file is wrong.");
}

@Test
Expand All @@ -57,7 +55,7 @@ public void testShouldNotReturnClassFileWhenSourceFileHasWrongSuffix() {

Set<File> results = mapping.getTargetFiles(basedir, base + ".xml");

assertThat("Returned wrong number of target files.", results, empty());
assertTrue(results.isEmpty(), "Returned wrong number of target files.");
}

@Test
Expand All @@ -74,12 +72,11 @@ public void testShouldReturnOneClassFileAndOneXmlFileForSingleJavaFile() {

Set<File> results = mapping.getTargetFiles(basedir, base + ".java");

assertThat("Returned wrong number of target files.", results.size(), is(2));
assertEquals(2, results.size(), "Returned wrong number of target files.");

assertThat(
"Targets do not contain class target.",
results,
containsInAnyOrder(new File(basedir, base + ".class"), new File(basedir, base + ".xml")));
assertEquals(2, results.size());
assertTrue(results.contains(new File(basedir, base + ".class")), "Targets do not contain class target.");
assertTrue(results.contains(new File(basedir, base + ".xml")), "Targets do not contain xml target.");
}

@Test
Expand All @@ -96,7 +93,7 @@ public void testShouldReturnNoTargetFilesWhenSourceFileHasWrongSuffix() {

Set<File> results = mapping.getTargetFiles(basedir, base + ".apt");

assertThat("Returned wrong number of target files.", results, empty());
assertTrue(results.isEmpty(), "Returned wrong number of target files.");
}

@Test
Expand All @@ -109,10 +106,10 @@ public void testSingleTargetMapper() throws Exception {

Set<File> results = mapping.getTargetFiles(basedir, base + ".apt");

assertThat(results, empty());
assertTrue(results.isEmpty());

results = mapping.getTargetFiles(basedir, base + ".cs");

assertThat(results.size(), is(1));
assertEquals(1, results.size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@
import javax.inject.Inject;

import org.codehaus.plexus.testing.PlexusTest;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

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

/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
*/
Expand All @@ -38,7 +39,7 @@ public class CompilerManagerTest {
private CompilerManager compilerManager;

@Test
public void testBasic() throws Exception {
Assertions.assertThrows(NoSuchCompilerException.class, () -> compilerManager.getCompiler("foo"));
public void testBasic() {
assertThrows(NoSuchCompilerException.class, () -> compilerManager.getCompiler("foo"));
}
}
5 changes: 0 additions & 5 deletions plexus-compiler-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@
<artifactId>plexus-testing</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
Expand Down
Loading