home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / perl560.zip / jpl / JNI / test.pl < prev    next >
Text File  |  1999-09-14  |  1KB  |  59 lines

  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.  
  9. BEGIN { $| = 1; print "1..3\n"; }
  10. END {print "not ok 1\n" unless $loaded;}
  11. use JNI;
  12. $loaded = 1;
  13. print "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. #
  23. use JPL::AutoLoader;
  24. use JPL::Class 'java::lang::StringBuffer';
  25. $sb = java::lang::StringBuffer->new__s("TEST");
  26. if ($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. #
  34. use JPL::AutoLoader;
  35. use JPL::Class 'java::awt::Frame';
  36. use JPL::Class 'Closer';
  37.  
  38. $f = java::awt::Frame->new__s("Close Me, Please!");
  39. my $setSize = getmeth("setSize", ["int", "int"], []);
  40. my $addWindowListener = getmeth("addWindowListener",
  41.             ["java.awt.event.WindowListener"], []);
  42.  
  43. $f->$addWindowListener( new Closer );
  44. $f->$setSize(200,200);
  45. $f->show();
  46.  
  47. while (1) {
  48.  
  49.     if (!$f->isVisible____Z) {
  50.         last;
  51.     }
  52.  
  53.     # Sleep a bit.
  54.     #
  55.     sleep 1;
  56. }
  57.  
  58. print "ok 3\n";
  59.