Switch class loading logic in blackBoxWithJava tests

BoxWithJava tests now by default are loaded with the classloader which has
test's classpath in itself, as in the former ClassPathInTheSameClassLoaderTest
This commit is contained in:
Alexander Udalov
2013-02-08 17:51:29 +04:00
committed by Alexander Udalov
parent 22bf8b25b8
commit b485c7ae26
49 changed files with 203 additions and 238 deletions
@@ -0,0 +1,9 @@
import java.lang.String;
class J {
String value;
J(String value) {
this.value = value;
}
}
@@ -0,0 +1 @@
fun doTest() = J("OK").value
@@ -1,28 +0,0 @@
/*
* Copyright 2010-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.codegen;
import org.jetbrains.annotations.NotNull;
public abstract class AbstractJavaVisibilityTest extends CodegenTestCase {
@NotNull
@Override
protected GeneratedClassLoader createClassLoader(@NotNull ClassFileFactory factory) {
initializedClassLoader = new GeneratedClassLoader(factory, CodegenTestCase.class.getClassLoader(), getClassPathURLs());
return initializedClassLoader;
}
}
@@ -0,0 +1,49 @@
/*
* Copyright 2010-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.codegen;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.ConfigurationKind;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.TestJdkKind;
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
import java.io.File;
import java.net.URLClassLoader;
import static org.jetbrains.jet.codegen.CodegenTestUtil.assertThrows;
import static org.jetbrains.jet.codegen.CodegenTestUtil.compileJava;
public class ClassPathInParentClassLoaderTest extends CodegenTestCase {
@NotNull
@Override
protected GeneratedClassLoader createClassLoader(@NotNull ClassFileFactory factory) {
ClassLoader parentClassLoader = new URLClassLoader(getClassPathURLs(), CodegenTestCase.class.getClassLoader());
initializedClassLoader = new GeneratedClassLoader(factory, parentClassLoader);
return initializedClassLoader;
}
public void testKt2781() throws Exception {
File javaClassesTempDirectory = compileJava("classPathInParentClassLoader/kt2781.java");
myEnvironment = new JetCoreEnvironment(getTestRootDisposable(), JetTestUtils.compilerConfigurationForTests(
ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, JetTestUtils.getAnnotationsJar(), javaClassesTempDirectory));
loadFile("classPathInParentClassLoader/kt2781.kt");
assertThrows(generateFunction(), IllegalAccessError.class, null);
}
}
@@ -1,32 +0,0 @@
/*
* Copyright 2010-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.codegen;
import org.jetbrains.annotations.NotNull;
public class ClassPathInTheSameClassLoaderTest extends CodegenTestCase {
@NotNull
@Override
protected GeneratedClassLoader createClassLoader(@NotNull ClassFileFactory factory) {
initializedClassLoader = new GeneratedClassLoader(factory, CodegenTestCase.class.getClassLoader(), getClassPathURLs());
return initializedClassLoader;
}
public void testKt2781() {
blackBoxFileWithJava("regressions/kt2781.kt");
}
}
@@ -166,8 +166,7 @@ public abstract class CodegenTestCase extends UsefulTestCase {
fail("Double initialization of class loader in same test");
}
ClassLoader parentClassLoader = new URLClassLoader(getClassPathURLs(), CodegenTestCase.class.getClassLoader());
initializedClassLoader = new GeneratedClassLoader(factory, parentClassLoader);
initializedClassLoader = new GeneratedClassLoader(factory, CodegenTestCase.class.getClassLoader(), getClassPathURLs());
return initializedClassLoader;
}
@@ -1,98 +0,0 @@
/*
* Copyright 2010-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.codegen;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;
import java.io.File;
import java.util.regex.Pattern;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.test.InnerTestClasses;
import org.jetbrains.jet.test.TestMetadata;
import org.jetbrains.jet.codegen.AbstractJavaVisibilityTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/codegen/visibility")
@InnerTestClasses({JavaVisibilityTestGenerated.Package.class, JavaVisibilityTestGenerated.Protected_and_package.class})
public class JavaVisibilityTestGenerated extends AbstractJavaVisibilityTest {
public void testAllFilesPresentInVisibility() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/codegen/visibility"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/testData/codegen/visibility/package")
public static class Package extends AbstractJavaVisibilityTest {
public void testAllFilesPresentInPackage() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/codegen/visibility/package"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("packageClass.kt")
public void testPackageClass() throws Exception {
blackBoxFileWithJavaByFullPath("compiler/testData/codegen/visibility/package/packageClass.kt");
}
@TestMetadata("packageFun.kt")
public void testPackageFun() throws Exception {
blackBoxFileWithJavaByFullPath("compiler/testData/codegen/visibility/package/packageFun.kt");
}
@TestMetadata("packageProperty.kt")
public void testPackageProperty() throws Exception {
blackBoxFileWithJavaByFullPath("compiler/testData/codegen/visibility/package/packageProperty.kt");
}
}
@TestMetadata("compiler/testData/codegen/visibility/protected_and_package")
public static class Protected_and_package extends AbstractJavaVisibilityTest {
public void testAllFilesPresentInProtected_and_package() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/codegen/visibility/protected_and_package"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("overrideProtectedFunInPackage.kt")
public void testOverrideProtectedFunInPackage() throws Exception {
blackBoxFileWithJavaByFullPath("compiler/testData/codegen/visibility/protected_and_package/overrideProtectedFunInPackage.kt");
}
@TestMetadata("protectedFunInPackage.kt")
public void testProtectedFunInPackage() throws Exception {
blackBoxFileWithJavaByFullPath("compiler/testData/codegen/visibility/protected_and_package/protectedFunInPackage.kt");
}
@TestMetadata("protectedPropertyInPackage.kt")
public void testProtectedPropertyInPackage() throws Exception {
blackBoxFileWithJavaByFullPath("compiler/testData/codegen/visibility/protected_and_package/protectedPropertyInPackage.kt");
}
@TestMetadata("protectedStaticClass.kt")
public void testProtectedStaticClass() throws Exception {
blackBoxFileWithJavaByFullPath("compiler/testData/codegen/visibility/protected_and_package/protectedStaticClass.kt");
}
}
public static Test suite() {
TestSuite suite = new TestSuite("JavaVisibilityTestGenerated");
suite.addTestSuite(JavaVisibilityTestGenerated.class);
suite.addTestSuite(Package.class);
suite.addTestSuite(Protected_and_package.class);
return suite;
}
}
@@ -31,7 +31,7 @@ import org.jetbrains.jet.codegen.generated.AbstractBlackBoxCodegenTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("compiler/testData/codegen/boxWithJava")
@InnerTestClasses({BlackBoxWithJavaCodegenTestGenerated.Enum.class, BlackBoxWithJavaCodegenTestGenerated.Functions.class, BlackBoxWithJavaCodegenTestGenerated.ProtectedStatic.class, BlackBoxWithJavaCodegenTestGenerated.StaticFun.class})
@InnerTestClasses({BlackBoxWithJavaCodegenTestGenerated.Enum.class, BlackBoxWithJavaCodegenTestGenerated.Functions.class, BlackBoxWithJavaCodegenTestGenerated.StaticFun.class, BlackBoxWithJavaCodegenTestGenerated.Visibility.class})
public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInBoxWithJava() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/codegen/boxWithJava"), Pattern.compile("^(.+)\\.kt$"), true);
@@ -88,74 +88,6 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege
}
@TestMetadata("compiler/testData/codegen/boxWithJava/protectedStatic")
public static class ProtectedStatic extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInProtectedStatic() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/codegen/boxWithJava/protectedStatic"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("funCallInConstructor.kt")
public void testFunCallInConstructor() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/protectedStatic/funCallInConstructor.kt");
}
@TestMetadata("funClassObject.kt")
public void testFunClassObject() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/protectedStatic/funClassObject.kt");
}
@TestMetadata("funGenericClass.kt")
public void testFunGenericClass() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/protectedStatic/funGenericClass.kt");
}
@TestMetadata("funNestedStaticClass.kt")
public void testFunNestedStaticClass() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/protectedStatic/funNestedStaticClass.kt");
}
@TestMetadata("funNestedStaticClass2.kt")
public void testFunNestedStaticClass2() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/protectedStatic/funNestedStaticClass2.kt");
}
@TestMetadata("funNestedStaticGenericClass.kt")
public void testFunNestedStaticGenericClass() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/protectedStatic/funNestedStaticGenericClass.kt");
}
@TestMetadata("funNotDirectSuperClass.kt")
public void testFunNotDirectSuperClass() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/protectedStatic/funNotDirectSuperClass.kt");
}
@TestMetadata("funObject.kt")
public void testFunObject() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/protectedStatic/funObject.kt");
}
@TestMetadata("simpleClass.kt")
public void testSimpleClass() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/protectedStatic/simpleClass.kt");
}
@TestMetadata("simpleClass2.kt")
public void testSimpleClass2() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/protectedStatic/simpleClass2.kt");
}
@TestMetadata("simpleFun.kt")
public void testSimpleFun() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/protectedStatic/simpleFun.kt");
}
@TestMetadata("simpleProperty.kt")
public void testSimpleProperty() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/protectedStatic/simpleProperty.kt");
}
}
@TestMetadata("compiler/testData/codegen/boxWithJava/staticFun")
public static class StaticFun extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInStaticFun() throws Exception {
@@ -169,13 +101,154 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege
}
@TestMetadata("compiler/testData/codegen/boxWithJava/visibility")
@InnerTestClasses({Visibility.Package.class, Visibility.ProtectedAndPackage.class, Visibility.ProtectedStatic.class})
public static class Visibility extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInVisibility() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/codegen/boxWithJava/visibility"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("compiler/testData/codegen/boxWithJava/visibility/package")
public static class Package extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInPackage() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/codegen/boxWithJava/visibility/package"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("kt2781.kt")
public void testKt2781() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/package/kt2781.kt");
}
@TestMetadata("packageClass.kt")
public void testPackageClass() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/package/packageClass.kt");
}
@TestMetadata("packageFun.kt")
public void testPackageFun() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/package/packageFun.kt");
}
@TestMetadata("packageProperty.kt")
public void testPackageProperty() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/package/packageProperty.kt");
}
}
@TestMetadata("compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage")
public static class ProtectedAndPackage extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInProtectedAndPackage() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("overrideProtectedFunInPackage.kt")
public void testOverrideProtectedFunInPackage() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/overrideProtectedFunInPackage.kt");
}
@TestMetadata("protectedFunInPackage.kt")
public void testProtectedFunInPackage() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/protectedFunInPackage.kt");
}
@TestMetadata("protectedPropertyInPackage.kt")
public void testProtectedPropertyInPackage() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/protectedPropertyInPackage.kt");
}
@TestMetadata("protectedStaticClass.kt")
public void testProtectedStaticClass() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/protectedStaticClass.kt");
}
}
@TestMetadata("compiler/testData/codegen/boxWithJava/visibility/protectedStatic")
public static class ProtectedStatic extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInProtectedStatic() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/codegen/boxWithJava/visibility/protectedStatic"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("funCallInConstructor.kt")
public void testFunCallInConstructor() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funCallInConstructor.kt");
}
@TestMetadata("funClassObject.kt")
public void testFunClassObject() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funClassObject.kt");
}
@TestMetadata("funGenericClass.kt")
public void testFunGenericClass() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funGenericClass.kt");
}
@TestMetadata("funNestedStaticClass.kt")
public void testFunNestedStaticClass() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNestedStaticClass.kt");
}
@TestMetadata("funNestedStaticClass2.kt")
public void testFunNestedStaticClass2() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNestedStaticClass2.kt");
}
@TestMetadata("funNestedStaticGenericClass.kt")
public void testFunNestedStaticGenericClass() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNestedStaticGenericClass.kt");
}
@TestMetadata("funNotDirectSuperClass.kt")
public void testFunNotDirectSuperClass() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNotDirectSuperClass.kt");
}
@TestMetadata("funObject.kt")
public void testFunObject() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funObject.kt");
}
@TestMetadata("simpleClass.kt")
public void testSimpleClass() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleClass.kt");
}
@TestMetadata("simpleClass2.kt")
public void testSimpleClass2() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleClass2.kt");
}
@TestMetadata("simpleFun.kt")
public void testSimpleFun() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleFun.kt");
}
@TestMetadata("simpleProperty.kt")
public void testSimpleProperty() throws Exception {
doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleProperty.kt");
}
}
public static Test innerSuite() {
TestSuite suite = new TestSuite("Visibility");
suite.addTestSuite(Visibility.class);
suite.addTestSuite(Package.class);
suite.addTestSuite(ProtectedAndPackage.class);
suite.addTestSuite(ProtectedStatic.class);
return suite;
}
}
public static Test suite() {
TestSuite suite = new TestSuite("BlackBoxWithJavaCodegenTestGenerated");
suite.addTestSuite(BlackBoxWithJavaCodegenTestGenerated.class);
suite.addTestSuite(Enum.class);
suite.addTestSuite(Functions.class);
suite.addTestSuite(ProtectedStatic.class);
suite.addTestSuite(StaticFun.class);
suite.addTest(Visibility.innerSuite());
return suite;
}
}
@@ -21,7 +21,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.checkers.AbstractDiagnosticsTestWithEagerResolve;
import org.jetbrains.jet.checkers.AbstractJetPsiCheckerTest;
import org.jetbrains.jet.codegen.AbstractCheckLocalVariablesTableTest;
import org.jetbrains.jet.codegen.AbstractJavaVisibilityTest;
import org.jetbrains.jet.codegen.defaultConstructor.AbstractDefaultConstructorCodegenTest;
import org.jetbrains.jet.codegen.flags.AbstractWriteFlagsTest;
import org.jetbrains.jet.codegen.generated.AbstractBlackBoxCodegenTest;
@@ -97,13 +96,6 @@ public class GenerateTests {
testModel("compiler/testData/codegen/boxWithStdlib", "doTestWithStdlib")
);
generateTest(
"compiler/tests/",
"JavaVisibilityTestGenerated",
AbstractJavaVisibilityTest.class,
testModel("compiler/testData/codegen/visibility", "blackBoxFileWithJavaByFullPath")
);
generateTest(
"compiler/tests/",
"CheckLocalVariablesTableTestGenerated",