Index: beans/src/test/support/java/org/apache/harmony/beans/tests/support/StringEditor.java =================================================================== --- beans/src/test/support/java/org/apache/harmony/beans/tests/support/StringEditor.java (revision 0) +++ beans/src/test/support/java/org/apache/harmony/beans/tests/support/StringEditor.java (revision 0) @@ -0,0 +1,34 @@ +/* + * Copyright 2005-2006 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 org.apache.harmony.beans.tests.support; + +import java.beans.*; + +public class StringEditor extends PropertyEditorSupport { + + public StringEditor(final Object source) { + super(source); + } + + public StringEditor() { + super(); + } + + public void setAsText(String text) { + setValue(text); + } +} Index: beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerRegressionTest.java =================================================================== --- beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerRegressionTest.java (revision 0) +++ beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerRegressionTest.java (revision 0) @@ -0,0 +1,71 @@ +/* Copyright 2005-2006 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 org.apache.harmony.beans.tests.java.beans; + +import java.beans.*; +import junit.framework.TestCase; +import org.apache.harmony.beans.tests.support.StringEditor; + +/** + * Regression test for PropertyEditorManager + */ +public class PropertyEditorManagerRegressionTest extends TestCase { + + static String origPath[] = PropertyEditorManager.getEditorSearchPath(); + + // Regression Harmony-1205 + public void testFindEditorAccordingPath_1() throws ClassNotFoundException{ + String newPath[] = new String[origPath.length + 1]; + newPath[0] = "org.apache.harmony.beans.tests.support"; + for(int i = 0; i < origPath.length; i++) newPath[i + 1] = origPath[i]; + + PropertyEditorManager + .setEditorSearchPath(newPath); + + PropertyEditor editor = + PropertyEditorManager.findEditor(Class.forName("java.lang.String")); + assertTrue(editor instanceof org.apache.harmony.beans.tests.support.StringEditor); // + assertEquals(org.apache.harmony.beans.tests.support.StringEditor.class, editor.getClass()); + } + + public void testFindEditorAccordingPath_2() throws ClassNotFoundException{ + String newPath[] = new String[origPath.length + 1]; + newPath[origPath.length] = "org.apache.harmony.beans.tests.support"; + for(int i = 0; i < origPath.length; i++) newPath[i] = origPath[i]; + + PropertyEditorManager + .setEditorSearchPath(newPath); + + PropertyEditor editor = + PropertyEditorManager.findEditor(Class.forName("java.lang.String")); + assertTrue(editor instanceof org.apache.harmony.beans.editors.StringEditor); // + assertEquals(org.apache.harmony.beans.editors.StringEditor.class, editor.getClass()); + } + + // Regression Harmony-1199 + public void testStringEditor() throws ClassNotFoundException{ + PropertyEditorManager.setEditorSearchPath(origPath); + PropertyEditor editor = + PropertyEditorManager.findEditor(Class.forName("java.lang.String")); + String text = "A sample string"; + try{ + editor.setAsText(text); + assertEquals(text, editor.getAsText()); + }catch(IllegalArgumentException e){ + fail("Unexpected IllegalArgumentException"); + } + } +}