diff --git a/plugins/ui-designer/testSrc/com/intellij/uiDesigner/core/AsmCodeGeneratorTest.java b/plugins/ui-designer/testSrc/com/intellij/uiDesigner/core/AsmCodeGeneratorTest.java index 14742a2c2ef6..d77e6378af03 100644 --- a/plugins/ui-designer/testSrc/com/intellij/uiDesigner/core/AsmCodeGeneratorTest.java +++ b/plugins/ui-designer/testSrc/com/intellij/uiDesigner/core/AsmCodeGeneratorTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2011 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -20,6 +20,7 @@ import com.intellij.openapi.actionSystem.DataProvider; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.PathManager; import com.intellij.openapi.application.PluginPathManager; +import com.intellij.openapi.components.BaseState; import com.intellij.openapi.util.SystemInfoRt; import com.intellij.openapi.util.io.FileUtil; import com.intellij.ui.components.JBTabbedPane; @@ -29,11 +30,13 @@ import com.intellij.uiDesigner.compiler.NestedFormLoader; import com.intellij.uiDesigner.compiler.Utils; import com.intellij.uiDesigner.lw.CompiledClassPropertiesProvider; import com.intellij.uiDesigner.lw.LwRootContainer; +import com.intellij.util.ArrayUtil; import com.intellij.util.PathUtil; import com.intellij.util.ui.UIUtil; import com.sun.tools.javac.Main; import gnu.trove.TIntObjectHashMap; import junit.framework.TestCase; +import kotlin.reflect.KDeclarationContainer; import org.jetbrains.org.objectweb.asm.ClassWriter; import javax.swing.*; @@ -47,10 +50,10 @@ import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; +import java.util.*; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; /** * @author yole @@ -66,7 +69,7 @@ public class AsmCodeGeneratorTest extends TestCase { final String swingPath = PathUtil.getJarPathForClass(AbstractButton.class); - java.util.List cp = new ArrayList<>(); + List cp = new ArrayList<>(); appendPath(cp, JBTabbedPane.class); appendPath(cp, TIntObjectHashMap.class); appendPath(cp, UIUtil.class); @@ -76,6 +79,8 @@ public class AsmCodeGeneratorTest extends TestCase { appendPath(cp, PathManager.getResourceRoot(this.getClass(), "/RuntimeBundle.properties")); appendPath(cp, GridLayoutManager.class); // forms_rt appendPath(cp, DataProvider.class); + appendPath(cp, BaseState.class); + appendPath(cp, KDeclarationContainer.class); myClassFinder = new MyClassFinder( new URL[] {new File(swingPath).toURI().toURL()}, cp.toArray(new URL[cp.size()]) @@ -93,13 +98,17 @@ public class AsmCodeGeneratorTest extends TestCase { @Override protected void tearDown() throws Exception { - myNestedFormLoader = null; - final MyClassFinder classFinder = myClassFinder; - if (classFinder != null) { - classFinder.releaseResources(); - myClassFinder = null; + try { + myNestedFormLoader = null; + final MyClassFinder classFinder = myClassFinder; + if (classFinder != null) { + classFinder.releaseResources(); + myClassFinder = null; + } + } + finally { + super.tearDown(); } - super.tearDown(); } private AsmCodeGenerator initCodeGenerator(final String formFileName, final String className) throws Exception { @@ -228,7 +237,7 @@ public class AsmCodeGeneratorTest extends TestCase { } private static Object invokeMethod(Object obj, String methodName) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { - return invokeMethod(obj, methodName, new Class[0], new Object[0]); + return invokeMethod(obj, methodName, ArrayUtil.EMPTY_CLASS_ARRAY, ArrayUtil.EMPTY_OBJECT_ARRAY); } private static Object invokeMethod(Object obj, String methodName, Class[] params, Object[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { @@ -236,7 +245,7 @@ public class AsmCodeGeneratorTest extends TestCase { return method.invoke(obj, args); } - private static Method findMethod(Class aClass, String methodName, Class[] params) { + private static Method findMethod(Class aClass, String methodName, Class[] params) { try { final Method method = aClass.getDeclaredMethod(methodName, params); method.setAccessible(true); @@ -262,7 +271,7 @@ public class AsmCodeGeneratorTest extends TestCase { public void testCardLayoutShow() throws Exception { JComponent rootComponent = getInstrumentedRootComponent("TestCardLayoutShow.form", "BindingTest"); assertTrue(rootComponent.getLayout() instanceof CardLayout); - assertEquals(rootComponent.getComponentCount(), 2); + assertThat(rootComponent.getComponentCount()).isEqualTo(2); assertFalse(rootComponent.getComponent(0).isVisible()); assertTrue(rootComponent.getComponent(1).isVisible()); } @@ -452,6 +461,7 @@ public class AsmCodeGeneratorTest extends TestCase { myClassData.put(name.replace('.', '/'), bytes); } + @Override protected InputStream lookupClassBeforeClasspath(String internalClassName) { final byte[] bytes = myClassData.get(internalClassName); if (bytes != null) { @@ -460,6 +470,7 @@ public class AsmCodeGeneratorTest extends TestCase { return null; } + @Override public InputStream getResourceAsStream(String name) throws IOException { if (name.equals("TestProperties.properties")) { return new ByteArrayInputStream(myTestProperties, 0, TEST_PROPERTY_CONTENT.length()); diff --git a/plugins/ui-designer/ui-designer.iml b/plugins/ui-designer/ui-designer.iml index eca27c766b69..502602a8b85b 100644 --- a/plugins/ui-designer/ui-designer.iml +++ b/plugins/ui-designer/ui-designer.iml @@ -29,6 +29,7 @@ +