Update of /cvsroot/metamorphosis/krysalis-version/src/test/org/krysalis/version/internal/data
In directory sc8-pr-cvs1:/tmp/cvs-serv20296/src/test/org/krysalis/version/internal/data
Modified Files:
VersionDataConstructorTests.java
Added Files:
ReleaseLevelTests.java VersionImporterTests.java
VersionDataElementSetTest.java
Log Message:
First stab at replacing Formats with Specifications for "non-Krysalis" formats.
Fixed some bugs via new tests.
--- 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.internal.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: 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.internal.data;
import junit.framework.TestCase;
import org.krysalis.version.exception.VersionException;
import org.krysalis.version.impl.KrysalisVersion;
import org.krysalis.version.impl.VersionImporter;
import org.krysalis.version.internal.VersionIdentifier;
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.internal.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
}
Index: VersionDataConstructorTests.java
===================================================================
RCS file: /cvsroot/metamorphosis/krysalis-version/src/test/org/krysalis/version/internal/data/VersionDataConstructorTests.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** VersionDataConstructorTests.java 6 Feb 2003 22:17:35 -0000 1.2
--- VersionDataConstructorTests.java 10 Mar 2003 20:44:08 -0000 1.3
***************
*** 61,64 ****
--- 61,66 ----
import org.krysalis.version.exception.VersionException;
+ import org.krysalis.version.impl.KrysalisVersion;
+ import org.krysalis.version.internal.VersionIdentifier;
/**
***************
*** 76,80 ****
public void testEqual() throws VersionException {
! VersionData version1 = new VersionData("1.2.3-alpha-20030302");
HashMap properties = new HashMap();
--- 78,82 ----
public void testEqual() throws VersionException {
! KrysalisVersion version1 = new KrysalisVersion(VersionIdentifier.BOGUS, "1.2.3-alpha-20030302");
HashMap properties = new HashMap();
***************
*** 85,89 ****
properties.put("buildNumber", "20030302");
! VersionData version2 = new VersionData(properties);
assertTrue("Extracted Major", (1 == version1.getMajor()));
--- 87,91 ----
properties.put("buildNumber", "20030302");
! KrysalisVersion version2 = new KrysalisVersion(VersionIdentifier.BOGUS, properties);
assertTrue("Extracted Major", (1 == version1.getMajor()));
***************
*** 92,96 ****
assertTrue(
"Extracted Release Level",
! (ReleaseLevel.ALPHA.equals(version1.getReleaseLevel())));
assertTrue(
"Extracted Build Number",
--- 94,98 ----
assertTrue(
"Extracted Release Level",
! (ReleaseLevel.ALPHA.equals(version1.getReleaseLevelObject())));
assertTrue(
"Extracted Build Number",
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.