krysalis-version/src/test/java/org/krysalis/version/impl/fourpart FourPartVersionTest.java,NONE,1.1

Nick Chalko <[email protected]> Fri, 12 Nov 2004 03:10:25 +0000
Newsgroups gmane.comp.krysalis.cvs
Message-ID <[email protected]>
Update of /cvsroot/krysalis/krysalis-version/src/test/java/org/krysalis/version/impl/fourpart
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2307/src/test/java/org/krysalis/version/impl/fourpart

Added Files:
	FourPartVersionTest.java 
Log Message:
Start of a FourPartVersion.

--- NEW FILE: FourPartVersionTest.java ---
/*
 * Copyright  2004 The Apache Software Foundation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.krysalis.version.impl.fourpart;

import org.krysalis.version.VersionException;
import org.krysalis.version.VersionFormatException;
import org.krysalis.version.VersionTestCase;
import org.krysalis.version.impl.CompoundVersion;
import org.krysalis.version.impl.data.ReleaseLevel;

/**
 * @version $Revision: 1.1 $
 */
public class FourPartVersionTest extends VersionTestCase {

	

	/**
	 * @param specification
	 */
	public FourPartVersionTest() {
		super(FourPartVersion.UNKNOWN.getSpecification());
	}

	/*
	 * Class under test for void ApacheVersion(String)
	 */
	public void testApacheVersionString() throws VersionException {
		//Logger.testInit();

		assertFourPartVersion("1.2.1", 1, 2, 1, ReleaseLevel.DEFAULT);
		assertFourPartVersion("1.2.1-dev", 1, 2, 1, ReleaseLevel.DEVELOPMENT);
		assertFourPartVersion("1.2", 1, 2, -1, ReleaseLevel.DEFAULT);
		assertFourPartVersion("1.2.99-b", 1, 2, 99, ReleaseLevel.BETA);
	}

	// :TODO: 1.0.0 ! 1.0.-1 == UNSET
	// Maybe it should be....
	// :TODO: final != rel 
	// Maybe it should be....
	
	
	public void testEquals() throws VersionFormatException {
		assertAllEqual(new String[] { "1","1", "1.0", "1.0","1.0-rel" });
	}

	public void testNonCompatible() throws VersionFormatException {
		assertVersionInOrder(new String[] { "1", "2" }, INCOMPATIBLE);
	}

	// :TODO:
	// "1.1.0", "1.1.2" has same problem as above 0 != UNSET
	// :TODO:
	// "1.1" is 1.1 release, that is not compatible with 1.1 < release
	public void testCompatible() throws VersionFormatException {
		assertVersionInOrder(new String[] { "1.1-a7","1.1-beta1","1.1-rc2"}, FORWARD);
	}

	/**
	 * @param versionString
	 * @param expectedMajor
	 * @param expectedMinor
	 * @param expectedPoint
	 * @param expectedReleaseLevel
	 * @throws VersionException
	 */
	private void assertFourPartVersion(final String versionString,
			int expectedMajor, int expectedMinor, int expectedPoint,
			ReleaseLevel expectedReleaseLevel) throws VersionException {
		FourPartVersion av = new FourPartVersion(versionString);
		assertVersion(versionString, av, expectedMajor, expectedMinor,
				expectedPoint, expectedReleaseLevel);
	}

	/**
	 * @param versionString
	 * @param fv
	 * @param expectedMajor
	 * @param expectedMinor
	 * @param expectedPoint
	 * @param expectedReleaseLevel
	 */
	private void assertVersion(final String versionString, FourPartVersion fv,
			int expectedMajor, int expectedMinor, int expectedPoint,
			ReleaseLevel expectedReleaseLevel) {
		
		assertEquals(versionString + ".major", expectedMajor, fv.getMajor());
		assertEquals(versionString + ".minor", expectedMinor, fv.getMinor());
		assertEquals(versionString + ".point", expectedPoint, fv.getPoint());
		assertEquals(versionString + ".releaseLevel", expectedReleaseLevel, fv
				.getReleaseLevelObject());
	}

	/**
	 * @param versionString
	 * @param av
	 * @param expectedMajor
	 * @param expectedMinor
	 * @param expectedPoint
	 */
	private void assertCompondVersion(final String versionString,
			CompoundVersion av, int expectedMajor, int expectedMinor,
			int expectedPoint) {
		
	}
}


-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click