You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by tv...@apache.org on 2007/05/05 08:58:51 UTC
svn commit: r535465 [17/49] - in /jakarta/turbine/fulcrum/trunk: ./ bsf/
bsf/src/java/org/apache/fulcrum/bsf/ bsf/src/test/ bsf/xdocs/ cache/
cache/src/java/org/apache/fulcrum/cache/
cache/src/java/org/apache/fulcrum/cache/impl/ cache/src/test/ cache/s...
Modified: jakarta/turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/Validate.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/Validate.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/Validate.java (original)
+++ jakarta/turbine/fulcrum/trunk/script/src/java/org/apache/fulcrum/script/impl/Validate.java Fri May 4 23:58:06 2007
@@ -1,611 +1,614 @@
-/*
- * Copyright 2002-2005 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.fulcrum.script.impl;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * <p>Assists in validating arguments.</p>
- *
- * <p>The class is based along the lines of JUnit. If an argument value is
- * deemed invalid, an IllegalArgumentException is thrown. For example:</p>
- *
- * <pre>
- * Validate.isTrue( i > 0, "The value must be greater than zero: ", i);
- * Validate.notNull( surname, "The surname must not be null");
- * </pre>
- *
- * @author <a href="mailto:ola.berg@arkitema.se">Ola Berg</a>
- * @author Stephen Colebourne
- * @author Gary Gregory
- * @author Norm Deane
- * @since 2.0
- * @version $Id: Validate.java,v 1.1.1.1 2005/12/28 12:10:22 sigi Exp $
- */
-public class Validate
-{
- // Validate has no dependencies on other classes in Commons Lang at present
-
- /**
- * Constructor. This class should not normally be instantiated.
- */
- public Validate()
- {
- // nothing to do
- }
-
- // isTrue
- //---------------------------------------------------------------------------------
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the test result is <code>false</code>.</p>
- *
- * <p>This is used when validating according to an arbitrary boolean expression,
- * such as validating a primitive number or using your own custom validation
- * expression.</p>
- *
- * <pre>
- * Validate.isTrue( myObject.isOk(), "The object is not OK: ", myObject);
- * </pre>
- *
- * <p>For performance reasons, the object is passed as a separate parameter and
- * appended to the message string only in the case of an error.</p>
- *
- * @param expression a boolean expression
- * @param message the exception message you would like to see if the
- * expression is <code>false</code>
- * @param value the value to append to the message in case of error
- * @throws IllegalArgumentException if expression is <code>false</code>
- */
- public static void isTrue(boolean expression, String message, Object value)
- {
- if (expression == false)
- {
- throw new IllegalArgumentException( message + value );
- }
- }
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the test result is <code>false</code>.</p>
- *
- * <p>This is used when validating according to an arbitrary boolean expression,
- * such as validating a primitive number or using your own custom validation
- * expression.</p>
- *
- * <pre>
- * Validate.isTrue( i > 0, "The value must be greater than zero: ", i);
- * </pre>
- *
- * <p>For performance reasons, the long value is passed as a separate parameter and
- * appended to the message string only in the case of an error.</p>
- *
- * @param expression a boolean expression
- * @param message the exception message you would like to see if the expression is <code>false</code>
- * @param value the value to append to the message in case of error
- * @throws IllegalArgumentException if expression is <code>false</code>
- */
- public static void isTrue(boolean expression, String message, long value)
- {
- if (expression == false)
- {
- throw new IllegalArgumentException( message + value );
- }
- }
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the test result is <code>false</code>.</p>
- *
- * <p>This is used when validating according to an arbitrary boolean expression,
- * such as validating a primitive number or using your own custom validation
- * expression.</p>
- *
- * <pre>
- * Validate.isTrue( d > 0.0, "The value must be greater than zero: ", d);
- * </pre>
- *
- * <p>For performance reasons, the double value is passed as a separate parameter and
- * appended to the message string only in the case of an error.</p>
- *
- * @param expression a boolean expression
- * @param message the exception message you would like to see if the expression
- * is <code>false</code>
- * @param value the value to append to the message in case of error
- * @throws IllegalArgumentException if expression is <code>false</code>
- */
- public static void isTrue(boolean expression, String message, double value)
- {
- if (expression == false)
- {
- throw new IllegalArgumentException( message + value );
- }
- }
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the test result is <code>false</code>.</p>
- *
- * <p>This is used when validating according to an arbitrary boolean expression,
- * such as validating a primitive number or using your own custom validation
- * expression.</p>
- *
- * <pre>
- * Validate.isTrue( (i > 0), "The value must be greater than zero");
- * Validate.isTrue( myObject.isOk(), "The object is not OK");
- * </pre>
- *
- * <p>For performance reasons, the message string should not involve a string append,
- * instead use the {@link #isTrue(boolean, String, Object)} method.</p>
- *
- * @param expression a boolean expression
- * @param message the exception message you would like to see if the expression
- * is <code>false</code>
- * @throws IllegalArgumentException if expression is <code>false</code>
- */
- public static void isTrue(boolean expression, String message)
- {
- if (expression == false)
- {
- throw new IllegalArgumentException( message );
- }
- }
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the test result is <code>false</code>.</p>
- *
- * <p>This is used when validating according to an arbitrary boolean expression,
- * such as validating a primitive number or using your own custom validation
- * expression.</p>
- *
- * <pre>
- * Validate.isTrue( i > 0 );
- * Validate.isTrue( myObject.isOk() );
- * </pre>
- *
- * <p>The message in the exception is 'The validated expression is false'.</p>
- *
- * @param expression a boolean expression
- * @throws IllegalArgumentException if expression is <code>false</code>
- */
- public static void isTrue(boolean expression)
- {
- if (expression == false)
- {
- throw new IllegalArgumentException(
- "The validated expression is false" );
- }
- }
-
- // notNull
- //---------------------------------------------------------------------------------
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the argument is <code>null</code>.</p>
- *
- * <pre>
- * Validate.notNull(myObject, "The object must not be null");
- * </pre>
- *
- * @param object the object to check is not <code>null</code>
- * @param message the exception message you would like to see
- * if the object is <code>null</code>
- * @throws IllegalArgumentException if the object is <code>null</code>
- */
- public static void notNull(Object object, String message)
- {
- if (object == null)
- {
- throw new IllegalArgumentException( message );
- }
- }
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the argument is <code>null</code>.</p>
- *
- * <pre>
- * Validate.notNull(myObject);
- * </pre>
- *
- * <p>The message in the exception is 'The validated object is null'.</p>
- *
- * @param object the object to check is not <code>null</code>
- * @throws IllegalArgumentException if the object is <code>null</code>
- */
- public static void notNull(Object object)
- {
- if (object == null)
- {
- throw new IllegalArgumentException( "The validated object is null" );
- }
- }
-
- // notEmpty array
- //---------------------------------------------------------------------------------
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the argument array is empty (<code>null</code> or no elements).</p>
- *
- * <pre>
- * Validate.notEmpty(myArray, "The array must not be empty");
- * </pre>
- *
- * @param array the array to check is not empty
- * @param message the exception message you would like to see if the array is empty
- * @throws IllegalArgumentException if the array is empty
- */
- public static void notEmpty(Object [] array, String message)
- {
- if (array == null || array.length == 0)
- {
- throw new IllegalArgumentException( message );
- }
- }
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the argument array is empty (<code>null</code> or no elements).</p>
- *
- * <pre>
- * Validate.notEmpty(myArray);
- * </pre>
- *
- * <p>The message in the exception is 'The validated array is empty'.
- *
- * @param array the array to check is not empty
- * @throws IllegalArgumentException if the array is empty
- */
- public static void notEmpty(Object [] array)
- {
- if (array == null || array.length == 0)
- {
- throw new IllegalArgumentException( "The validated array is empty" );
- }
- }
-
- // notEmpty collection
- //---------------------------------------------------------------------------------
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the argument Collection is empty (<code>null</code> or no elements).</p>
- *
- * <pre>
- * Validate.notEmpty(myCollection, "The collection must not be empty");
- * </pre>
- *
- * @param collection the collection to check is not empty
- * @param message the exception message you would like to see if the collection is empty
- * @throws IllegalArgumentException if the collection is empty
- */
- public static void notEmpty(Collection collection, String message)
- {
- if (collection == null || collection.size() == 0)
- {
- throw new IllegalArgumentException( message );
- }
- }
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the argument Collection is empty (<code>null</code> or no elements).</p>
- *
- * <pre>
- * Validate.notEmpty(myCollection);
- * </pre>
- *
- * <p>The message in the exception is 'The validated collection is empty'.</p>
- *
- * @param collection the collection to check is not empty
- * @throws IllegalArgumentException if the collection is empty
- */
- public static void notEmpty(Collection collection)
- {
- if (collection == null || collection.size() == 0)
- {
- throw new IllegalArgumentException(
- "The validated collection is empty" );
- }
- }
-
- // notEmpty map
- //---------------------------------------------------------------------------------
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the argument Map is empty (<code>null</code> or no elements).</p>
- *
- * <pre>
- * Validate.notEmpty(myMap, "The map must not be empty");
- * </pre>
- *
- * @param map the map to check is not empty
- * @param message the exception message you would like to see if the map is empty
- * @throws IllegalArgumentException if the map is empty
- */
- public static void notEmpty(Map map, String message)
- {
- if (map == null || map.size() == 0)
- {
- throw new IllegalArgumentException( message );
- }
- }
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the argument Map is empty (<code>null</code> or no elements).</p>
- *
- * <pre>
- * Validate.notEmpty(myMap);
- * </pre>
- *
- * <p>The message in the exception is 'The validated map is empty'.</p>
- *
- * @param map the map to check is not empty
- * @throws IllegalArgumentException if the map is empty
- */
- public static void notEmpty(Map map)
- {
- if (map == null || map.size() == 0)
- {
- throw new IllegalArgumentException( "The validated map is empty" );
- }
- }
-
- // notEmpty string
- //---------------------------------------------------------------------------------
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the argument String is empty (<code>null</code> or zero length).</p>
- *
- * <pre>
- * Validate.notEmpty(myString, "The string must not be empty");
- * </pre>
- *
- * @param string the string to check is not empty
- * @param message the exception message you would like to see if the string is empty
- * @throws IllegalArgumentException if the string is empty
- */
- public static void notEmpty(String string, String message)
- {
- if (string == null || string.length() == 0)
- {
- throw new IllegalArgumentException( message );
- }
- }
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the argument String is empty (<code>null</code> or zero length).</p>
- *
- * <pre>
- * Validate.notEmpty(myString);
- * </pre>
- *
- * <p>The message in the exception is 'The validated string is empty'.</p>
- *
- * @param string the string to check is not empty
- * @throws IllegalArgumentException if the string is empty
- */
- public static void notEmpty(String string)
- {
- if (string == null || string.length() == 0)
- {
- throw new IllegalArgumentException( "The validated string is empty" );
- }
- }
-
- // notNullElements array
- //---------------------------------------------------------------------------------
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the argument array has <code>null</code> elements or is
- * <code>null</code>.</p>
- *
- * <pre>
- * Validate.noNullElements(myArray, "The array must not contain null elements");
- * </pre>
- *
- * <p>If the array is null then the message in the exception is 'The validated object is null'.</p>
- *
- * @param array the array to check
- * @param message the exception message if the array has
- * <code>null</code> elements
- * @throws IllegalArgumentException if the array has <code>null</code>
- * elements or is <code>null</code>
- */
- public static void noNullElements(Object [] array, String message)
- {
- Validate.notNull( array );
- for (int i = 0; i < array.length; i++)
- {
- if (array[i] == null)
- {
- throw new IllegalArgumentException( message );
- }
- }
- }
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the argument array has <code>null</code> elements or is
- * <code>null</code>.</p>
- *
- * <pre>
- * Validate.noNullElements(myArray);
- * </pre>
- *
- * <p>If the array has a null element the message in the exception is
- * 'The validated array contains null element at index: '.</p>
- *
- * <p>If the array is null then the message in the exception is 'The validated object is null'.</p>
- *
- * @param array the array to check
- * @throws IllegalArgumentException if the array has <code>null</code>
- * elements or is <code>null</code>
- */
- public static void noNullElements(Object [] array)
- {
- Validate.notNull( array );
- for (int i = 0; i < array.length; i++)
- {
- if (array[i] == null)
- {
- throw new IllegalArgumentException(
- "The validated array contains null element at index: "
- + i );
- }
- }
- }
-
- // notNullElements collection
- //---------------------------------------------------------------------------------
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the argument Collection has <code>null</code> elements or is
- * <code>null</code>.</p>
- *
- * <pre>
- * Validate.noNullElements(myCollection, "The collection must not contain null elements");
- * </pre>
- *
- * <p>If the collection is null then the message in the exception is 'The validated object is null'.</p>
- *
- * @param collection the collection to check
- * @param message the exception message if the collection has
- * <code>null</code> elements
- * @throws IllegalArgumentException if the collection has
- * <code>null</code> elements or is <code>null</code>
- */
- public static void noNullElements(Collection collection, String message)
- {
- Validate.notNull( collection );
- for (Iterator it = collection.iterator(); it.hasNext();)
- {
- if (it.next() == null)
- {
- throw new IllegalArgumentException( message );
- }
- }
- }
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the argument Collection has <code>null</code> elements or is
- * <code>null</code>.</p>
- *
- * <pre>
- * Validate.noNullElements(myCollection);
- * </pre>
- *
- * <p>The message in the exception is 'The validated collection contains null element at index: '.</p>
- *
- * <p>If the collection is null then the message in the exception is 'The validated object is null'.</p>
- *
- * @param collection the collection to check
- * @throws IllegalArgumentException if the collection has
- * <code>null</code> elements or is <code>null</code>
- */
- public static void noNullElements(Collection collection)
- {
- Validate.notNull( collection );
- int i = 0;
- for (Iterator it = collection.iterator(); it.hasNext(); i++)
- {
- if (it.next() == null)
- {
- throw new IllegalArgumentException(
- "The validated collection contains null element at index: "
- + i );
- }
- }
- }
-
- /**
- * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
- * if the argument collection is <code>null</code> or has elements that
- * are not of type <code>clazz</code> or a subclass.</p>
- *
- * <pre>
- * Validate.allElementsOfType(collection, String.class, "Collection has invalid elements");
- * </pre>
- *
- * @param collection the collection to check, not null
- * @param clazz the <code>Class</code> which the collection's elements are expected to be, not null
- * @param message the exception message if the <code>Collection</code> has elements not of type <code>clazz</code>
- * @since 2.1
- */
- public static void allElementsOfType(Collection collection, Class clazz,
- String message)
- {
- Validate.notNull( collection );
- Validate.notNull( clazz );
- for (Iterator it = collection.iterator(); it.hasNext();)
- {
- if (clazz.isInstance( it.next() ) == false)
- {
- throw new IllegalArgumentException( message );
- }
- }
- }
-
- /**
- * <p>
- * Validate an argument, throwing <code>IllegalArgumentException</code> if the argument collection is
- * <code>null</code> or has elements that are not of type <code>clazz</code> or a subclass.
- * </p>
- *
- * <pre>
- * Validate.allElementsOfType(collection, String.class);
- * </pre>
- *
- * <p>
- * The message in the exception is 'The validated collection contains an element not of type clazz at index: '.
- * </p>
- *
- * @param collection
- * the collection to check, not null
- * @param clazz
- * the <code>Class</code> which the collection's elements are expected to be, not null
- * @since 2.1
- */
- public static void allElementsOfType(Collection collection, Class clazz)
- {
- Validate.notNull( collection );
- Validate.notNull( clazz );
- int i = 0;
- for (Iterator it = collection.iterator(); it.hasNext(); i++)
- {
- if (clazz.isInstance( it.next() ) == false)
- {
- throw new IllegalArgumentException(
- "The validated collection contains an element not of type "
- + clazz.getName()
- + " at index: " + i );
- }
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.fulcrum.script.impl;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * <p>Assists in validating arguments.</p>
+ *
+ * <p>The class is based along the lines of JUnit. If an argument value is
+ * deemed invalid, an IllegalArgumentException is thrown. For example:</p>
+ *
+ * <pre>
+ * Validate.isTrue( i > 0, "The value must be greater than zero: ", i);
+ * Validate.notNull( surname, "The surname must not be null");
+ * </pre>
+ *
+ * @author <a href="mailto:ola.berg@arkitema.se">Ola Berg</a>
+ * @author Stephen Colebourne
+ * @author Gary Gregory
+ * @author Norm Deane
+ * @since 2.0
+ * @version $Id: Validate.java,v 1.1.1.1 2005/12/28 12:10:22 sigi Exp $
+ */
+public class Validate
+{
+ // Validate has no dependencies on other classes in Commons Lang at present
+
+ /**
+ * Constructor. This class should not normally be instantiated.
+ */
+ public Validate()
+ {
+ // nothing to do
+ }
+
+ // isTrue
+ //---------------------------------------------------------------------------------
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the test result is <code>false</code>.</p>
+ *
+ * <p>This is used when validating according to an arbitrary boolean expression,
+ * such as validating a primitive number or using your own custom validation
+ * expression.</p>
+ *
+ * <pre>
+ * Validate.isTrue( myObject.isOk(), "The object is not OK: ", myObject);
+ * </pre>
+ *
+ * <p>For performance reasons, the object is passed as a separate parameter and
+ * appended to the message string only in the case of an error.</p>
+ *
+ * @param expression a boolean expression
+ * @param message the exception message you would like to see if the
+ * expression is <code>false</code>
+ * @param value the value to append to the message in case of error
+ * @throws IllegalArgumentException if expression is <code>false</code>
+ */
+ public static void isTrue(boolean expression, String message, Object value)
+ {
+ if (expression == false)
+ {
+ throw new IllegalArgumentException( message + value );
+ }
+ }
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the test result is <code>false</code>.</p>
+ *
+ * <p>This is used when validating according to an arbitrary boolean expression,
+ * such as validating a primitive number or using your own custom validation
+ * expression.</p>
+ *
+ * <pre>
+ * Validate.isTrue( i > 0, "The value must be greater than zero: ", i);
+ * </pre>
+ *
+ * <p>For performance reasons, the long value is passed as a separate parameter and
+ * appended to the message string only in the case of an error.</p>
+ *
+ * @param expression a boolean expression
+ * @param message the exception message you would like to see if the expression is <code>false</code>
+ * @param value the value to append to the message in case of error
+ * @throws IllegalArgumentException if expression is <code>false</code>
+ */
+ public static void isTrue(boolean expression, String message, long value)
+ {
+ if (expression == false)
+ {
+ throw new IllegalArgumentException( message + value );
+ }
+ }
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the test result is <code>false</code>.</p>
+ *
+ * <p>This is used when validating according to an arbitrary boolean expression,
+ * such as validating a primitive number or using your own custom validation
+ * expression.</p>
+ *
+ * <pre>
+ * Validate.isTrue( d > 0.0, "The value must be greater than zero: ", d);
+ * </pre>
+ *
+ * <p>For performance reasons, the double value is passed as a separate parameter and
+ * appended to the message string only in the case of an error.</p>
+ *
+ * @param expression a boolean expression
+ * @param message the exception message you would like to see if the expression
+ * is <code>false</code>
+ * @param value the value to append to the message in case of error
+ * @throws IllegalArgumentException if expression is <code>false</code>
+ */
+ public static void isTrue(boolean expression, String message, double value)
+ {
+ if (expression == false)
+ {
+ throw new IllegalArgumentException( message + value );
+ }
+ }
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the test result is <code>false</code>.</p>
+ *
+ * <p>This is used when validating according to an arbitrary boolean expression,
+ * such as validating a primitive number or using your own custom validation
+ * expression.</p>
+ *
+ * <pre>
+ * Validate.isTrue( (i > 0), "The value must be greater than zero");
+ * Validate.isTrue( myObject.isOk(), "The object is not OK");
+ * </pre>
+ *
+ * <p>For performance reasons, the message string should not involve a string append,
+ * instead use the {@link #isTrue(boolean, String, Object)} method.</p>
+ *
+ * @param expression a boolean expression
+ * @param message the exception message you would like to see if the expression
+ * is <code>false</code>
+ * @throws IllegalArgumentException if expression is <code>false</code>
+ */
+ public static void isTrue(boolean expression, String message)
+ {
+ if (expression == false)
+ {
+ throw new IllegalArgumentException( message );
+ }
+ }
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the test result is <code>false</code>.</p>
+ *
+ * <p>This is used when validating according to an arbitrary boolean expression,
+ * such as validating a primitive number or using your own custom validation
+ * expression.</p>
+ *
+ * <pre>
+ * Validate.isTrue( i > 0 );
+ * Validate.isTrue( myObject.isOk() );
+ * </pre>
+ *
+ * <p>The message in the exception is 'The validated expression is false'.</p>
+ *
+ * @param expression a boolean expression
+ * @throws IllegalArgumentException if expression is <code>false</code>
+ */
+ public static void isTrue(boolean expression)
+ {
+ if (expression == false)
+ {
+ throw new IllegalArgumentException(
+ "The validated expression is false" );
+ }
+ }
+
+ // notNull
+ //---------------------------------------------------------------------------------
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the argument is <code>null</code>.</p>
+ *
+ * <pre>
+ * Validate.notNull(myObject, "The object must not be null");
+ * </pre>
+ *
+ * @param object the object to check is not <code>null</code>
+ * @param message the exception message you would like to see
+ * if the object is <code>null</code>
+ * @throws IllegalArgumentException if the object is <code>null</code>
+ */
+ public static void notNull(Object object, String message)
+ {
+ if (object == null)
+ {
+ throw new IllegalArgumentException( message );
+ }
+ }
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the argument is <code>null</code>.</p>
+ *
+ * <pre>
+ * Validate.notNull(myObject);
+ * </pre>
+ *
+ * <p>The message in the exception is 'The validated object is null'.</p>
+ *
+ * @param object the object to check is not <code>null</code>
+ * @throws IllegalArgumentException if the object is <code>null</code>
+ */
+ public static void notNull(Object object)
+ {
+ if (object == null)
+ {
+ throw new IllegalArgumentException( "The validated object is null" );
+ }
+ }
+
+ // notEmpty array
+ //---------------------------------------------------------------------------------
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the argument array is empty (<code>null</code> or no elements).</p>
+ *
+ * <pre>
+ * Validate.notEmpty(myArray, "The array must not be empty");
+ * </pre>
+ *
+ * @param array the array to check is not empty
+ * @param message the exception message you would like to see if the array is empty
+ * @throws IllegalArgumentException if the array is empty
+ */
+ public static void notEmpty(Object [] array, String message)
+ {
+ if (array == null || array.length == 0)
+ {
+ throw new IllegalArgumentException( message );
+ }
+ }
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the argument array is empty (<code>null</code> or no elements).</p>
+ *
+ * <pre>
+ * Validate.notEmpty(myArray);
+ * </pre>
+ *
+ * <p>The message in the exception is 'The validated array is empty'.
+ *
+ * @param array the array to check is not empty
+ * @throws IllegalArgumentException if the array is empty
+ */
+ public static void notEmpty(Object [] array)
+ {
+ if (array == null || array.length == 0)
+ {
+ throw new IllegalArgumentException( "The validated array is empty" );
+ }
+ }
+
+ // notEmpty collection
+ //---------------------------------------------------------------------------------
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the argument Collection is empty (<code>null</code> or no elements).</p>
+ *
+ * <pre>
+ * Validate.notEmpty(myCollection, "The collection must not be empty");
+ * </pre>
+ *
+ * @param collection the collection to check is not empty
+ * @param message the exception message you would like to see if the collection is empty
+ * @throws IllegalArgumentException if the collection is empty
+ */
+ public static void notEmpty(Collection collection, String message)
+ {
+ if (collection == null || collection.size() == 0)
+ {
+ throw new IllegalArgumentException( message );
+ }
+ }
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the argument Collection is empty (<code>null</code> or no elements).</p>
+ *
+ * <pre>
+ * Validate.notEmpty(myCollection);
+ * </pre>
+ *
+ * <p>The message in the exception is 'The validated collection is empty'.</p>
+ *
+ * @param collection the collection to check is not empty
+ * @throws IllegalArgumentException if the collection is empty
+ */
+ public static void notEmpty(Collection collection)
+ {
+ if (collection == null || collection.size() == 0)
+ {
+ throw new IllegalArgumentException(
+ "The validated collection is empty" );
+ }
+ }
+
+ // notEmpty map
+ //---------------------------------------------------------------------------------
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the argument Map is empty (<code>null</code> or no elements).</p>
+ *
+ * <pre>
+ * Validate.notEmpty(myMap, "The map must not be empty");
+ * </pre>
+ *
+ * @param map the map to check is not empty
+ * @param message the exception message you would like to see if the map is empty
+ * @throws IllegalArgumentException if the map is empty
+ */
+ public static void notEmpty(Map map, String message)
+ {
+ if (map == null || map.size() == 0)
+ {
+ throw new IllegalArgumentException( message );
+ }
+ }
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the argument Map is empty (<code>null</code> or no elements).</p>
+ *
+ * <pre>
+ * Validate.notEmpty(myMap);
+ * </pre>
+ *
+ * <p>The message in the exception is 'The validated map is empty'.</p>
+ *
+ * @param map the map to check is not empty
+ * @throws IllegalArgumentException if the map is empty
+ */
+ public static void notEmpty(Map map)
+ {
+ if (map == null || map.size() == 0)
+ {
+ throw new IllegalArgumentException( "The validated map is empty" );
+ }
+ }
+
+ // notEmpty string
+ //---------------------------------------------------------------------------------
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the argument String is empty (<code>null</code> or zero length).</p>
+ *
+ * <pre>
+ * Validate.notEmpty(myString, "The string must not be empty");
+ * </pre>
+ *
+ * @param string the string to check is not empty
+ * @param message the exception message you would like to see if the string is empty
+ * @throws IllegalArgumentException if the string is empty
+ */
+ public static void notEmpty(String string, String message)
+ {
+ if (string == null || string.length() == 0)
+ {
+ throw new IllegalArgumentException( message );
+ }
+ }
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the argument String is empty (<code>null</code> or zero length).</p>
+ *
+ * <pre>
+ * Validate.notEmpty(myString);
+ * </pre>
+ *
+ * <p>The message in the exception is 'The validated string is empty'.</p>
+ *
+ * @param string the string to check is not empty
+ * @throws IllegalArgumentException if the string is empty
+ */
+ public static void notEmpty(String string)
+ {
+ if (string == null || string.length() == 0)
+ {
+ throw new IllegalArgumentException( "The validated string is empty" );
+ }
+ }
+
+ // notNullElements array
+ //---------------------------------------------------------------------------------
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the argument array has <code>null</code> elements or is
+ * <code>null</code>.</p>
+ *
+ * <pre>
+ * Validate.noNullElements(myArray, "The array must not contain null elements");
+ * </pre>
+ *
+ * <p>If the array is null then the message in the exception is 'The validated object is null'.</p>
+ *
+ * @param array the array to check
+ * @param message the exception message if the array has
+ * <code>null</code> elements
+ * @throws IllegalArgumentException if the array has <code>null</code>
+ * elements or is <code>null</code>
+ */
+ public static void noNullElements(Object [] array, String message)
+ {
+ Validate.notNull( array );
+ for (int i = 0; i < array.length; i++)
+ {
+ if (array[i] == null)
+ {
+ throw new IllegalArgumentException( message );
+ }
+ }
+ }
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the argument array has <code>null</code> elements or is
+ * <code>null</code>.</p>
+ *
+ * <pre>
+ * Validate.noNullElements(myArray);
+ * </pre>
+ *
+ * <p>If the array has a null element the message in the exception is
+ * 'The validated array contains null element at index: '.</p>
+ *
+ * <p>If the array is null then the message in the exception is 'The validated object is null'.</p>
+ *
+ * @param array the array to check
+ * @throws IllegalArgumentException if the array has <code>null</code>
+ * elements or is <code>null</code>
+ */
+ public static void noNullElements(Object [] array)
+ {
+ Validate.notNull( array );
+ for (int i = 0; i < array.length; i++)
+ {
+ if (array[i] == null)
+ {
+ throw new IllegalArgumentException(
+ "The validated array contains null element at index: "
+ + i );
+ }
+ }
+ }
+
+ // notNullElements collection
+ //---------------------------------------------------------------------------------
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the argument Collection has <code>null</code> elements or is
+ * <code>null</code>.</p>
+ *
+ * <pre>
+ * Validate.noNullElements(myCollection, "The collection must not contain null elements");
+ * </pre>
+ *
+ * <p>If the collection is null then the message in the exception is 'The validated object is null'.</p>
+ *
+ * @param collection the collection to check
+ * @param message the exception message if the collection has
+ * <code>null</code> elements
+ * @throws IllegalArgumentException if the collection has
+ * <code>null</code> elements or is <code>null</code>
+ */
+ public static void noNullElements(Collection collection, String message)
+ {
+ Validate.notNull( collection );
+ for (Iterator it = collection.iterator(); it.hasNext();)
+ {
+ if (it.next() == null)
+ {
+ throw new IllegalArgumentException( message );
+ }
+ }
+ }
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the argument Collection has <code>null</code> elements or is
+ * <code>null</code>.</p>
+ *
+ * <pre>
+ * Validate.noNullElements(myCollection);
+ * </pre>
+ *
+ * <p>The message in the exception is 'The validated collection contains null element at index: '.</p>
+ *
+ * <p>If the collection is null then the message in the exception is 'The validated object is null'.</p>
+ *
+ * @param collection the collection to check
+ * @throws IllegalArgumentException if the collection has
+ * <code>null</code> elements or is <code>null</code>
+ */
+ public static void noNullElements(Collection collection)
+ {
+ Validate.notNull( collection );
+ int i = 0;
+ for (Iterator it = collection.iterator(); it.hasNext(); i++)
+ {
+ if (it.next() == null)
+ {
+ throw new IllegalArgumentException(
+ "The validated collection contains null element at index: "
+ + i );
+ }
+ }
+ }
+
+ /**
+ * <p>Validate an argument, throwing <code>IllegalArgumentException</code>
+ * if the argument collection is <code>null</code> or has elements that
+ * are not of type <code>clazz</code> or a subclass.</p>
+ *
+ * <pre>
+ * Validate.allElementsOfType(collection, String.class, "Collection has invalid elements");
+ * </pre>
+ *
+ * @param collection the collection to check, not null
+ * @param clazz the <code>Class</code> which the collection's elements are expected to be, not null
+ * @param message the exception message if the <code>Collection</code> has elements not of type <code>clazz</code>
+ * @since 2.1
+ */
+ public static void allElementsOfType(Collection collection, Class clazz,
+ String message)
+ {
+ Validate.notNull( collection );
+ Validate.notNull( clazz );
+ for (Iterator it = collection.iterator(); it.hasNext();)
+ {
+ if (clazz.isInstance( it.next() ) == false)
+ {
+ throw new IllegalArgumentException( message );
+ }
+ }
+ }
+
+ /**
+ * <p>
+ * Validate an argument, throwing <code>IllegalArgumentException</code> if the argument collection is
+ * <code>null</code> or has elements that are not of type <code>clazz</code> or a subclass.
+ * </p>
+ *
+ * <pre>
+ * Validate.allElementsOfType(collection, String.class);
+ * </pre>
+ *
+ * <p>
+ * The message in the exception is 'The validated collection contains an element not of type clazz at index: '.
+ * </p>
+ *
+ * @param collection
+ * the collection to check, not null
+ * @param clazz
+ * the <code>Class</code> which the collection's elements are expected to be, not null
+ * @since 2.1
+ */
+ public static void allElementsOfType(Collection collection, Class clazz)
+ {
+ Validate.notNull( collection );
+ Validate.notNull( clazz );
+ int i = 0;
+ for (Iterator it = collection.iterator(); it.hasNext(); i++)
+ {
+ if (clazz.isInstance( it.next() ) == false)
+ {
+ throw new IllegalArgumentException(
+ "The validated collection contains an element not of type "
+ + clazz.getName()
+ + " at index: " + i );
+ }
+ }
+ }
+}
Modified: jakarta/turbine/fulcrum/trunk/script/src/test/TestGroovyComponentConfig.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/script/src/test/TestGroovyComponentConfig.xml?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/TestGroovyComponentConfig.xml (original)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/TestGroovyComponentConfig.xml Fri May 4 23:58:06 2007
@@ -1,40 +1,58 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<componentConfig>
-
- <ResourceManagerService>
- <domain name="groovy">
- <suffix>groovy</suffix>
- <location>./src/test/scripts/groovy</location>
- <useLocator>true</useLocator>
- </domain>
- </ResourceManagerService>
-
- <!--
- ScriptService
-
- scriptEngines := the list of available script engines
- scriptEngines/scriptEngine := configuration of a single script engine
- scriptEngines/scriptEngine/name := the name of the script engine
- scriptEngines/scriptEngine/isCached := cache the scripts or reload it each time from the ResourceManagerService
- scriptEngines/scriptEngine/isCompiled := precompile the script
- scriptEngines/scriptEngine/location := the location of the scripts
- scriptEngines/scriptEngine/preLoad := a list of scripts to load on startup
- scriptEngines/scriptEngine/preLoad/script := the script to preload
- -->
-
- <ScriptService>
- <scriptEngines>
- <scriptEngine>
- <name>groovy</name>
- <isCached>true</isCached>
- <isCompiled>true</isCompiled>
- <location>groovy</location>
- </scriptEngine>
- </scriptEngines>
- <scriptConfiguration>
- <isDebug>true</isDebug>
- </scriptConfiguration>
- </ScriptService>
-
-</componentConfig>
\ No newline at end of file
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+
+<componentConfig>
+
+ <ResourceManagerService>
+ <domain name="groovy">
+ <suffix>groovy</suffix>
+ <location>./src/test/scripts/groovy</location>
+ <useLocator>true</useLocator>
+ </domain>
+ </ResourceManagerService>
+
+ <!--
+ ScriptService
+
+ scriptEngines := the list of available script engines
+ scriptEngines/scriptEngine := configuration of a single script engine
+ scriptEngines/scriptEngine/name := the name of the script engine
+ scriptEngines/scriptEngine/isCached := cache the scripts or reload it each time from the ResourceManagerService
+ scriptEngines/scriptEngine/isCompiled := precompile the script
+ scriptEngines/scriptEngine/location := the location of the scripts
+ scriptEngines/scriptEngine/preLoad := a list of scripts to load on startup
+ scriptEngines/scriptEngine/preLoad/script := the script to preload
+ -->
+
+ <ScriptService>
+ <scriptEngines>
+ <scriptEngine>
+ <name>groovy</name>
+ <isCached>true</isCached>
+ <isCompiled>true</isCompiled>
+ <location>groovy</location>
+ </scriptEngine>
+ </scriptEngines>
+ <scriptConfiguration>
+ <isDebug>true</isDebug>
+ </scriptConfiguration>
+ </ScriptService>
+
+</componentConfig>
Modified: jakarta/turbine/fulcrum/trunk/script/src/test/TestRhinoComponentConfig.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/script/src/test/TestRhinoComponentConfig.xml?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/TestRhinoComponentConfig.xml (original)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/TestRhinoComponentConfig.xml Fri May 4 23:58:06 2007
@@ -1,43 +1,61 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<componentConfig>
-
- <ResourceManagerService>
- <domain name="js">
- <suffix>js</suffix>
- <location>./src/test/scripts/js</location>
- <useLocator>true</useLocator>
- </domain>
- </ResourceManagerService>
-
- <!--
- ScriptService
-
- scriptEngines := the list of available script engines
- scriptEngines/scriptEngine := configuration of a single script engine
- scriptEngines/scriptEngine/name := the name of the script engine
- scriptEngines/scriptEngine/isCached := cache the scripts or reload it each time from the ResourceManagerService
- scriptEngines/scriptEngine/isCompiled := precompile the script
- scriptEngines/scriptEngine/location := the location of the scripts
- scriptEngines/scriptEngine/preLoad := a list of scripts to load on startup
- scriptEngines/scriptEngine/preLoad/script := the script to preload
- -->
-
- <ScriptService>
- <scriptEngines>
- <scriptEngine>
- <name>js</name>
- <isCached>true</isCached>
- <isCompiled>true</isCompiled>
- <location>js</location>
- <preLoad>
- <script>InvocableIntf.js</script>
- </preLoad>
- </scriptEngine>
- </scriptEngines>
- <scriptConfiguration>
- <isDebug>true</isDebug>
- </scriptConfiguration>
- </ScriptService>
-
-</componentConfig>
\ No newline at end of file
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+
+<componentConfig>
+
+ <ResourceManagerService>
+ <domain name="js">
+ <suffix>js</suffix>
+ <location>./src/test/scripts/js</location>
+ <useLocator>true</useLocator>
+ </domain>
+ </ResourceManagerService>
+
+ <!--
+ ScriptService
+
+ scriptEngines := the list of available script engines
+ scriptEngines/scriptEngine := configuration of a single script engine
+ scriptEngines/scriptEngine/name := the name of the script engine
+ scriptEngines/scriptEngine/isCached := cache the scripts or reload it each time from the ResourceManagerService
+ scriptEngines/scriptEngine/isCompiled := precompile the script
+ scriptEngines/scriptEngine/location := the location of the scripts
+ scriptEngines/scriptEngine/preLoad := a list of scripts to load on startup
+ scriptEngines/scriptEngine/preLoad/script := the script to preload
+ -->
+
+ <ScriptService>
+ <scriptEngines>
+ <scriptEngine>
+ <name>js</name>
+ <isCached>true</isCached>
+ <isCompiled>true</isCompiled>
+ <location>js</location>
+ <preLoad>
+ <script>InvocableIntf.js</script>
+ </preLoad>
+ </scriptEngine>
+ </scriptEngines>
+ <scriptConfiguration>
+ <isDebug>true</isDebug>
+ </scriptConfiguration>
+ </ScriptService>
+
+</componentConfig>
Modified: jakarta/turbine/fulcrum/trunk/script/src/test/TestRoleConfig.xml
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/script/src/test/TestRoleConfig.xml?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/TestRoleConfig.xml (original)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/TestRoleConfig.xml Fri May 4 23:58:06 2007
@@ -1,21 +1,39 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<role-list>
-
- <role
- name="org.apache.fulcrum.resourcemanager.ResourceManagerService"
- default-class="org.apache.fulcrum.resourcemanager.impl.ResourceManagerServiceImpl"
- shorthand="ResourceManagerService"
- early-init="true"
- description="Handles the management of resources"
- />
-
- <role
- name="org.apache.fulcrum.script.ScriptService"
- default-class="org.apache.fulcrum.script.impl.ScriptServiceImpl"
- shorthand="ScriptService"
- early-init="true"
- description="Handles the execution of scripts"
- />
-
-</role-list>
\ No newline at end of file
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+
+<role-list>
+
+ <role
+ name="org.apache.fulcrum.resourcemanager.ResourceManagerService"
+ default-class="org.apache.fulcrum.resourcemanager.impl.ResourceManagerServiceImpl"
+ shorthand="ResourceManagerService"
+ early-init="true"
+ description="Handles the management of resources"
+ />
+
+ <role
+ name="org.apache.fulcrum.script.ScriptService"
+ default-class="org.apache.fulcrum.script.impl.ScriptServiceImpl"
+ shorthand="ScriptService"
+ early-init="true"
+ description="Handles the execution of scripts"
+ />
+
+</role-list>
Modified: jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/AbstractScriptTest.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/AbstractScriptTest.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/AbstractScriptTest.java (original)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/AbstractScriptTest.java Fri May 4 23:58:06 2007
@@ -1,288 +1,290 @@
-package org.apache.fulcrum.script;
-
-/*
- * Copyright 2005 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.
- */
-
-import java.util.Hashtable;
-
-import javax.script.GenericScriptContext;
-import javax.script.Namespace;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-import javax.script.SimpleNamespace;
-
-import org.apache.fulcrum.script.impl.ScriptRunnableImpl;
-import org.apache.fulcrum.testcontainer.BaseUnitTest;
-
-/**
- * Common test cases for all scripting languages.
- *
- * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
- */
-public class AbstractScriptTest extends BaseUnitTest
-{
- protected ScriptService scriptService;
-
- /**
- * Defines the testcase name for JUnit.
- *
- * @param name the testcase's name.
- */
- public AbstractScriptTest(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
- this.scriptService = (ScriptService) this.lookup(ScriptService.class.getName());
- }
-
- /**
- * Taken from the JSR 223 reference implementation
- */
- public void testCompilableInterface() throws Exception
- {
- for (int i=0; i<3; i++)
- {
- SimpleNamespace args = new SimpleNamespace();
- args.put("count",new Integer(i));
- args.put("currentTime",new Long(System.currentTimeMillis()));
- this.scriptService.eval("CompilableInterface", args);
- }
- }
-
- /**
- * Taken from the JSR 223 reference implementation
- */
- public void testHelloWorld() throws Exception
- {
- this.scriptService.eval("HelloWorld");
- }
-
- /**
- * Taken from the JSR 223 reference implementation. This test
- * does not work with the "small" interpreter
- */
- public void testInvocableIntf() throws Exception
- {
- MyInterface myInterface = (MyInterface) scriptService.getInterface(
- MyInterface.class
- );
-
- System.out.println("Initial value for X: " + myInterface.getX());
- myInterface.setX("New string");
- System.out.println("Current value for X: " + myInterface.getX());
- System.out.println("\nInitial value for Y: " + myInterface.getY());
- myInterface.setY(100);
- System.out.println("Current value for Y: " + myInterface.getY());
- }
-
- /**
- * Taken from the JSR 223 reference implementation.
- */
- public void testNamespaceDemo2() throws Exception
- {
- ScriptEngine eng = this.scriptService.getScriptEngine();
-
- //create two simple namespaces
- SimpleNamespace eNamespace = new SimpleNamespace();
- eNamespace.put("key", new Testobj("Original engine scope."));
- SimpleNamespace cNamespace = new SimpleNamespace();
- cNamespace.put("key", new Testobj("Original ENGINE_SCOPE in context."));
-
- //use external namespace instead of the default one
- eng.setNamespace(eNamespace,ScriptContext.ENGINE_SCOPE);
- System.out.println("Starting value of key in engine scope is \"" + eng.get("key") + "\"");
-
- //execute script using the namespace
- Object ret = this.scriptService.eval("NamespaceDemo2");
- System.out.println("Ending value of key in engine scope is \"" + eng.get("key") + "\"");
-
- //create a scriptcontext and set its engine scope namespace
- ScriptContext ctxt = new GenericScriptContext();
- ctxt.setNamespace(cNamespace, ScriptContext.ENGINE_SCOPE);
-
- ret = this.scriptService.eval("NamespaceDemo2", ctxt);
- System.out.println("Ending value of key in engine scope is \"" + eng.get("key") + "\"");
- System.out.println("Ending value of key in ENGINE_SCOPE of context is " +
- ctxt.getAttribute("key",ScriptContext.ENGINE_SCOPE));
- }
-
- /**
- * Taken from the JSR 223 reference implementation.
- */
- public void testNamespaceDemo3() throws Exception
- {
- final int STATE1 = 1;
- final int STATE2 = 2;
- final ScriptEngine engine = this.scriptService.getScriptEngine();
- final ScriptService scriptService = this.scriptService;
-
- //set engine-scope namespace with state=1
- Namespace n = new SimpleNamespace();
- engine.setNamespace(n, ScriptContext.ENGINE_SCOPE);
- n.put("state", new Integer(STATE1));
-
- //create a new thread to run script
- Thread t = new Thread(new Runnable(){
- public void run() {
- try {
- scriptService.eval("NamespaceDemo3");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- t.start();
-
- // wait for the script engine to start and execute the script
- Thread.sleep(2000);
-
- //changes state
- n.put("state", new Integer(STATE2));
- t.join();
- System.out.println("Script has executed.. current state is " +
- n.get("state"));
- }
-
- /**
- * Test access to the Avalon infrastructure
- */
- public void testAvalonContext() throws Exception
- {
- SimpleNamespace args = new SimpleNamespace();
- args.put("bar",new Integer(2));
- Object result = this.scriptService.eval("Avalon", args);
- System.out.println("RESULT ==> " + result);
- }
-
- /**
- * Test the general performance of the JSR 223 integration
- */
- public void testPerformance() throws Exception
- {
- long startTime = System.currentTimeMillis();
- for( int i=0; i<500; i++ )
- {
- this.testHelloWorld();
- this.testCompilableInterface();
- this.testNamespaceDemo2();
- this.testAvalonContext();
- }
- long endTime = System.currentTimeMillis();
- long duration = endTime - startTime;
-
- System.out.println("=== Exceution took " + duration + " ms ===");
- }
-
- /**
- * Check ScriptService.exist()
- *
- */
- public void testExists() throws Exception
- {
- assertTrue(this.scriptService.exists("HelloWorld"));
- assertFalse(this.scriptService.exists("grmpff"));
- }
-
- /**
- * Execute a script using multiple threads.
- */
- public void testMultithreadingScript() throws Exception
- {
- Hashtable args0 = new Hashtable();
- args0.put("foo", new Double(0));
- ScriptRunnable runnable0 = new ScriptRunnableImpl( this.scriptService, "MultiThreaded", args0 );
-
- Hashtable args1 = new Hashtable();
- args1.put("foo", new Double(1));
- ScriptRunnable runnable1 = new ScriptRunnableImpl( this.scriptService, "MultiThreaded", args1 );
- Thread thread1 = new Thread(runnable1,"Thread1");
-
- Hashtable args2 = new Hashtable();
- args2.put("foo", new Double(2));
- ScriptRunnable runnable2 = new ScriptRunnableImpl( this.scriptService, "MultiThreaded", args2 );
- Thread thread2 = new Thread(runnable2,"Thread2");
-
- thread1.start();
- thread2.start();
- runnable0.run();
-
- assertTrue( runnable0.getResult() == runnable0.getResult() );
- assertTrue( runnable1.getResult() == runnable1.getResult() );
- assertTrue( runnable2.getResult() == runnable2.getResult() );
-
- thread1.join();
- thread2.join();
-
- assertEquals( new Double(0), args0.get("foo") );
- assertEquals( new Double(2), args1.get("foo") );
- assertEquals( new Double(4), args2.get("foo") );
- }
-
- /**
- * Execute a script resulting in a ScriptException.
- */
- public void testRuntimeErrorScript() throws Exception
- {
- try
- {
- this.scriptService.eval("RuntimeError");
- fail("Expected ScriptException");
- }
- catch (ScriptException e)
- {
- return;
- }
- }
-
- /**
- * Tests the call() method of an Invocable.
- */
- public void testCall() throws Exception
- {
- String newX = "New X String";
- String oldX = (String) this.scriptService.call("getX", new Object[0]);
- this.scriptService.call("setX", new Object[]{newX} );
- newX = (String) this.scriptService.call("getX", new Object[0]);
- this.scriptService.call("setX", new Object[]{oldX} );
- }
-
- /**
- * Tests the locator functionality
- */
- public void testLocatorFunctionality() throws Exception
- {
- String result = null;
-
- // execute locator/foo.extension
- result = this.scriptService.eval("locator/foo").toString();
- assertTrue(result.startsWith("locator/foo."));
-
- // execute locator/foo/foo.extension which is not found but locator/foo.extension is
- result = this.scriptService.eval("locator/foo/foo").toString();
- assertTrue(result.startsWith("locator/foo."));
-
- // execute locator/bar/foo.extension
- result = this.scriptService.eval("locator/bar/foo").toString();
- assertTrue(result.startsWith("locator/bar/foo."));
-
- }
-}
+package org.apache.fulcrum.script;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import java.util.Hashtable;
+
+import javax.script.GenericScriptContext;
+import javax.script.Namespace;
+import javax.script.ScriptContext;
+import javax.script.ScriptEngine;
+import javax.script.ScriptException;
+import javax.script.SimpleNamespace;
+
+import org.apache.fulcrum.script.impl.ScriptRunnableImpl;
+import org.apache.fulcrum.testcontainer.BaseUnitTest;
+
+/**
+ * Common test cases for all scripting languages.
+ *
+ * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
+ */
+public class AbstractScriptTest extends BaseUnitTest
+{
+ protected ScriptService scriptService;
+
+ /**
+ * Defines the testcase name for JUnit.
+ *
+ * @param name the testcase's name.
+ */
+ public AbstractScriptTest(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ this.scriptService = (ScriptService) this.lookup(ScriptService.class.getName());
+ }
+
+ /**
+ * Taken from the JSR 223 reference implementation
+ */
+ public void testCompilableInterface() throws Exception
+ {
+ for (int i=0; i<3; i++)
+ {
+ SimpleNamespace args = new SimpleNamespace();
+ args.put("count",new Integer(i));
+ args.put("currentTime",new Long(System.currentTimeMillis()));
+ this.scriptService.eval("CompilableInterface", args);
+ }
+ }
+
+ /**
+ * Taken from the JSR 223 reference implementation
+ */
+ public void testHelloWorld() throws Exception
+ {
+ this.scriptService.eval("HelloWorld");
+ }
+
+ /**
+ * Taken from the JSR 223 reference implementation. This test
+ * does not work with the "small" interpreter
+ */
+ public void testInvocableIntf() throws Exception
+ {
+ MyInterface myInterface = (MyInterface) scriptService.getInterface(
+ MyInterface.class
+ );
+
+ System.out.println("Initial value for X: " + myInterface.getX());
+ myInterface.setX("New string");
+ System.out.println("Current value for X: " + myInterface.getX());
+ System.out.println("\nInitial value for Y: " + myInterface.getY());
+ myInterface.setY(100);
+ System.out.println("Current value for Y: " + myInterface.getY());
+ }
+
+ /**
+ * Taken from the JSR 223 reference implementation.
+ */
+ public void testNamespaceDemo2() throws Exception
+ {
+ ScriptEngine eng = this.scriptService.getScriptEngine();
+
+ //create two simple namespaces
+ SimpleNamespace eNamespace = new SimpleNamespace();
+ eNamespace.put("key", new Testobj("Original engine scope."));
+ SimpleNamespace cNamespace = new SimpleNamespace();
+ cNamespace.put("key", new Testobj("Original ENGINE_SCOPE in context."));
+
+ //use external namespace instead of the default one
+ eng.setNamespace(eNamespace,ScriptContext.ENGINE_SCOPE);
+ System.out.println("Starting value of key in engine scope is \"" + eng.get("key") + "\"");
+
+ //execute script using the namespace
+ Object ret = this.scriptService.eval("NamespaceDemo2");
+ System.out.println("Ending value of key in engine scope is \"" + eng.get("key") + "\"");
+
+ //create a scriptcontext and set its engine scope namespace
+ ScriptContext ctxt = new GenericScriptContext();
+ ctxt.setNamespace(cNamespace, ScriptContext.ENGINE_SCOPE);
+
+ ret = this.scriptService.eval("NamespaceDemo2", ctxt);
+ System.out.println("Ending value of key in engine scope is \"" + eng.get("key") + "\"");
+ System.out.println("Ending value of key in ENGINE_SCOPE of context is " +
+ ctxt.getAttribute("key",ScriptContext.ENGINE_SCOPE));
+ }
+
+ /**
+ * Taken from the JSR 223 reference implementation.
+ */
+ public void testNamespaceDemo3() throws Exception
+ {
+ final int STATE1 = 1;
+ final int STATE2 = 2;
+ final ScriptEngine engine = this.scriptService.getScriptEngine();
+ final ScriptService scriptService = this.scriptService;
+
+ //set engine-scope namespace with state=1
+ Namespace n = new SimpleNamespace();
+ engine.setNamespace(n, ScriptContext.ENGINE_SCOPE);
+ n.put("state", new Integer(STATE1));
+
+ //create a new thread to run script
+ Thread t = new Thread(new Runnable(){
+ public void run() {
+ try {
+ scriptService.eval("NamespaceDemo3");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ t.start();
+
+ // wait for the script engine to start and execute the script
+ Thread.sleep(2000);
+
+ //changes state
+ n.put("state", new Integer(STATE2));
+ t.join();
+ System.out.println("Script has executed.. current state is " +
+ n.get("state"));
+ }
+
+ /**
+ * Test access to the Avalon infrastructure
+ */
+ public void testAvalonContext() throws Exception
+ {
+ SimpleNamespace args = new SimpleNamespace();
+ args.put("bar",new Integer(2));
+ Object result = this.scriptService.eval("Avalon", args);
+ System.out.println("RESULT ==> " + result);
+ }
+
+ /**
+ * Test the general performance of the JSR 223 integration
+ */
+ public void testPerformance() throws Exception
+ {
+ long startTime = System.currentTimeMillis();
+ for( int i=0; i<500; i++ )
+ {
+ this.testHelloWorld();
+ this.testCompilableInterface();
+ this.testNamespaceDemo2();
+ this.testAvalonContext();
+ }
+ long endTime = System.currentTimeMillis();
+ long duration = endTime - startTime;
+
+ System.out.println("=== Exceution took " + duration + " ms ===");
+ }
+
+ /**
+ * Check ScriptService.exist()
+ *
+ */
+ public void testExists() throws Exception
+ {
+ assertTrue(this.scriptService.exists("HelloWorld"));
+ assertFalse(this.scriptService.exists("grmpff"));
+ }
+
+ /**
+ * Execute a script using multiple threads.
+ */
+ public void testMultithreadingScript() throws Exception
+ {
+ Hashtable args0 = new Hashtable();
+ args0.put("foo", new Double(0));
+ ScriptRunnable runnable0 = new ScriptRunnableImpl( this.scriptService, "MultiThreaded", args0 );
+
+ Hashtable args1 = new Hashtable();
+ args1.put("foo", new Double(1));
+ ScriptRunnable runnable1 = new ScriptRunnableImpl( this.scriptService, "MultiThreaded", args1 );
+ Thread thread1 = new Thread(runnable1,"Thread1");
+
+ Hashtable args2 = new Hashtable();
+ args2.put("foo", new Double(2));
+ ScriptRunnable runnable2 = new ScriptRunnableImpl( this.scriptService, "MultiThreaded", args2 );
+ Thread thread2 = new Thread(runnable2,"Thread2");
+
+ thread1.start();
+ thread2.start();
+ runnable0.run();
+
+ assertTrue( runnable0.getResult() == runnable0.getResult() );
+ assertTrue( runnable1.getResult() == runnable1.getResult() );
+ assertTrue( runnable2.getResult() == runnable2.getResult() );
+
+ thread1.join();
+ thread2.join();
+
+ assertEquals( new Double(0), args0.get("foo") );
+ assertEquals( new Double(2), args1.get("foo") );
+ assertEquals( new Double(4), args2.get("foo") );
+ }
+
+ /**
+ * Execute a script resulting in a ScriptException.
+ */
+ public void testRuntimeErrorScript() throws Exception
+ {
+ try
+ {
+ this.scriptService.eval("RuntimeError");
+ fail("Expected ScriptException");
+ }
+ catch (ScriptException e)
+ {
+ return;
+ }
+ }
+
+ /**
+ * Tests the call() method of an Invocable.
+ */
+ public void testCall() throws Exception
+ {
+ String newX = "New X String";
+ String oldX = (String) this.scriptService.call("getX", new Object[0]);
+ this.scriptService.call("setX", new Object[]{newX} );
+ newX = (String) this.scriptService.call("getX", new Object[0]);
+ this.scriptService.call("setX", new Object[]{oldX} );
+ }
+
+ /**
+ * Tests the locator functionality
+ */
+ public void testLocatorFunctionality() throws Exception
+ {
+ String result = null;
+
+ // execute locator/foo.extension
+ result = this.scriptService.eval("locator/foo").toString();
+ assertTrue(result.startsWith("locator/foo."));
+
+ // execute locator/foo/foo.extension which is not found but locator/foo.extension is
+ result = this.scriptService.eval("locator/foo/foo").toString();
+ assertTrue(result.startsWith("locator/foo."));
+
+ // execute locator/bar/foo.extension
+ result = this.scriptService.eval("locator/bar/foo").toString();
+ assertTrue(result.startsWith("locator/bar/foo."));
+
+ }
+}
Modified: jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/GroovyTest.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/GroovyTest.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/GroovyTest.java (original)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/GroovyTest.java Fri May 4 23:58:06 2007
@@ -1,66 +1,68 @@
-package org.apache.fulcrum.script;
-
-/*
- * Copyright 2005 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.
- */
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-/**
- * Regression test for Groovy
- *
- * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
- */
-public class GroovyTest extends AbstractScriptTest
-{
- /**
- * Defines the testcase name for JUnit.
- *
- * @param name the testcase's name.
- */
- public GroovyTest(String name)
- {
- super(name);
- this.setConfigurationFileName("./src/test/TestGroovyComponentConfig.xml");
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
- }
-
- /**
- * Add all of our test suites
- */
- public static Test suite()
- {
- TestSuite suite= new TestSuite("GroovyTest");
-
- suite.addTest( new GroovyTest("testCompilableInterface") );
- suite.addTest( new GroovyTest("testHelloWorld") );
- suite.addTest( new GroovyTest("testNamespaceDemo2") );
- suite.addTest( new GroovyTest("testNamespaceDemo3") );
-
- suite.addTest( new GroovyTest("testAvalonContext") );
- suite.addTest( new GroovyTest("testExists") );
- suite.addTest( new GroovyTest("testPerformance") );
- suite.addTest( new GroovyTest("testMultithreadingScript") );
- suite.addTest( new GroovyTest("testRuntimeErrorScript") );
-
- return suite;
- }
-}
+package org.apache.fulcrum.script;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Regression test for Groovy
+ *
+ * @author <a href="mailto:siegfried.goeschl@it20one.at">Siegfried Goeschl</a>
+ */
+public class GroovyTest extends AbstractScriptTest
+{
+ /**
+ * Defines the testcase name for JUnit.
+ *
+ * @param name the testcase's name.
+ */
+ public GroovyTest(String name)
+ {
+ super(name);
+ this.setConfigurationFileName("./src/test/TestGroovyComponentConfig.xml");
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ /**
+ * Add all of our test suites
+ */
+ public static Test suite()
+ {
+ TestSuite suite= new TestSuite("GroovyTest");
+
+ suite.addTest( new GroovyTest("testCompilableInterface") );
+ suite.addTest( new GroovyTest("testHelloWorld") );
+ suite.addTest( new GroovyTest("testNamespaceDemo2") );
+ suite.addTest( new GroovyTest("testNamespaceDemo3") );
+
+ suite.addTest( new GroovyTest("testAvalonContext") );
+ suite.addTest( new GroovyTest("testExists") );
+ suite.addTest( new GroovyTest("testPerformance") );
+ suite.addTest( new GroovyTest("testMultithreadingScript") );
+ suite.addTest( new GroovyTest("testRuntimeErrorScript") );
+
+ return suite;
+ }
+}
Modified: jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/MyInterface.java
URL: http://svn.apache.org/viewvc/jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/MyInterface.java?view=diff&rev=535465&r1=535464&r2=535465
==============================================================================
--- jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/MyInterface.java (original)
+++ jakarta/turbine/fulcrum/trunk/script/src/test/org/apache/fulcrum/script/MyInterface.java Fri May 4 23:58:06 2007
@@ -1,42 +1,60 @@
-/*
-Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
--Redistribution of source code must retain the above copyright notice, this
- list of conditions and the following disclaimer.
-
--Redistribution in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
-
-Neither the name of Sun Microsystems, Inc. or the names of contributors may
-be used to endorse or promote products derived from this software without
-specific prior written permission.
-
-This software is provided "AS IS," without a warranty of any kind. ALL
-EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
-ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
-OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN")
-AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
-AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
-DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
-REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
-INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
-OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
-EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-
-You acknowledge that this software is not designed, licensed or intended
-for use in the design, construction, operation or maintenance of any
-nuclear facility.
-*/
-
-package org.apache.fulcrum.script;
-
-public interface MyInterface {
- public void setX(String value);
- public String getX();
- public void setY(int value);
- public Integer getY();
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+/*
+ * Copyright (c) 2004 Sun Microsystems, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * -Redistribution of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * -Redistribution in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of contributors may
+ * be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
+ * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
+ * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MIDROSYSTEMS, INC. ("SUN")
+ * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
+ * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
+ * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
+ * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
+ * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
+ * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
+ * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ * You acknowledge that this software is not designed, licensed or intended
+ * for use in the design, construction, operation or maintenance of any
+ * nuclear facility.
+ */
+
+package org.apache.fulcrum.script;
+
+public interface MyInterface {
+ public void setX(String value);
+ public String getX();
+ public void setY(int value);
+ public Integer getY();
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org