krysalis-version/src/test/java/org/krysalis/version/impl/data ImporterTests.java,NONE,1.1 TestApacheVersion.java,NONE,1.1 VersionTest.java,NONE,1.1 VersionIdentifierTest.java,NONE,1.1 ResolverTests.java,NONE,1.1 TestApacheVersionMarker.java,NONE,1.1 ApacheVersionTest.java,NONE,1.1 VersionImporterTests.java,NONE,1.1 CompatibilityTests.java,NONE,1.1 ApacheVersionSpecTest.java,NONE,1.1

Nick Chalko <[email protected]> Tue, 09 Nov 2004 07:54:53 +0000
Newsgroups gmane.comp.krysalis.cvs
Message-ID <[email protected]>
Update of /cvsroot/krysalis/krysalis-version/src/test/java/org/krysalis/version/impl/data
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2087/src/test/java/org/krysalis/version/impl/data

Added Files:
	ImporterTests.java TestApacheVersion.java VersionTest.java 
	VersionIdentifierTest.java ResolverTests.java 
	TestApacheVersionMarker.java ApacheVersionTest.java 
	VersionImporterTests.java CompatibilityTests.java 
	ApacheVersionSpecTest.java 
Log Message:
Coppied over a bunch of tests.

--- NEW FILE: TestApacheVersionMarker.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.data;


public class TestApacheVersionMarker extends ApacheVersionMarker {
	TestApacheVersionMarker(String identifier) {
		super(identifier, TestApacheVersion.getTestVersion());
	}

	TestApacheVersionMarker(String identifier, int major, int minor) {
		super(identifier, TestApacheVersion.getTestVersion(major, minor));
	}

	TestApacheVersionMarker(VersionIdentifier identifier) {
		super(identifier, TestApacheVersion.getTestVersion());
	}

	TestApacheVersionMarker(VersionIdentifier identifier, int major, int minor) {
		super(identifier, TestApacheVersion.getTestVersion(major, minor));
	}

    public static ApacheVersionMarker getTestVersionMarker(String identifier) {
    	return new TestApacheVersionMarker(identifier);
    }

    public static ApacheVersionMarker getTestVersionMarker(
    		VersionIdentifier identifier) {
    	return new TestApacheVersionMarker(identifier);
    }

    public static ApacheVersionMarker getTestVersionMarker(String identifier,
    		int major, int minor) {
    	return new TestApacheVersionMarker(identifier, major, minor);
    }

    public static ApacheVersionMarker getTestVersionMarker(
    		VersionIdentifier identifier, int major, int minor) {
    	return new TestApacheVersionMarker(identifier, major, minor);
    }
}
--- NEW FILE: CompatibilityTests.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.data;

import junit.framework.TestCase;

import org.krysalis.version.VersionException;

/**
 *
 * @author $Author: chalko $
 * @version $Revision: 1.1 $
 * 
 */
public class CompatibilityTests extends TestCase {

	/**
	 * Constructor for CompatibilityTests.
	 * @param arg0
	 */
	public CompatibilityTests(String test) {
		super(test);
	}

	public static void main(String[] args) {
		junit.textui.TestRunner.run(CompatibilityTests.class);
	}

	public void testSameVersion() throws VersionException {
		testCompatible("1.0", "1.0");
	}

	public void testSameMajor() throws VersionException {
		testCompatible("1", "1.0");
	}

	public void testSameMajorButLessorMinor() throws VersionException {
		testCompatible(false, "1.1", "1.0");
	}

	public void testSameMajorButNewerMinor() throws VersionException {
		testCompatible(false, "1.0", "1.1");
	}

	public void testSameMajorMinorButDifferentRelease()
		throws VersionException {
		testCompatible("1.0-alpha", "1.0-dev");
	}

	public void testSameMajorMinorButDifferentReleaseFirstRelease()
		throws VersionException {
		testCompatible(false, "1.0", "1.0-dev");
	}

	public void testSameMajorMinorButDifferentReleaseSecondRelease()
		throws VersionException {
		testCompatible("1.0-dev", "1.0");
	}

	public void testIncompatibleMajor() throws VersionException {
		testCompatible(false, "2.1.1", "1.1.1-dev");
	}

	public void testMajorToDev() throws VersionException {
		testCompatible(false, "1.2", "0.0-dev1");
	}

	public void testCompatible(String controlStr, String str2)
		throws VersionException {
		testCompatible(true, controlStr, str2);
	}

	public void testCompatible(
		boolean compatible,
		String controlStr,
		String testStr)
		throws VersionException {
		ApacheVersion controlVersion =
			VersionImporter.importApacheVersion(controlStr);
		ApacheVersion testVersion =
			VersionImporter.importApacheVersion(testStr);
		testCompatible(compatible, controlVersion, testVersion);
	}

	public void testCompatible(
		boolean compatible,
		ApacheVersion controlVersion,
		ApacheVersion testVersion) {

		assertEquals(
			"Compatible v1 [" + controlVersion + " ] ~ [" + testVersion + " ]",
			compatible,
			controlVersion.isCompatible(testVersion));
	}
}

--- NEW FILE: ApacheVersionTest.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.data;

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

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

	/**
	 * @param specification
	 */
	public ApacheVersionTest() {
		super(ApacheVersion.UNKNOWN.getSpecification());
	}

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

		assertApacheVersion("1.2.1", 1, 2, 1, ReleaseLevel.DEFAULT);
		assertApacheVersion("1.2.1-dev", 1, 2, 1, ReleaseLevel.DEVELOPMENT);
		assertApacheVersion("1.2", 1, 2, -1, ReleaseLevel.DEFAULT);
		assertApacheVersion("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 assertApacheVersion(final String versionString,
			int expectedMajor, int expectedMinor, int expectedPoint,
			ReleaseLevel expectedReleaseLevel) throws VersionException {
		ApacheVersion av = new ApacheVersion(versionString);
		assertVersion(versionString, av, expectedMajor, expectedMinor,
				expectedPoint, expectedReleaseLevel);
	}

	/**
	 * @param versionString
	 * @param av
	 * @param expectedMajor
	 * @param expectedMinor
	 * @param expectedPoint
	 * @param expectedReleaseLevel
	 */
	private void assertVersion(final String versionString, ApacheVersion av,
			int expectedMajor, int expectedMinor, int expectedPoint,
			ReleaseLevel expectedReleaseLevel) {
		assertCompondVersion(versionString, av, expectedMajor, expectedMinor,
				expectedPoint);
		assertEquals(versionString + ".releaseLevel", expectedReleaseLevel, av
				.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) {
		assertEquals(versionString + ".major", expectedMajor, av.getMajor());
		assertEquals(versionString + ".minor", expectedMinor, av.getMinor());
		assertEquals(versionString + ".point", expectedPoint, av.getPoint());
	}
}
--- NEW FILE: VersionTest.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.data;

import java.util.Iterator;
import java.util.TreeSet;

import junit.framework.TestCase;

import org.krysalis.version.impl.data.ReleaseLevel;

/**
 * @author ajack
 */
public class VersionTest extends TestCase {

    private ApacheVersion m_version11A1 = null;
    private ApacheVersion m_version11A2 = null;
    private ApacheVersion m_version11B1 = null;
    private ApacheVersion m_version12A1 = null;
    private ApacheVersion m_version21A1 = null;

    //private VersionReference m_version11A1Ref = null;
    //private VersionReference m_version11A2Ref = null;
    //private VersionReference m_version11B1Ref = null;
    //private VersionReference m_version12A1Ref = null;
    //private VersionReference m_version21A1Ref = null;

    /**
     * Constructor for VersionTest.
     * @param arg0
     */
    public VersionTest(String arg0) {
        super(arg0);
    }

    public static void main(String[] args) {
        junit.textui.TestRunner.run(VersionTest.class);
    }

    /**
     * @see TestCase#setUp()
     */
    protected void setUp() throws Exception {
        m_version11A1 =
            TestApacheVersion.getTestVersion(1, 1, ReleaseLevel.ALPHA, 1);
        m_version11A2 =
            TestApacheVersion.getTestVersion(1, 1, ReleaseLevel.ALPHA, 2);
        m_version11B1 =
            TestApacheVersion.getTestVersion(1, 1, ReleaseLevel.BETA, 1);
        m_version12A1 =
            TestApacheVersion.getTestVersion(1, 2, ReleaseLevel.ALPHA, 1);
        m_version21A1 =
            TestApacheVersion.getTestVersion(2, 1, ReleaseLevel.ALPHA, 1);
    }

    /**
     * @see TestCase#tearDown()
     */
    protected void tearDown() throws Exception {
        m_version11A1 = null;
        m_version11A2 = null;
        m_version11B1 = null;
        m_version12A1 = null;
        m_version21A1 = null;
    }

    /*
     * Test for boolean equals(Object)
     */
    public void testEqualsObject() {
        assertTrue("self equal to self", m_version11A1.equals(m_version11A1));
        assertTrue(
            "Alpha not equal to beta",
            !m_version11A1.equals(m_version11B1));
        assertTrue("minor changes", !m_version11A1.equals(m_version12A1));
    }

    public void testCompareTo() {
        assertTrue(
            "compares to self",
            m_version11A1.compareTo(m_version11A1) == 0);
        assertTrue(
                "alpha less than beta",
                m_version11A1.compareTo(m_version11B1) < 0);
        assertTrue(
            "11 beta with 12 alpha",
            m_version11B1.compareTo(m_version12A1) < 0);
        assertTrue(
            "11 alpha with 12 alpha",
            m_version11A1.compareTo(m_version12A1) < 0);
    }

    public void testCompareTo2() {
        TreeSet set = new TreeSet();

        set.add(m_version11A1);
        set.add(m_version11A2);
        set.add(m_version11B1);
        set.add(m_version12A1);
        set.add(m_version21A1);

        //for ( Iterator ii = set.iterator(); ii.hasNext(); )
        //{
        //    ((VersionContainer)ii.next()).dump(System.out);
        //}

        Iterator i = set.iterator();

        assertTrue("11A1 comes first", m_version11A1.equals(i.next()));
    }
}

--- NEW FILE: ResolverTests.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.data;

import junit.framework.TestCase;

import org.krysalis.version.VersionRuntime;
import org.krysalis.version.context.Resolver;
import org.krysalis.version.context.VersionInformation;

/**
 * @author [email protected]
 */
public class ResolverTests extends TestCase {

    private Resolver m_resolver = null;

    public ResolverTests(String arg0) {
        super(arg0);
    }

    public static void main(String[] args) {
        junit.textui.TestRunner.run(ResolverTests.class);
    }

	public void setUp()
	{
		m_resolver = VersionRuntime.getRuntime().getContext().getResolver();
	}

    public void testComplexInterface1() throws Exception {

        String id = VersionImplementationConstants.VERSION_PACKAGE;
        
        VersionInformation ref = m_resolver.resolve(id);

        assertNotNull("Resolved " + id, ref);
    }
}

--- NEW FILE: TestApacheVersion.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.data;

import org.apache.depot.version.impl.data.TestVersionData;
import org.krysalis.version.VersionException;
import org.krysalis.version.impl.data.ReleaseLevel;

public class TestApacheVersion extends ApacheVersion {
	TestApacheVersion() {
		super(TestVersionData.getTestVersionData());
	}

	TestApacheVersion(int major,int minor) {
		super(TestVersionData.getTestVersionData(major,minor));
	}

	TestApacheVersion(int major, int minor, ReleaseLevel level, int point) {
		super(TestVersionData.getTestVersionData(major,minor,level,point));
	}

	TestApacheVersion(String format) throws VersionException {
		super(VersionImporter.importApacheVersion(format));
	}

    public static ApacheVersion getTestVersion() {
    	return new TestApacheVersion();
    }

    public static ApacheVersion getTestVersion(int major, int minor) {
    	return new TestApacheVersion(major, minor);
    }

    public static ApacheVersion getTestVersion(int major, int minor,
    		ReleaseLevel level, int point) {
    	return new TestApacheVersion(major, minor, level, point);
    }
}

--- NEW FILE: ImporterTests.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.data;

import java.util.Date;

import junit.framework.TestCase;

import org.krysalis.version.VersionException;
import org.krysalis.version.impl.data.VersionData;
import org.krysalis.version.specification.DatetimestampedVersionSpecification;

/**
 *
 * @author $Author: chalko $
 * @version $Revision: 1.1 $
 * 
 */
public class ImporterTests extends TestCase {
    public ImporterTests(String arg0) {
        super(arg0);
    }

    public static void main(String[] args) {
        junit.textui.TestRunner.run(ImporterTests.class);
    }

    public void testDated1() throws Exception {
        String dated = "21022003";

        Date date = VersionImplementationConstants.DATE_FORMAT.parse(dated);

        test(
            dated,
            new ApacheVersion(
                new DatetimestampedVersionSpecification(),
                new VersionData(date)));
    }

    private void test(String versionString, ApacheVersion expectedVersion)
        throws VersionException {

        //
        //  Parse the data
        //
        ApacheVersion version =
            VersionImporter.importApacheVersion(
                versionString);

        //DebugUtils.dump("Imported Version : ", version);
        //DebugUtils.dump("Expected Version : ", expectedVersion);

        assertEquals("Expected Version", expectedVersion, version);
    }
}

--- NEW FILE: VersionImporterTests.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.data;

import junit.framework.TestCase;

import org.krysalis.common.log.Logger;
import org.krysalis.version.VersionException;
import org.krysalis.version.impl.data.ReleaseLevel;
import org.krysalis.version.specification.ApacheVersionSpecification;
import org.krysalis.version.specification.VersionSpecification;

/**
 * @author ajack
 */
public class VersionImporterTests extends TestCase {
	public VersionImporterTests(String arg0) {
		super(arg0);
		
		Logger.testInit();
	}

	public static void main(String[] args) {
		junit.textui.TestRunner.run(VersionImporterTests.class);
	}

	public void testApacheFormatIsDefaulted() throws VersionException {

		ApacheVersion version = importApacheVersion("1.0");

		VersionSpecification spec = version.getSpecification();

		assertEquals("Apache Specification Used",
				new ApacheVersionSpecification(), spec);
	}

	public void testTypical() throws VersionException {
		ApacheVersion version = importApacheVersion("1.2.3-alpha-20030302");

		assertEquals("Release Qualifier Correct", ReleaseLevel.ALPHA, version
				.getReleaseLevelObject());

		VersionSpecification spec = version.getSpecification();

		assertEquals("Apache Specification Used", 
				new ApacheVersionSpecification(), spec);
	}

	public void testReleaseQualifier() throws VersionException {
		ApacheVersion version = importApacheVersion("1.2.3-alpha1-20030302");

		assertEquals("Release Qualifier for" + version, 1, version
				.getReleaseQualifier());

		VersionSpecification spec = version.getSpecification();

		assertEquals("Specification Used", new ApacheVersionSpecification(),
				spec);
	}

	private ApacheVersion importApacheVersion(String data) throws VersionException {
		ApacheVersion version = VersionImporter.importApacheVersion(data);

		return version;
	}

}
--- NEW FILE: ApacheVersionSpecTest.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.data;

import java.util.Iterator;

import junit.framework.TestCase;

import org.krysalis.common.log.Logger;
import org.krysalis.version.VersionException;
import org.krysalis.version.specification.ApacheVersionSpecification;
import org.krysalis.version.specification.DatetimestampedVersionSpecification;
import org.krysalis.version.specification.EclipseVersionSpecification;
import org.krysalis.version.specification.JavasoftVersionSpecification;
import org.krysalis.version.specification.VersionSpecification;
import org.krysalis.version.specification.VersionSpecificationFactory;
import org.krysalis.version.specification.experimental.JakartaCommonsVersionSpecification;

/**
 * @version $Revision: 1.1 $
 */
public class ApacheVersionSpecTest extends TestCase {

    /*
     * Class under test for void ApacheVersion(String)
     */
    public void testSpecs1() throws VersionException {
        //Logger.testInit();
        
		checkVersionSpecification(
				VersionImplementationConstants.DATETIMESTAMPED_VERSION_ID,
				DatetimestampedVersionSpecification.class);
		checkVersionSpecification(
				VersionImplementationConstants.APACHE_VERSION_ID,
				ApacheVersionSpecification.class);
		checkVersionSpecification(
				VersionImplementationConstants.ECLIPSE_VERSION_ID,
				EclipseVersionSpecification.class);
		checkVersionSpecification(
				VersionImplementationConstants.JAVASOFT_VERSION_ID,
				JavasoftVersionSpecification.class);
		checkVersionSpecification(
				VersionImplementationConstants.JAKARTA_COMMONS_VERSION_ID,
				JakartaCommonsVersionSpecification.class);
    }
    
    public void testSpecs2()  throws VersionException{
    	int count = 0;
    
    	for (Iterator i =
			VersionSpecificationFactory.getRegisteredSpecificationIds().iterator();
			i.hasNext();
			) {    	
    		VersionSpecification spec = VersionSpecificationFactory.createVersionSpecificationFromId((String)i.next());
    		count ++;
    		Logger.getLogger().debug("Spec: " + spec);
    	}
    	
    	assertEquals("Registered Versions", count,6);
    }
    private void checkVersionSpecification(String id, Class clazz) throws VersionException
    {
    	assertEquals(clazz.getName(), 
    			VersionSpecificationFactory.createVersionSpecificationFromId(id).getClass(), clazz);
    }
}
--- NEW FILE: VersionIdentifierTest.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.data;

import junit.framework.TestCase;

import org.apache.depot.version.impl.sample.Version1;
import org.krysalis.version.version.Version;

/**
 * @author ajack
 */
public class VersionIdentifierTest extends TestCase {
	public VersionIdentifierTest(String arg0) {
		super(arg0);
	}

	public static void main(String[] args) {
		junit.textui.TestRunner.run(VersionIdentifierTest.class);
	}

	public void testTrim1() {
		String idKey = VersionImplementationConstants.VERSION_PACKAGE;

		VersionIdentifier id =
			VersionIdentifier.extractVersionIdentifier(Version.class);

		assertEquals("Correctly trim .version.Version", idKey, id.getKey());
	}

	public void testTrim2() {
		String idKey = "org.apache.depot.version.impl.sample";

		VersionIdentifier id =
			VersionIdentifier.extractVersionIdentifier(Version1.class);

		assertEquals("Correctly trim ", idKey, id.getKey());
	}
}



-------------------------------------------------------
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