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

[email protected] Fri, 21 Mar 2003 14:04:14 -0800
Newsgroups gmane.comp.krysalis.sandbox
Message-ID <[email protected]>
Update of /cvsroot/metamorphosis/krysalis-version/src/test/org/krysalis/version/impl
In directory sc8-pr-cvs1:/tmp/cvs-serv18425/src/test/org/krysalis/version/impl

Added Files:
	CompatibilityTests.java 
Log Message:
Compatibility

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

import junit.framework.TestCase;

import org.krysalis.version.exception.VersionException;
import org.krysalis.version.internal.VersionIdentifier;

/**
 *
 * @author $Author: arb_jack $
 * @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", "1.0");
    }

    public void testSameMajorButNewerMinor() throws VersionException {
        testCompatible("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, "1.1.1", "1.1.1-dev");
    }

    public void testCompatible(String str1, String str2)
        throws VersionException {
        KrysalisVersion v1 =
            VersionImporter.importKrysalisVersion(
                VersionIdentifier.BOGUS,
                str1);
        KrysalisVersion v2 =
            VersionImporter.importKrysalisVersion(
                VersionIdentifier.BOGUS,
                str2);
        testCompatible(true, v1, v2);
    }

    public void testCompatible(boolean compatible, String str1, String str2)
        throws VersionException {
        KrysalisVersion v1 =
            VersionImporter.importKrysalisVersion(
                VersionIdentifier.BOGUS,
                str1);
        KrysalisVersion v2 =
            VersionImporter.importKrysalisVersion(
                VersionIdentifier.BOGUS,
                str2);
        testCompatible(compatible, v1, v2);
    }

    public void testCompatible(
        boolean compatible,
        KrysalisVersion version1,
        KrysalisVersion version2) {

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




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