Author: tchemit Date: 2008-02-13 11:55:25 +0000 (Wed, 13 Feb 2008) New Revision: 906 Added: trunk/simexplorer-is/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/entities/metadata/VersionTest.java Removed: trunk/simexplorer-is/simexplorer-is-entities/src/test/fr/cemagref/simexplorer/is/entities/metadata/VersionTest.java Log: reunification des modules entities et storage en un unique module storage Deleted: trunk/simexplorer-is/simexplorer-is-entities/src/test/fr/cemagref/simexplorer/is/entities/metadata/VersionTest.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-entities/src/test/fr/cemagref/simexplorer/is/entities/metadata/VersionTest.java 2008-02-13 11:54:29 UTC (rev 905) +++ trunk/simexplorer-is/simexplorer-is-entities/src/test/fr/cemagref/simexplorer/is/entities/metadata/VersionTest.java 2008-02-13 11:55:25 UTC (rev 906) @@ -1,187 +0,0 @@ -/* -* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais, Tony Chemit -* -* 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. -* ##% */ -package fr.cemagref.simexplorer.is.entities.metadata; - -import junit.framework.TestCase; - -/** - * Version Tester. - * - * @author chemit - * @version 1.0 - * @since - * - * <pre> - * 02 / 02 / 2008 - * </pre> - */ -public class VersionTest extends TestCase { - - /** The v0. */ - Version v0; - - /** The v1. */ - Version v1; - - /** - * Instantiates a new version test. - * - * @param name - * the name - */ - public VersionTest(String name) { - super(name); - } - - /** - * Test set get version. - * - * @throws Exception - * the exception - */ - public void testSetGetVersion() throws Exception { - // TODO: Test goes here... - } - - /** - * Test get length. - * - * @throws Exception - * the exception - */ - public void testGetLength() throws Exception { - - v0 = Version.valueOf(""); - assertEquals(0, v0.getLength()); - - v0 = Version.valueOf("0"); - assertEquals(1, v0.getLength()); - - v0 = Version.valueOf("0.1"); - assertEquals(2, v0.getLength()); - - v0 = Version.valueOf("0.0.1"); - assertEquals(3, v0.getLength()); - } - - /** - * Test equals. - * - * @throws Exception - * the exception - */ - public void testEquals() throws Exception { - - v0 = Version.valueOf(""); - v1 = Version.valueOf(""); - assertEquals(v0, v1); - - v0 = Version.valueOf("0"); - v1 = Version.valueOf("0"); - assertEquals(v0, v1); - - v0 = Version.valueOf("0.1"); - v1 = Version.valueOf("0.1"); - assertEquals(v0, v1); - - v0 = Version.valueOf("0.0.1"); - v1 = Version.valueOf("0.0.1"); - assertEquals(v0, v1); - } - - /** - * Test inc sub version. - * - * @throws Exception - * the exception - */ - public void testIncSubVersion() throws Exception { - v0 = Version.valueOf("0.1"); - - v1 = v0.incVersion(0); - assertEquals(Version.valueOf("0.1"), v0); - assertEquals(Version.valueOf("1.1"), v1); - - v1 = v0.incVersion(1); - assertEquals(Version.valueOf("0.1"), v0); - assertEquals(Version.valueOf("0.2"), v1); - - v1 = v0.incVersion(2); - assertEquals(Version.valueOf("0.1"), v0); - assertEquals(Version.valueOf("0.1.1"), v1); - } - - /** - * Test order. - * - * @throws Exception - * the exception - */ - public void testOrder() throws Exception { - v0 = Version.valueOf("1"); - v1 = Version.valueOf("1"); - assertEqualsVersion(v0, v1); - - v1 = Version.valueOf("1.0"); - assertSmallerVersion(v0, v1); - v1 = Version.valueOf("2"); - assertSmallerVersion(v0, v1); - - v1 = Version.valueOf("0"); - assertGreaterVersion(v0, v1); - v1 = Version.valueOf("0.1"); - assertGreaterVersion(v0, v1); - } - - /** - * Assert equals version. - * - * @param va - * the va - * @param vb - * the vb - */ - private void assertEqualsVersion(Version va, Version vb) { - assertEquals(0, va.compareTo(vb)); - } - - /** - * Assert smaller version. - * - * @param va - * the va - * @param vb - * the vb - */ - private void assertSmallerVersion(Version va, Version vb) { - assertEquals(-1, va.compareTo(vb)); - } - - /** - * Assert greater version. - * - * @param va - * the va - * @param vb - * the vb - */ - private void assertGreaterVersion(Version va, Version vb) { - assertEquals(1, va.compareTo(vb)); - } - -} Copied: trunk/simexplorer-is/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/entities/metadata/VersionTest.java (from rev 899, trunk/simexplorer-is/simexplorer-is-entities/src/test/fr/cemagref/simexplorer/is/entities/metadata/VersionTest.java) =================================================================== --- trunk/simexplorer-is/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/entities/metadata/VersionTest.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-storage/src/test/fr/cemagref/simexplorer/is/entities/metadata/VersionTest.java 2008-02-13 11:55:25 UTC (rev 906) @@ -0,0 +1,187 @@ +/* +* ##% Copyright (C) 2008 Code Lutin, Gabriel Landais, Tony Chemit +* +* 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. +* ##% */ +package fr.cemagref.simexplorer.is.entities.metadata; + +import junit.framework.TestCase; + +/** + * Version Tester. + * + * @author chemit + * @version 1.0 + * @since + * + * <pre> + * 02 / 02 / 2008 + * </pre> + */ +public class VersionTest extends TestCase { + + /** The v0. */ + Version v0; + + /** The v1. */ + Version v1; + + /** + * Instantiates a new version test. + * + * @param name + * the name + */ + public VersionTest(String name) { + super(name); + } + + /** + * Test set get version. + * + * @throws Exception + * the exception + */ + public void testSetGetVersion() throws Exception { + // TODO: Test goes here... + } + + /** + * Test get length. + * + * @throws Exception + * the exception + */ + public void testGetLength() throws Exception { + + v0 = Version.valueOf(""); + assertEquals(0, v0.getLength()); + + v0 = Version.valueOf("0"); + assertEquals(1, v0.getLength()); + + v0 = Version.valueOf("0.1"); + assertEquals(2, v0.getLength()); + + v0 = Version.valueOf("0.0.1"); + assertEquals(3, v0.getLength()); + } + + /** + * Test equals. + * + * @throws Exception + * the exception + */ + public void testEquals() throws Exception { + + v0 = Version.valueOf(""); + v1 = Version.valueOf(""); + assertEquals(v0, v1); + + v0 = Version.valueOf("0"); + v1 = Version.valueOf("0"); + assertEquals(v0, v1); + + v0 = Version.valueOf("0.1"); + v1 = Version.valueOf("0.1"); + assertEquals(v0, v1); + + v0 = Version.valueOf("0.0.1"); + v1 = Version.valueOf("0.0.1"); + assertEquals(v0, v1); + } + + /** + * Test inc sub version. + * + * @throws Exception + * the exception + */ + public void testIncSubVersion() throws Exception { + v0 = Version.valueOf("0.1"); + + v1 = v0.incVersion(0); + assertEquals(Version.valueOf("0.1"), v0); + assertEquals(Version.valueOf("1.1"), v1); + + v1 = v0.incVersion(1); + assertEquals(Version.valueOf("0.1"), v0); + assertEquals(Version.valueOf("0.2"), v1); + + v1 = v0.incVersion(2); + assertEquals(Version.valueOf("0.1"), v0); + assertEquals(Version.valueOf("0.1.1"), v1); + } + + /** + * Test order. + * + * @throws Exception + * the exception + */ + public void testOrder() throws Exception { + v0 = Version.valueOf("1"); + v1 = Version.valueOf("1"); + assertEqualsVersion(v0, v1); + + v1 = Version.valueOf("1.0"); + assertSmallerVersion(v0, v1); + v1 = Version.valueOf("2"); + assertSmallerVersion(v0, v1); + + v1 = Version.valueOf("0"); + assertGreaterVersion(v0, v1); + v1 = Version.valueOf("0.1"); + assertGreaterVersion(v0, v1); + } + + /** + * Assert equals version. + * + * @param va + * the va + * @param vb + * the vb + */ + private void assertEqualsVersion(Version va, Version vb) { + assertEquals(0, va.compareTo(vb)); + } + + /** + * Assert smaller version. + * + * @param va + * the va + * @param vb + * the vb + */ + private void assertSmallerVersion(Version va, Version vb) { + assertEquals(-1, va.compareTo(vb)); + } + + /** + * Assert greater version. + * + * @param va + * the va + * @param vb + * the vb + */ + private void assertGreaterVersion(Version va, Version vb) { + assertEquals(1, va.compareTo(vb)); + } + +}
participants (1)
-
tchemit@users.labs.libre-entreprise.org