summaryrefslogtreecommitdiffstats
path: root/src/junit/com/jogamp/common
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-05-13 13:06:19 +0200
committerSven Gothel <[email protected]>2014-05-13 13:06:19 +0200
commit64615f17a8c63f692159235e169dbdd14d30b737 (patch)
treef9fb29fe7b7862b72dc5028d9173ea3ec33add25 /src/junit/com/jogamp/common
parentc06288d2a12586ab8df3715cf130549fdd7499fb (diff)
Unit Test: Modularize Semantic Version Test / Fix 'excludes'
Refactor base semjar unit test class into com.jogamp.junit.util.VersionSemanticsUtil, part of new gluegen-test-util.jar. The new gluegen-test-util.jar shall be used by all other modules to test versioning.
Diffstat (limited to 'src/junit/com/jogamp/common')
-rw-r--r--src/junit/com/jogamp/common/util/TestVersionSemantics.java98
1 files changed, 25 insertions, 73 deletions
diff --git a/src/junit/com/jogamp/common/util/TestVersionSemantics.java b/src/junit/com/jogamp/common/util/TestVersionSemantics.java
index a4f33b2..dba42b5 100644
--- a/src/junit/com/jogamp/common/util/TestVersionSemantics.java
+++ b/src/junit/com/jogamp/common/util/TestVersionSemantics.java
@@ -29,27 +29,21 @@ package com.jogamp.common.util;
import java.io.File;
import java.io.IOException;
-import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
-import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.osjava.jardiff.DiffCriteria;
import org.osjava.jardiff.SimpleDiffCriteria;
-import org.semver.Comparer;
import org.semver.Delta;
-import org.semver.Dumper;
-import org.semver.Delta.Difference;
import com.jogamp.common.GlueGenVersion;
-import com.jogamp.common.util.IOUtil;
-import com.jogamp.common.util.JarUtil;
import com.jogamp.common.util.VersionNumberString;
+import com.jogamp.junit.util.JunitTracer;
+import com.jogamp.junit.util.VersionSemanticsUtil;
/**
* Compares a defined previous version with the current version.
@@ -70,80 +64,38 @@ import com.jogamp.common.util.VersionNumberString;
* @throws URISyntaxException
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class TestVersionSemantics {
- public static final String jarFile = "gluegen-rt.jar";
- public static final VersionNumberString preVersion = new VersionNumberString("2.1.5");
- public static final Delta.CompatibilityType expectedCompatibilityType = Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER;
+public class TestVersionSemantics extends JunitTracer {
+ static final String jarFile = "gluegen-rt.jar";
+ static final VersionNumberString preVersionNumber = new VersionNumberString("2.1.5");
+ static final Delta.CompatibilityType expectedCompatibilityType = Delta.CompatibilityType.BACKWARD_COMPATIBLE_USER;
+
+ static final DiffCriteria diffCriteria = new SimpleDiffCriteria();
+ // static final DiffCriteria diffCriteria = new PublicDiffCriteria();
+
+ static final JogampVersion curVersion = GlueGenVersion.getInstance();
+ static final VersionNumberString curVersionNumber = new VersionNumberString(curVersion.getImplementationVersion());
+
+ static final Set<String> excludes;
+ static {
+ excludes = new HashSet<String>();
+ excludes.add("jogamp.common.**");
+ excludes.add("jogamp.android.**");
+ }
@Test
- public void testVersion01() throws IllegalArgumentException, IOException, URISyntaxException {
-
- final GlueGenVersion glueGenVersion = GlueGenVersion.getInstance();
- final VersionNumberString curVersion = new VersionNumberString(glueGenVersion.getImplementationVersion());
-
- final File previousJar = new File("lib/v"+preVersion.getVersionString()+"/"+jarFile);
-
- final ClassLoader rootCL = TestVersionSemantics.class.getClassLoader();
-
- // Get containing JAR file "TestJarsInJar.jar" and add it to the TempJarCache
- final URI currentJarURI = JarUtil.getJarSubURI(GlueGenVersion.class.getName(), rootCL);
- final String currentJarLocS = IOUtil.decodeURIIfFilePath(currentJarURI);
- final File currentJar = new File(currentJarLocS);
-
- final DiffCriteria diffCriteria = new SimpleDiffCriteria();
-
- final Set<String> includes = new HashSet<String>();
+ public void testVersionLatest() throws IllegalArgumentException, IOException, URISyntaxException {
- final Set<String> excludes = new HashSet<String>();
- excludes.add("jogamp/**");
+ final File previousJar = new File("lib/v"+preVersionNumber.getVersionString()+"/"+jarFile);
- final Comparer comparer = new Comparer(diffCriteria, previousJar, currentJar, includes, excludes);
- final Delta delta = comparer.diff();
+ final ClassLoader currentCL = TestVersionSemantics.class.getClassLoader();
- //Validates that computed and provided compatibility type are compatible.
- final Delta.CompatibilityType detectedCompatibilityType = delta.computeCompatibilityType();
- final int comp = detectedCompatibilityType.compareTo(expectedCompatibilityType);
- final boolean compOK = 0 >= comp;
- final String compS;
- if( 0 > comp ) {
- compS = "< ";
- } else if ( 0 == comp ) {
- compS = "==";
- } else {
- compS = "> ";
- }
-
- System.err.println("GlueGen Semantic Versioning Test");
- System.err.println("Previous version: "+preVersion+" - "+previousJar.toString());
- System.err.println("Current version: "+curVersion+" - "+currentJar.toString());
- System.err.println("Compat. expected: "+expectedCompatibilityType);
- System.err.println("Compat. pre -> cur: "+detectedCompatibilityType);
- System.err.println("Compat. result: detected "+compS+" expected -> "+(compOK ? "OK" : "ERROR"));
-
- final Set<Difference> diffs = delta.getDifferences();
- System.err.println(diffs.size()+" differences!");
- int diffI = 0;
- for(final Iterator<Difference> iter = diffs.iterator(); iter.hasNext(); diffI++) {
- final Difference diff = iter.next();
- System.err.printf("Diff %4d: %-11s in class %s%n", diffI, diff.getClass().getSimpleName(), diff.getClassName());
- }
- Dumper.dump(delta);
-
- Assert.assertTrue("Current version "+curVersion+" is "+compS+" of previous version "+preVersion, compOK);
-
- /***
- //Provide version number for previous and current Jar files.
- final Version previous = Version.parse(...);
- final Version current = Version.parse(...);
-
- //Validates that current version number is valid based on semantic versioning principles.
- final boolean compatible = delta.validate(previous, current);
- */
+ VersionSemanticsUtil.testVersion(diffCriteria, expectedCompatibilityType,
+ previousJar, preVersionNumber,
+ curVersion.getClass(), currentCL, curVersionNumber, excludes);
}
public static void main(String args[]) throws IOException {
String tstname = TestVersionSemantics.class.getName();
org.junit.runner.JUnitCore.main(tstname);
}
-
}