KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > scriptella > util > UrlPathTokenizerTest


1 /*
2  * Copyright 2006-2007 The Scriptella Project Team.
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 package scriptella.util;
17
18 import scriptella.AbstractTestCase;
19
20 import java.net.MalformedURLException JavaDoc;
21 import java.net.URL JavaDoc;
22
23 /**
24  * Tests tokenizer logic
25  *
26  * @author Fyodor Kupolov
27  * @version 1.0
28  */

29 public class UrlPathTokenizerTest extends AbstractTestCase {
30     public void testWin() throws MalformedURLException JavaDoc {
31         URL JavaDoc base = new URL JavaDoc("file:/c:/docs/etl.xml");
32         String JavaDoc s = " 1.jar;;;:::: lib/second.jar ;../third.jar:http://5.jar; file:/file name ; ";
33         UrlPathTokenizer tok = new UrlPathTokenizer(base);
34         URL JavaDoc[] actual = tok.split(s);
35         String JavaDoc[] expected = new String JavaDoc[] {"file:/c:/docs/1.jar", "file:/c:/docs/lib/second.jar",
36                 "file:/c:/third.jar", "http://5.jar", "file:/file name"};
37         assertEquals(expected.length, actual.length);
38         for (int i = 0; i < expected.length; i++) {
39             assertEquals(expected[i], actual[i].toString());
40         }
41     }
42
43     public void testUnix() throws MalformedURLException JavaDoc {
44         URL JavaDoc base = new URL JavaDoc("file:/var/etl.xml");
45         String JavaDoc s = "1.jar: lib/second.jar :third.jar:;http://5.jar; ::; http://ftp:/user";
46         UrlPathTokenizer tok = new UrlPathTokenizer(base);
47         URL JavaDoc[] actual = tok.split(s);
48         String JavaDoc[] expected = new String JavaDoc[] {"file:/var/1.jar", "file:/var/lib/second.jar",
49                 "file:/var/third.jar", "http://5.jar", "http://ftp:/user"};
50         assertEquals(expected.length, actual.length);
51         for (int i = 0; i < expected.length; i++) {
52             assertEquals(expected[i], actual[i].toString());
53         }
54     }
55
56
57 }
58
Popular Tags