mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[tests] adds Groovy cases to not-null instrumenter test
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
import org.jetbrains.annotations.NotNull
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
enum GroovyEnum {
|
||||
Value(null, "1");
|
||||
|
||||
GroovyEnum(String s1, @NotNull String s2) { }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import org.jetbrains.annotations.NotNull
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
class GroovyInnerClass {
|
||||
GroovyInnerClass() {
|
||||
new Inner(null, "")
|
||||
}
|
||||
|
||||
private class Inner {
|
||||
Inner(String s1, @NotNull String s2) { }
|
||||
}
|
||||
}
|
||||
+30
-3
@@ -19,6 +19,7 @@ import org.junit.Test;
|
||||
import org.junit.rules.TestName;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@@ -144,6 +145,12 @@ public class NotNullVerifyingInstrumenterTest {
|
||||
assertNotNull(testClass.getField("Value").get(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGroovyEnum() throws Exception {
|
||||
Class testClass = prepareTest();
|
||||
assertNotNull(testClass.getField("Value").get(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStaticInnerClass() throws Exception {
|
||||
Class aClass = prepareTest();
|
||||
@@ -156,6 +163,12 @@ public class NotNullVerifyingInstrumenterTest {
|
||||
assertNotNull(aClass.newInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGroovyInnerClass() throws Exception {
|
||||
Class aClass = prepareTest();
|
||||
assertNotNull(aClass.newInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSkipBridgeMethods() throws Exception {
|
||||
Class<?> testClass = prepareTest();
|
||||
@@ -277,15 +290,29 @@ public class NotNullVerifyingInstrumenterTest {
|
||||
|
||||
List<String> cmdLine = ContainerUtil.newArrayList("-d", classesDir.getAbsolutePath(), "-classpath", testDir + "/annotations.jar");
|
||||
if (withDebugInfo) cmdLine.add("-g");
|
||||
cmdLine.add(testDir + '/' + testName + ".java");
|
||||
com.sun.tools.javac.Main.compile(ArrayUtil.toStringArray(cmdLine));
|
||||
|
||||
Class mainClass = null;
|
||||
File testFile = new File(testDir, testName + ".java");
|
||||
if (testFile.exists()) {
|
||||
cmdLine.add(testFile.getPath());
|
||||
com.sun.tools.javac.Main.compile(ArrayUtil.toStringArray(cmdLine));
|
||||
}
|
||||
else {
|
||||
testFile = new File(testDir, testName + ".groovy");
|
||||
if (testFile.exists()) {
|
||||
cmdLine.add(testFile.getPath());
|
||||
org.codehaus.groovy.tools.FileSystemCompiler.main(ArrayUtil.toStringArray(cmdLine));
|
||||
}
|
||||
else {
|
||||
throw new FileNotFoundException("No test source for " + testName);
|
||||
}
|
||||
}
|
||||
|
||||
File[] files = classesDir.listFiles();
|
||||
assertNotNull(files);
|
||||
Arrays.sort(files, (o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName()));
|
||||
boolean modified = false;
|
||||
MyClassLoader classLoader = new MyClassLoader(getClass().getClassLoader());
|
||||
Class mainClass = null;
|
||||
for (File file: files) {
|
||||
FailSafeClassReader reader = new FailSafeClassReader(FileUtil.loadFileBytes(file));
|
||||
ClassWriter writer = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES);
|
||||
|
||||
Reference in New Issue
Block a user