1/**
2 * Copyright 2007 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.tonicsystems.jarjar;
18
19import junit.framework.*;
20
21public class WildcardTest
22extends TestCase
23{
24    public void testWildcards() {
25        wildcard("net/sf/cglib/**", "foo/@1", "net/sf/cglib/proxy/Mixin$Generator",
26            "foo/proxy/Mixin$Generator");
27        wildcard("net/sf/cglib/**", "foo/@1", "net/sf/cglib/Bar", "foo/Bar");
28        wildcard("net/sf/cglib/**", "foo/@1", "net/sf/cglib/Bar/Baz", "foo/Bar/Baz");
29        wildcard("net/sf/cglib/**", "foo/@1", "net/sf/cglib/", "foo/");
30        wildcard("net/sf/cglib/**", "foo/@1", "net/sf/cglib/!", null);
31        wildcard("net/sf/cglib/*", "foo/@1", "net/sf/cglib/Bar", "foo/Bar");
32        wildcard("net/sf/cglib/*/*", "foo/@2/@1", "net/sf/cglib/Bar/Baz", "foo/Baz/Bar");
33    }
34
35    private void wildcard(String pattern, String result, String value, String expect) {
36        Wildcard wc = new Wildcard(pattern, result);
37        // System.err.println(wc);
38        assertEquals(expect, wc.replace(value));
39    }
40
41    public WildcardTest(String name) {
42        super(name);
43    }
44
45    public static Test suite() {
46        return new TestSuite(WildcardTest.class);
47    }
48}
49