TestShutdown.java revision 2854
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
@bug 6799345
@summary Tests that no exceptions are thrown from TimerQueue and
SwingWorker on AppContext shutdown
@author art
@run main TestShutdown
*/
public class TestShutdown
{
private static AppContext targetAppContext;
private static JFrame f;
private static JTextField tf;
private static volatile boolean exceptionsOccurred = false;
private static volatile boolean appcontextInitDone = false;
private static int timerValue = 0;
throws Exception
{
t.start();
while (!appcontextInitDone)
{
}
if (exceptionsOccurred)
{
throw new RuntimeException("Test FAILED: some exceptions occurred");
}
}
static void initGUI()
{
f = new JFrame("F");
f.setVisible(true);
}
static void startGUI()
{
// caret blink Timer
// misc Timer
{
{
}
};
}
static class TestThreadGroup extends ThreadGroup
{
{
super(name);
}
{
if (t instanceof ThreadDeath)
{
// this one is expected, rethrow
throw (ThreadDeath)t;
}
exceptionsOccurred = true;
}
}
static class TestRunnable implements Runnable
{
public void run()
{
// create and show frame and text field
{
public void run()
{
initGUI();
}
});
// start some Timers
{
public void run()
{
startGUI();
}
});
// start multiple SwingWorkers
while (!Thread.interrupted())
{
try
{
new TestSwingWorker().execute();
}
catch (Exception e)
{
// exception here is expected, skip
break;
}
}
}
}
{
public String doInBackground()
{
for (int i = 0; i < 10; i++)
{
try
{
}
catch (Exception z)
{
break;
}
}
if (!appcontextInitDone)
{
appcontextInitDone = true;
}
return "Done";
}
{
{
}
}
}
}