You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@depot.apache.org by ni...@apache.org on 2004/08/18 14:20:02 UTC
svn commit: rev 36565 - incubator/depot/trunk/version/src/test/java/org/apache/depot/version
Author: nickchalko
Date: Wed Aug 18 07:20:01 2004
New Revision: 36565
Added:
incubator/depot/trunk/version/src/test/java/org/apache/depot/version/VersionTestCase.java
Log:
Forgot to check this in.
Added: incubator/depot/trunk/version/src/test/java/org/apache/depot/version/VersionTestCase.java
==============================================================================
--- (empty file)
+++ incubator/depot/trunk/version/src/test/java/org/apache/depot/version/VersionTestCase.java Wed Aug 18 07:20:01 2004
@@ -0,0 +1,97 @@
+/*
+ * Created on Aug 17, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+package org.apache.depot.version;
+
+import org.apache.depot.version.impl.data.VersionData;
+import org.apache.depot.version.specification.VersionSpecification;
+import org.apache.depot.version.specification.formatting.VersionFormatException;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Nick
+ *
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public class VersionTestCase extends TestCase {
+ private final VersionSpecification specification;
+
+ private Version base;
+
+ /**
+ * @param specification
+ */
+ public VersionTestCase(final VersionSpecification specification) {
+ super();
+ this.specification = specification;
+ }
+
+ public void setUp() throws VersionFormatException {
+ base = createVersion(getBaseVersionString());
+
+ }
+
+ /**
+ * @param versionString
+ * @return @throws
+ * VersionFormatException
+ */
+ private Version createVersion(String versionString)
+ throws VersionFormatException {
+ return VersionManager.getManager().createVersion(specification,
+ versionString);
+ }
+
+ public void tearDown() {
+ base = null;
+ }
+
+ public void testCreation() {
+ assertNotNull("Version for " + getBaseVersionString()
+ + " should not be null", base);
+ }
+
+ public void testEquality() throws VersionException {
+ assertSymetricNotEquals(base, Version.UNKNOWN);
+ Version same = createVersion(getBaseVersionString());
+ assertEquals("Version of " + getBaseVersionString(), base, same);
+ assertEquals("Version of " + getBaseVersionString(), same, base);
+ Version other = base.increment("major");
+ assertSymetricNotEquals(other, base);
+ }
+
+ /**
+ * assert !v1.eqauls(v2) && !v2.equals(v1)
+ *
+ * @param v1
+ * @param v2
+ */
+ public void assertSymetricNotEquals(Version v1, Version v2) {
+ assertTrue(v2 + " should not equals " + v1, v2 != v1);
+ assertTrue(v1 + " should not equals " + v2, v1 != v2);
+ }
+
+ /**
+ * assert v1.eqauls(v2) && v2.equals(v1)
+ *
+ * @param v1
+ * @param v2
+ */
+ public void assertSymetricEquals(Version v1, Version v2) {
+ assertEquals(v2 + " should equal " + v1, v2 ,v1);
+ assertEquals(v1 + " should equal " + v2, v1 , v2);
+ }
+
+ /**
+ * @return
+ */
+ private String getBaseVersionString() {
+ return "1";
+ }
+
+}
\ No newline at end of file