Skip to content

Commit eeebda6

Browse files
committed
Finished refactor to runtime resolution strategies.
Finished pdex.util.runtime.* for processing#5753 / processing#5750 which adds support for restructured modules (Jigsaw) and OpenJFX.
1 parent 0bbf9f0 commit eeebda6

16 files changed

+472
-2
lines changed

java/src/processing/mode/java/pdex/util/runtime/strategy/CachedRuntimePathFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/*
44
Part of the Processing project - http://processing.org
5-
Copyright (c) 2012-19 The Processing Foundation
5+
Copyright (c) 2019 The Processing Foundation
66
77
This program is free software; you can redistribute it and/or modify
88
it under the terms of the GNU General Public License version 2

java/src/processing/mode/java/pdex/util/runtime/strategy/RuntimePathFactoryStrategy.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2+
3+
/*
4+
Part of the Processing project - http://processing.org
5+
Copyright (c) 2019 The Processing Foundation
6+
7+
This program is free software; you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License version 2
9+
as published by the Free Software Foundation.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program; if not, write to the Free Software Foundation, Inc.
18+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*/
20+
121
package processing.mode.java.pdex.util.runtime.strategy;
222

323
import processing.app.Sketch;

java/src/processing/mode/java/pdex/util/runtime/strategy/RuntimePathFactoryStrategyCollection.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2+
3+
/*
4+
Part of the Processing project - http://processing.org
5+
Copyright (c) 20119 The Processing Foundation
6+
7+
This program is free software; you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License version 2
9+
as published by the Free Software Foundation.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program; if not, write to the Free Software Foundation, Inc.
18+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*/
20+
121
package processing.mode.java.pdex.util.runtime.strategy;
222

323
import processing.app.Sketch;
@@ -8,10 +28,18 @@
828
import java.util.stream.Collectors;
929

1030

31+
/**
32+
* Strategy which concatenates paths generated from a collection of RuntimePathFactoryStrategies.
33+
*/
1134
public class RuntimePathFactoryStrategyCollection implements RuntimePathFactoryStrategy {
1235

1336
private final List<RuntimePathFactoryStrategy> strategies;
1437

38+
/**
39+
* Create a new path concatenation operation.
40+
*
41+
* @param newStrategies
42+
*/
1543
public RuntimePathFactoryStrategyCollection(List<RuntimePathFactoryStrategy> newStrategies) {
1644
strategies = newStrategies;
1745
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2+
3+
/*
4+
Part of the Processing project - http://processing.org
5+
Copyright (c) 2019 The Processing Foundation
6+
7+
This program is free software; you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License version 2
9+
as published by the Free Software Foundation.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program; if not, write to the Free Software Foundation, Inc.
18+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*/
20+
21+
package processing.mode.java.pdex.util.runtime;
22+
23+
import org.junit.Before;
24+
import org.junit.Test;
25+
import processing.app.Sketch;
26+
import processing.mode.java.JavaMode;
27+
import processing.mode.java.pdex.ImportStatement;
28+
import processing.mode.java.pdex.PreprocessedSketch;
29+
import processing.mode.java.pdex.util.runtime.strategy.RuntimePathFactoryTestUtil;
30+
31+
import java.util.Arrays;
32+
import java.util.List;
33+
34+
import static org.junit.Assert.*;
35+
36+
37+
public class RuntimePathBuilderTest {
38+
39+
private RuntimePathBuilder builder;
40+
private JavaMode testMode;
41+
private List<ImportStatement> testImports;
42+
private Sketch testSketch;
43+
private PreprocessedSketch.Builder result;
44+
45+
@Before
46+
public void setUp() throws Exception {
47+
builder = new RuntimePathBuilder();
48+
testMode = RuntimePathFactoryTestUtil.createTestJavaMode();
49+
testImports = RuntimePathFactoryTestUtil.createTestImports();
50+
testSketch = RuntimePathFactoryTestUtil.createTestSketch();
51+
52+
result = new PreprocessedSketch.Builder();
53+
result.programImports.addAll(testImports);
54+
result.sketch = testSketch;
55+
56+
builder.prepareClassPath(result, testMode);
57+
}
58+
59+
@Test
60+
public void testClassPathLoader() {
61+
assertNotNull(result.classLoader);
62+
}
63+
64+
@Test
65+
public void testClassPathObj() {
66+
assertNotNull(result.classPath);
67+
}
68+
69+
@Test
70+
public void testSketchClassPathStrategiesJava() {
71+
checkPresent(result.classPathArray, "java.base.jmod");
72+
}
73+
74+
@Test
75+
public void testSketchClassPathStrategiesLibrary() {
76+
checkPresent(result.classPathArray, "library3");
77+
}
78+
79+
@Test
80+
public void testSketchClassPathStrategiesCore() {
81+
checkPresent(result.classPathArray, "library3");
82+
}
83+
84+
@Test
85+
public void testSketchClassPathStrategiesMode() {
86+
checkPresent(result.classPathArray, "library6");
87+
}
88+
89+
@Test
90+
public void testSketchClassPathStrategiesCodeFolder() {
91+
checkPresent(result.classPathArray, "file1.jar");
92+
}
93+
94+
@Test
95+
public void testSearchClassPathStrategiesCodeJava() {
96+
checkPresent(result.searchClassPathArray, "java.base.jmod");
97+
}
98+
99+
@Test
100+
public void testSearchClassPathStrategiesCodeMode() {
101+
checkPresent(result.classPathArray, "library6");
102+
}
103+
104+
@Test
105+
public void testSearchClassPathStrategiesCodeLibrary() {
106+
checkPresent(result.classPathArray, "library3");
107+
}
108+
109+
@Test
110+
public void testSearchClassPathStrategiesCodeCore() {
111+
checkPresent(result.classPathArray, "library1");
112+
}
113+
114+
@Test
115+
public void testSearchClassPathStrategiesCodeCodeFolder() {
116+
checkPresent(result.classPathArray, "file3.zip");
117+
}
118+
119+
private void checkPresent(String[] classPathArray, String target) {
120+
long count = Arrays.stream(classPathArray)
121+
.filter((x) -> x.contains(target))
122+
.count();
123+
124+
assertTrue(count > 0);
125+
}
126+
127+
}

java/test/processing/mode/java/pdex/util/runtime/RuntimePathUtilTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2+
3+
/*
4+
Part of the Processing project - http://processing.org
5+
Copyright (c) 2019 The Processing Foundation
6+
7+
This program is free software; you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License version 2
9+
as published by the Free Software Foundation.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program; if not, write to the Free Software Foundation, Inc.
18+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*/
20+
121
package processing.mode.java.pdex.util.runtime;
222

323
import org.junit.Test;

java/test/processing/mode/java/pdex/util/runtime/strategy/CachedRuntimePathFactoryTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2+
3+
/*
4+
Part of the Processing project - http://processing.org
5+
Copyright (c) 2019 The Processing Foundation
6+
7+
This program is free software; you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License version 2
9+
as published by the Free Software Foundation.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program; if not, write to the Free Software Foundation, Inc.
18+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*/
20+
121
package processing.mode.java.pdex.util.runtime.strategy;
222

323
import org.junit.Before;

java/test/processing/mode/java/pdex/util/runtime/strategy/CodeFolderRuntimePathFactoryTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2+
3+
/*
4+
Part of the Processing project - http://processing.org
5+
Copyright (c) 2019 The Processing Foundation
6+
7+
This program is free software; you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License version 2
9+
as published by the Free Software Foundation.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program; if not, write to the Free Software Foundation, Inc.
18+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*/
20+
121
package processing.mode.java.pdex.util.runtime.strategy;
222

323
import org.junit.Before;

java/test/processing/mode/java/pdex/util/runtime/strategy/CoreLibraryRuntimePathFactoryTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2+
3+
/*
4+
Part of the Processing project - http://processing.org
5+
Copyright (c) 2019 The Processing Foundation
6+
7+
This program is free software; you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License version 2
9+
as published by the Free Software Foundation.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program; if not, write to the Free Software Foundation, Inc.
18+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*/
20+
121
package processing.mode.java.pdex.util.runtime.strategy;
222

323
import org.junit.Before;

java/test/processing/mode/java/pdex/util/runtime/strategy/JavaFxRuntimePathFactoryTest.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2+
3+
/*
4+
Part of the Processing project - http://processing.org
5+
Copyright (c) 2019 The Processing Foundation
6+
7+
This program is free software; you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License version 2
9+
as published by the Free Software Foundation.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program; if not, write to the Free Software Foundation, Inc.
18+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*/
20+
121
package processing.mode.java.pdex.util.runtime.strategy;
222

323
import org.junit.Before;
@@ -7,7 +27,6 @@
727
import processing.mode.java.pdex.ImportStatement;
828
import processing.mode.java.pdex.util.runtime.RuntimeConst;
929

10-
import java.io.IOException;
1130
import java.util.List;
1231

1332
import static org.junit.Assert.*;

java/test/processing/mode/java/pdex/util/runtime/strategy/JavaRuntimePathFactoryTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2+
3+
/*
4+
Part of the Processing project - http://processing.org
5+
Copyright (c) 2019 The Processing Foundation
6+
7+
This program is free software; you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License version 2
9+
as published by the Free Software Foundation.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program; if not, write to the Free Software Foundation, Inc.
18+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*/
20+
121
package processing.mode.java.pdex.util.runtime.strategy;
222

323
import org.junit.Before;

java/test/processing/mode/java/pdex/util/runtime/strategy/LibrarySearchRuntimePathFactoryTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2+
3+
/*
4+
Part of the Processing project - http://processing.org
5+
Copyright (c) 2019 The Processing Foundation
6+
7+
This program is free software; you can redistribute it and/or modify
8+
it under the terms of the GNU General Public License version 2
9+
as published by the Free Software Foundation.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program; if not, write to the Free Software Foundation, Inc.
18+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*/
20+
121
package processing.mode.java.pdex.util.runtime.strategy;
222

323
import org.junit.Before;

0 commit comments

Comments
 (0)