Index: src/test/java-internal/java/beans/PropertyEditorSupportTest.java =================================================================== --- src/test/java-internal/java/beans/PropertyEditorSupportTest.java (revision 0) +++ src/test/java-internal/java/beans/PropertyEditorSupportTest.java (revision 0) @@ -0,0 +1,107 @@ +/* + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * 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 java.beans; + +import java.beans.PropertyEditorSupport; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Test class for java.beans.beancontext.BeanContextSupport. + *
+ */ + +public class PropertyEditorSupportTest extends TestCase { + + /** + * No arguments constructor to enable serialization. + *
+ */ + public PropertyEditorSupportTest() { + super(); + } + + /** + * Constructs this test case with the given name. + *
+ * + * @param name - The name for this test case. + *
+ */ + public PropertyEditorSupportTest(String name) { + super(name); + } + + public void test_setAsTextNull(){ + PropertyEditorSupport undefPropertyEditorSupport = new PropertyEditorSupport(); + try { + undefPropertyEditorSupport.setAsText("string"); + fail("IllegalArgumentException expected, but nothing was thrown!"); + } catch (IllegalArgumentException e) { + // Expected IllegalArgumentException + } catch (Exception e) { + fail("IllegalArgumentException expected, but found: " + + e.getMessage()); + } + } + + public void test_setAsTextObject(){ + PropertyEditorSupport defPropertyEditorSupport = new PropertyEditorSupport(); + try { + defPropertyEditorSupport.setValue(new Object()); + defPropertyEditorSupport.setAsText("string"); + fail("IllegalArgumentException expected, but nothing was thrown!"); + } catch (IllegalArgumentException e) { + // Expected IllegalArgumentException + } catch (Exception e) { + fail("IllegalArgumentException expected, but found: " + + e.getMessage()); + } + } + + public void test_setAsTextString(){ + PropertyEditorSupport defPropertyEditorSupport = new PropertyEditorSupport(); + try { + defPropertyEditorSupport.setValue(new String()); + defPropertyEditorSupport.setAsText("string"); + } catch (Exception e) { + fail("Unexpected Exception: " + e.getMessage()); + + } + } + + /** + * Start testing from the command line. + *
+ */ + public static Test suite() { + return new TestSuite(PropertyEditorSupportTest.class); + } + + /** + * Start testing from the command line. + *
+ * + * @param args - Command line parameters. + *
+ */ + public static void main(String args[]) { + junit.textui.TestRunner.run(suite()); + } +}