01: /*
02: * $Id: CompilationUnitTest.java 3790 2006-05-30 18:27:48Z blackdrag $
03: *
04: * Copyright (c) 2005 The Codehaus - http://groovy.codehaus.org
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: package org.codehaus.groovy.control;
19:
20: import java.util.Iterator;
21:
22: import org.jmock.Mock;
23: import org.jmock.cglib.MockObjectTestCase;
24:
25: import groovy.lang.GroovyClassLoader;
26:
27: public class CompilationUnitTest extends MockObjectTestCase {
28:
29: public void testAppendsTheClasspathOfTheCompilerConfigurationToCurrentClassLoaderWhenInstantiated() {
30: CompilerConfiguration configuration = new CompilerConfiguration();
31: configuration.setClasspath(System
32: .getProperty("java.class.path"));
33: // disabled until checked with fraz
34: //new CompilationUnit(configuration, null, createGroovyClassLoaderWithExpectations(configuration));
35: }
36:
37: private GroovyClassLoader createGroovyClassLoaderWithExpectations(
38: CompilerConfiguration configuration) {
39: Mock mockGroovyClassLoader = mock(GroovyClassLoader.class);
40: for (Iterator iterator = configuration.getClasspath()
41: .iterator(); iterator.hasNext();) {
42: mockGroovyClassLoader.expects(once())
43: .method("addClasspath").with(eq(iterator.next()));
44: }
45: return (GroovyClassLoader) mockGroovyClassLoader.proxy();
46: }
47: }
|