/*
 * Copyright 2002-2006 The Apache Software Foundation.
 * 
 * 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.
 */
package org.apache.commons.jexl;

import java.io.File;
import java.net.URL;

import junit.framework.TestCase;

/**
 * Tests for ScriptFactory
 * @since 1.1
 */
public class ScriptFactoryTest extends TestCase {

    /**
     * Creates a new test case.
     * @param name the test case name.
     */
    public ScriptFactoryTest(String name) {
        super(name);
    }
    
    /**
     * Ensure the factory can create a script from a String
     * @throws Exception on a parse error
     */
    public void testCreateFromString() throws Exception {
        String code = ";";
        assertNotNull("No script created", ScriptFactory.createScript(code));
    }

    /**
     * Ensure the factory can create a script from a file.
     * @throws Exception on a parse error.
     */
    public void testCreateFromFile() throws Exception {
        File testScript = new File("src/test-scripts/test1.jexl");
        assertNotNull("No script created", ScriptFactory.createScript(testScript));
    }

    /**
     * Ensure the factory can create a script from a URL.
     * @throws Exception on a parse error.
     */
    public void testCreateFromURL() throws Exception {
        URL testUrl = new File("src/test-scripts/test1.jexl").toURL();
        assertNotNull("No script created", ScriptFactory.createScript(testUrl));
    }
}

@@ -1344,607 +1344,2212 @@
 m a 
-file.%0A     * @throws Exception on a parse error.%0A     */%0A    public void testCreateFromFile() throws Exception %7B%0A        File testScript = new File(%22src/test-scripts/test1.jexl%22);%0A        assertNotNull(%22No script created%22, ScriptFactory.createScript(testScript));%0A    %7D%0A%0A    /**%0A     * Ensure the factory can create a script from a URL.%0A     * @throws Exception on a parse error.%0A     */%0A    public void testCreateFromURL() throws Exception %7B%0A        URL testUrl = new File(%22src/test-scripts/test1.jexl%22).toURL();%0A        assertNotNull(%22No script created%22, ScriptFactory.createScript(testUrl));%0A    %7D
+String%0A     * @throws Exception on a parse error%0A     */%0A    public void testCreateFromSimpleString() throws Exception %7B%0A        String code = %22(1 + 2) * 4%22;%0A        assertNotNull(%22No script created%22, ScriptFactory.createScript(code));%0A    %7D%0A%0A    /**%0A     * Ensure the factory throws an NPE on an null String%0A     * @throws Exception on a parse error%0A     */%0A    public void testCreateFromNullString() throws Exception %7B%0A        String code = null;%0A        try %7B%0A            assertNotNull(%22No script created%22, ScriptFactory.createScript(code));%0A            fail(%22Null script created%22);%0A        %7D catch (NullPointerException e) %7B%0A            // expected%0A        %7D%0A    %7D%0A%0A    /**%0A     * Ensure the factory can create a script from a file.%0A     * @throws Exception on a parse error.%0A     */%0A    public void testCreateFromFile() throws Exception %7B%0A        File testScript = new File(%22src/test-scripts/test1.jexl%22);%0A        assertNotNull(%22No script created%22, ScriptFactory.createScript(testScript));%0A    %7D%0A%0A    /**%0A     * Ensure the factory throws npe on a null file.%0A     * @throws Exception on a parse error.%0A     */%0A    public void testCreateFromNullFile() throws Exception %7B%0A        File testScript = null;%0A        try%0A        %7B%0A            assertNotNull(%22No script created%22, ScriptFactory.createScript(testScript));%0A            fail(%22Null script created%22);%0A        %7D%0A        catch (NullPointerException e)%0A        %7B%0A            // expected%0A        %7D%0A    %7D%0A%0A    /**%0A     * Ensure the factory can create a script from a URL.%0A     * @throws Exception on a parse error.%0A     */%0A    public void testCreateFromURL() throws Exception %7B%0A        URL testUrl = new File(%22src/test-scripts/test1.jexl%22).toURL();%0A        assertNotNull(%22No script created%22, ScriptFactory.createScript(testUrl));%0A    %7D%0A%0A    /**%0A     * Ensure the factory throws an NPE on an null URL%0A     * @throws Exception on a parse error%0A     */%0A    public void testCreateFromNullURL() throws Exception %7B%0A        URL code = null;%0A        try %7B%0A            assertNotNull(%22No script created%22, ScriptFactory.createScript(code));%0A            fail(%22Null script created%22);%0A        %7D catch (NullPointerException e) %7B%0A            // expected%0A        %7D%0A    %7D%0A
 %0A%7D%0A

Add null behaviour checks