Index: lutinutil/src/test/org/codelutin/util/ObjectUtilTest.java diff -u /dev/null lutinutil/src/test/org/codelutin/util/ObjectUtilTest.java:1.1 --- /dev/null Fri Dec 14 14:16:48 2007 +++ lutinutil/src/test/org/codelutin/util/ObjectUtilTest.java Fri Dec 14 14:16:43 2007 @@ -0,0 +1,108 @@ +/* *##% + * Copyright (C) 2007 + * Code Lutin, Benjamin Poussin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * ObjectUtilTest.java + * + * Created: 19 nov. 07 12:39:28 + * + * @author poussin + * @version $Revision: 1.1 $ + * + * Last update: $Date: 2007-12-14 14:16:43 $ + * by : $Author: bpoussin $ + */ + +package org.codelutin.util; + +import java.io.File; + +import junit.framework.TestCase; + + +/** + * @author poussin + * + */ +public class ObjectUtilTest extends TestCase { + + public void testCreate() throws Exception { + Object o = ObjectUtil.create("java.lang.StringBuffer"); + assertTrue(o != null); + assertTrue(o instanceof StringBuffer); + + Dummy dummy = (Dummy)ObjectUtil.create( + "org.codelutin.util.ObjectUtilTest$Dummy(name=\"coucou le monde\", file=/tmp/fileTest, integer=50)"); + assertTrue(dummy != null); + assertEquals("coucou le monde", dummy.getName()); + assertEquals(50, dummy.getInteger()); + assertEquals(new File("/tmp/fileTest"), dummy.getFile()); + } + + + static public class Dummy { + + String name; + int integer; + File file; + + + /** + * @return the file + */ + public File getFile() { + return this.file; + } + + /** + * @return the integer + */ + public int getInteger() { + return this.integer; + } + + /** + * @return the name + */ + public String getName() { + return this.name; + } + + /** + * @param file the file to set + */ + public void setFile(File file) { + this.file = file; + } + + /** + * @param integer the integer to set + */ + public void setInteger(int integer) { + this.integer = integer; + } + + /** + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + } +} \ No newline at end of file