mirror of
https://github.com/processing/processing4.git
synced 2026-01-30 20:01:09 +01:00
Moves to Java11 and OpenJDK via AdoptOpenJDK within the processing4 train.
Moves to Java11 and OpenJDK via AdoptOpenJDK within the processing4 train using a squash of sampottinger processing fork's java11 branch. **Primary required changes:** Some changes directly support OpenJFX / OpenJDK 11: - Response to image loading changes caused by [JEP 320](https://openjdk.java.net/jeps/320) - Use of jmodules as necessitated by [JEP 261](https://openjdk.java.net/jeps/261) - Reponse to largely changed file paths caused by [JEP 220](https://openjdk.java.net/jeps/220). - Modifications in build system related to AdoptOpenJDK and Java 11 which have a different naming structure for downloads. - Allowing use of non-Oracle Java within internal Processing checks. **Secondary required changes:** There were some secondary required changes that impacted the usability of Processing after having moved to OpenJFX / OpenJDK 11: - Removal of com.apple.eawt calls related to [JEP 272](http://openjdk.java.net/jeps/272) - Response to HiDPI support on Windows and Linux in [JEP 263](https://openjdk.java.net/jeps/263) - Removal of `java.ext.dirs`. Would be forced by [JEP 220](http://openjdk.java.net/jeps/220). - Due to bugs on Windows, updated the JNA jars. - Changes in downloader build tasks to support AdoptOpenJDK and OpenJFX. - Updated org.eclipse.* / equinox jars. - Some optimization around size of distribution. - Update of AppBundler. - Some changes in formulation of classpath and modifications in PreprocessingService given [JEP 261](https://openjdk.java.net/jeps/261). **Incidental changes:** This was (ahem) a bit of a larger PR with the above modifications. So, I wanted to introduce automated tests when possible and convenient along with a few changes for platform sustainability in order to support development: - Addition of cross-building capability (!) made possible by AdoptOpenJDK. - Addition of mockito for testing. - Upgrade of junit. - Addition of ant-contrib. - Standardized nomenclature around JRE / JDK in `build/build.xml` - Deduplication of code in `jre/build.xml`. - Addition of JavaDoc in a few places. - Some refactoring of PImage / Shape to support increased testing and readability in image manipulation code.
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
Copyright (c) 2019 The Processing Foundation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package processing.mode.java.pdex.util.runtime;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.app.Sketch;
|
||||
import processing.mode.java.JavaMode;
|
||||
import processing.mode.java.pdex.ImportStatement;
|
||||
import processing.mode.java.pdex.PreprocessedSketch;
|
||||
import processing.mode.java.pdex.util.runtime.strategy.RuntimePathFactoryTestUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
public class RuntimePathBuilderTest {
|
||||
|
||||
private RuntimePathBuilder builder;
|
||||
private JavaMode testMode;
|
||||
private List<ImportStatement> testImports;
|
||||
private Sketch testSketch;
|
||||
private PreprocessedSketch.Builder result;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
builder = new RuntimePathBuilder();
|
||||
testMode = RuntimePathFactoryTestUtil.createTestJavaMode();
|
||||
testImports = RuntimePathFactoryTestUtil.createTestImports();
|
||||
testSketch = RuntimePathFactoryTestUtil.createTestSketch();
|
||||
|
||||
result = new PreprocessedSketch.Builder();
|
||||
result.programImports.addAll(testImports);
|
||||
result.sketch = testSketch;
|
||||
|
||||
builder.prepareClassPath(result, testMode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassPathLoader() {
|
||||
assertNotNull(result.classLoader);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassPathObj() {
|
||||
assertNotNull(result.classPath);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSketchClassPathStrategiesJava() {
|
||||
checkPresent(result.classPathArray, "java.base.jmod");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSketchClassPathStrategiesLibrary() {
|
||||
checkPresent(result.classPathArray, "library3");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSketchClassPathStrategiesCore() {
|
||||
checkPresent(result.classPathArray, "library3");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSketchClassPathStrategiesMode() {
|
||||
checkPresent(result.classPathArray, "library6");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSketchClassPathStrategiesCodeFolder() {
|
||||
checkPresent(result.classPathArray, "file1.jar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchClassPathStrategiesCodeJava() {
|
||||
checkPresent(result.searchClassPathArray, "java.base.jmod");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchClassPathStrategiesCodeMode() {
|
||||
checkPresent(result.classPathArray, "library6");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchClassPathStrategiesCodeLibrary() {
|
||||
checkPresent(result.classPathArray, "library3");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchClassPathStrategiesCodeCore() {
|
||||
checkPresent(result.classPathArray, "library1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchClassPathStrategiesCodeCodeFolder() {
|
||||
checkPresent(result.classPathArray, "file3.zip");
|
||||
}
|
||||
|
||||
private void checkPresent(String[] classPathArray, String target) {
|
||||
long count = Arrays.stream(classPathArray)
|
||||
.filter((x) -> x.contains(target))
|
||||
.count();
|
||||
|
||||
assertTrue(count > 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
Copyright (c) 2019 The Processing Foundation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package processing.mode.java.pdex.util.runtime;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
public class RuntimePathUtilTest {
|
||||
|
||||
@Test
|
||||
public void sanitizeClassPath() {
|
||||
StringJoiner testStrJoiner = new StringJoiner(File.pathSeparator);
|
||||
testStrJoiner.add("test1");
|
||||
testStrJoiner.add("");
|
||||
testStrJoiner.add("test2");
|
||||
|
||||
List<String> classPath = RuntimePathUtil.sanitizeClassPath(testStrJoiner.toString());
|
||||
assertEquals(2, classPath.size());
|
||||
assertEquals("test1", classPath.get(0));
|
||||
assertEquals("test2", classPath.get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sanitizeClassPathNoDuplicate() {
|
||||
StringJoiner testStrJoiner = new StringJoiner(File.pathSeparator);
|
||||
testStrJoiner.add("test1");
|
||||
testStrJoiner.add("");
|
||||
testStrJoiner.add("test2");
|
||||
testStrJoiner.add("test2");
|
||||
|
||||
List<String> classPath = RuntimePathUtil.sanitizeClassPath(testStrJoiner.toString());
|
||||
assertEquals(2, classPath.size());
|
||||
assertEquals("test1", classPath.get(0));
|
||||
assertEquals("test2", classPath.get(1));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
Copyright (c) 2019 The Processing Foundation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package processing.mode.java.pdex.util.runtime.strategy;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.app.Sketch;
|
||||
import processing.mode.java.JavaMode;
|
||||
import processing.mode.java.pdex.ImportStatement;
|
||||
import processing.mode.java.pdex.util.runtime.RuntimePathUtilTest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
public class CachedRuntimePathFactoryTest {
|
||||
|
||||
private CachedRuntimePathFactory cachedRuntimePathFactory;
|
||||
private JavaMode testMode;
|
||||
private List<ImportStatement> testImports;
|
||||
private Sketch testSketch;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
cachedRuntimePathFactory = new CachedRuntimePathFactory(new RuntimePathFactoryStrategy() {
|
||||
|
||||
private int calls = 0;
|
||||
|
||||
@Override
|
||||
public List<String> buildClasspath(JavaMode mode, List<ImportStatement> imports,
|
||||
Sketch sketch) {
|
||||
|
||||
String retVal = String.format("Test%d", calls);
|
||||
calls++;
|
||||
|
||||
List<String> retList = new ArrayList<>();
|
||||
retList.add(retVal);
|
||||
return retList;
|
||||
}
|
||||
});
|
||||
|
||||
testMode = RuntimePathFactoryTestUtil.createTestJavaMode();
|
||||
testImports = RuntimePathFactoryTestUtil.createTestImports();
|
||||
testSketch = RuntimePathFactoryTestUtil.createTestSketch();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildClasspath() {
|
||||
List<String> classpath = cachedRuntimePathFactory.buildClasspath(
|
||||
testMode,
|
||||
testImports,
|
||||
testSketch
|
||||
);
|
||||
|
||||
assertEquals(1, classpath.size());
|
||||
assertEquals("Test0", classpath.get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void invalidateCache() {
|
||||
cachedRuntimePathFactory.buildClasspath(
|
||||
testMode,
|
||||
testImports,
|
||||
testSketch
|
||||
);
|
||||
|
||||
cachedRuntimePathFactory.invalidateCache();
|
||||
|
||||
List<String> classpath = cachedRuntimePathFactory.buildClasspath(
|
||||
testMode,
|
||||
testImports,
|
||||
testSketch
|
||||
);
|
||||
|
||||
assertEquals(1, classpath.size());
|
||||
assertEquals("Test1", classpath.get(0));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
Copyright (c) 2019 The Processing Foundation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package processing.mode.java.pdex.util.runtime.strategy;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.app.Sketch;
|
||||
import processing.mode.java.JavaMode;
|
||||
import processing.mode.java.pdex.ImportStatement;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class CodeFolderRuntimePathFactoryTest {
|
||||
|
||||
private CodeFolderRuntimePathFactory factory;
|
||||
private JavaMode testMode;
|
||||
private List<ImportStatement> testImports;
|
||||
private Sketch testSketch;
|
||||
|
||||
private List<String> classpath;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
factory = new CodeFolderRuntimePathFactory();
|
||||
testMode = RuntimePathFactoryTestUtil.createTestJavaMode();
|
||||
testImports = RuntimePathFactoryTestUtil.createTestImports();
|
||||
testSketch = RuntimePathFactoryTestUtil.createTestSketch();
|
||||
|
||||
classpath = factory.buildClasspath(testMode, testImports, testSketch);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildClasspathSize() {
|
||||
assertEquals(2, classpath.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildClasspathValues() {
|
||||
assertEquals("testdir" + File.separator + "file1.jar", classpath.get(0));
|
||||
assertEquals("testdir" + File.separator + "file3.zip", classpath.get(1));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
Copyright (c) 2019 The Processing Foundation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package processing.mode.java.pdex.util.runtime.strategy;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.app.Sketch;
|
||||
import processing.mode.java.JavaMode;
|
||||
import processing.mode.java.pdex.ImportStatement;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class CoreLibraryRuntimePathFactoryTest {
|
||||
|
||||
private CoreLibraryRuntimePathFactory factory;
|
||||
private JavaMode testMode;
|
||||
private List<ImportStatement> testImports;
|
||||
private Sketch testSketch;
|
||||
private List<String> classPath;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
factory = new CoreLibraryRuntimePathFactory();
|
||||
testMode = RuntimePathFactoryTestUtil.createTestJavaMode();
|
||||
testImports = RuntimePathFactoryTestUtil.createTestImports();
|
||||
testSketch = RuntimePathFactoryTestUtil.createTestSketch();
|
||||
|
||||
classPath = factory.buildClasspath(testMode, testImports, testSketch);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildClasspathSize() {
|
||||
assertEquals(2, classPath.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildClasspathValue() {
|
||||
assertEquals("library1", classPath.get(0));
|
||||
assertEquals("library2", classPath.get(1));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
Copyright (c) 2019 The Processing Foundation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package processing.mode.java.pdex.util.runtime.strategy;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.app.Sketch;
|
||||
import processing.mode.java.JavaMode;
|
||||
import processing.mode.java.pdex.ImportStatement;
|
||||
import processing.mode.java.pdex.util.runtime.RuntimeConst;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
public class JavaFxRuntimePathFactoryTest {
|
||||
|
||||
private JavaFxRuntimePathFactory factory;
|
||||
private JavaMode testMode;
|
||||
private List<ImportStatement> testImports;
|
||||
private Sketch testSketch;
|
||||
private List<String> classpath;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
factory = new JavaFxRuntimePathFactory();
|
||||
testMode = RuntimePathFactoryTestUtil.createTestJavaMode();
|
||||
testImports = RuntimePathFactoryTestUtil.createTestImports();
|
||||
testSketch = RuntimePathFactoryTestUtil.createTestSketch();
|
||||
|
||||
classpath = factory.buildClasspath(testMode, testImports, testSketch);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildClasspathSize() {
|
||||
assertEquals(RuntimeConst.JAVA_FX_JARS.length, classpath.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildClasspathValues() {
|
||||
boolean foundTarget = false;
|
||||
for (String entry : classpath) {
|
||||
boolean justFound = entry.contains("javafx.base.jar") && entry.contains("lib");
|
||||
foundTarget = foundTarget || justFound;
|
||||
}
|
||||
|
||||
assertTrue(foundTarget);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
Copyright (c) 2019 The Processing Foundation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package processing.mode.java.pdex.util.runtime.strategy;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.app.Sketch;
|
||||
import processing.mode.java.JavaMode;
|
||||
import processing.mode.java.pdex.ImportStatement;
|
||||
import processing.mode.java.pdex.util.runtime.RuntimeConst;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
public class JavaRuntimePathFactoryTest {
|
||||
|
||||
private JavaRuntimePathFactory factory;
|
||||
private JavaMode testMode;
|
||||
private List<ImportStatement> testImports;
|
||||
private Sketch testSketch;
|
||||
|
||||
private List<String> classpath;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
factory = new JavaRuntimePathFactory();
|
||||
testMode = RuntimePathFactoryTestUtil.createTestJavaMode();
|
||||
testImports = RuntimePathFactoryTestUtil.createTestImports();
|
||||
testSketch = RuntimePathFactoryTestUtil.createTestSketch();
|
||||
|
||||
classpath = factory.buildClasspath(testMode, testImports, testSketch);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildClasspathSize() {
|
||||
assertEquals(RuntimeConst.STANDARD_MODULES.length, classpath.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildClasspathValues() {
|
||||
boolean foundTarget = false;
|
||||
for (String entry : classpath) {
|
||||
boolean justFound = entry.contains("java.base.jmod") && entry.contains("jmods");
|
||||
foundTarget = foundTarget || justFound;
|
||||
}
|
||||
|
||||
assertTrue(foundTarget);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
Copyright (c) 2019 The Processing Foundation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package processing.mode.java.pdex.util.runtime.strategy;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.app.Sketch;
|
||||
import processing.mode.java.JavaMode;
|
||||
import processing.mode.java.pdex.ImportStatement;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class LibrarySearchRuntimePathFactoryTest {
|
||||
|
||||
private LibrarySearchRuntimePathFactory factory;
|
||||
private JavaMode testMode;
|
||||
private List<ImportStatement> testImports;
|
||||
private Sketch testSketch;
|
||||
|
||||
private List<String> classpath;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
factory = new LibrarySearchRuntimePathFactory();
|
||||
testMode = RuntimePathFactoryTestUtil.createTestJavaMode();
|
||||
testImports = RuntimePathFactoryTestUtil.createTestImports();
|
||||
testSketch = RuntimePathFactoryTestUtil.createTestSketch();
|
||||
|
||||
classpath = factory.buildClasspath(testMode, testImports, testSketch);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildClasspathSize() {
|
||||
assertEquals(3, classpath.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildClasspathValues() {
|
||||
assertTrue(classpath.get(0).contains("library3"));
|
||||
assertTrue(classpath.get(1).contains("java.library4"));
|
||||
assertTrue(classpath.get(2).contains("library5"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
Copyright (c) 2019 The Processing Foundation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package processing.mode.java.pdex.util.runtime.strategy;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.app.Sketch;
|
||||
import processing.mode.java.JavaMode;
|
||||
import processing.mode.java.pdex.ImportStatement;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
public class LibrarySketchRuntimePathFactoryTest {
|
||||
|
||||
private LibrarySketchRuntimePathFactory factory;
|
||||
private JavaMode testMode;
|
||||
private List<ImportStatement> testImports;
|
||||
private Sketch testSketch;
|
||||
private List<String> classpathEntries;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
factory = new LibrarySketchRuntimePathFactory();
|
||||
testMode = RuntimePathFactoryTestUtil.createTestJavaMode();
|
||||
testImports = RuntimePathFactoryTestUtil.createTestImports();
|
||||
testSketch = RuntimePathFactoryTestUtil.createTestSketch();
|
||||
|
||||
classpathEntries = factory.buildClasspath(testMode, testImports, testSketch);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildClasspathSize() {
|
||||
assertEquals(2, classpathEntries.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildClasspathValues() {
|
||||
assertTrue(classpathEntries.get(0).contains("library3"));
|
||||
assertTrue(classpathEntries.get(1).contains("library5"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
Copyright (c) 2019 The Processing Foundation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package processing.mode.java.pdex.util.runtime.strategy;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.app.Sketch;
|
||||
import processing.mode.java.JavaMode;
|
||||
import processing.mode.java.pdex.ImportStatement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class ModeSearchRuntimePathFactoryTest {
|
||||
|
||||
private ModeSearchRuntimePathFactory factory;
|
||||
private JavaMode testMode;
|
||||
private List<ImportStatement> testImports;
|
||||
private Sketch testSketch;
|
||||
private List<String> classpath;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
factory = new ModeSearchRuntimePathFactory();
|
||||
testMode = RuntimePathFactoryTestUtil.createTestJavaMode();
|
||||
testImports = RuntimePathFactoryTestUtil.createTestImports();
|
||||
testSketch = RuntimePathFactoryTestUtil.createTestSketch();
|
||||
|
||||
classpath = factory.buildClasspath(testMode, testImports, testSketch);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildClasspathLength() {
|
||||
assertEquals(3, classpath.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildClasspathValues() {
|
||||
assertEquals("library6", classpath.get(0));
|
||||
assertEquals("javax.library7", classpath.get(1));
|
||||
assertEquals("library8", classpath.get(2));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
Copyright (c) 2019 The Processing Foundation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package processing.mode.java.pdex.util.runtime.strategy;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.app.Sketch;
|
||||
import processing.mode.java.JavaMode;
|
||||
import processing.mode.java.pdex.ImportStatement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class ModeSketchRuntimePathFactoryTest {
|
||||
|
||||
private ModeSketchRuntimePathFactory factory;
|
||||
private JavaMode testMode;
|
||||
private List<ImportStatement> testImports;
|
||||
private Sketch testSketch;
|
||||
private List<String> classpath;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
factory = new ModeSketchRuntimePathFactory();
|
||||
testMode = RuntimePathFactoryTestUtil.createTestJavaMode();
|
||||
testImports = RuntimePathFactoryTestUtil.createTestImports();
|
||||
testSketch = RuntimePathFactoryTestUtil.createTestSketch();
|
||||
|
||||
classpath = factory.buildClasspath(testMode, testImports, testSketch);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildClasspathLength() {
|
||||
assertEquals(3, classpath.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildClasspathValues() {
|
||||
assertEquals("library6", classpath.get(0));
|
||||
assertEquals("javax.library7", classpath.get(1));
|
||||
assertEquals("library8", classpath.get(2));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
Copyright (c) 2019 The Processing Foundation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package processing.mode.java.pdex.util.runtime.strategy;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import processing.app.Sketch;
|
||||
import processing.mode.java.JavaMode;
|
||||
import processing.mode.java.pdex.ImportStatement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
|
||||
public class RuntimePathFactoryStrategyCollectionTest {
|
||||
|
||||
private RuntimePathFactoryStrategyCollection factory;
|
||||
private JavaMode testMode;
|
||||
private List<ImportStatement> testImports;
|
||||
private Sketch testSketch;
|
||||
private List<String> classpath;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
List<RuntimePathFactoryStrategy> innerFactories = new ArrayList<>();
|
||||
innerFactories.add(createInnerFactory("test1"));
|
||||
innerFactories.add(createInnerFactory("test2"));
|
||||
factory = new RuntimePathFactoryStrategyCollection(innerFactories);
|
||||
|
||||
testMode = RuntimePathFactoryTestUtil.createTestJavaMode();
|
||||
testImports = RuntimePathFactoryTestUtil.createTestImports();
|
||||
testSketch = RuntimePathFactoryTestUtil.createTestSketch();
|
||||
|
||||
classpath = factory.buildClasspath(testMode, testImports, testSketch);
|
||||
}
|
||||
|
||||
private RuntimePathFactoryStrategy createInnerFactory(String retStr) {
|
||||
return (mode, imports, sketch) -> {
|
||||
List<String> retList = new ArrayList<>();
|
||||
retList.add(retStr);
|
||||
return retList;
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildClasspathLength() {
|
||||
assertEquals(2, classpath.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBuildClasspathContent() {
|
||||
assertEquals("test1", classpath.get(0));
|
||||
assertEquals("test2", classpath.get(1));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
||||
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
Copyright (c) 2019 The Processing Foundation
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License version 2
|
||||
as published by the Free Software Foundation.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package processing.mode.java.pdex.util.runtime.strategy;
|
||||
|
||||
import org.mockito.Mockito;
|
||||
import processing.app.Library;
|
||||
import processing.app.Sketch;
|
||||
import processing.app.SketchException;
|
||||
import processing.mode.java.JavaMode;
|
||||
import processing.mode.java.pdex.ImportStatement;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
|
||||
public class RuntimePathFactoryTestUtil {
|
||||
|
||||
public static JavaMode createTestJavaMode() throws SketchException {
|
||||
JavaMode mode = Mockito.mock(JavaMode.class);
|
||||
|
||||
List<Library> fakeCoreLibraries = new ArrayList<>();
|
||||
Library testLib1 = createTestLibrary("library1");
|
||||
Library testLib2 = createTestLibrary("library2");
|
||||
fakeCoreLibraries.add(testLib1);
|
||||
fakeCoreLibraries.add(testLib2);
|
||||
mode.coreLibraries = fakeCoreLibraries;
|
||||
|
||||
List<Library> fakeContribLibraries = new ArrayList<>();
|
||||
Library testLib3 = createTestLibrary("library3");
|
||||
Library testLib4 = createTestLibrary("java.library4");
|
||||
Library testLib5 = createTestLibrary("library5");
|
||||
fakeContribLibraries.add(testLib3);
|
||||
fakeContribLibraries.add(testLib4);
|
||||
fakeContribLibraries.add(testLib5);
|
||||
mode.contribLibraries = fakeContribLibraries;
|
||||
|
||||
Library testLib6 = createTestLibrary("library6");
|
||||
Library testLib7 = createTestLibrary("javax.library7");
|
||||
Library testLib8 = createTestLibrary("library8");
|
||||
StringJoiner searchPathBuilder = new StringJoiner(File.pathSeparator);
|
||||
searchPathBuilder.add("library6");
|
||||
searchPathBuilder.add("javax.library7");
|
||||
searchPathBuilder.add("library8");
|
||||
Mockito.when(mode.getSearchPath()).thenReturn(searchPathBuilder.toString());
|
||||
|
||||
Mockito.when(mode.getLibrary("library1")).thenReturn(testLib1);
|
||||
Mockito.when(mode.getLibrary("library2")).thenReturn(testLib2);
|
||||
Mockito.when(mode.getLibrary("library3")).thenReturn(testLib3);
|
||||
Mockito.when(mode.getLibrary("java.library4")).thenReturn(testLib4);
|
||||
Mockito.when(mode.getLibrary("library5")).thenReturn(testLib5);
|
||||
Mockito.when(mode.getLibrary("library6")).thenReturn(testLib6);
|
||||
Mockito.when(mode.getLibrary("javax.library7")).thenReturn(testLib7);
|
||||
Mockito.when(mode.getLibrary("library8")).thenReturn(testLib8);
|
||||
|
||||
return mode;
|
||||
}
|
||||
|
||||
public static List<ImportStatement> createTestImports() {
|
||||
List<ImportStatement> importStatements = new ArrayList<>();
|
||||
|
||||
importStatements.add(createTestImportStatement("library3"));
|
||||
importStatements.add(createTestImportStatement("java.library4"));
|
||||
importStatements.add(createTestImportStatement("library5"));
|
||||
|
||||
return importStatements;
|
||||
}
|
||||
|
||||
public static Sketch createTestSketch() throws IOException {
|
||||
Sketch retSketch = Mockito.mock(Sketch.class);
|
||||
|
||||
File fakeCodeFolder = createFakeCodeFolder();
|
||||
|
||||
Mockito.when(retSketch.hasCodeFolder()).thenReturn(true);
|
||||
Mockito.when(retSketch.getCodeFolder()).thenReturn(fakeCodeFolder);
|
||||
|
||||
return retSketch;
|
||||
}
|
||||
|
||||
private static File createFakeCodeFolder() throws IOException {
|
||||
File fakeCodeFolder = Mockito.mock(File.class);
|
||||
|
||||
Mockito.when(fakeCodeFolder.getCanonicalPath()).thenReturn("testdir");
|
||||
Mockito.when(fakeCodeFolder.list()).thenReturn(
|
||||
new String[]{"file1.jar", "file2.txt", "file3.zip"}
|
||||
);
|
||||
|
||||
return fakeCodeFolder;
|
||||
}
|
||||
|
||||
private static Library createTestLibrary(String libraryClassPath) {
|
||||
Library fakeLibrary = Mockito.mock(Library.class);
|
||||
Mockito.when(fakeLibrary.getClassPath()).thenReturn(libraryClassPath);
|
||||
return fakeLibrary;
|
||||
}
|
||||
|
||||
private static ImportStatement createTestImportStatement(String packageName) {
|
||||
ImportStatement retStatement = Mockito.mock(ImportStatement.class);
|
||||
Mockito.when(retStatement.getPackageName()).thenReturn(packageName);
|
||||
return retStatement;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user