001package org.andromda.core.common;
002
003import junit.framework.TestCase;
004
005/**
006 * JUnit tests for {@link org.andromda.core.common}
007 *
008 * @author Chad Brandon
009 */
010public class PathMatcherTest
011    extends TestCase
012{
013    /**
014     *
015     */
016    public void testWildcardMatch()
017    {
018        String path = "org/andromda/some/file/Test.java";
019        assertTrue(PathMatcher.wildcardMatch(path, "**/*.java"));
020        assertFalse(PathMatcher.wildcardMatch(path, "*.java"));
021        assertTrue(PathMatcher.wildcardMatch(path, "*/*/*/*/*.java"));
022        assertFalse(PathMatcher.wildcardMatch(path, "*/*/*.java"));
023        assertTrue(PathMatcher.wildcardMatch(path, "**/*Test.java"));
024        assertTrue(PathMatcher.wildcardMatch(path, "**/*Tes*.java"));
025        assertFalse(PathMatcher.wildcardMatch(path, "**/*TestFile*.java"));
026        assertFalse(PathMatcher.wildcardMatch(path, "**/.java"));
027        assertTrue(PathMatcher.wildcardMatch(path, "org/andromda/**/*"));
028
029        path = "Test.java";
030        assertTrue(PathMatcher.wildcardMatch(path, "*.java"));
031        assertTrue(PathMatcher.wildcardMatch(path, "**/*.java"));
032        assertTrue(PathMatcher.wildcardMatch(path, "**/*"));
033
034        assertTrue(PathMatcher.wildcardMatch(path, "*.java"));
035        assertTrue(PathMatcher.wildcardMatch(path, "**.java"));
036        assertTrue(PathMatcher.wildcardMatch(path, "**/*"));
037        assertFalse(PathMatcher.wildcardMatch(path, "***/*.java"));
038
039        path = "org/Test.java";
040        assertFalse(PathMatcher.wildcardMatch(path, "*.java"));
041        assertTrue(PathMatcher.wildcardMatch(path, "**/*"));
042    }
043}