<head>
<title>
Babelj PHP3 client test page
</title>
</head>
<body>
<pre>
<?php

include("babelj.php3");

  //  
  // Babelj is a language server library for Java.
  // Copyright (C) 1999  Pharmatrak
  //
  // This library is free software; you can redistribute it and/or
  // modify it under the terms of the GNU Library General Public
  // License as published by the Free Software Foundation; either
  // version 2 of the License, or (at your option) any later version.
  // 
  // This library 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
  // Library General Public License for more details.
  // 
  // You should have received a copy of the GNU Library General Public
  // License along with this library; if not, write to the
  // Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  // Boston, MA  02111-1307, USA.
  //   
  //    This class provides regression tests for the
  //    php3 Babelj client.
  //   
  //    @author  Timothy W Macinta (twm@alum.mit.edu)
  //   


$client = new Babelj;
$client->connect();

// test static method call
// test method call

$oa[0] = "www.yahoo.com";
$ot[0] = "string";
$localhost = $client->staticMethodCall("java.net.InetAddress", "getByName", $oa, $ot);
$addr = $client->methodCall($localhost, "getHostAddress", array());
if (substr($addr, 0, 4) == "204.") {
  echo "$addr - staticMethodCall <font color=\"#0000FF\">Passed</font>\n";
} else {
  echo "$addr - staticMethodCall <font color=\"#FF0000\">Failed</font>\n";
}

// test get static field

$jlit = $client->getStaticField("java.lang.Integer", "TYPE");
$to_string = $client->methodCall($jlit, "toString", array());
if ($to_string == "int") {
  echo "$to_string - getStaticField <font color=\"#0000FF\">Passed</font>\n";
} else {
  echo "$to_string - getStaticField <font color=\"#FF0000\">Failed</font>\n";
}

// test get field
// test new instance call

$oa2[0] = "123"; $oa2[1] = "456";
$ot2[0] = "int"; $ot2[1] = "int";
$d = $client->newInstanceCall("java.awt.Dimension", $oa2, $ot2);
$w = $client->getField($d, "width");
$h = $client->getField($d, "height");
if ($w == 123 && $h == 456) {
  echo "(123, 456) - getField <font color=\"#0000FF\">Passed</font>\n";
} else {
  echo "($w, $h) - getField <font color=\"#FF0000\">Failed</font>\n";
}

// test reading in an array  //  TO DO: Add this test



$client->disconnect();

?>
</pre>
</body>
