krysalis-version/src/test/org/krysalis/version/impl/data VersionDataRangeIteratorTest.java,NONE,1.1 VersionIdentifierHelperTest.java,NONE,1.1 ReleaseLevelTests.java,NONE,1.1 VersionDataComparisonTest.java,NONE,1.1 VersionDataConstructorTests.java,NONE,1.1 VersionDataRangeTest.java,NONE,1.1 VersionImporterTests.java,NONE,1.1 VersionDataElementSetTest.java,NONE,1.1

[email protected] Sun, 23 Mar 2003 17:25:50 -0800
Newsgroups gmane.comp.krysalis.sandbox
Message-ID <[email protected]>
Update of /cvsroot/metamorphosis/krysalis-version/src/test/org/krysalis/version/impl/data
In directory sc8-pr-cvs1:/tmp/cvs-serv27679/src/test/org/krysalis/version/impl/data

Added Files:
	VersionDataRangeIteratorTest.java 
	VersionIdentifierHelperTest.java ReleaseLevelTests.java 
	VersionDataComparisonTest.java 
	VersionDataConstructorTests.java VersionDataRangeTest.java 
	VersionImporterTests.java VersionDataElementSetTest.java 
Log Message:
Cleaned up package naming

--- NEW FILE: VersionDataRangeIteratorTest.java ---
/*
The Krysalis Patchy Software License, Version 1.1_01

Copyright (c) 2002-2003 Nicola Ken Barozzi.  All rights reserved.

This Licence is compatible with the BSD licence as described and 
approved by http://www.opensource.org/, and is based on the
Apache Software Licence Version 1.1.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in
   the documentation and/or other materials provided with the
   distribution.

3. The end-user documentation included with the redistribution,
   if any, must include the following acknowledgment:
	  "This product includes software developed for project 
	   Krysalis (http://www.krysalis.org/)."
   Alternately, this acknowledgment may appear in the software itself,
   if and wherever such third-party acknowledgments normally appear.

4. The names "Krysalis" and "Nicola Ken Barozzi" and
   "Krysalis Centipede" must not be used to endorse or promote products
   derived from this software without prior written permission. For
   written permission, please contact [email protected].

5. Products derived from this software may not be called "Krysalis",
   "Krysalis Centipede", nor may "Krysalis" appear in their name, without
	prior written permission of Nicola Ken Barozzi.

6. This software may contain voluntary contributions made by many 
   individuals, who decided to donate the code to this project in respect 
   of this licence.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
====================================================================
*/
package org.krysalis.version.impl.data;

import java.util.Iterator;

import junit.framework.TestCase;

import org.krysalis.version.exception.VersionException;
import org.krysalis.version.impl.data.util.VersionDataRangeIterator;

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

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

    public void testTenBuildNumbers()  throws VersionException {
        VersionData lower = new VersionData(1, 1, "alpha", 1, 1, 1);
        VersionData upper = new VersionData(1, 1, "alpha", 1, 1, 10);

        int count = 0;
        for (Iterator i = new VersionDataRangeIterator(lower, upper);
            i.hasNext();
            ++count) {
                
                i.next();
                
                	
        }

        assertTrue(10 == count);
    }

    // :TODO: Complete
}

--- NEW FILE: VersionIdentifierHelperTest.java ---
/*
The Krysalis Patchy Software License, Version 1.1_01

Copyright (c) 2003 Nicola Ken Barozzi.  All rights reserved.

This Licence is compatible with the BSD licence as described and 
approved by http://www.opensource.org/, and is based on the
Apache Software Licence Version 1.1.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in
   the documentation and/or other materials provided with the
   distribution.

3. The end-user documentation included with the redistribution,
   if any, must include the following acknowledgment:
	  "This product includes software developed for project 
	   Krysalis (http://www.krysalis.org/)."
   Alternately, this acknowledgment may appear in the software itself,
   if and wherever such third-party acknowledgments normally appear.

4. The names "Krysalis" and "Nicola Ken Barozzi" and
   "Krysalis Centipede" must not be used to endorse or promote products
   derived from this software without prior written permission. For
   written permission, please contact [email protected].

5. Products derived from this software may not be called "Krysalis",
   "Krysalis Centipede", nor may "Krysalis" appear in their name, without
	prior written permission of Nicola Ken Barozzi.

6. This software may contain voluntary contributions made by many 
   individuals, who decided to donate the code to this project in respect 
   of this licence.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
====================================================================
*/
package org.krysalis.version.impl.data;

import junit.framework.TestCase;

import org.krysalis.version.impl.VersionImplementationConstants;
import org.krysalis.version.impl.VersionIdentifier;
import org.krysalis.version.impl.VersionIdentifierHelper;
import org.krysalis.version.version.Version;

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

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

	public void testTrim()
	{
		String idKey = VersionImplementationConstants.VERSION_PACKAGE;
		
		VersionIdentifier id = VersionIdentifierHelper.extractVersionIdentifier(Version.class);
				
		assertTrue(
			"Correctly trim .version.Version",
			idKey.equals(id.getKey()));
	}
}

--- NEW FILE: ReleaseLevelTests.java ---
/*
The Krysalis Patchy Software License, Version 1.1_01

Copyright (c) 2003 Nicola Ken Barozzi.  All rights reserved.

This Licence is compatible with the BSD licence as described and 
approved by http://www.opensource.org/, and is based on the
Apache Software Licence Version 1.1.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in
   the documentation and/or other materials provided with the
   distribution.

3. The end-user documentation included with the redistribution,
   if any, must include the following acknowledgment:
	  "This product includes software developed for project 
	   Krysalis (http://www.krysalis.org/)."
   Alternately, this acknowledgment may appear in the software itself,
   if and wherever such third-party acknowledgments normally appear.

4. The names "Krysalis" and "Nicola Ken Barozzi" and
   "Krysalis Centipede" must not be used to endorse or promote products
   derived from this software without prior written permission. For
   written permission, please contact [email protected].

5. Products derived from this software may not be called "Krysalis",
   "Krysalis Centipede", nor may "Krysalis" appear in their name, without
	prior written permission of Nicola Ken Barozzi.

6. This software may contain voluntary contributions made by many 
   individuals, who decided to donate the code to this project in respect 
   of this licence.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
====================================================================
*/
package org.krysalis.version.impl.data;

import junit.framework.TestCase;

import org.krysalis.version.exception.VersionException;

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

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

    public void testKrysalisFormatIsDefaulted() throws VersionException {

       ReleaseLevel alpha = ReleaseLevel.ALPHA;
       ReleaseLevel other = ReleaseLevel.getFromString("alpha");
       
       assertEquals("ALPHA = from(\"alpha\")", alpha, other);
    }

}

--- NEW FILE: VersionDataComparisonTest.java ---
/*
The Krysalis Patchy Software License, Version 1.1_01

Copyright (c) 2003 Nicola Ken Barozzi.  All rights reserved.

This Licence is compatible with the BSD licence as described and 
approved by http://www.opensource.org/, and is based on the
Apache Software Licence Version 1.1.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in
   the documentation and/or other materials provided with the
   distribution.

3. The end-user documentation included with the redistribution,
   if any, must include the following acknowledgment:
      "This product includes software developed for project
       Krysalis (http://www.krysalis.org/)."
   Alternately, this acknowledgment may appear in the software itself,
   if and wherever such third-party acknowledgments normally appear.

4. The names "Krysalis" and "Nicola Ken Barozzi" and
   "Krysalis Centipede" must not be used to endorse or promote products
   derived from this software without prior written permission. For
   written permission, please contact [email protected].

5. Products derived from this software may not be called "Krysalis",
   "Krysalis Centipede", nor may "Krysalis" appear in their name, without
    prior written permission of Nicola Ken Barozzi.

6. This software may contain voluntary contributions made by many 
   individuals, who decided to donate the code to this project in respect 
   of this licence.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
====================================================================
*/
package org.krysalis.version.impl.data;

import junit.framework.TestCase;

import org.krysalis.version.exception.VersionException;
import org.krysalis.version.impl.data.util.VersionDataComparison;

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

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

    public void testEqual() throws VersionException {
        VersionData data1 = new VersionData(1, 1, "alpha", 1, 1, 1);
        VersionData data2 = new VersionData(2, 1, "alpha", 1, 1, 1);

        VersionDataComparison eq1 = VersionDataComparison.getEqual(data1);

        assertTrue("Equals Itself", eq1.evaluate(data1));
        assertTrue("Equals Other", !(eq1.evaluate(data2)));
    }

    public void testLessThan() throws VersionException {
        VersionData data1 = new VersionData(1, 1, "alpha", 1, 1, 1);
        VersionData data2 = new VersionData(2, 1, "alpha", 1, 1, 1);

        VersionDataComparison eq1 = VersionDataComparison.getLessThan(data1);
        VersionDataComparison eq2 = VersionDataComparison.getLessThan(data2);

        assertTrue("Not Less Than Itself", !(eq1.evaluate(data1)));
        assertTrue("Less Than Other", !(eq1.evaluate(data2)));
        assertTrue("Other Less Than", eq2.evaluate(data1));
    }

    // :TODO: Complete
}

--- NEW FILE: VersionDataConstructorTests.java ---
/*
The Krysalis Patchy Software License, Version 1.1_01

Copyright (c) 2002-2003 Nicola Ken Barozzi.  All rights reserved.

This Licence is compatible with the BSD licence as described and 
approved by http://www.opensource.org/, and is based on the
Apache Software Licence Version 1.1.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in
   the documentation and/or other materials provided with the
   distribution.

3. The end-user documentation included with the redistribution,
   if any, must include the following acknowledgment:
      "This product includes software developed for project 
       Krysalis (http://www.krysalis.org/)."
   Alternately, this acknowledgment may appear in the software itself,
   if and wherever such third-party acknowledgments normally appear.

4. The names "Krysalis" and "Nicola Ken Barozzi" and
   "Krysalis Centipede" must not be used to endorse or promote products
   derived from this software without prior written permission. For
   written permission, please contact [email protected].

5. Products derived from this software may not be called "Krysalis",
   "Krysalis Centipede", nor may "Krysalis" appear in their name, without
    prior written permission of Nicola Ken Barozzi.

6. This software may contain voluntary contributions made by many 
   individuals, who decided to donate the code to this project in respect 
   of this licence.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
====================================================================
*/
package org.krysalis.version.impl.data;

import java.util.HashMap;

import junit.framework.TestCase;

import org.krysalis.version.exception.VersionException;
import org.krysalis.version.impl.KrysalisVersion;
import org.krysalis.version.impl.VersionIdentifier;

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

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

    public void testEqual() throws VersionException {

        KrysalisVersion version1 = new KrysalisVersion(VersionIdentifier.BOGUS, "1.2.3-alpha-20030302");

        HashMap properties = new HashMap();
        properties.put("major", "1");
        properties.put("minor", "2");
        properties.put("point", "3");
        properties.put("releaseLevel", "alpha");
        properties.put("buildNumber", "20030302");

        KrysalisVersion version2 = new KrysalisVersion(VersionIdentifier.BOGUS, properties);

        assertTrue("Extracted Major", (1 == version1.getMajor()));
        assertTrue("Extracted Minor", (2 == version1.getMinor()));
        assertTrue("Extracted Point", (3 == version1.getPoint()));
        assertTrue(
            "Extracted Release Level",
            (ReleaseLevel.ALPHA.equals(version1.getReleaseLevelObject())));
        assertTrue(
            "Extracted Build Number",
            (20030302 == version1.getBuildNumber()));

        assertTrue("Extracted Major", (1 == version2.getMajor()));
        assertTrue("Extracted Minor", (2 == version2.getMinor()));
        assertTrue("Extracted Point", (3 == version2.getPoint()));
        assertTrue(
            "Extracted Release Level",
            (ReleaseLevel.ALPHA.equals(version2.getReleaseLevel())));
        assertTrue(
            "Extracted Build Number",
            (20030302 == version2.getBuildNumber()));

        assertEquals("Equal", version1, version2);
    }

    // :TODO: Complete
}

--- NEW FILE: VersionDataRangeTest.java ---
/*
The Krysalis Patchy Software License, Version 1.1_01

Copyright (c) 2002-2003 Nicola Ken Barozzi.  All rights reserved.

This Licence is compatible with the BSD licence as described and 
approved by http://www.opensource.org/, and is based on the
Apache Software Licence Version 1.1.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in
   the documentation and/or other materials provided with the
   distribution.

3. The end-user documentation included with the redistribution,
   if any, must include the following acknowledgment:
      "This product includes software developed for project 
       Krysalis (http://www.krysalis.org/)."
   Alternately, this acknowledgment may appear in the software itself,
   if and wherever such third-party acknowledgments normally appear.

4. The names "Krysalis" and "Nicola Ken Barozzi" and
   "Krysalis Centipede" must not be used to endorse or promote products
   derived from this software without prior written permission. For
   written permission, please contact [email protected].

5. Products derived from this software may not be called "Krysalis",
   "Krysalis Centipede", nor may "Krysalis" appear in their name, without
    prior written permission of Nicola Ken Barozzi.

6. This software may contain voluntary contributions made by many 
   individuals, who decided to donate the code to this project in respect 
   of this licence.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
====================================================================
*/
package org.krysalis.version.impl.data;

import junit.framework.TestCase;

import org.krysalis.version.exception.VersionException;
import org.krysalis.version.impl.data.VersionData;
import org.krysalis.version.impl.data.util.VersionDataRange;

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

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

    public void testEqual() throws VersionException {
        VersionData lower =
            new VersionData(1, 1, "alpha", 1, 1, 1);
        VersionData upper =
            new VersionData(2, 1, "alpha", 1, 1, 1);

        VersionData in =
            new VersionData(1, 2, "alpha", 1, 1, 1);
        VersionData out =
            new VersionData(3, 1, "alpha", 1, 1, 1);

        VersionDataRange r1 = new VersionDataRange(lower, upper);

        assertTrue("In Range -- lower", r1.inRange(lower));
        assertTrue("In Range -- upper", r1.inRange(upper));
        assertTrue("In Range", r1.inRange(in));
        assertTrue("Not In Range", !r1.inRange(out));
    }

    // :TODO: Complete
}

--- NEW FILE: VersionImporterTests.java ---
/*
The Krysalis Patchy Software License, Version 1.1_01

Copyright (c) 2003 Nicola Ken Barozzi.  All rights reserved.

This Licence is compatible with the BSD licence as described and 
approved by http://www.opensource.org/, and is based on the
Apache Software Licence Version 1.1.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in
   the documentation and/or other materials provided with the
   distribution.

3. The end-user documentation included with the redistribution,
   if any, must include the following acknowledgment:
	  "This product includes software developed for project 
	   Krysalis (http://www.krysalis.org/)."
   Alternately, this acknowledgment may appear in the software itself,
   if and wherever such third-party acknowledgments normally appear.

4. The names "Krysalis" and "Nicola Ken Barozzi" and
   "Krysalis Centipede" must not be used to endorse or promote products
   derived from this software without prior written permission. For
   written permission, please contact [email protected].

5. Products derived from this software may not be called "Krysalis",
   "Krysalis Centipede", nor may "Krysalis" appear in their name, without
	prior written permission of Nicola Ken Barozzi.

6. This software may contain voluntary contributions made by many 
   individuals, who decided to donate the code to this project in respect 
   of this licence.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
====================================================================
*/
package org.krysalis.version.impl.data;

import junit.framework.TestCase;

import org.krysalis.version.exception.VersionException;
import org.krysalis.version.impl.KrysalisVersion;
import org.krysalis.version.impl.VersionIdentifier;
import org.krysalis.version.impl.VersionImporter;
import org.krysalis.version.specification.VersionSpecification;
import org.krysalis.version.specification.VersionSpecificationFactory;

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

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

    public void testKrysalisFormatIsDefaulted() throws VersionException {

        KrysalisVersion version = importVersion("1.0");

        VersionSpecification spec = version.getSpecification();

        assertTrue(
            "Krysalis Specification Used",
            spec.equals(
                VersionSpecificationFactory
                    .createKrysalisVersionSpecification()));
    }

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

        assertTrue(
            "Release Qualifier Correct",
            ReleaseLevel.ALPHA.equals(version.getReleaseLevelObject()));
            
        VersionSpecification spec = version.getSpecification();

        assertEquals(
            "Krysalis Specification Used",
            spec,VersionSpecificationFactory
                    .createKrysalisVersionSpecification());
    }

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

        assertTrue(
            "Release Qualifier Correct",
            1 == version.getReleaseQualifier());
            
        VersionSpecification spec = version.getSpecification();

        assertTrue(
            "Krysalis Specification Used",
            spec.equals(
                VersionSpecificationFactory
                    .createKrysalisVersionSpecification()));
    }

    private KrysalisVersion importVersion(String data)
        throws VersionException {
        KrysalisVersion version =
            VersionImporter.importKrysalisVersion(
                VersionIdentifier.BOGUS,
                data);

        return version;
    }

}

--- NEW FILE: VersionDataElementSetTest.java ---
/*
The Krysalis Patchy Software License, Version 1.1_01

Copyright (c) 2003 Nicola Ken Barozzi.  All rights reserved.

This Licence is compatible with the BSD licence as described and 
approved by http://www.opensource.org/, and is based on the
Apache Software Licence Version 1.1.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in
   the documentation and/or other materials provided with the
   distribution.

3. The end-user documentation included with the redistribution,
   if any, must include the following acknowledgment:
      "This product includes software developed for project
       Krysalis (http://www.krysalis.org/)."
   Alternately, this acknowledgment may appear in the software itself,
   if and wherever such third-party acknowledgments normally appear.

4. The names "Krysalis" and "Nicola Ken Barozzi" and
   "Krysalis Centipede" must not be used to endorse or promote products
   derived from this software without prior written permission. For
   written permission, please contact [email protected].

5. Products derived from this software may not be called "Krysalis",
   "Krysalis Centipede", nor may "Krysalis" appear in their name, without
    prior written permission of Nicola Ken Barozzi.

6. This software may contain voluntary contributions made by many 
   individuals, who decided to donate the code to this project in respect 
   of this licence.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
====================================================================
*/
package org.krysalis.version.impl.data;

import junit.framework.TestCase;

import org.krysalis.version.exception.VersionException;

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

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

    public void testFull() throws VersionException {
        VersionDataElementSet set = VersionDataElementSet.FULL;

        assertTrue("hasMajor", set.hasMajor());
        assertTrue("hasMinor", set.hasMinor());
        assertTrue("hasPoint", set.hasPoint());
        assertTrue("hasReleaseLevel", set.hasReleaseLevel());
        assertTrue("hasReleaseQualifier", set.hasReleaseQualifier());
        assertTrue("hasBuildNumber", set.hasBuildNumber());
    }

    public void testEmpty() throws VersionException {
        VersionDataElementSet set = new VersionDataElementSet(0);

        assertTrue("!hasMajor", !set.hasMajor());
        assertTrue("!hasMinor", !set.hasMinor());
        assertTrue("!hasPoint", !set.hasPoint());
        assertTrue("!hasReleaseLevel", !set.hasReleaseLevel());
        assertTrue("!hasReleaseQualifier", !set.hasReleaseQualifier());
        assertTrue("!hasBuildNumber", !set.hasBuildNumber());
    }

    // :TODO: Complete
}




-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open! 
Get cracking and register here for some mind boggling fun and 
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en