GlueGen v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java™ (public API).
TestVersionSemantics.java
Go to the documentation of this file.
1/**
2 * Copyright 2014 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28package com.jogamp.common.util;
29
30import java.io.File;
31import java.io.IOException;
32import java.net.URISyntaxException;
33import java.util.HashSet;
34import java.util.Set;
35
36import org.junit.FixMethodOrder;
37import org.junit.Test;
38import org.junit.runners.MethodSorters;
39
40import com.jogamp.common.GlueGenVersion;
41import com.jogamp.junit.util.SingletonJunitCase;
42import com.jogamp.junit.util.VersionSemanticsUtil;
43import com.jogamp.junit.util.VersionSemanticsUtil.CompatibilityType;
44
45/**
46 * Compares a defined previous version with the current version.
47 * <p>
48 * {@link SimpleDiffCriteria} is chosen as it's {@link DiffCriteria},
49 * i.e. considering:
50 * <ul>
51 * <li>not synthetic classes, methods and fields which are either
52 * <ul>
53 * <li>public</li>
54 * <li>protected</li>
55 * </ul></li>
56 * </ul>
57 * </p>
58 *
59 * @throws IllegalArgumentException
60 * @throws IOException
61 * @throws URISyntaxException
62 */
63@FixMethodOrder(MethodSorters.NAME_ASCENDING)
65 static final String jarFile = "gluegen-rt.jar";
66
67 static final JogampVersion curVersion = GlueGenVersion.getInstance();
68 static final VersionNumberString curVersionNumber = new VersionNumberString(curVersion.getImplementationVersion());
69
70 static final String excludesDefault;
71 static {
72 excludesDefault = "jogamp";
73 }
74
75 @Test
76 public void testVersionV220V221() throws IllegalArgumentException, IOException, URISyntaxException {
77 testVersions(CompatibilityType.BACKWARD_COMPATIBLE_SOURCE, "2.2.0", "2.2.1", excludesDefault);
78 }
79
80 @Test
81 public void testVersionV221V230() throws IllegalArgumentException, IOException, URISyntaxException {
82 testVersions(CompatibilityType.NON_BACKWARD_COMPATIBLE, "2.2.1", "2.3.0", excludesDefault);
83 }
84
85 @Test
86 public void testVersionV230V232() throws IllegalArgumentException, IOException, URISyntaxException {
87 testVersions(CompatibilityType.BACKWARD_COMPATIBLE_BINARY, "2.3.0", "2.3.2", excludesDefault);
88 }
89
90 void testVersions(final CompatibilityType expectedCompatibilityType,
91 final String v1, final String v2, final String excludes)
92 throws IllegalArgumentException, IOException, URISyntaxException {
93 final VersionNumberString preVersionNumber = new VersionNumberString(v1);
94 final File previousJar = new File("lib/v"+v1+"/"+jarFile);
95
96 final VersionNumberString curVersionNumber = new VersionNumberString(v2);
97 final File currentJar = new File("lib/v"+v2+"/"+jarFile);
98
99 VersionSemanticsUtil.testVersion2(expectedCompatibilityType,
100 previousJar, preVersionNumber,
101 currentJar, curVersionNumber, excludes, true);
102 }
103
104 @Test
105 public void testVersionV232V24x() throws IllegalArgumentException, IOException, URISyntaxException {
106 final CompatibilityType expectedCompatibilityType = CompatibilityType.NON_BACKWARD_COMPATIBLE;
107 // final CompatibilityType expectedCompatibilityType = CompatibilityType.BACKWARD_COMPATIBLE_SOURCE;
108 // final CompatibilityType expectedCompatibilityType = CompatibilityType.BACKWARD_COMPATIBLE_BINARY;
109
110 final VersionNumberString preVersionNumber = new VersionNumberString("2.3.2");
111 final File previousJar = new File("lib/v"+preVersionNumber.getVersionString()+"/"+jarFile);
112
113 final ClassLoader currentCL = TestVersionSemantics.class.getClassLoader();
114
115 VersionSemanticsUtil.testVersion2(expectedCompatibilityType,
116 previousJar, preVersionNumber,
117 curVersion.getClass(), currentCL, curVersionNumber, excludesDefault, true);
118 }
119
120 public static void main(final String args[]) throws IOException {
121 final String tstname = TestVersionSemantics.class.getName();
122 org.junit.runner.JUnitCore.main(tstname);
123 }
124}
static GlueGenVersion getInstance()
final String getImplementationVersion()
Returns the IMPLEMENTATION_VERSION.
Compares a defined previous version with the current version.
VersionNumber specialization, holding the versionString this instance is derived from.
final String getVersionString()
Returns the version string this version number is derived from.
static void testVersion2(final CompatibilityType expectedCompatibilityType, final File previousJar, final VersionNumberString preVersionNumber, final Class<?> currentJarClazz, final ClassLoader currentJarCL, final VersionNumberString curVersionNumber, final String excludesArgOption, final boolean summaryOnly)
BACKWARD_COMPATIBLE_SOURCE
Only added and deprecated changes, i.e.
BACKWARD_COMPATIBLE_BINARY
Contains binary compatible changes, but may not be fully source compatible and may contain changed va...