mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
test discovery: update agent with boot classpath fix + add test
This commit is contained in:
Generated
+2
-2
@@ -1,8 +1,8 @@
|
||||
<component name="libraryTable">
|
||||
<library name="intellij-coverage" type="repository">
|
||||
<properties include-transitive-deps="false" maven-id="org.jetbrains.intellij.deps:intellij-coverage:1.0.406" />
|
||||
<properties include-transitive-deps="false" maven-id="org.jetbrains.intellij.deps:intellij-coverage-agent:1.0.410" />
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/intellij/deps/intellij-coverage/1.0.406/intellij-coverage-1.0.406.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/intellij/deps/intellij-coverage-agent/1.0.410/intellij-coverage-agent-1.0.410.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
<component name="libraryTable">
|
||||
<library name="intellij-test-discovery" type="repository">
|
||||
<properties include-transitive-deps="false" maven-id="org.jetbrains.intellij.deps:intellij-test-discovery:1.0.406" />
|
||||
<properties include-transitive-deps="false" maven-id="org.jetbrains.intellij.deps:intellij-test-discovery-agent:1.0.410" />
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/intellij/deps/intellij-test-discovery/1.0.406/intellij-test-discovery-1.0.406.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/intellij/deps/intellij-test-discovery-agent/1.0.410/intellij-test-discovery-agent-1.0.410.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
|
||||
+6
@@ -36,6 +36,7 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
// TODO parametrize by 1) junit version 2) TD protocol
|
||||
// TODO get agent from sources
|
||||
public class TestDiscoveryJUnitIntegrationTest extends JUnitAbstractIntegrationTest {
|
||||
private static final String myJUnitVersion = "4.12";
|
||||
private CompilerTester myCompilerTester;
|
||||
@@ -84,6 +85,11 @@ public class TestDiscoveryJUnitIntegrationTest extends JUnitAbstractIntegrationT
|
||||
assertTestDiscoveryIndex("Person", "getName", t("PersonTest1", "testPersonName"), t("PersonTest2", "testPersonName"));
|
||||
}
|
||||
|
||||
public void testClassLoaderMagic() throws Exception {
|
||||
runTestConfiguration(findClass(myModule, "Test"));
|
||||
assertTestDiscoveryIndex("Magic", "abracadabra", t("Test", "testClassLoaderMagic"));
|
||||
}
|
||||
|
||||
public void _testConstructor() throws Exception {
|
||||
runTestConfiguration(findClass(myModule, "PersonTest"));
|
||||
assertTestDiscoveryIndex("Person", "<init>", t("PersonTest", "testPerson"));
|
||||
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class MyClassLoader extends ClassLoader {
|
||||
|
||||
public MyClassLoader(ClassLoader extClassLoader) {
|
||||
super(extClassLoader);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
doMagic(ClassLoader.getSystemClassLoader().getParent());
|
||||
}
|
||||
|
||||
public static void doMagic(ClassLoader extClassLoader) throws Exception {
|
||||
byte[] bytes = getMagicClassBytes();
|
||||
MyClassLoader classLoader = new MyClassLoader(extClassLoader);
|
||||
classLoader.defineClass("Magic", bytes, 0, bytes.length);
|
||||
Class<?> magic = classLoader.loadClass("Magic");
|
||||
Method abracadabra = magic.getDeclaredMethod("abracadabra");
|
||||
abracadabra.setAccessible(true);
|
||||
abracadabra.invoke(null);
|
||||
}
|
||||
|
||||
private static byte[] getMagicClassBytes() throws IOException {
|
||||
InputStream is = getSystemClassLoader().getResourceAsStream("Magic.class");
|
||||
try {
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
|
||||
int nRead;
|
||||
byte[] data = new byte[16384];
|
||||
|
||||
while ((nRead = is.read(data, 0, data.length)) != -1) {
|
||||
buffer.write(data, 0, nRead);
|
||||
}
|
||||
|
||||
buffer.flush();
|
||||
return buffer.toByteArray();
|
||||
}
|
||||
finally {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Magic {
|
||||
public static void abracadabra() {
|
||||
System.out.println("abracadabra");
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
public class Test {
|
||||
@org.junit.Test
|
||||
public void testClassLoaderMagic() throws Exception {
|
||||
ClassLoader cl = ClassLoader.getSystemClassLoader().getParent();
|
||||
org.junit.Assert.assertTrue(cl.getClass().getName().contains("ExtClassLoader"));
|
||||
org.junit.Assert.assertTrue(Class.forName("com.intellij.rt.coverage.data.TestDiscoveryProjectData").getClassLoader() == null);
|
||||
MyClassLoader.doMagic(cl);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user