/*
 * Copyright 2014 NAVER Corp.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.navercorp.pinpoint.bootstrap.util;

import com.navercorp.pinpoint.common.Version;

import org.junit.Assert;
import org.junit.Test;

/**
 * @author emeroad
 */
public class AntPathMatcherTest {
    @Test
    public void isAntStyle() {
        Assert.assertTrue(AntPathMatcher.isAntStylePattern("/*/test"));
        Assert.assertTrue(AntPathMatcher.isAntStylePattern("/*/?"));
        Assert.assertTrue(AntPathMatcher.isAntStylePattern("*.test"));
        Assert.assertTrue(AntPathMatcher.isAntStylePattern("*.?"));

        Assert.assertFalse(AntPathMatcher.isAntStylePattern("/abc/test"));
        Assert.assertFalse(AntPathMatcher.isAntStylePattern("abc.test"));
    }

    @Test
    public void isMatched() {

        AntPathMatcher matcher = new AntPathMatcher("/test/?bc");
        Assert.assertTrue(matcher.isMatched("/test/abc"));

        Assert.assertFalse(matcher.isMatched("/test/axx"));


        Assert.assertFalse(matcher.isMatched(null));
        Assert.assertFalse(matcher.isMatched(""));
        Assert.assertFalse(matcher.isMatched("test"));
    }

    @Test
    public void  asteriskTest() {
        String linuxPath = "/home/.m2/repository/pinpoint-mssql-jdbc-driver-plugin/2.3.1-SNAPSHOT/pinpoint-mssql-jdbc-driver-plugin-2.3.1-SNAPSHOT.jar";
        String windowsPath = "C:\\.m2\\repository\\pinpoint-mssql-jdbc-driver-plugin\\2.3.1-SNAPSHOT\\pinpoint-mssql-jdbc-driver-plugin-2.3.1-SNAPSHOT.jar";

        AntPathMatcher linuxMatcher = new AntPathMatcher("/**/pinpoint-*-plugin-" + Version.VERSION + ".jar");
        Assert.assertTrue(linuxMatcher.isMatched(linuxPath));
        Assert.assertFalse(linuxMatcher.isMatched(windowsPath));

        AntPathMatcher windowsMatcher = new AntPathMatcher("**\\pinpoint-*-plugin-" + Version.VERSION + ".jar");
        Assert.assertFalse(windowsMatcher.isMatched(linuxPath));
        Assert.assertTrue(windowsMatcher.isMatched(windowsPath));
    }


    @Test
    public void isMatchedDotSeparator() {
        final String pathSeparator = ".";
        AntPathMatcher matcher = new AntPathMatcher("test.?bc", pathSeparator);
        Assert.assertTrue(matcher.isMatched("test.abc"));

        Assert.assertFalse(matcher.isMatched("test.axx"));


        Assert.assertFalse(matcher.isMatched(null));
        Assert.assertFalse(matcher.isMatched(""));
        Assert.assertFalse(matcher.isMatched("test"));
    }

}
@@ -1693,17 +1693,16 @@
 ic void 
- 
 asterisk
@@ -1706,24 +1706,67 @@
 iskTest() %7B%0A
+        String version = Version.VERSION;%0A%0A
         Stri
@@ -1836,30 +1836,31 @@
 -plugin/
-2.3.1-SNAPSHOT
+%22 + version + %22
 /pinpoin
@@ -1882,38 +1882,39 @@
 iver-plugin-
-2.3.1-SNAPSHOT
+%22 + version + %22
 .jar%22;%0A     
@@ -1994,30 +1994,31 @@
 plugin%5C%5C
-2.3.1-SNAPSHOT
+%22 + version + %22
 %5C%5Cpinpoi
@@ -2049,22 +2049,23 @@
 gin-
-2.3.1-SNAPSHOT
+%22 + version + %22
 .jar
@@ -2148,39 +2148,31 @@
 -plugin-%22 + 
-V
+v
 ersion
-.VERSION
  + %22.jar%22);%0A
@@ -2385,31 +2385,23 @@
 gin-%22 + 
-V
+v
 ersion
-.VERSION
  + %22.jar

Fix test