source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/testcases/org/apache/tools/ant/util/ClasspathUtilsTest.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 1.9 KB
Line 
1/*
2 * Copyright 2000-2002,2004 The Apache Software Foundation
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 */
17
18package org.apache.tools.ant.util;
19
20import java.io.File;
21import java.io.IOException;
22import java.util.Enumeration;
23import junit.framework.TestCase;
24
25import org.apache.tools.ant.BuildException;
26import org.apache.tools.ant.Project;
27import org.apache.tools.ant.types.Path;
28
29
30/**
31 * Test case for ClasspathUtils
32 *
33 */
34public class ClasspathUtilsTest extends TestCase {
35
36 private Project p;
37
38 public ClasspathUtilsTest(String name) {
39 super(name);
40 }
41
42 public void setUp() {
43 p = new Project();
44 p.init();
45 }
46
47
48 public void testOnlyOneInstance() {
49 Enumeration enumeration;
50 String list = "";
51 ClassLoader c = ClasspathUtils.getUniqueClassLoaderForPath(p, (Path) null, false);
52 try {
53 enumeration = c.getResources(
54 "org/apache/tools/ant/taskdefs/defaults.properties");
55 } catch (IOException e) {
56 throw new BuildException(
57 "Could not get the defaults.properties resource");
58 }
59 int count = 0;
60 while (enumeration.hasMoreElements()) {
61 list = list + " " + enumeration.nextElement();
62 count++;
63 }
64 assertTrue("Should be only one and not " + count + " " + list, count == 1);
65 }
66}
Note: See TracBrowser for help on using the repository browser.