Author: tchemit Date: 2010-05-11 13:20:39 +0200 (Tue, 11 May 2010) New Revision: 1850 Url: http://nuiton.org/repositories/revision/nuiton-utils/1850 Log: move tests Added: trunk/src/test/java/org/nuiton/util/converter/ConverterUtilTest.java trunk/src/test/java/org/nuiton/util/converter/VersionConverterTest.java Copied: trunk/src/test/java/org/nuiton/util/converter/ConverterUtilTest.java (from rev 1848, trunk/src/test/java/org/nuiton/util/ConverterUtilTest.java) =================================================================== --- trunk/src/test/java/org/nuiton/util/converter/ConverterUtilTest.java (rev 0) +++ trunk/src/test/java/org/nuiton/util/converter/ConverterUtilTest.java 2010-05-11 11:20:39 UTC (rev 1850) @@ -0,0 +1,82 @@ +/* + * #%L + * Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2010 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +package org.nuiton.util; + +import org.apache.commons.beanutils.ConvertUtils; +import org.apache.commons.beanutils.Converter; +import org.junit.Assert; +import org.junit.Test; + +/** + * ConverterUtil Tester. + * + * @author tchemit <chemit@codelutin.com> + * @version 1.0 + * @since <pre>02/13/2008</pre> + */ +public class ConverterUtilTest { + + @Test + public void testInitConverters() { + + ConverterUtil.deregister(); + + Converter t = ConvertUtils.lookup(Version.class); + Assert.assertNull(t); + ConverterUtil.initConverters(); + t = ConvertUtils.lookup(Version.class); + Assert.assertNotNull(t); + } + + @Test + public void testConvert() throws Exception { + String s; + s = ""; + Assert.assertEquals( + new String(s.getBytes()), + new String(ConverterUtil.convert(s.toCharArray()))); + + s = "a"; + Assert.assertEquals( + new String(s.getBytes()), + new String(ConverterUtil.convert(s.toCharArray()))); + + s = "kZZFIOFEIOFEfdskdfmldsfjklsfjldfldfjdsfiosabcd4567'''`~teAZEst"; + Assert.assertEquals( + new String(s.getBytes()), + new String(ConverterUtil.convert(s.toCharArray()))); + + s = "]{}{}{{[#{[{#[#]{][{^#][^]#{^[]{#][#]{]@[{#][^#{][^]#{teAZEst"; + Assert.assertEquals( + new String(s.getBytes()), + new String(ConverterUtil.convert(s.toCharArray()))); + + // FIXME following test won't pass + //s = "éééééé]{}{}{{[#{[{#[#]{][{^#][^]#{^[]{#][#]{]@[{#][^#{][^]#{teAZEst"; + //assertEquals(new String(s.getBytes()), new String(ConverterUtil.convert(s.toCharArray()))); + + } +} Property changes on: trunk/src/test/java/org/nuiton/util/converter/ConverterUtilTest.java ___________________________________________________________________ Added: svn:keywords + HeadURL Id Date Revision Author Added: svn:mergeinfo + Added: svn:eol-style + native Copied: trunk/src/test/java/org/nuiton/util/converter/VersionConverterTest.java (from rev 1848, trunk/src/test/java/org/nuiton/util/VersionConverterTest.java) =================================================================== --- trunk/src/test/java/org/nuiton/util/converter/VersionConverterTest.java (rev 0) +++ trunk/src/test/java/org/nuiton/util/converter/VersionConverterTest.java 2010-05-11 11:20:39 UTC (rev 1850) @@ -0,0 +1,100 @@ +/* + * #%L + * Nuiton Utils + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2004 - 2010 CodeLutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +package org.nuiton.util; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author tchemit <chemit@codelutin.com> + */ +public class VersionConverterTest { + + VersionConverter converter; + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + converter = new VersionConverter(); + } + + @After + public void tearDown() { + } + + /** + * Test of convert method, of class VersionConverter. + */ + @Test + public void testConvert() { + Object value; + Object expResult; + Object result; + + value = ""; + expResult = new Version(); + result = converter.convert(Version.class, value); + assertEquals(expResult, result); + + value = "0"; + expResult = new Version(); + result = converter.convert(Version.class, value); + assertEquals(expResult, result); + + value = "1.2.3.4"; + expResult = new Version(1, 2, 3, 4); + result = converter.convert(Version.class, value); + assertEquals(expResult, result); + + value = "1.2.3.4-alpha-11"; + expResult = new Version("alpha", 11, 1, 2, 3, 4); + result = converter.convert(Version.class, value); + assertEquals(expResult, result); + } + + /** + * Test of isEnabled method, of class VersionConverter. + */ + @Test + public void testIsEnabled() { + + boolean expResult = true; + boolean result = converter.isEnabled(Version.class); + assertEquals(expResult, result); + } +} Property changes on: trunk/src/test/java/org/nuiton/util/converter/VersionConverterTest.java ___________________________________________________________________ Added: svn:keywords + HeadURL Id Date Revision Author Added: svn:mergeinfo +
participants (1)
-
tchemit@users.nuiton.org