1# Before `make install' is performed this script should be runnable with 2# `make test'. After `make install' it should work as `perl test.pl' 3 4######################### We start with some black magic to print on failure. 5 6# Change 1..1 below to 1..last_test_to_print . 7# (It may become useful if the test is moved to ./t subdirectory.) 8 9BEGIN { $| = 1; print "1..3\n"; } 10END {print "not ok 1\n" unless $loaded;} 11use JNI; 12$loaded = 1; 13print "ok 1\n"; 14 15######################### End of black magic. 16 17# Insert your test code below (better if it prints "ok 13" 18# (correspondingly "not ok 13") depending on the success of chunk 13 19# of the test code): 20 21# Simple StringBuffer test. 22# 23use JPL::AutoLoader; 24use JPL::Class 'java::lang::StringBuffer'; 25$sb = java::lang::StringBuffer->new__s("TEST"); 26if ($sb->toString____s() eq "TEST") { 27 print "ok 2\n"; 28} else { 29 print "not ok 2\n"; 30} 31 32# Put up a frame and let the user close it. 33# 34use JPL::AutoLoader; 35use JPL::Class 'java::awt::Frame'; 36use JPL::Class 'Closer'; 37 38$f = java::awt::Frame->new__s("Close Me, Please!"); 39my $setSize = getmeth("setSize", ["int", "int"], []); 40my $addWindowListener = getmeth("addWindowListener", 41 ["java.awt.event.WindowListener"], []); 42 43$f->$addWindowListener( new Closer ); 44$f->$setSize(200,200); 45$f->show(); 46 47while (1) { 48 49 if (!$f->isVisible____Z) { 50 last; 51 } 52 53 # Sleep a bit. 54 # 55 sleep 1; 56} 57 58print "ok 3\n"; 59