Skip to content

Commit

Permalink
Added test for #31: swing does not work
Browse files Browse the repository at this point in the history
  • Loading branch information
FroMage committed Mar 7, 2013
1 parent bf8cb4b commit 0f074e5
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
Expand Up @@ -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");
Expand Down
32 changes: 32 additions & 0 deletions 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 <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
*/
@Module(name = "org.jboss.swing",
version = "1.0.0.CR1")
public class module_ {
public static void run() {
System.out.println("run ...");
}
}
68 changes: 68 additions & 0 deletions 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 <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
*/
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 ...");
}
}

0 comments on commit 0f074e5

Please sign in to comment.