1   /*
2    * $Id: GroovyClassLoaderTest.java,v 1.1 2005/06/27 17:34:04 fraz Exp $
3    *
4    * Copyright (c) 2005 The Codehaus - http://groovy.codehaus.org
5    *
6    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
7    * the License. You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
12   * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *
14   * See the License for the specific language governing permissions and limitations under the License.
15   *
16   */
17  
18  
19  package groovy.lang;
20  
21  import java.util.Arrays;
22  
23  import junit.framework.TestCase;
24  
25  public class GroovyClassLoaderTest extends TestCase {
26  
27      private final GroovyClassLoader classLoader = new GroovyClassLoader();
28  
29      public void testAddsAClasspathEntryOnlyIfItHasNotAlreadyBeenAdded() {
30          String newClasspathEntry = "/tmp";
31          int initialNumberOfClasspathEntries = classLoader.getClassPath().length;
32  
33          classLoader.addClasspath(newClasspathEntry);
34          assertEquals("number of classpath entries", initialNumberOfClasspathEntries + 1, classLoader.getClassPath().length);
35          assertTrue("contains new classpath entry", Arrays.asList(classLoader.getClassPath()).contains(newClasspathEntry));
36  
37          classLoader.addClasspath(newClasspathEntry);
38          assertEquals("number of classpath entries", initialNumberOfClasspathEntries + 1, classLoader.getClassPath().length);
39          assertTrue("contains new classpath entry", Arrays.asList(classLoader.getClassPath()).contains(newClasspathEntry));
40      }
41  }