Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Junit4 annotations #55

Merged
merged 4 commits into from Dec 21, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/test/java/org/codehaus/plexus/util/CollectionUtilsTest.java
Expand Up @@ -16,17 +16,21 @@
* limitations under the License.
*/

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

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

public class CollectionUtilsTest
extends TestCase
{
@Test
public void testMergeMaps()
{
Map<String, String> dominantMap = new HashMap<String, String>();
Expand Down Expand Up @@ -63,6 +67,7 @@ public void testMergeMaps()
}

@SuppressWarnings( "unchecked" )
@Test
public void testMergeMapArray()
{
// Test empty array of Maps
Expand Down Expand Up @@ -114,6 +119,7 @@ public void testMergeMapArray()
assertEquals( "ccc", result5.get( "c" ) );
}

@Test
public void testMavenPropertiesLoading()
{
// Mimic MavenSession properties loading. Properties listed
Expand Down Expand Up @@ -170,6 +176,7 @@ public void testMavenPropertiesLoading()
assertEquals( mavenRepoRemote, (String) result.get( "maven.repo.remote" ) );
}

@Test
public void testIteratorToListWithAPopulatedList()
{
List<String> original = new ArrayList<String>();
Expand All @@ -189,6 +196,7 @@ public void testIteratorToListWithAPopulatedList()
assertEquals( "tre", copy.get( 2 ) );
}

@Test
public void testIteratorToListWithAEmptyList()
{
List<String> original = new ArrayList<String>();
Expand Down
21 changes: 21 additions & 0 deletions src/test/java/org/codehaus/plexus/util/DirectoryScannerTest.java
Expand Up @@ -16,6 +16,11 @@
* limitations under the License.
*/

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.File;
import java.io.IOException;
import java.net.URI;
Expand All @@ -25,6 +30,8 @@
import java.util.Arrays;
import java.util.List;

import org.junit.Test;

/**
* Base class for testcases doing tests with files.
*
Expand All @@ -35,6 +42,7 @@ public class DirectoryScannerTest
{
private static String testDir = getTestDirectory().getPath();

@Test
public void testCrossPlatformIncludesString()
throws IOException, URISyntaxException
{
Expand All @@ -59,6 +67,7 @@ public void testCrossPlatformIncludesString()
assertEquals( 1, files.length );
}

@Test
public void testCrossPlatformExcludesString()
throws IOException, URISyntaxException
{
Expand Down Expand Up @@ -110,6 +119,7 @@ private void createTestFiles()
this.createFile( new File( testDir + "/scanner5.dat" ), 0 );
}

@Test
public void testGeneral()
throws IOException
{
Expand All @@ -127,6 +137,7 @@ public void testGeneral()

}

@Test
public void testIncludesExcludesWithWhiteSpaces()
throws IOException
{
Expand All @@ -144,6 +155,7 @@ public void testIncludesExcludesWithWhiteSpaces()
assertTrue( "5 not found.", fileNames.contains( new File( "scanner5.dat" ) ) );
}

@Test
public void testFollowSymlinksFalse()
{
DirectoryScanner ds = new DirectoryScanner();
Expand Down Expand Up @@ -175,6 +187,7 @@ private void assertAlwaysIncluded( List<String> included )
assertTrue( included.contains( "symLinkToFileOnTheOutside" ) );
}

@Test
public void testFollowSymlinks()
{
DirectoryScanner ds = new DirectoryScanner();
Expand Down Expand Up @@ -211,6 +224,7 @@ private void createTestDirectories()
+ File.separator + "file1.dat" ), 0 );
}

@Test
public void testDirectoriesWithHyphens()
throws IOException
{
Expand All @@ -229,6 +243,7 @@ public void testDirectoriesWithHyphens()
assertEquals( "Wrong number of results.", 3, files.length );
}

@Test
public void testAntExcludesOverrideIncludes()
throws IOException
{
Expand Down Expand Up @@ -263,6 +278,7 @@ public void testAntExcludesOverrideIncludes()
assertInclusionsAndExclusions( ds.getIncludedFiles(), excludedPaths, includedPaths );
}

@Test
public void testAntExcludesOverrideIncludesWithExplicitAntPrefix()
throws IOException
{
Expand Down Expand Up @@ -298,6 +314,7 @@ public void testAntExcludesOverrideIncludesWithExplicitAntPrefix()
assertInclusionsAndExclusions( ds.getIncludedFiles(), excludedPaths, includedPaths );
}

@Test
public void testRegexIncludeWithExcludedPrefixDirs()
throws IOException
{
Expand Down Expand Up @@ -328,6 +345,7 @@ public void testRegexIncludeWithExcludedPrefixDirs()
assertInclusionsAndExclusions( ds.getIncludedFiles(), excludedPaths, includedPaths );
}

@Test
public void testRegexExcludeWithNegativeLookahead()
throws IOException
{
Expand Down Expand Up @@ -366,6 +384,7 @@ public void testRegexExcludeWithNegativeLookahead()
assertInclusionsAndExclusions( ds.getIncludedFiles(), excludedPaths, includedPaths );
}

@Test
public void testRegexWithSlashInsideCharacterClass()
throws IOException
{
Expand Down Expand Up @@ -405,6 +424,7 @@ public void testRegexWithSlashInsideCharacterClass()
assertInclusionsAndExclusions( ds.getIncludedFiles(), excludedPaths, includedPaths );
}

@Test
public void testIsSymbolicLink()
throws IOException
{
Expand All @@ -422,6 +442,7 @@ public void testIsSymbolicLink()
assertFalse( ds.isSymbolicLink( directory, "aRegularDir" ) );
}

@Test
public void testIsParentSymbolicLink()
throws IOException
{
Expand Down
Expand Up @@ -16,13 +16,17 @@
* limitations under the License.
*/

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.io.File;

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

public class DirectoryWalkerTest
extends TestCase
{
@Test
public void testDirectoryWalk()
{
DirectoryWalker walker = new DirectoryWalker();
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/codehaus/plexus/util/FileBasedTestCase.java
Expand Up @@ -16,6 +16,8 @@
* limitations under the License.
*/

import static org.junit.Assert.assertTrue;

import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
Expand All @@ -30,15 +32,13 @@
import java.util.Arrays;

import junit.framework.AssertionFailedError;
import junit.framework.TestCase;

/**
* Base class for testcases doing tests with files.
*
* @author Jeremias Maerki
*/
public abstract class FileBasedTestCase
extends TestCase
{
private static File testDir;

Expand Down