KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonicsystems > jarjar > WildcardTest


1 /*
2   Jar Jar Links - A utility to repackage and embed Java libraries
3   Copyright (C) 2004 Tonic Systems, Inc.
4
5   This program is free software; you can redistribute it and/or modify
6   it under the terms of the GNU General Public License as published by
7   the Free Software Foundation; either version 2 of the License, or
8   (at your option) any later version.
9
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13   GNU General Public License for more details.
14
15   You should have received a copy of the GNU General Public License
16   along with this program; see the file COPYING. if not, write to
17   the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18   Boston, MA 02111-1307 USA
19 */

20
21 package com.tonicsystems.jarjar;
22
23 import junit.framework.*;
24
25 public class WildcardTest
26 extends TestCase
27 {
28     public void testWildcards() {
29         identifier("net.sf.cglib.**", "foo.@1", "net.sf.cglib.Bar", "foo.Bar");
30         identifier("net.sf.cglib.**", "foo.@1", "net.sf.cglib.", "foo.");
31         identifier("net.sf.cglib.**", "foo.@1", "net.sf.cglib.!", null);
32     }
33
34     private void identifier(String JavaDoc pattern, String JavaDoc result, String JavaDoc value, String JavaDoc expect) {
35         helper(pattern, result, value, expect, Wildcard.STYLE_IDENTIFIER);
36     }
37
38     private void descriptor(String JavaDoc pattern, String JavaDoc result, String JavaDoc value, String JavaDoc expect) {
39         helper(pattern, result, value, expect, Wildcard.STYLE_DESC);
40     }
41
42     private void helper(String JavaDoc pattern, String JavaDoc result, String JavaDoc value, String JavaDoc expect, int style) {
43         Wildcard wc = new Wildcard(pattern, result);
44         // System.err.println(wc);
45
assertEquals(expect, wc.replace(value, style));
46     }
47     
48     public WildcardTest(String JavaDoc name) {
49         super(name);
50     }
51
52     public static Test suite() {
53         return new TestSuite(WildcardTest.class);
54     }
55 }
56
Popular Tags