--- /dev/null 2011-11-07 22:05:58.722000001 +0400 +++ new/test/java/awt/EventQueue/MainAppContext/MainAppContext.java 2011-12-19 18:27:53.000000000 +0400 @@ -0,0 +1,36 @@ +/* + * @test + * @bug 7122796 + * @summary Tests 7122796 + * @author anthony.petrov@oracle.com + */ + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import sun.awt.*; + +public class MainAppContext { + + public static void main(String[] args) { + ThreadGroup secondGroup = new ThreadGroup("test"); + new Thread(secondGroup, new Runnable() { + public void run() { + SunToolkit.createNewAppContext(); + test(true); + } + }).start(); + + // Sleep on the main thread so that the AWT Toolkit is initialized + // in a user AppContext first + try { Thread.sleep(2000); } catch (Exception e) {} + + test(false); + } + + private static void test(boolean userAppContext) { + if (Toolkit.getDefaultToolkit().getSystemEventQueue() == null) { + throw new RuntimeException("No EventQueue for the current app context! userAppContext: " + userAppContext); + } + } +}