package groovy.lang;
import java.io.File;
import java.net.URL;

import junit.framework.TestCase;

import org.codehaus.groovy.grails.commons.DefaultGrailsApplication;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
/*
 * Copyright 2004-2005 the original author or authors.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class ClassNotFoundExceptionTests extends TestCase {

	public ClassNotFoundExceptionTests() {
		super();
	}

	public ClassNotFoundExceptionTests(String arg0) {
		super(arg0);
	}

	public void testLoadFileFromClassLoader() throws Exception {
		ClassLoader cl = Thread.currentThread().getContextClassLoader();
		URL url = cl.getResource("groovy/lang/Order.groovy");
		assertNotNull(url);
	}
	
	public void testClassNotFoundException() throws Exception {
		GroovyClassLoader gcl = new GroovyClassLoader();
		gcl.parseClass(new File("test/commons/groovy/lang/OrderService.groovy"));
	}
	
	public void testClassNotFoundExceptionGrailsApplication() throws Exception {
		DefaultGrailsApplication app = new DefaultGrailsApplication(new PathMatchingResourcePatternResolver().getResources("file:test/commons/groovy/lang/OrderService.groovy"));
	}
}

@@ -1071,31 +1071,30 @@
 test
-LoadFileFromClassLoader
+ClassNotFoundException
 () t
@@ -1113,16 +1113,22 @@
 ion %7B%0A%09%09
+Groovy
 ClassLoa
@@ -1135,46 +1135,24 @@
 der 
+g
 cl = 
-Thread.currentThread().getContext
+new Groovy
 Clas
@@ -1168,22 +1168,13 @@
 ;%0A%09%09
-URL url = cl.g
+gcl.s
 etRe
@@ -1183,174 +1183,237 @@
 urce
-(%22groovy/lang/Order.groovy%22);%0A%09%09assertNotNull(url);%0A%09%7D%0A%09%0A%09public void testClassNotFoundException() throws Exception %7B%0A%09%09G
+Loader(new GroovyResourceLoader() %7B%0A%09%09%09public File loadGroovyFile(String filename) %7B%0A%09%09%09%09if (%22Order%22.equals(filename)) %7B%0A%09%09%09%09%09return new File(%22test/commons/g
 roovy
-ClassLoader gcl = new GroovyClassLoader(
+/lang/Order.groovy%22);%0A%09%09%09%09%7D else %7B%0A%09%09%09%09%09return null;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D
 );%0A%09
@@ -1714,36 +1714,25 @@
 groovy/lang/
-OrderService
+*
 .groovy%22));%0A

Refactor test to accomodate resource loader.