Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.uberfire.io.regex;
  
  import java.io.File;
  import java.net.URI;
  import java.util.HashMap;
 
 import org.junit.Test;
 import  org.uberfire.java.nio.file.FileSystems;
 import  org.uberfire.java.nio.file.Path;
 import  org.uberfire.java.nio.file.Paths;
 import  org.uberfire.java.nio.file.api.FileSystemProviders;
 import  org.uberfire.java.nio.fs.jgit.JGitFileSystemProvider;
 
 import static org.uberfire.io.regex.AntPathMatcher.*;
 
 public class AntPathMatcherTest {
 
     private static File path;
 
     @BeforeClass
     public static void setup() throws IOException {
          = CommonIOServiceDotFileTest.createTempDirectory();
 
         // XXX this is shaky at best: FileSystemProviders bootstraps the JGit FS in a static initializer.
         //     if anything has referenced it before now, setting this system property will have no effect.
         System.setProperty"org.uberfire.nio.git.dir".getAbsolutePath() );
         ..println".niogit: " + .getAbsolutePath() );
 
         final URI newRepo = URI.create"git://antpathmatcher" );
 
         FileSystems.newFileSystem( newReponew HashMap<StringObject>() );
     }
 
     @AfterClass
     public static void cleanup() {
         FileUtils.deleteQuietly );
         JGitFileSystemProvider gitFsProvider = (JGitFileSystemProvider) FileSystemProviders.resolveProvider( URI.create"git://whatever" ) );
         gitFsProvider.shutdown();
         FileUtils.deleteQuietlygitFsProvider.getGitRepoContainerDir() );
         gitFsProvider.rescanForExistingRepositories();
     }
 
     @Test
     public void testIncludes() {
         final Collection<Stringpatterns = new ArrayList<String>() {{
             add"git://**" );
             add"**/repo/**" );
         }};
 
         {
             final Path path = Paths.get( URI.create"file:///Users/home" ) );
             Assert.assertFalseincludespatternspath ) );
         }
 
         {
             final Path path = Paths.get( URI.create"git://antpathmatcher" ) );
             Assert.assertTrueincludespatternspath ) );
         }
 
         {
             final Path path = Paths.get( URI.create"git://master@antpathmatcher" ) );
             Assert.assertTrueincludespatternspath ) );
         }
     }
 
     @Test
     public void testIncludesMid() {
         final Collection<Stringpatterns = new ArrayList<String>() {{
             add"default://**" );
             add"**/repo/**" );
         }};
 
         {
             final Path path = Paths.get( URI.create"file:///Users/home" ) );
             Assert.assertTrueincludespatternspath ) );
         }
 
         {
             final Path path = Paths.get( URI.create"git://antpathmatcher" ) );
             Assert.assertFalseincludespatternspath ) );
         }
 
         {
             final Path path = Paths.get( URI.create"git://master@antpathmatcher/repo/sss" ) );
             Assert.assertTrueincludespatternspath ) );
         }
     }
 
     @Test
     public void testExcludes() {
        final Collection<Stringpatterns = new ArrayList<String>() {{
            add"git://**" );
            add"**/repo/**" );
        }};
        {
            final Path path = Paths.get( URI.create"file:///Users/home" ) );
            Assert.assertFalseexcludespatternspath ) );
        }
        {
            final Path path = Paths.get( URI.create"git://antpathmatcher" ) );
            Assert.assertTrueexcludespatternspath ) );
        }
        {
            final Path path = Paths.get( URI.create"git://master@antpathmatcher" ) );
            Assert.assertTrueexcludespatternspath ) );
        }
    }
    @Test
    public void testExcludesMid() {
        final Collection<Stringpatterns = new ArrayList<String>() {{
            add"default://**" );
            add"**/repo/**" );
        }};
        {
            final Path path = Paths.get( URI.create"file:///Users/home" ) );
            Assert.assertTrueexcludespatternspath ) );
        }
        {
            final Path path = Paths.get( URI.create"git://antpathmatcher" ) );
            Assert.assertFalseexcludespatternspath ) );
        }
        {
            final Path path = Paths.get( URI.create"git://master@antpathmatcher/repo/sss" ) );
            Assert.assertTrueexcludespatternspath ) );
        }
    }
    @Test
    public void testFilter() {
        final Collection<Stringincludes = new ArrayList<String>() {{
            add"git://**" );
        }};
        final Collection<Stringexcludes = new ArrayList<String>() {{
            add"default://**" );
        }};
        {
            final Path path = Paths.get( URI.create"file:///Users/home" ) );
            Assert.assertFalsefilterincludesexcludespath ) );
        }
        {
            final Path path = Paths.get( URI.create"git://antpathmatcher" ) );
            Assert.assertTruefilterincludesexcludespath ) );
        }
        {
            final Path path = Paths.get( URI.create"git://master@antpathmatcher/repo/sss" ) );
            Assert.assertTruefilterincludesexcludespath ) );
        }
        Assert.assertTruefilter( Collections.<String>emptyList(), Collections.<String>emptyList(), Paths.get( URI.create"git://master@antpathmatcher/repo/sss" ) ) ) );
        Assert.assertTruefilter( Collections.<String>emptyList(), Collections.<String>emptyList(), Paths.get( URI.create"git://antpathmatcher" ) ) ) );
    }
    @Test
    public void testIncludesUri() {
        final Collection<Stringpatterns = new ArrayList<String>() {{
            add"git://**" );
            add"**/repo/**" );
        }};
        Assert.assertFalseincludespatterns, URI.create"file:///Users/home" ) ) );
        Assert.assertTrueincludespatterns, URI.create"git://antpathmatcher" ) ) );
        Assert.assertTrueincludespatterns, URI.create"git://master@antpathmatcher" ) ) );
    }
    @Test
    public void testIncludesMidUri() {
        final Collection<Stringpatterns = new ArrayList<String>() {{
            add"file://**" );
            add"**/repo/**" );
        }};
        Assert.assertTrueincludespatterns, URI.create"file:///Users/home" ) ) );
        Assert.assertFalseincludespatterns, URI.create"git://antpathmatcher" ) ) );
        Assert.assertTrueincludespatterns, URI.create"git://master@antpathmatcher/repo/sss" ) ) );
    }
    @Test
    public void testExcludesUri() {
        final Collection<Stringpatterns = new ArrayList<String>() {{
            add"git://**" );
            add"**/repo/**" );
        }};
        Assert.assertFalseexcludespatterns, URI.create"file:///Users/home" ) ) );
        Assert.assertTrueexcludespatterns, URI.create"git://antpathmatcher" ) ) );
        Assert.assertTrueexcludespatterns, URI.create"git://master@antpathmatcher" ) ) );
    }
    @Test
    public void testExcludesMidUri() {
        final Collection<Stringpatterns = new ArrayList<String>() {{
            add"file://**" );
            add"**/repo/**" );
        }};
        Assert.assertTrueexcludespatterns, URI.create"file:///Users/home" ) ) );
        Assert.assertFalseexcludespatterns, URI.create"git://antpathmatcher" ) ) );
        Assert.assertTrueexcludespatterns, URI.create"git://master@antpathmatcher/repo/sss" ) ) );
    }
    @Test
    public void testFilterUri() {
        final Collection<Stringincludes = new ArrayList<String>() {{
            add"git://**" );
        }};
        final Collection<Stringexcludes = new ArrayList<String>() {{
            add"file://**" );
        }};
        Assert.assertFalsefilterincludesexcludes, URI.create"file:///Users/home" ) ) );
        Assert.assertTruefilterincludesexcludes, URI.create"git://antpathmatcher" ) ) );
        Assert.assertTruefilterincludesexcludes, URI.create"git://master@antpathmatcher/repo/sss" ) ) );
        Assert.assertTruefilter( Collections.<String>emptyList(), Collections.<String>emptyList(), URI.create"file:///Users/home" ) ) );
        Assert.assertTruefilter( Collections.<String>emptyList(), Collections.<String>emptyList(), URI.create"git://master@antpathmatcher/repo/sss" ) ) );
    }
New to GrepCode? Check out our FAQ X