[Ejtools-cvs] libraries/common/src/test/test/beans CustomPropertyEditorManagerTest.java,NONE,1.1 Sor
Brought to you by:
letiemble
From: <let...@us...> - 2003-12-14 10:50:06
|
Update of /cvsroot/ejtools/libraries/common/src/test/test/beans In directory sc8-pr-cvs1:/tmp/cvs-serv18971/common/src/test/test/beans Modified Files: SortTest.java Added Files: CustomPropertyEditorManagerTest.java Log Message: Add more javadocs. Add package.html files. --- NEW FILE: CustomPropertyEditorManagerTest.java --- /* * EJTools, the Enterprise Java Tools * * Distributable under LGPL license. * See terms of license at www.gnu.org. */ package test.beans; import java.beans.PropertyEditor; import java.beans.PropertyEditorManager; import java.beans.PropertyEditorSupport; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Arrays; import java.util.List; import junit.framework.TestCase; import org.ejtools.beans.CustomPropertyEditorManager; /** * @author Laurent Etiemble * @version $Revision: 1.1 $ */ public class CustomPropertyEditorManagerTest extends TestCase { /** Constructor for the CustomPropertyEditorManagerTest object */ public CustomPropertyEditorManagerTest() { super(); } /** * Constructor for the CustomPropertyEditorManagerTest object * * @param name Description of the Parameter */ public CustomPropertyEditorManagerTest(String name) { super(name); } /** A unit test for JUnit */ public void testInitialization() { List paths = null; String[] beforePaths = PropertyEditorManager.getEditorSearchPath(); // Force class loading CustomPropertyEditorManager.findEditor(String.class); String path = CustomPropertyEditorManager.EDITORS_PACKAGE; String[] afterPaths = PropertyEditorManager.getEditorSearchPath(); paths = Arrays.asList(beforePaths); if (paths.contains(path)) { fail("Must not find " + path + " among the paths"); } paths = Arrays.asList(afterPaths); if (!paths.contains(path)) { fail("Must find " + path + " among the paths"); } } /** A unit test for JUnit */ public void testSearch() { PropertyEditor pe = null; pe = CustomPropertyEditorManager.findEditor(String.class); assertNotNull("Must find at least one property editor", pe); pe = CustomPropertyEditorManager.findEditor(Thread.class); assertNull("Must not find a property editor", pe); PropertyEditorManager.registerEditor(ObjectInput.class, InputStreamPropertyEditor.class); PropertyEditorManager.registerEditor(ObjectOutput.class, OutputStreamPropertyEditor.class); pe = CustomPropertyEditorManager.findEditor(ObjectInputStream.class); assertNotNull("Must find one property editor", pe); assertEquals("Must find one property editor", pe.getClass(), InputStreamPropertyEditor.class); pe = CustomPropertyEditorManager.findEditor(ObjectOutputStream.class); assertNotNull("Must find one property editor", pe); assertEquals("Must find one property editor", pe.getClass(), OutputStreamPropertyEditor.class); } /** * Description of the Class * * @author Laurent Etiemble * @version $Revision: 1.1 $ */ public static class InputStreamPropertyEditor extends PropertyEditorSupport { } /** * Description of the Class * * @author Laurent Etiemble * @version $Revision: 1.1 $ */ public static class OutputStreamPropertyEditor extends PropertyEditorSupport { } } Index: SortTest.java =================================================================== RCS file: /cvsroot/ejtools/libraries/common/src/test/test/beans/SortTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SortTest.java 27 Nov 2003 00:40:24 -0000 1.3 --- SortTest.java 13 Dec 2003 21:27:50 -0000 1.4 *************** *** 1,39 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package test.beans; ! ! import junit.framework.TestCase; ! ! /** ! * @author letiemble ! * @version $Revision$ ! */ ! public class SortTest extends TestCase ! { ! /**Constructor for the SortTest object */ ! public SortTest() ! { ! super(); ! } ! ! ! /** ! *Constructor for the SortTest object ! * ! * @param name Description of the Parameter ! */ ! public SortTest(String name) ! { ! super(name); ! } ! ! ! /** A unit test for JUnit */ ! public void testSortByClass() ! { ! } ! } --- 1,236 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package test.beans; ! ! import java.util.ArrayList; ! import java.util.Collection; ! import java.util.Iterator; ! ! import org.ejtools.beans.Sort; ! ! import junit.framework.TestCase; ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public class SortTest extends TestCase ! { ! private Collection content; ! ! ! /** Constructor for the SortTest object */ ! public SortTest() ! { ! super(); ! } ! ! ! /** ! * Constructor for the SortTest object ! * ! * @param name Description of the Parameter ! */ ! public SortTest(String name) ! { ! super(name); ! } ! ! ! /** A unit test for JUnit */ ! public void testGetChildrenByClass() ! { ! int i = 0; ! for (Iterator it = Sort.getChildrenByClass(this.content.iterator(), String.class); it.hasNext(); i++) ! { ! it.next(); ! } ! assertEquals("Four elements must be found", i, 4); ! ! i = 0; ! for (Iterator it = Sort.getChildrenByClass(this.content.iterator(), Double.class); it.hasNext(); i++) ! { ! it.next(); ! } ! assertEquals("Tow elements must be found", i, 2); ! ! i = 0; ! for (Iterator it = Sort.getChildrenByClass(this.content.iterator(), Object.class); it.hasNext(); i++) ! { ! it.next(); ! } ! assertEquals("Eight elements must be found", i, 8); ! } ! ! ! /** A unit test for JUnit */ ! public void testSortByClass() ! { ! int i = 0; ! for (Iterator it = Sort.sortByClass(this.content.iterator()); it.hasNext(); i++) ! { ! Object o = it.next(); ! switch (i) ! { ! case 0: ! assertEquals("Class is not correct", Double.class, o.getClass()); ! break; ! case 1: ! assertEquals("Class is not correct", Double.class, o.getClass()); ! break; ! case 2: ! assertEquals("Class is not correct", Object.class, o.getClass()); ! break; ! case 3: ! assertEquals("Class is not correct", Object.class, o.getClass()); ! break; ! case 4: ! assertEquals("Class is not correct", String.class, o.getClass()); ! break; ! case 5: ! assertEquals("Class is not correct", String.class, o.getClass()); ! break; ! case 6: ! assertEquals("Class is not correct", String.class, o.getClass()); ! break; ! case 7: ! assertEquals("Class is not correct", String.class, o.getClass()); ! break; ! default: ! } ! } ! } ! ! ! /** A unit test for JUnit */ ! public void testSortByClassAndName() ! { ! int i = 0; ! for (Iterator it = Sort.sortByClassAndName(this.content.iterator()); it.hasNext(); i++) ! { ! Object o = it.next(); ! switch (i) ! { ! case 0: ! assertEquals("Class is not correct", Double.class, o.getClass()); ! assertEquals("Name is not correct", "0.0", o.toString()); ! break; ! case 1: ! assertEquals("Class is not correct", Double.class, o.getClass()); ! assertEquals("Name is not correct", "1.0", o.toString()); ! break; ! case 2: ! assertEquals("Class is not correct", Object.class, o.getClass()); ! break; ! case 3: ! assertEquals("Class is not correct", Object.class, o.getClass()); ! break; ! case 4: ! assertEquals("Class is not correct", String.class, o.getClass()); ! assertEquals("Name is not correct", "s0", o.toString()); ! break; ! case 5: ! assertEquals("Class is not correct", String.class, o.getClass()); ! assertEquals("Name is not correct", "s1", o.toString()); ! break; ! case 6: ! assertEquals("Class is not correct", String.class, o.getClass()); ! assertEquals("Name is not correct", "s2", o.toString()); ! break; ! case 7: ! assertEquals("Class is not correct", String.class, o.getClass()); ! assertEquals("Name is not correct", "s3", o.toString()); ! break; ! default: ! } ! } ! } ! ! ! /** A unit test for JUnit */ ! public void testSortByName() ! { ! int i = 0; ! for (Iterator it = Sort.sortByName(this.content.iterator()); it.hasNext(); i++) ! { ! Object o = it.next(); ! switch (i) ! { ! case 0: ! assertEquals("Class is not correct", Double.class, o.getClass()); ! assertEquals("Name is not correct", "0.0", o.toString()); ! break; ! case 1: ! assertEquals("Class is not correct", Double.class, o.getClass()); ! assertEquals("Name is not correct", "1.0", o.toString()); ! break; ! case 2: ! assertEquals("Class is not correct", Object.class, o.getClass()); ! break; ! case 3: ! assertEquals("Class is not correct", Object.class, o.getClass()); ! break; ! case 4: ! assertEquals("Class is not correct", String.class, o.getClass()); ! assertEquals("Name is not correct", "s0", o.toString()); ! break; ! case 5: ! assertEquals("Class is not correct", String.class, o.getClass()); ! assertEquals("Name is not correct", "s1", o.toString()); ! break; ! case 6: ! assertEquals("Class is not correct", String.class, o.getClass()); ! assertEquals("Name is not correct", "s2", o.toString()); ! break; ! case 7: ! assertEquals("Class is not correct", String.class, o.getClass()); ! assertEquals("Name is not correct", "s3", o.toString()); ! break; ! default: ! } ! } ! } ! ! ! /** A unit test for JUnit */ ! public void testSortByProperty() ! { ! } ! ! ! /** ! * The JUnit setup method ! * ! * @exception Exception Description of the Exception ! */ ! protected void setUp() ! throws Exception ! { ! this.content = new ArrayList(); ! ! this.content.add("s0"); ! this.content.add(new Object()); ! this.content.add("s1"); ! this.content.add(new Double(1)); ! this.content.add("s2"); ! this.content.add(new Object()); ! this.content.add("s3"); ! this.content.add(new Double(0)); ! } ! ! ! /** ! * The teardown method for JUnit ! * ! * @exception Exception Description of the Exception ! */ ! protected void tearDown() ! throws Exception ! { ! this.content = null; ! } ! } |