diff --git a/testsuite/src/test/java/org/jboss/ceylon/test/modules/smoke/test/SmokeTestCase.java b/testsuite/src/test/java/org/jboss/ceylon/test/modules/smoke/test/SmokeTestCase.java index cbfb002..a291edc 100644 --- a/testsuite/src/test/java/org/jboss/ceylon/test/modules/smoke/test/SmokeTestCase.java +++ b/testsuite/src/test/java/org/jboss/ceylon/test/modules/smoke/test/SmokeTestCase.java @@ -38,6 +38,13 @@ public void singleModule() throws Throwable { testArchive(module); } + @Test + public void swingModule() throws Throwable { + JavaArchive module = ShrinkWrap.create(JavaArchive.class, "org.jboss.swing-1.0.0.CR1.car"); + module.addClasses(org.jboss.swing.module_.class, org.jboss.swing.run_.class); + testArchive(module); + } + @Test public void filteredAndCycleModule() throws Throwable { JavaArchive module = ShrinkWrap.create(JavaArchive.class, "eu.cloud.clazz-1.0.0.GA.car"); diff --git a/testsuite/src/test/java/org/jboss/swing/module_.java b/testsuite/src/test/java/org/jboss/swing/module_.java new file mode 100644 index 0000000..bad227d --- /dev/null +++ b/testsuite/src/test/java/org/jboss/swing/module_.java @@ -0,0 +1,32 @@ +/* + * Copyright 2011 Red Hat inc. and third party contributors as noted + * by the author tags. + * + * 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.jboss.swing; + +import com.redhat.ceylon.compiler.java.metadata.Module; + + +/** + * @author Ales Justin + */ +@Module(name = "org.jboss.swing", + version = "1.0.0.CR1") +public class module_ { + public static void run() { + System.out.println("run ..."); + } +} diff --git a/testsuite/src/test/java/org/jboss/swing/run_.java b/testsuite/src/test/java/org/jboss/swing/run_.java new file mode 100644 index 0000000..5cab210 --- /dev/null +++ b/testsuite/src/test/java/org/jboss/swing/run_.java @@ -0,0 +1,68 @@ +/* + * Copyright 2011 Red Hat inc. and third party contributors as noted + * by the author tags. + * + * 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.jboss.swing; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.UIDefaults; +import javax.swing.UIManager; +import javax.swing.plaf.ComponentUI; + +/** + * @author Ales Justin + */ +public class run_ { + public static void main(String[] args) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { + System.out.println(run_.class.getName() + ": run_ 1 ..."); + JPanel jPanel = new javax.swing.JPanel(); + UIDefaults defaults = UIManager.getDefaults(); + Object cl = defaults.get("ClassLoader"); + ClassLoader uiClassLoader = + (cl != null) ? (ClassLoader)cl : jPanel.getClass().getClassLoader(); + try { + String className = (String)defaults.get(jPanel.getUIClassID()); + if (className != null) { + Class cls = (Class)defaults.get(className); + if (cls == null) { + if (uiClassLoader == null) { + Method m = SwingUtilities.class.getDeclaredMethod("loadSystemClass", String.class); + m.setAccessible(true); + m.invoke(null, className); + // cls = SwingUtilities.loadSystemClass(className); + throw new RuntimeException("FAIL"); + } + else { + cls = uiClassLoader.loadClass(className); + } + } + } + } + catch (ClassNotFoundException e) { + e.printStackTrace(); + } + catch (ClassCastException e) { + e.printStackTrace(); + } + + System.out.println(run_.class.getName() + ": run_ 2 ..."); + } +}