Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Arthanareeswaran2018-03-28 16:26:59 +0000
committerJay Arthanareeswaran2018-03-29 11:42:47 +0000
commit9b1349b24227ae82944926b1116c312d435e83ee (patch)
tree5c779bce8b47fd7dc3a20fcd9e84fadb9f7cc08f /org.eclipse.jdt.compiler.tool.tests
parentfd87f2811a7b8387374eea8050e0106e6019b835 (diff)
downloadeclipse.jdt.core-9b1349b24227ae82944926b1116c312d435e83ee.tar.gz
eclipse.jdt.core-9b1349b24227ae82944926b1116c312d435e83ee.tar.xz
eclipse.jdt.core-9b1349b24227ae82944926b1116c312d435e83ee.zip
Bug 533043 : [9] CLASS_OUTPUT is not set properly when
MODULE_SOURCE_PATH set for individual modules Change-Id: Ida01c29a695306b363a83023131c648137f2b5d3 Signed-off-by: Jay Arthanareeswaran <jarthana@in.ibm.com>
Diffstat (limited to 'org.eclipse.jdt.compiler.tool.tests')
-rw-r--r--org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolJava9Tests.java80
1 files changed, 74 insertions, 6 deletions
diff --git a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolJava9Tests.java b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolJava9Tests.java
index 0fadc35aff..9eb7775919 100644
--- a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolJava9Tests.java
+++ b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolJava9Tests.java
@@ -161,7 +161,7 @@ public class CompilerToolJava9Tests extends TestCase {
}
}
// Incomplete tests - fails both with Javac and ECJ
- public void _testGetLocationForModule2() throws IOException {
+ public void testGetLocationForModule2() throws IOException {
if (this.isJREBelow9) return;
for(int i = 0; i < 2; i++) {
String cName = this.compilerNames[i];
@@ -170,9 +170,9 @@ public class CompilerToolJava9Tests extends TestCase {
continue;
StandardJavaFileManager manager = compiler.getStandardFileManager(null, Locale.getDefault(), Charset.defaultCharset());
Path path = Paths.get(modules_directory + File.separator + "source" + File.separator + "SimpleModules");
- manager.setLocationFromPaths(StandardLocation.MODULE_PATH, Arrays.asList(path));
+ manager.setLocationFromPaths(StandardLocation.MODULE_SOURCE_PATH, Arrays.asList(path));
try {
- JavaFileManager.Location location = manager.getLocationForModule(StandardLocation.MODULE_PATH, "module.two");
+ JavaFileManager.Location location = manager.getLocationForModule(StandardLocation.MODULE_SOURCE_PATH, "module.two");
assertNotNull(cName + ":module path location should not be null", location);
} catch (UnsupportedOperationException ex) {
fail(cName + ":Should support getLocationForModule()");
@@ -180,7 +180,7 @@ public class CompilerToolJava9Tests extends TestCase {
}
}
// Incomplete tests - fails both with Javac and ECJ
- public void _testGetLocationForModule3() throws IOException {
+ public void testGetLocationForModule3() throws IOException {
if (this.isJREBelow9) return;
for(int i = 0; i < 2; i++) {
String cName = this.compilerNames[i];
@@ -189,9 +189,9 @@ public class CompilerToolJava9Tests extends TestCase {
continue;
StandardJavaFileManager manager = compiler.getStandardFileManager(null, Locale.getDefault(), Charset.defaultCharset());
Path path = Paths.get(modules_directory + File.separator + "source" + File.separator + "SimpleModules");
- manager.setLocationFromPaths(StandardLocation.MODULE_PATH, Arrays.asList(path));
+ manager.setLocationFromPaths(StandardLocation.MODULE_SOURCE_PATH, Arrays.asList(path));
try {
- JavaFileManager.Location location = manager.getLocationForModule(StandardLocation.MODULE_PATH, "module.one");
+ JavaFileManager.Location location = manager.getLocationForModule(StandardLocation.MODULE_SOURCE_PATH, "module.one");
assertNotNull(cName + ":module path location should not be null", location);
} catch (UnsupportedOperationException ex) {
fail(cName + ":Should support getLocationForModule()");
@@ -498,6 +498,74 @@ public class CompilerToolJava9Tests extends TestCase {
assertEquals("option -source is not supported when --release is used", iae.getMessage());
}
}
+ public void testClassOutputLocationForModule_1() throws IOException {
+ if (this.isJREBelow9) return;
+ for(int i = 0; i < 2; i++) {
+ String cName = this.compilerNames[i];
+ JavaCompiler compiler = this.compilers[i];
+ if (!(compiler instanceof EclipseCompiler))
+ continue;
+ StandardJavaFileManager manager = compiler.getStandardFileManager(null, Locale.getDefault(), Charset.defaultCharset());
+ Path path = Paths.get(modules_directory + File.separator + "source" + File.separator + "SimpleModules");
+ manager.setLocationFromPaths(StandardLocation.MODULE_SOURCE_PATH, Arrays.asList(path));
+ manager.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(_tmpBinDir));
+ try {
+ JavaFileManager.Location location = manager.getLocationForModule(StandardLocation.CLASS_OUTPUT, "module.two");
+ assertNotNull(cName + ":module path location should not be null", location);
+ assertTrue("should be output location", location.isOutputLocation());
+ } catch (UnsupportedOperationException ex) {
+ fail(cName + ":Should support getLocationForModule()");
+ }
+ }
+ }
+ public void testClassOutputLocationForModule_2() throws IOException {
+ if (this.isJREBelow9) return;
+ for(int i = 0; i < 2; i++) {
+ String cName = this.compilerNames[i];
+ JavaCompiler compiler = this.compilers[i];
+ if (!(compiler instanceof EclipseCompiler))
+ continue;
+ StandardJavaFileManager manager = compiler.getStandardFileManager(null, Locale.getDefault(), Charset.defaultCharset());
+ Path path = Paths.get(modules_directory + File.separator + "source" + File.separator + "SimpleModules" + File.separator + "module.one");
+ manager.setLocationForModule(StandardLocation.MODULE_SOURCE_PATH, "module.one", Arrays.asList(path));
+ path = Paths.get(modules_directory + File.separator + "source" + File.separator + "SimpleModules" + File.separator + "module.two");
+ manager.setLocationForModule(StandardLocation.MODULE_SOURCE_PATH, "module.two", Arrays.asList(path));
+ manager.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(_tmpBinDir));
+ try {
+ JavaFileManager.Location location = manager.getLocationForModule(StandardLocation.CLASS_OUTPUT, "module.one");
+ assertTrue("should be output location", location.isOutputLocation());
+ assertNotNull(cName + ":module path location should not be null", location);
+ Iterable<? extends Path> locationAsPaths = manager.getLocationAsPaths(location);
+ int count = 0;
+ boolean found = false;
+ for (Path path2 : locationAsPaths) {
+ if (path2.endsWith("module.one")) {
+ found = true;
+ }
+ count++;
+ }
+ assertEquals("incorrect no of output locations", 1, count);
+ assertTrue("output location for module.two not found", found);
+ location = manager.getLocationForModule(StandardLocation.CLASS_OUTPUT, "module.two");
+ assertTrue("should be output location", location.isOutputLocation());
+ assertNotNull(cName + ":module path location should not be null", location);
+ locationAsPaths = manager.getLocationAsPaths(location);
+ count = 0;
+ found = false;
+ for (Path path2 : locationAsPaths) {
+ if (path2.endsWith("module.two")) {
+ found = true;
+ }
+ count++;
+ }
+ assertEquals("incorrect no of output locations", 1, count);
+ assertTrue("output location for module.two not found", found);
+
+ } catch (UnsupportedOperationException ex) {
+ fail(cName + ":Should support getLocationForModule()");
+ }
+ }
+ }
public void testGetJavaFileObjects() {
if (this.isJREBelow9) return;
}

Back to the top