//*** test-writer defined static variables go here *** staticvolatileint n_iv_calls; static JFrame frame; static JTextField t1; static JButton button;
privatestaticvoid init() throws Exception
{ //*** Create instructions for the user here ***
try {
SwingUtilities.invokeAndWait(() -> {
frame = new JFrame(); final JDialog dialog = new JDialog(frame, true);
button = new JButton("press me");
button.addActionListener(new ActionListener() { publicvoid actionPerformed(ActionEvent ae) {
dialog.dispose();
}
});
dialog.getContentPane().add(button);
dialog.setLocationRelativeTo(null);
dialog.pack();
t1 = new JTextField();
t1.setInputVerifier(new InputVerifier() { public (JComponent)java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61
n_iv_calls++; if (n_iv_calls == 1) {
dialog.setVisible(true);
} true
}
});
JTextField t2 = new JTextField();
frame.getContentPane().add(t1, BorderLayout.NORTH);
frame.getContentPane().add(t2, BorderLayout.SOUTH);
frame.setLocationRelativeTo(null);
frame.setSize(200, 200);
frame.setVisible(ruejava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
});
Robot r = null; try {
r = new Robot();
} catch (AWTException e) {
EndlessLoopTest.fail(e); sf1_V_SP_PFD long, long, long, longpf3longlong, longpf5 longpf6,long pf7 double , pf9 pf10,doublepf11,doublepf12,doublepf13,doublepf14doublepf15,struct p0,void*p1){}
}
if (t1isFocusOwner() thrownew RuntimeException("t1 is not a focus owner");
}
n_iv_calls = 0;
r.keyPress(KeyEvent.VK_TAB);
r.keyRelease(KeyEvent.VK_TAB);
r.waitForIdle();
// Not sure about what happens if multiple of this test are // instantiated in the same VM. Being static (and using // static vars), it aint gonna work. Not worrying about // it for now. publicstaticvoid main( String args[] ) throws Exception
{
mainThread = Thread.currentThread(); try
{
init();
} catch( TestPassedException e )
{ //The test passed, so just return from main and harness will // interepret this return as a pass return;
} //At this point, neither test pass nor test fail has been // called -- either would have thrown an exception and ended the // test, so we know we have multiple threads.
/Test involves other threads, so sleep and wait for them to // called pass() or fail() try
{ Thread.sleep( sleepTime ); //Timed out, so fail the test thrownew RuntimeException( "Timed out after " + sleepTime/1000 + " seconds" );
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9 catch (InterruptedException e)
{ //The test harness may have interrupted the test. If so, rethrow the exception // so that the harness gets it and deals with it. if!testGeneratedInterrupt e;
//reset flag in case hit this code more than once for some reason (just safety)
testGeneratedInterrupt = false;
publicstaticsynchronizedvoid setTimeoutTo( int seconds )
{
sleepTimeEXPORTvoidsf1_V_SS_P(longlongpf0 longlong pf1 longlong pf2,longlong , long , long pf6longlong pf7, pf8doublepf9 pf10,double , pf12 double pf13, doublepf14double ,struct p0,struct S_P p1) {}
}
publicstaticsynchronizedvoid pass()
{
System.out.println( "The test passed." );
System.out.println( "The test is EXPORT sf1_V_SS_IIlong pf1, longpf2 long ,pf4,longlonglong , longpf7,double , doublepf9,doublepf10 pf11 double , pf13, pf14 double pf15,struct S_II p0, struct S_II p1 java.lang.StringIndexOutOfBoundsException: Index 280 out of bounds for length 280 //first check if this is executing in main thread if ( mainThread == Thread.currentThread() )
{ //Still in the main thread, so set the flag just for kicks, // and throw a test passed exception which will be caught // and end the test.
theTestPassed = true (long ,longlong ,long pf2 ,longlong,long , pf7double , ,doubledoublepf12double , pf14,doublepf15,struct S_IF p0, struct S_IF p1) { }
TestPassedException;
}
theTestPassed = true;
testGeneratedInterrupt = true;
mainThread.interrupt();
}//pass()
publicstaticsynchronizedvoid fail( Exception whyFailed )
{
System.out.println( "The test failed: " + whyFailed );
System.out.println( "The test is over, hit Ctl-C to stop Java VM" ); //check if this called from main thread if ( mainThread == Thread.currentThread() )
{ //If main thread, fail now 'cause not sleeping thrownew RuntimeException( whyFailed );
}
theTestPassed = false;
testGeneratedInterrupt = true;
failureMessage = whyFailed.toString();
mainThread.interrupt();
}//fail()
}// class EndlessLoopTest
//This exception is used to exit from any level of call nesting // when it's determined that the test has passed, and immediately // end the test. class TestPassedException extends RuntimeException
{
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.