harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r417685 [9/15] - in /incubator/harmony/enhanced/classlib/trunk/modules/beans: ./ make/ src/test/java/org/apache/harmony/beans/tests/java/beans/ src/test/java/org/apache/harmony/beans/tests/java/beans/auxiliary/ src/test/java/org/apache/harm...
Date Wed, 28 Jun 2006 07:22:23 GMT
Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java?rev=417685&r1=417684&r2=417685&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorManagerTest.java Wed Jun 28 00:22:12 2006
@@ -24,722 +24,683 @@
 import java.util.Arrays;
 
 import junit.framework.TestCase;
-import org.apache.harmony.beans.tests.java.beans.mock.Foz;
-import org.apache.harmony.beans.tests.java.beans.mock.FozDefault;
-import org.apache.harmony.beans.tests.java.beans.mock.Fozz;
-import org.apache.harmony.beans.tests.java.beans.mock.FozzEditor;
-import org.apache.harmony.beans.tests.java.beans.mock.Fozzz;
-import org.apache.harmony.beans.tests.java.beans.mock.MockButton;
-import org.apache.harmony.beans.tests.java.beans.mock.MockFoo;
-
-import org.apache.harmony.beans.tests.java.beans.auxiliary.AnotherSampleProperty;
-import org.apache.harmony.beans.tests.java.beans.auxiliary.SampleProperty;
-import org.apache.harmony.beans.tests.java.beans.auxiliary.SamplePropertyEditor;
-import org.apache.harmony.beans.tests.java.beans.auxiliary.OtherEditor;
-
-import org.apache.harmony.beans.tests.java.beans.editors.AnotherSamplePropertyEditor;
 
+import org.apache.harmony.beans.tests.support.AnotherSampleProperty;
+import org.apache.harmony.beans.tests.support.AnotherSamplePropertyEditor;
+import org.apache.harmony.beans.tests.support.OtherEditor;
+import org.apache.harmony.beans.tests.support.SampleProperty;
+import org.apache.harmony.beans.tests.support.SamplePropertyEditor;
+import org.apache.harmony.beans.tests.support.mock.Foz;
+import org.apache.harmony.beans.tests.support.mock.Fozz;
+import org.apache.harmony.beans.tests.support.mock.FozzEditor;
+import org.apache.harmony.beans.tests.support.mock.Fozzz;
+import org.apache.harmony.beans.tests.support.mock.MockButton;
+import org.apache.harmony.beans.tests.support.mock.MockFoo;
 
 /**
  * Unit test for PropertyEditorManager
  */
 public class PropertyEditorManagerTest extends TestCase {
 
-	/*
-	 * Constructors
-	 */
-	public void testPropertyEditorManager() {
-		PropertyEditorManager managers = new PropertyEditorManager();
-	}
-
-	/*
-	 * find the editor which has been registered through registerEditor.
-	 */
-	public void testFindEditor_registered() {
-		Class editorClass = FozRegisteredEditor.class;
-		Class type = Foz.class;
-		PropertyEditorManager.registerEditor(type, editorClass);
-		PropertyEditor editor = PropertyEditorManager.findEditor(type);
-		assertTrue(editor instanceof FozRegisteredEditor);
-		assertEquals(editorClass, editor.getClass());
-	}
-
-	/*
-	 * Find editor of which name is XXXEditor in the same package
-	 */
-	public void testFindEditor_SamePackage() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Fozz.class);
-		assertTrue(editor instanceof FozzEditor);
-		assertEquals(FozzEditor.class, editor.getClass());
-	}
-
-	/*
-	 * Find editor in search path
-	 */
-	public void testFindEditor_DifferentPackage() {
-		String[] original = PropertyEditorManager.getEditorSearchPath();
-		PropertyEditorManager
-				.setEditorSearchPath(new String[] { "org.apache.harmony.beans.tests.java.beans" });
-		PropertyEditor editor = PropertyEditorManager.findEditor(Fozzz.class);
-		assertTrue(editor instanceof FozzzEditor);
-		assertEquals(FozzzEditor.class, editor.getClass());
-
-		PropertyEditorManager.setEditorSearchPath(original);
-	}
-
-	/*
-	 * Find editor for Java primitive types and java.lang.String.
-	 * java.awt.Color, and java.awt.Font
-	 */
-	public void testFindEditor_DefaultType() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Integer.TYPE);
-	}
-
-    //Regression test for HARMONY-258
-	public void testFindEditor_TypeNull() {
-		try {
-			PropertyEditorManager.findEditor(null);
-			fail("Should throw NullPointerException.");
-		} catch (NullPointerException e) {
-			// expected
-		}
-	}
-
-	public void testFindEditor_TypeNoEditor() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(MockFoo.class);
-		assertNull(editor);
-	}
-
-	public void testGetEditorSearchPath_default() {
-		String[] path = PropertyEditorManager.getEditorSearchPath();
-		assertEquals(1, path.length);
-		assertEquals("sun.beans.editors", path[0]);
-	}
-
-	public void testGetEditorSearchPath() {
-		String[] original = PropertyEditorManager.getEditorSearchPath();
-
-		String[] path = new String[] { "java.beans",
-				"org.apache.harmony.beans.tests.java.beans.editor", "", };
-		PropertyEditorManager.setEditorSearchPath(path);
-		String[] newPath = PropertyEditorManager.getEditorSearchPath();
-
-		assertTrue(Arrays.equals(path, newPath));
-
-		PropertyEditorManager.setEditorSearchPath(original);
-	}
-
-	/*
-	 * RegisterEditor
-	 */
-	public void testRegisterEditor() {
-		Class type = MockButton.class;
-
-		PropertyEditorManager.registerEditor(type, ButtonEditor.class);
-		PropertyEditor editor = PropertyEditorManager.findEditor(type);
-		assertEquals(ButtonEditor.class, editor.getClass());
-
-		PropertyEditorManager.registerEditor(type, FozRegisteredEditor.class);
-		editor = PropertyEditorManager.findEditor(type);
-		assertEquals(FozRegisteredEditor.class, editor.getClass());
-
-		PropertyEditorManager.registerEditor(type, null);
-		editor = PropertyEditorManager.findEditor(type);
-		assertNull(editor);
-	}
-
-	/*
-	 * registerEditor for type null
-     * Regression test for HARMONY-258
-	 */
-	public void testRegisterEditorType_Null() {
-		try {
-			PropertyEditorManager.registerEditor(null, ButtonEditor.class);
-			fail("Should throw NullPointerException.");
-		} catch (NullPointerException e) {
-			// expected
-		}
-	}
-
-	/*
-	 * set search path as {null}
-	 */
-	public void testSetEditorSearchPath_nullpath() {
-		String[] original = PropertyEditorManager.getEditorSearchPath();
-		PropertyEditorManager.setEditorSearchPath(new String[] { null });
-		assertEquals(1, PropertyEditorManager.getEditorSearchPath().length);
-		assertNull(PropertyEditorManager.getEditorSearchPath()[0]);
-		PropertyEditorManager.setEditorSearchPath(original);
-	}
-
-	/*
-	 * set search null
-	 */
-	public void testSetEditorSearchPath_null() {
-		String[] original = PropertyEditorManager.getEditorSearchPath();
-		PropertyEditorManager.setEditorSearchPath(null);
-		assertEquals(0, PropertyEditorManager.getEditorSearchPath().length);
-		PropertyEditorManager.setEditorSearchPath(original);
-	}
-
-	// Test internal Editor
-	public void testBoolEditor_setAsText() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Boolean.TYPE);
-		editor.setAsText("false");
-		assertEquals("false", editor.getAsText().toLowerCase());
-		assertEquals("false", editor.getJavaInitializationString());
-		assertEquals("True", editor.getTags()[0]);
-		assertEquals("False", editor.getTags()[1]);
-		assertEquals(Boolean.FALSE, editor.getValue());
-
-		editor.setAsText("TrUE");
-		assertEquals("true", editor.getAsText().toLowerCase());
-		assertEquals("true", editor.getJavaInitializationString());
-		assertEquals(Boolean.TRUE, editor.getValue());
-	}
-
-	public void testBoolEditor_setAsText_null() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Boolean.TYPE);
-		try {
-			editor.setAsText(null);
-			fail("Should throw a Exception");
-		} catch (Exception e) {
-		}
-	}
-
-	public void testBoolEditor_setAsText_Invalid() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Boolean.TYPE);
-		try {
-			editor.setAsText("***true***");
-			fail("Should throw a IllegalArgumentException");
-		} catch (IllegalArgumentException e) {
-		}
-	}
-
-	public void testByteEditor() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Byte.TYPE);
-		byte b = (byte) 0x7F;
-		editor.setAsText(Byte.toString(b));
-		assertEquals(Byte.toString(b), editor.getAsText());
-		assertEquals("((byte)127)", editor.getJavaInitializationString());
-		assertEquals(new Byte(b), editor.getValue());
-		assertNull(editor.getTags());
-	}
-
-	public void testByteEditor_null() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Byte.TYPE);
-		try {
-			editor.setAsText(null);
-			fail("Should throw a NumberFormatException");
-		} catch (NumberFormatException e) {
-
-		}
-	}
-
-	public void testByteEditor_invalid() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Byte.TYPE);
-		try {
-			editor.setAsText("invalid");
-			fail("Should throw a NumberFormatException");
-		} catch (NumberFormatException e) {
-
-		}
-	}
-
-	public void testByteEditor_invalid2() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Byte.TYPE);
-		try {
-			editor.setAsText("128");
-			fail("Should throw a NumberFormatException");
-		} catch (NumberFormatException e) {
-
-		}
-	}
-
-	public void testDoubleEditor() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Double.TYPE);
-		double d = 12345.678;
-		editor.setAsText(Double.toString(d));
-		assertEquals(Double.toString(d), editor.getAsText());
-		assertEquals(Double.toString(d), editor.getJavaInitializationString());
-		assertEquals(new Double(d), editor.getValue());
-		assertNull(editor.getTags());
-	}
-
-	public void testDoubleEditor_SetAsText_Null() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Double.TYPE);
-		try {
-			editor.setAsText(null);
-			fail("Should throw a NullPointerException");
-		} catch (NullPointerException e) {
-
-		}
-	}
-
-	public void testDoubleEditor_SetAsText_Invalid() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Double.TYPE);
-		try {
-			editor.setAsText("invalid");
-			fail("Should throw a NumberFormatException");
-		} catch (NumberFormatException e) {
-
-		}
-	}
-
-	public void testFloatEditor() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Float.TYPE);
-		float f = 12345.678f;
-		String text = Float.toString(f);
-		editor.setAsText(text);
-		assertEquals(text, editor.getAsText());
-		assertEquals(text + "F", editor.getJavaInitializationString());
-		assertEquals(new Float(f), editor.getValue());
-		assertNull(editor.getTags());
-	}
-
-	public void testFloatEditor_SetAsText_Null() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Float.TYPE);
-		try {
-			editor.setAsText(null);
-			fail("Should throw a NullPointerException");
-		} catch (NullPointerException e) {
-
-		}
-	}
-
-	public void testFloatEditor_SetAsText_Invalid() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Float.TYPE);
-		try {
-			editor.setAsText("invalid");
-			fail("Should throw a NumberFormatException");
-		} catch (NumberFormatException e) {
-
-		}
-	}
-
-	public void testLongEditor() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Long.TYPE);
-		long l = 123456789;
-		String text = Long.toString(l);
-		editor.setAsText(text);
-		assertEquals(text, editor.getAsText());
-		assertEquals(text + "L", editor.getJavaInitializationString());
-		assertEquals(new Long(l), editor.getValue());
-		assertNull(editor.getTags());
-	}
-
-	public void testLongEditor_SetAsText_Null() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Long.TYPE);
-		try {
-			editor.setAsText(null);
-			fail("Should throw a NumberFormatException");
-		} catch (NumberFormatException e) {
-
-		}
-	}
-
-	public void testLongEditor_SetAsText_Invalid() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Long.TYPE);
-		try {
-			editor.setAsText("invalid");
-			fail("Should throw a NumberFormatException");
-		} catch (NumberFormatException e) {
-
-		}
-	}
-
-	public void testShortEditor() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Short.TYPE);
-		short s = (short) 123456789;
-		String text = Short.toString(s);
-		editor.setAsText(text);
-		assertEquals(text, editor.getAsText());
-		assertEquals("((short)" + text + ")", editor
-				.getJavaInitializationString());
-		assertEquals(new Short(s), editor.getValue());
-		assertNull(editor.getTags());
-	}
-
-	public void testShortEditor_SetAsText_Null() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Short.TYPE);
-		try {
-			editor.setAsText(null);
-			fail("Should throw a NumberFormatException");
-		} catch (NumberFormatException e) {
-
-		}
-	}
-
-	public void testShortEditor_SetAsText_Invalid() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Short.TYPE);
-		try {
-			editor.setAsText("invalid");
-			fail("Should throw a NumberFormatException");
-		} catch (NumberFormatException e) {
-
-		}
-	}
-
-	public void testIntegerEditor() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Integer.TYPE);
-		int i = 123456789;
-		String text = Integer.toString(i);
-		editor.setAsText(text);
-		assertEquals(text, editor.getAsText());
-		assertEquals(text, editor.getJavaInitializationString());
-		assertEquals(new Integer(i), editor.getValue());
-		assertNull(editor.getTags());
-	}
-
-	public void testIntegerEditor_SetAsText_Null() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Integer.TYPE);
-		try {
-			editor.setAsText(null);
-			fail("Should throw a NumberFormatException");
-		} catch (NumberFormatException e) {
-
-		}
-	}
-
-	public void testIntegerEditor_SetAsText_Invalid() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(Integer.TYPE);
-		try {
-			editor.setAsText("invalid");
-			fail("Should throw a NumberFormatException");
-		} catch (NumberFormatException e) {
-
-		}
-	}
-
-	public void testStringEditor() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(String.class);
-		String text = "A sample string";
-		editor.setAsText(text);
-		assertEquals(text, editor.getAsText());
-		assertEquals("\"" + text + "\"", editor.getJavaInitializationString());
-		assertEquals(text, editor.getValue());
-		assertNull(editor.getTags());
-	}
-
-	public void testStringEditor_SetAsText_Null() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(String.class);
-
-		editor.setAsText("null");
-		assertEquals("null", editor.getAsText());
-		assertEquals("\"null\"", editor.getJavaInitializationString());
-		assertEquals("null", editor.getValue());
-
-		editor.setAsText("");
-		assertEquals("", editor.getAsText());
-		assertEquals("\"\"", editor.getJavaInitializationString());
-
-		editor.setAsText(null);
-		assertEquals("null", editor.getAsText());
-		assertEquals("null", editor.getJavaInitializationString());
-		assertNull(editor.getValue());
-	}
-
-	public void testStringEditor_SetAsText_SpecialChars() {
-		PropertyEditor editor = PropertyEditorManager.findEditor(String.class);
-		String str = "\n\t\\a\"";
-		editor.setAsText(str);
-		assertEquals(str, editor.getAsText());
-		assertEquals("\"\\n\\u0009\\\\a\\\"\"", editor
-				.getJavaInitializationString());
-	}
-
-	public static class FozRegisteredEditor implements PropertyEditor {
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#addPropertyChangeListener(java.beans.PropertyChangeListener)
-		 */
-		public void addPropertyChangeListener(PropertyChangeListener listener) {
-			// TO DO Auto-generated method stub
-
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#getAsText()
-		 */
-		public String getAsText() {
-			// TO DO Auto-generated method stub
-			return null;
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#getCustomEditor()
-		 */
-		public Component getCustomEditor() {
-			// TO DO Auto-generated method stub
-			return null;
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#getJavaInitializationString()
-		 */
-		public String getJavaInitializationString() {
-			// TO DO Auto-generated method stub
-			return null;
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#getTags()
-		 */
-		public String[] getTags() {
-			// TO DO Auto-generated method stub
-			return null;
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#getValue()
-		 */
-		public Object getValue() {
-			// TO DO Auto-generated method stub
-			return null;
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#isPaintable()
-		 */
-		public boolean isPaintable() {
-			// TO DO Auto-generated method stub
-			return false;
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#paintValue(java.awt.Graphics,
-		 *      java.awt.Rectangle)
-		 */
-		public void paintValue(Graphics graphics, Rectangle box) {
-			// TO DO Auto-generated method stub
-
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#removePropertyChangeListener(java.beans.PropertyChangeListener)
-		 */
-		public void removePropertyChangeListener(PropertyChangeListener listener) {
-			// TO DO Auto-generated method stub
-
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#setAsText(java.lang.String)
-		 */
-		public void setAsText(String text) throws IllegalArgumentException {
-			// TO DO Auto-generated method stub
-
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#setValue(java.lang.Object)
-		 */
-		public void setValue(Object value) {
-			// TO DO Auto-generated method stub
-
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#supportsCustomEditor()
-		 */
-		public boolean supportsCustomEditor() {
-			// TO DO Auto-generated method stub
-			return false;
-		}
-
-	}
-
-	public static class ButtonEditor implements PropertyEditor {
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#addPropertyChangeListener(java.beans.PropertyChangeListener)
-		 */
-		public void addPropertyChangeListener(PropertyChangeListener listener) {
-			// TO DO Auto-generated method stub
-
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#getAsText()
-		 */
-		public String getAsText() {
-			// TO DO Auto-generated method stub
-			return null;
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#getCustomEditor()
-		 */
-		public Component getCustomEditor() {
-			// TO DO Auto-generated method stub
-			return null;
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#getJavaInitializationString()
-		 */
-		public String getJavaInitializationString() {
-			// TO DO Auto-generated method stub
-			return null;
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#getTags()
-		 */
-		public String[] getTags() {
-			// TO DO Auto-generated method stub
-			return null;
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#getValue()
-		 */
-		public Object getValue() {
-			// TO DO Auto-generated method stub
-			return null;
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#isPaintable()
-		 */
-		public boolean isPaintable() {
-			// TO DO Auto-generated method stub
-			return false;
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#paintValue(java.awt.Graphics,
-		 *      java.awt.Rectangle)
-		 */
-		public void paintValue(Graphics graphics, Rectangle box) {
-			// TO DO Auto-generated method stub
-
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#removePropertyChangeListener(java.beans.PropertyChangeListener)
-		 */
-		public void removePropertyChangeListener(PropertyChangeListener listener) {
-			// TO DO Auto-generated method stub
-
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#setAsText(java.lang.String)
-		 */
-		public void setAsText(String text) throws IllegalArgumentException {
-			// TO DO Auto-generated method stub
-
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#setValue(java.lang.Object)
-		 */
-		public void setValue(Object value) {
-			// TO DO Auto-generated method stub
-
-		}
-
-		/*
-		 * (non-Javadoc)
-		 * 
-		 * @see java.beans.PropertyEditor#supportsCustomEditor()
-		 */
-		public boolean supportsCustomEditor() {
-			// TO DO Auto-generated method stub
-			return false;
-		}
-
-	}
-    
-    
+    /*
+     * Constructors
+     */
+    public void testPropertyEditorManager() {
+        new PropertyEditorManager();
+    }
+
+    /*
+     * find the editor which has been registered through registerEditor.
+     */
+    public void testFindEditor_registered() {
+        Class editorClass = FozRegisteredEditor.class;
+        Class type = Foz.class;
+        PropertyEditorManager.registerEditor(type, editorClass);
+        PropertyEditor editor = PropertyEditorManager.findEditor(type);
+        assertTrue(editor instanceof FozRegisteredEditor);
+        assertEquals(editorClass, editor.getClass());
+    }
+
+    /*
+     * Find editor of which name is XXXEditor in the same package
+     */
+    public void testFindEditor_SamePackage() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Fozz.class);
+        assertTrue(editor instanceof FozzEditor);
+        assertEquals(FozzEditor.class, editor.getClass());
+    }
+
+    /*
+     * Find editor in search path
+     */
+    public void testFindEditor_DifferentPackage() {
+        String[] original = PropertyEditorManager.getEditorSearchPath();
+        PropertyEditorManager
+                .setEditorSearchPath(new String[] { "org.apache.harmony.beans.tests.java.beans" });
+        PropertyEditor editor = PropertyEditorManager.findEditor(Fozzz.class);
+        assertTrue(editor instanceof FozzzEditor);
+        assertEquals(FozzzEditor.class, editor.getClass());
+
+        PropertyEditorManager.setEditorSearchPath(original);
+    }
+
+    /*
+     * Find editor for Java primitive types and java.lang.String.
+     * java.awt.Color, and java.awt.Font
+     */
+    public void testFindEditor_DefaultType() {
+        PropertyEditorManager.findEditor(Integer.TYPE);
+    }
+
+    // Regression test for HARMONY-258
+    public void testFindEditor_TypeNull() {
+        try {
+            PropertyEditorManager.findEditor(null);
+            fail("Should throw NullPointerException.");
+        } catch (NullPointerException e) {
+            // expected
+        }
+    }
+
+    public void testFindEditor_TypeNoEditor() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(MockFoo.class);
+        assertNull(editor);
+    }
+
+    public void testGetEditorSearchPath_default() {
+        String[] path = PropertyEditorManager.getEditorSearchPath();
+        assertEquals(1, path.length);
+        assertEquals("sun.beans.editors", path[0]);
+    }
+
+    public void testGetEditorSearchPath() {
+        String[] original = PropertyEditorManager.getEditorSearchPath();
+
+        String[] path = new String[] { "java.beans",
+                "org.apache.harmony.beans.tests.java.beans.editor", "", };
+        PropertyEditorManager.setEditorSearchPath(path);
+        String[] newPath = PropertyEditorManager.getEditorSearchPath();
+
+        assertTrue(Arrays.equals(path, newPath));
+
+        PropertyEditorManager.setEditorSearchPath(original);
+    }
+
+    /*
+     * RegisterEditor
+     */
+    public void testRegisterEditor() {
+        Class type = MockButton.class;
+
+        PropertyEditorManager.registerEditor(type, ButtonEditor.class);
+        PropertyEditor editor = PropertyEditorManager.findEditor(type);
+        assertEquals(ButtonEditor.class, editor.getClass());
+
+        PropertyEditorManager.registerEditor(type, FozRegisteredEditor.class);
+        editor = PropertyEditorManager.findEditor(type);
+        assertEquals(FozRegisteredEditor.class, editor.getClass());
+
+        PropertyEditorManager.registerEditor(type, null);
+        editor = PropertyEditorManager.findEditor(type);
+        assertNull(editor);
+    }
+
+    /*
+     * registerEditor for type null Regression test for HARMONY-258
+     */
+    public void testRegisterEditorType_Null() {
+        try {
+            PropertyEditorManager.registerEditor(null, ButtonEditor.class);
+            fail("Should throw NullPointerException.");
+        } catch (NullPointerException e) {
+            // expected
+        }
+    }
+
+    /*
+     * set search path as {null}
+     */
+    public void testSetEditorSearchPath_nullpath() {
+        String[] original = PropertyEditorManager.getEditorSearchPath();
+        PropertyEditorManager.setEditorSearchPath(new String[] { null });
+        assertEquals(1, PropertyEditorManager.getEditorSearchPath().length);
+        assertNull(PropertyEditorManager.getEditorSearchPath()[0]);
+        PropertyEditorManager.setEditorSearchPath(original);
+    }
+
+    /*
+     * set search null
+     */
+    public void testSetEditorSearchPath_null() {
+        String[] original = PropertyEditorManager.getEditorSearchPath();
+        PropertyEditorManager.setEditorSearchPath(null);
+        assertEquals(0, PropertyEditorManager.getEditorSearchPath().length);
+        PropertyEditorManager.setEditorSearchPath(original);
+    }
+
+    // Test internal Editor
+    public void testBoolEditor_setAsText() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Boolean.TYPE);
+        editor.setAsText("false");
+        assertEquals("false", editor.getAsText().toLowerCase());
+        assertEquals("false", editor.getJavaInitializationString());
+        assertEquals("True", editor.getTags()[0]);
+        assertEquals("False", editor.getTags()[1]);
+        assertEquals(Boolean.FALSE, editor.getValue());
+
+        editor.setAsText("TrUE");
+        assertEquals("true", editor.getAsText().toLowerCase());
+        assertEquals("true", editor.getJavaInitializationString());
+        assertEquals(Boolean.TRUE, editor.getValue());
+    }
+
+    public void testBoolEditor_setAsText_null() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Boolean.TYPE);
+        try {
+            editor.setAsText(null);
+            fail("Should throw a Exception");
+        } catch (Exception e) {}
+    }
+
+    public void testBoolEditor_setAsText_Invalid() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Boolean.TYPE);
+        try {
+            editor.setAsText("***true***");
+            fail("Should throw a IllegalArgumentException");
+        } catch (IllegalArgumentException e) {}
+    }
+
+    public void testByteEditor() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Byte.TYPE);
+        byte b = (byte) 0x7F;
+        editor.setAsText(Byte.toString(b));
+        assertEquals(Byte.toString(b), editor.getAsText());
+        assertEquals("((byte)127)", editor.getJavaInitializationString());
+        assertEquals(new Byte(b), editor.getValue());
+        assertNull(editor.getTags());
+    }
+
+    public void testByteEditor_null() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Byte.TYPE);
+        try {
+            editor.setAsText(null);
+            fail("Should throw a NumberFormatException");
+        } catch (NumberFormatException e) {}
+    }
+
+    public void testByteEditor_invalid() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Byte.TYPE);
+        try {
+            editor.setAsText("invalid");
+            fail("Should throw a NumberFormatException");
+        } catch (NumberFormatException e) {}
+    }
+
+    public void testByteEditor_invalid2() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Byte.TYPE);
+        try {
+            editor.setAsText("128");
+            fail("Should throw a NumberFormatException");
+        } catch (NumberFormatException e) {}
+    }
+
+    public void testDoubleEditor() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Double.TYPE);
+        double d = 12345.678;
+        editor.setAsText(Double.toString(d));
+        assertEquals(Double.toString(d), editor.getAsText());
+        assertEquals(Double.toString(d), editor.getJavaInitializationString());
+        assertEquals(new Double(d), editor.getValue());
+        assertNull(editor.getTags());
+    }
+
+    public void testDoubleEditor_SetAsText_Null() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Double.TYPE);
+        try {
+            editor.setAsText(null);
+            fail("Should throw a NullPointerException");
+        } catch (NullPointerException e) {}
+    }
+
+    public void testDoubleEditor_SetAsText_Invalid() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Double.TYPE);
+        try {
+            editor.setAsText("invalid");
+            fail("Should throw a NumberFormatException");
+        } catch (NumberFormatException e) {}
+    }
+
+    public void testFloatEditor() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Float.TYPE);
+        float f = 12345.678f;
+        String text = Float.toString(f);
+        editor.setAsText(text);
+        assertEquals(text, editor.getAsText());
+        assertEquals(text + "F", editor.getJavaInitializationString());
+        assertEquals(new Float(f), editor.getValue());
+        assertNull(editor.getTags());
+    }
+
+    public void testFloatEditor_SetAsText_Null() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Float.TYPE);
+        try {
+            editor.setAsText(null);
+            fail("Should throw a NullPointerException");
+        } catch (NullPointerException e) {}
+    }
+
+    public void testFloatEditor_SetAsText_Invalid() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Float.TYPE);
+        try {
+            editor.setAsText("invalid");
+            fail("Should throw a NumberFormatException");
+        } catch (NumberFormatException e) {}
+    }
+
+    public void testLongEditor() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Long.TYPE);
+        long l = 123456789;
+        String text = Long.toString(l);
+        editor.setAsText(text);
+        assertEquals(text, editor.getAsText());
+        assertEquals(text + "L", editor.getJavaInitializationString());
+        assertEquals(new Long(l), editor.getValue());
+        assertNull(editor.getTags());
+    }
+
+    public void testLongEditor_SetAsText_Null() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Long.TYPE);
+        try {
+            editor.setAsText(null);
+            fail("Should throw a NumberFormatException");
+        } catch (NumberFormatException e) {}
+    }
+
+    public void testLongEditor_SetAsText_Invalid() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Long.TYPE);
+        try {
+            editor.setAsText("invalid");
+            fail("Should throw a NumberFormatException");
+        } catch (NumberFormatException e) {}
+    }
+
+    public void testShortEditor() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Short.TYPE);
+        short s = (short) 123456789;
+        String text = Short.toString(s);
+        editor.setAsText(text);
+        assertEquals(text, editor.getAsText());
+        assertEquals("((short)" + text + ")", editor
+                .getJavaInitializationString());
+        assertEquals(new Short(s), editor.getValue());
+        assertNull(editor.getTags());
+    }
+
+    public void testShortEditor_SetAsText_Null() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Short.TYPE);
+        try {
+            editor.setAsText(null);
+            fail("Should throw a NumberFormatException");
+        } catch (NumberFormatException e) {}
+    }
+
+    public void testShortEditor_SetAsText_Invalid() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Short.TYPE);
+        try {
+            editor.setAsText("invalid");
+            fail("Should throw a NumberFormatException");
+        } catch (NumberFormatException e) {}
+    }
+
+    public void testIntegerEditor() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Integer.TYPE);
+        int i = 123456789;
+        String text = Integer.toString(i);
+        editor.setAsText(text);
+        assertEquals(text, editor.getAsText());
+        assertEquals(text, editor.getJavaInitializationString());
+        assertEquals(new Integer(i), editor.getValue());
+        assertNull(editor.getTags());
+    }
+
+    public void testIntegerEditor_SetAsText_Null() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Integer.TYPE);
+        try {
+            editor.setAsText(null);
+            fail("Should throw a NumberFormatException");
+        } catch (NumberFormatException e) {}
+    }
+
+    public void testIntegerEditor_SetAsText_Invalid() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(Integer.TYPE);
+        try {
+            editor.setAsText("invalid");
+            fail("Should throw a NumberFormatException");
+        } catch (NumberFormatException e) {
+
+        }
+    }
+
+    public void testStringEditor() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(String.class);
+        String text = "A sample string";
+        editor.setAsText(text);
+        assertEquals(text, editor.getAsText());
+        assertEquals("\"" + text + "\"", editor.getJavaInitializationString());
+        assertEquals(text, editor.getValue());
+        assertNull(editor.getTags());
+    }
+
+    public void testStringEditor_SetAsText_Null() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(String.class);
+
+        editor.setAsText("null");
+        assertEquals("null", editor.getAsText());
+        assertEquals("\"null\"", editor.getJavaInitializationString());
+        assertEquals("null", editor.getValue());
+
+        editor.setAsText("");
+        assertEquals("", editor.getAsText());
+        assertEquals("\"\"", editor.getJavaInitializationString());
+
+        editor.setAsText(null);
+        assertEquals("null", editor.getAsText());
+        assertEquals("null", editor.getJavaInitializationString());
+        assertNull(editor.getValue());
+    }
+
+    public void testStringEditor_SetAsText_SpecialChars() {
+        PropertyEditor editor = PropertyEditorManager.findEditor(String.class);
+        String str = "\n\t\\a\"";
+        editor.setAsText(str);
+        assertEquals(str, editor.getAsText());
+        assertEquals("\"\\n\\u0009\\\\a\\\"\"", editor
+                .getJavaInitializationString());
+    }
+
+    public static class FozRegisteredEditor implements PropertyEditor {
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#addPropertyChangeListener(java.beans.PropertyChangeListener)
+         */
+        public void addPropertyChangeListener(PropertyChangeListener listener) {
+        // TO DO Auto-generated method stub
+
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#getAsText()
+         */
+        public String getAsText() {
+            // TO DO Auto-generated method stub
+            return null;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#getCustomEditor()
+         */
+        public Component getCustomEditor() {
+            // TO DO Auto-generated method stub
+            return null;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#getJavaInitializationString()
+         */
+        public String getJavaInitializationString() {
+            // TO DO Auto-generated method stub
+            return null;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#getTags()
+         */
+        public String[] getTags() {
+            // TO DO Auto-generated method stub
+            return null;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#getValue()
+         */
+        public Object getValue() {
+            // TO DO Auto-generated method stub
+            return null;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#isPaintable()
+         */
+        public boolean isPaintable() {
+            // TO DO Auto-generated method stub
+            return false;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#paintValue(java.awt.Graphics,
+         *      java.awt.Rectangle)
+         */
+        public void paintValue(Graphics graphics, Rectangle box) {
+        // TO DO Auto-generated method stub
+
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#removePropertyChangeListener(java.beans.PropertyChangeListener)
+         */
+        public void removePropertyChangeListener(PropertyChangeListener listener) {
+        // TO DO Auto-generated method stub
+
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#setAsText(java.lang.String)
+         */
+        public void setAsText(String text) throws IllegalArgumentException {
+        // TO DO Auto-generated method stub
+
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#setValue(java.lang.Object)
+         */
+        public void setValue(Object value) {
+        // TO DO Auto-generated method stub
+
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#supportsCustomEditor()
+         */
+        public boolean supportsCustomEditor() {
+            // TO DO Auto-generated method stub
+            return false;
+        }
+
+    }
+
+    public static class ButtonEditor implements PropertyEditor {
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#addPropertyChangeListener(java.beans.PropertyChangeListener)
+         */
+        public void addPropertyChangeListener(PropertyChangeListener listener) {
+        // TO DO Auto-generated method stub
+
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#getAsText()
+         */
+        public String getAsText() {
+            // TO DO Auto-generated method stub
+            return null;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#getCustomEditor()
+         */
+        public Component getCustomEditor() {
+            // TO DO Auto-generated method stub
+            return null;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#getJavaInitializationString()
+         */
+        public String getJavaInitializationString() {
+            // TO DO Auto-generated method stub
+            return null;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#getTags()
+         */
+        public String[] getTags() {
+            // TO DO Auto-generated method stub
+            return null;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#getValue()
+         */
+        public Object getValue() {
+            // TO DO Auto-generated method stub
+            return null;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#isPaintable()
+         */
+        public boolean isPaintable() {
+            // TO DO Auto-generated method stub
+            return false;
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#paintValue(java.awt.Graphics,
+         *      java.awt.Rectangle)
+         */
+        public void paintValue(Graphics graphics, Rectangle box) {
+        // TO DO Auto-generated method stub
+
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#removePropertyChangeListener(java.beans.PropertyChangeListener)
+         */
+        public void removePropertyChangeListener(PropertyChangeListener listener) {
+        // TO DO Auto-generated method stub
+
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#setAsText(java.lang.String)
+         */
+        public void setAsText(String text) throws IllegalArgumentException {
+        // TO DO Auto-generated method stub
+
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#setValue(java.lang.Object)
+         */
+        public void setValue(Object value) {
+        // TO DO Auto-generated method stub
+
+        }
+
+        /*
+         * (non-Javadoc)
+         * 
+         * @see java.beans.PropertyEditor#supportsCustomEditor()
+         */
+        public boolean supportsCustomEditor() {
+            // TO DO Auto-generated method stub
+            return false;
+        }
+
+    }
+
     /**
      * The test checks the method findEditor() for registered editors
      */
     public void testFindRegisteredEditor() {
         PropertyEditorManager.registerEditor(SampleProperty.class,
                 OtherEditor.class);
-        PropertyEditor pe = PropertyEditorManager.findEditor(
-                SampleProperty.class);
-        if(pe == null) {
-            fail("No property editor found");
-        } else {
-            assertTrue(pe instanceof OtherEditor);
-        }
+        PropertyEditor pe = PropertyEditorManager
+                .findEditor(SampleProperty.class);
+        assertNotNull("No property editor found", pe);
+        assertTrue(pe instanceof OtherEditor);
         PropertyEditorManager.registerEditor(SampleProperty.class, null);
     }
-    
+
     /**
      * The test checks the method findEditor() for editors found by name
      */
     public void testFindEditorByNameAddOn() {
-        PropertyEditor pe = PropertyEditorManager.findEditor(
-                SampleProperty.class);
-        if(pe == null) {
-            fail("No property editor found");
-        } else {
-            assertTrue(pe instanceof SamplePropertyEditor);
-        }
+        PropertyEditor pe = PropertyEditorManager
+                .findEditor(SampleProperty.class);
+        assertNotNull("No property editor found", pe);
+        assertTrue(pe instanceof SamplePropertyEditor);
     }
-    
+
     /**
      * The test checks the method findEditor() for editors on search path
      */
     public void testFindEditorByDefaultLocation() {
-        PropertyEditorManager.setEditorSearchPath(
-                new String[] {"org.apache.harmony.beans.tests.java.beans.editors"});
-        PropertyEditor pe = PropertyEditorManager.findEditor(
-                AnotherSampleProperty.class);
-        if(pe == null) {
-            fail("No property editor found");
-        } else {
-            assertTrue(pe instanceof AnotherSamplePropertyEditor);
-        }
+        PropertyEditorManager
+                .setEditorSearchPath(new String[] { "org.apache.harmony.beans.tests.java.beans.editors" });
+        PropertyEditor pe = PropertyEditorManager
+                .findEditor(AnotherSampleProperty.class);
+
+        assertNotNull("No property editor found", pe);
+        assertTrue(pe instanceof AnotherSamplePropertyEditor);
     }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorSupportTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorSupportTest.java?rev=417685&r1=417684&r2=417685&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorSupportTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyEditorSupportTest.java Wed Jun 28 00:22:12 2006
@@ -27,370 +27,359 @@
  */
 public class PropertyEditorSupportTest extends TestCase {
 
-	/*
-	 * Class under test for void PropertyEditorSupport()
-	 */
-	public void testPropertyEditorSupport() {
+    /*
+     * Class under test for void PropertyEditorSupport()
+     */
+    public void testPropertyEditorSupport() {
         // Regression for HARMONY-516
-		MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
 
-		assertEquals("null", support.getAsText());
-		assertNull(support.getValue());
-		assertNull(support.getCustomEditor());
-		assertEquals("???", support.getJavaInitializationString());
-		assertNull(support.getTags());
-		assertFalse(support.supportsCustomEditor());
-		assertFalse(support.isPaintable());
+        assertEquals("null", support.getAsText());
+        assertNull(support.getValue());
+        assertNull(support.getCustomEditor());
+        assertEquals("???", support.getJavaInitializationString());
+        assertNull(support.getTags());
+        assertFalse(support.supportsCustomEditor());
+        assertFalse(support.isPaintable());
 
         Object value = new String[] { "java.awt.Color.orange" };
         support.setValue(value);
         assertEquals(value.toString(), support.getAsText());
     }
 
-	/*
+    /*
      * Class under test for void PropertyEditorSupport(Object)
      */
-	public void testPropertyEditorSupportObject() {
-		MockSource source = new MockSource();
-		MockPropertyEditorSupport support = new MockPropertyEditorSupport(
-				source);
-
-		assertEquals("null", support.getAsText());
-		assertNull(support.getValue());
-		assertNull(support.getCustomEditor());
-		assertEquals("???", support.getJavaInitializationString());
-		assertNull(support.getTags());
-		assertFalse(support.supportsCustomEditor());
-		assertFalse(support.isPaintable());
+    public void testPropertyEditorSupportObject() {
+        MockSource source = new MockSource();
+        MockPropertyEditorSupport support = new MockPropertyEditorSupport(
+                source);
+
+        assertEquals("null", support.getAsText());
+        assertNull(support.getValue());
+        assertNull(support.getCustomEditor());
+        assertEquals("???", support.getJavaInitializationString());
+        assertNull(support.getTags());
+        assertFalse(support.supportsCustomEditor());
+        assertFalse(support.isPaintable());
     }
 
-	/*
+    /*
      * source null
      */
-	public void testPropertyEditorSupportObject_null() {
-		try {
-			MockPropertyEditorSupport support = new MockPropertyEditorSupport(
-					null);
-			fail("Should throw NullPointerException.");
-		} catch (NullPointerException e) {
-			// expected
-		}
-	}
-
-	/*
-	 * public void addPropertyChangeListener(PropertyChangeListener listener)
-	 */
-	public void testAddPropertyChangeListener() {
-		MockTarget target = new MockTarget();
-		MockPropertyEditorSupport support = new MockPropertyEditorSupport();
-		support.addPropertyChangeListener((PropertyChangeListener) EventHandler
-				.create(PropertyChangeListener.class, target, "setCalled"));
-		support.firePropertyChange();
-
-		assertEquals("called", target.getLabel());
-	}
-
-	public void testAddPropertyChangeListener_source() {
-		MockTarget target = new MockTarget();
-		MockSource source = new MockSource();
-		MockPropertyEditorSupport support = new MockPropertyEditorSupport(
-				source);
-		support.addPropertyChangeListener((PropertyChangeListener) EventHandler
-				.create(PropertyChangeListener.class, target, "eventSource",
-						"source"));
-		support.firePropertyChange();
-		assertSame(source, target.getEventSource());
-	}
-
-	public void testAddPropertyChangeListener_source_null() {
-		MockTarget target = new MockTarget();
-		MockPropertyEditorSupport support = new MockPropertyEditorSupport();
-		support
-				.addPropertyChangeListener((PropertyChangeListener) EventHandler
-						.create(PropertyChangeListener.class, target,
-								"eventSource", ""));
-		support.firePropertyChange();
-		PropertyChangeEvent event = (PropertyChangeEvent) target
-				.getEventSource();
-
-		assertNull(event.getPropertyName());
-		assertSame(support, event.getSource());
-	}
-
-	public void testFirePropertyChange_noListener() {
-		MockTarget target = new MockTarget();
-		MockPropertyEditorSupport support = new MockPropertyEditorSupport();
-		support.firePropertyChange();
-	}
-
-	/*
-	 * listener is null
-	 */
-	public void testAddPropertyChangeListener_null() {
-		MockTarget target = new MockTarget();
-		MockPropertyEditorSupport support = new MockPropertyEditorSupport();
-		support.addPropertyChangeListener(null);
-		try {
-			support.firePropertyChange();
-			fail("Should throw NullPointerException.");
-		} catch (NullPointerException e) {
-			// expected
-		}
-	}
-
-	public void testPaintValue() {
-		MockTarget target = new MockTarget();
-		MockPropertyEditorSupport support = new MockPropertyEditorSupport();
-		support.paintValue(null, null);
-	}
-
-	public void testRemovePropertyChangeListener() {
-		MockTarget target = new MockTarget();
-		MockPropertyEditorSupport support = new MockPropertyEditorSupport();
-		PropertyChangeListener proxy = (PropertyChangeListener) EventHandler
-				.create(PropertyChangeListener.class, target, "eventSource",
-						"source");
-		support.addPropertyChangeListener(proxy);
-		support.firePropertyChange();
-		assertSame(support, target.getEventSource());
-
-		target.setEventSource(null);
-		support.removePropertyChangeListener(proxy);
-		support.firePropertyChange();
-		assertNull(target.getEventSource());
-	}
-
-	public void testRemovePropertyChangeListener_null() {
-		MockTarget target = new MockTarget();
-		MockPropertyEditorSupport support = new MockPropertyEditorSupport();
-		PropertyChangeListener proxy = (PropertyChangeListener) EventHandler
-				.create(PropertyChangeListener.class, target, "eventSource",
-						"source");
-		support.addPropertyChangeListener(proxy);
-		support.firePropertyChange();
-		assertSame(support, target.getEventSource());
-
-		target.setEventSource(null);
-		support.removePropertyChangeListener(null);
-		support.firePropertyChange();
-		assertSame(support, target.getEventSource());
-	}
-
-	/*
-	 * remove a different listener
-	 */
-	public void testRemovePropertyChangeListener_diff() {
-		MockTarget target = new MockTarget();
-		MockPropertyEditorSupport support = new MockPropertyEditorSupport();
-		PropertyChangeListener proxy = (PropertyChangeListener) EventHandler
-				.create(PropertyChangeListener.class, target, "eventSource",
-						"source");
-		support.addPropertyChangeListener(proxy);
-		support.firePropertyChange();
-		assertSame(support, target.getEventSource());
-
-		target.setEventSource(null);
-		PropertyChangeListener proxy2 = (PropertyChangeListener) EventHandler
-				.create(PropertyChangeListener.class, target, "eventSource",
-						"source");
-		support.removePropertyChangeListener(proxy2);
-		support.firePropertyChange();
-		assertSame(support, target.getEventSource());
-	}
-
-	/*
-	 * remove null listener
-	 */
-	public void testRemovePropertyChangeListener_null_null() {
-		MockTarget target = new MockTarget();
-		MockPropertyEditorSupport support = new MockPropertyEditorSupport();
-		support.addPropertyChangeListener(null);
-		try {
-			support.firePropertyChange();
-			fail("Should throw NullPointerException.");
-		} catch (NullPointerException e) {
-			// expected
-		}
-
-		support.removePropertyChangeListener(null);
-		support.firePropertyChange();
-	}
-
-	public void testSetAsText() {
-		MockPropertyEditorSupport support = new MockPropertyEditorSupport();
-		String asText = "100";
-		try {
-			support.setAsText(asText);
-			fail("Should throw IllegalArgumentException.");
-		} catch (IllegalArgumentException e) {
-			// expected
-		}
-	}
-
-	public void testSetValue() {
-		MockPropertyEditorSupport support = new MockPropertyEditorSupport();
-		String[] value = new String[] { "This is a sample value." };
-		support.setValue(value);
-
-		assertEquals(value, support.getValue());
-		assertEquals(value.toString(), support.getAsText());
-
-		assertNull(support.getCustomEditor());
-		assertEquals("???", support.getJavaInitializationString());
-		assertNull(support.getTags());
-		assertFalse(support.supportsCustomEditor());
-		assertFalse(support.isPaintable());
-
-	}
-
-	public void testSetValue_null() {
-		MockPropertyEditorSupport support = new MockPropertyEditorSupport();
-		support.setValue(null);
-
-		assertEquals(null, support.getValue());
-		assertEquals("null", support.getAsText());
-
-		assertNull(support.getCustomEditor());
-		assertEquals("???", support.getJavaInitializationString());
-		assertNull(support.getTags());
-		assertFalse(support.supportsCustomEditor());
-		assertFalse(support.isPaintable());
-
-		MockTarget target = new MockTarget();
-		support.setValue(target);
-
-		assertSame(target, support.getValue());
-		assertEquals(target.toString(), support.getAsText());
-		assertNull(support.getCustomEditor());
-		assertEquals("???", support.getJavaInitializationString());
-		assertNull(support.getTags());
-		assertFalse(support.supportsCustomEditor());
-		assertFalse(support.isPaintable());
-	}
-
-	public static class MockPropertyEditorSupport extends PropertyEditorSupport {
-		public MockPropertyEditorSupport() {
-			super();
-		}
-
-		public MockPropertyEditorSupport(Object source) {
-			super(source);
-		}
-	}
-
-	public static class MockSource {
-		String id;
-
-		String text;
-
-		public MockSource() {
-			this.id = "0001";
-			this.text = getClass().getName();
-		}
-
-		/**
-		 * @return Returns the id.
-		 */
-		public String getId() {
-			return id;
-		}
-
-		/**
-		 * @param id
-		 *            The id to set.
-		 */
-		public void setId(String id) {
-			this.id = id;
-		}
-
-		/**
-		 * @return Returns the text.
-		 */
-		public String getText() {
-			return text;
-		}
-
-		/**
-		 * @param text
-		 *            The text to set.
-		 */
-		public void setText(String text) {
-			this.text = text;
-		}
-	}
-
-	public static class MockTarget {
-		String id;
-
-		String label;
-
-		Object eventSource;
-
-		public MockTarget() {
-			this.id = "0001";
-			this.label = getClass().getName();
-		}
-
-		/**
-		 * @return Returns the id.
-		 */
-		public String getId() {
-			return id;
-		}
-
-		/**
-		 * @param id
-		 *            The id to set.
-		 */
-		public void setId(String id) {
-			this.id = id;
-		}
-
-		/**
-		 * @return Returns the text.
-		 */
-		public String getLabel() {
-			return label;
-		}
-
-		/**
-		 * @param text
-		 *            The text to set.
-		 */
-		public void setLabel(String label) {
-			this.label = label;
-		}
-
-		public void setCalled() {
-			this.label = "called";
-		}
-
-		/**
-		 * @return Returns the eventSource.
-		 */
-		public Object getEventSource() {
-			return eventSource;
-		}
-
-		/**
-		 * @param eventSource
-		 *            The eventSource to set.
-		 */
-		public void setEventSource(Object eventSource) {
-			this.eventSource = eventSource;
-		}
-
-		public boolean equals(Object o) {
-			if (!(o instanceof MockTarget)) {
-				return false;
-			}
-
-			MockTarget other = (MockTarget) o;
-			return ((this.id == null ? other.id == null : this.id
-					.equals(other.id))
-					&& (this.eventSource == null ? other.eventSource == null
-							: this.eventSource.equals(other.eventSource)) && (this.label == null ? other.label == null
-					: this.label.equals(other.label)));
-		}
-	}
+    public void testPropertyEditorSupportObject_null() {
+        try {
+            new MockPropertyEditorSupport(null);
+            fail("Should throw NullPointerException.");
+        } catch (NullPointerException e) {
+            // expected
+        }
+    }
+
+    /*
+     * public void addPropertyChangeListener(PropertyChangeListener listener)
+     */
+    public void testAddPropertyChangeListener() {
+        MockTarget target = new MockTarget();
+        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        support.addPropertyChangeListener(EventHandler.create(
+                PropertyChangeListener.class, target, "setCalled"));
+        support.firePropertyChange();
+
+        assertEquals("called", target.getLabel());
+    }
+
+    public void testAddPropertyChangeListener_source() {
+        MockTarget target = new MockTarget();
+        MockSource source = new MockSource();
+        MockPropertyEditorSupport support = new MockPropertyEditorSupport(
+                source);
+        support.addPropertyChangeListener(EventHandler.create(
+                PropertyChangeListener.class, target, "eventSource", "source"));
+        support.firePropertyChange();
+        assertSame(source, target.getEventSource());
+    }
+
+    public void testAddPropertyChangeListener_source_null() {
+        MockTarget target = new MockTarget();
+        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        support.addPropertyChangeListener(EventHandler.create(
+                PropertyChangeListener.class, target, "eventSource", ""));
+        support.firePropertyChange();
+        PropertyChangeEvent event = (PropertyChangeEvent) target
+                .getEventSource();
+
+        assertNull(event.getPropertyName());
+        assertSame(support, event.getSource());
+    }
+
+    public void testFirePropertyChange_noListener() {
+        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        support.firePropertyChange();
+    }
+
+    /*
+     * listener is null
+     */
+    public void testAddPropertyChangeListener_null() {
+        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        support.addPropertyChangeListener(null);
+        try {
+            support.firePropertyChange();
+            fail("Should throw NullPointerException.");
+        } catch (NullPointerException e) {
+            // expected
+        }
+    }
+
+    public void testPaintValue() {
+        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        support.paintValue(null, null);
+    }
+
+    public void testRemovePropertyChangeListener() {
+        MockTarget target = new MockTarget();
+        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        PropertyChangeListener proxy = EventHandler.create(
+                PropertyChangeListener.class, target, "eventSource", "source");
+        support.addPropertyChangeListener(proxy);
+        support.firePropertyChange();
+        assertSame(support, target.getEventSource());
+
+        target.setEventSource(null);
+        support.removePropertyChangeListener(proxy);
+        support.firePropertyChange();
+        assertNull(target.getEventSource());
+    }
+
+    public void testRemovePropertyChangeListener_null() {
+        MockTarget target = new MockTarget();
+        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        PropertyChangeListener proxy = EventHandler.create(
+                PropertyChangeListener.class, target, "eventSource", "source");
+        support.addPropertyChangeListener(proxy);
+        support.firePropertyChange();
+        assertSame(support, target.getEventSource());
+
+        target.setEventSource(null);
+        support.removePropertyChangeListener(null);
+        support.firePropertyChange();
+        assertSame(support, target.getEventSource());
+    }
+
+    /*
+     * remove a different listener
+     */
+    public void testRemovePropertyChangeListener_diff() {
+        MockTarget target = new MockTarget();
+        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        PropertyChangeListener proxy = EventHandler.create(
+                PropertyChangeListener.class, target, "eventSource", "source");
+        support.addPropertyChangeListener(proxy);
+        support.firePropertyChange();
+        assertSame(support, target.getEventSource());
+
+        target.setEventSource(null);
+        PropertyChangeListener proxy2 = EventHandler.create(
+                PropertyChangeListener.class, target, "eventSource", "source");
+        support.removePropertyChangeListener(proxy2);
+        support.firePropertyChange();
+        assertSame(support, target.getEventSource());
+    }
+
+    /*
+     * remove null listener
+     */
+    public void testRemovePropertyChangeListener_null_null() {
+        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        support.addPropertyChangeListener(null);
+        try {
+            support.firePropertyChange();
+            fail("Should throw NullPointerException.");
+        } catch (NullPointerException e) {
+            // expected
+        }
+
+        support.removePropertyChangeListener(null);
+        support.firePropertyChange();
+    }
+
+    public void testSetAsText() {
+        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        String asText = "100";
+        try {
+            support.setAsText(asText);
+            fail("Should throw IllegalArgumentException.");
+        } catch (IllegalArgumentException e) {
+            // expected
+        }
+    }
+
+    public void testSetValue() {
+        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        String[] value = new String[] { "This is a sample value." };
+        support.setValue(value);
+
+        assertEquals(value, support.getValue());
+        assertEquals(value.toString(), support.getAsText());
+
+        assertNull(support.getCustomEditor());
+        assertEquals("???", support.getJavaInitializationString());
+        assertNull(support.getTags());
+        assertFalse(support.supportsCustomEditor());
+        assertFalse(support.isPaintable());
+
+    }
+
+    public void testSetValue_null() {
+        MockPropertyEditorSupport support = new MockPropertyEditorSupport();
+        support.setValue(null);
+
+        assertEquals(null, support.getValue());
+        assertEquals("null", support.getAsText());
+
+        assertNull(support.getCustomEditor());
+        assertEquals("???", support.getJavaInitializationString());
+        assertNull(support.getTags());
+        assertFalse(support.supportsCustomEditor());
+        assertFalse(support.isPaintable());
+
+        MockTarget target = new MockTarget();
+        support.setValue(target);
+
+        assertSame(target, support.getValue());
+        assertEquals(target.toString(), support.getAsText());
+        assertNull(support.getCustomEditor());
+        assertEquals("???", support.getJavaInitializationString());
+        assertNull(support.getTags());
+        assertFalse(support.supportsCustomEditor());
+        assertFalse(support.isPaintable());
+    }
+
+    public static class MockPropertyEditorSupport extends PropertyEditorSupport {
+
+        public MockPropertyEditorSupport() {
+            super();
+        }
+
+        public MockPropertyEditorSupport(Object source) {
+            super(source);
+        }
+    }
+
+    public static class MockSource {
+
+        String id;
+
+        String text;
+
+        public MockSource() {
+            this.id = "0001";
+            this.text = getClass().getName();
+        }
+
+        /**
+         * @return Returns the id.
+         */
+        public String getId() {
+            return id;
+        }
+
+        /**
+         * @param id The id to set.
+         */
+        public void setId(String id) {
+            this.id = id;
+        }
+
+        /**
+         * @return Returns the text.
+         */
+        public String getText() {
+            return text;
+        }
+
+        /**
+         * @param text The text to set.
+         */
+        public void setText(String text) {
+            this.text = text;
+        }
+    }
+
+    public static class MockTarget {
+
+        String id;
+
+        String label;
+
+        Object eventSource;
+
+        public MockTarget() {
+            this.id = "0001";
+            this.label = getClass().getName();
+        }
+
+        /**
+         * @return Returns the id.
+         */
+        public String getId() {
+            return id;
+        }
+
+        /**
+         * @param id
+         *            The id to set.
+         */
+        public void setId(String id) {
+            this.id = id;
+        }
+
+        /**
+         * @return Returns the text.
+         */
+        public String getLabel() {
+            return label;
+        }
+
+        /**
+         * @param text
+         *            The text to set.
+         */
+        public void setLabel(String label) {
+            this.label = label;
+        }
+
+        public void setCalled() {
+            this.label = "called";
+        }
+
+        /**
+         * @return Returns the eventSource.
+         */
+        public Object getEventSource() {
+            return eventSource;
+        }
+
+        /**
+         * @param eventSource
+         *            The eventSource to set.
+         */
+        public void setEventSource(Object eventSource) {
+            this.eventSource = eventSource;
+        }
+
+        public boolean equals(Object o) {
+            if (!(o instanceof MockTarget)) {
+                return false;
+            }
+
+            MockTarget other = (MockTarget) o;
+            return ((this.id == null ? other.id == null : this.id
+                    .equals(other.id))
+                    && (this.eventSource == null ? other.eventSource == null
+                            : this.eventSource.equals(other.eventSource)) && (this.label == null ? other.label == null
+                    : this.label.equals(other.label)));
+        }
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyVetoExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyVetoExceptionTest.java?rev=417685&r1=417684&r2=417685&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyVetoExceptionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/PropertyVetoExceptionTest.java Wed Jun 28 00:22:12 2006
@@ -20,6 +20,8 @@
 import java.beans.PropertyVetoException;
 import java.io.IOException;
 
+import org.apache.harmony.beans.tests.support.mock.MockJavaBean;
+
 import junit.framework.TestCase;
 import tests.util.SerializationTester;
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/SimpleBeanInfoTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/SimpleBeanInfoTest.java?rev=417685&r1=417684&r2=417685&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/SimpleBeanInfoTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/SimpleBeanInfoTest.java Wed Jun 28 00:22:12 2006
@@ -15,13 +15,9 @@
 
 package org.apache.harmony.beans.tests.java.beans;
 
-import java.awt.Image;
 import java.beans.SimpleBeanInfo;
 
-import org.apache.harmony.beans.tests.java.beans.mock.MockSimpleBeanInfo;
 import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
 
 
 /**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java?rev=417685&r1=417684&r2=417685&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/StatementTest.java Wed Jun 28 00:22:12 2006
@@ -27,7 +27,7 @@
 import junit.framework.TestSuite;
 import junit.textui.TestRunner;
 
-import org.apache.harmony.beans.tests.java.beans.auxiliary.SampleException;
+import org.apache.harmony.beans.tests.support.SampleException;
 
 /**
  * Test the class java.beans.Statement.
@@ -238,8 +238,6 @@
                 throw new IllegalAccessException("Text property is null.");
             } else {
                 // IndexOutOfBounds exception is thrown, if indexed bounds are violated
-                char oldValue = text.charAt(idx);
-                
                 String newText = "";
                 
                 if(idx > 0) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeListenerProxyTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeListenerProxyTest.java?rev=417685&r1=417684&r2=417685&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeListenerProxyTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/VetoableChangeListenerProxyTest.java Wed Jun 28 00:22:12 2006
@@ -16,7 +16,6 @@
 package org.apache.harmony.beans.tests.java.beans;
 
 import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListenerProxy;
 import java.beans.PropertyVetoException;
 import java.beans.VetoableChangeListener;
 import java.beans.VetoableChangeListenerProxy;



Mime
View raw message