/*****************************************************************************/
/* File name: TestClient.java                                                */
/* Purpose: to test NFS mount server                                         */
/*                                                                           */
/* Last modified: 30.07.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*                                                                           */
/* This program 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 for more details.                                          */
/*                                                                           */
/* This software is distributed under the terms                              */
/* of the GNU General Public License as published                            */
/* by the Free Software Foundation; either version 2, or (at your option)    */
/* any later version.                                                        */
/* See file COPYING for your rights (GNU GPL)                                */
/*****************************************************************************/

package mount;


import java.net.*;
import java.io.*;
import rpc.*;


public
class

TestClient
        extends rpc.ParserResponder
                                    implements Runnable
{

  private final static String RCSID = "$Header: /d/NFS/mount/RCS/TestClient.java,v 1.10 1999/08/02 16:49:07 vklimov Exp $";



  public

  TestClient( java.lang.String propertiesFilePath )

                                         throws  SocketException
/*****************************************************************************/
/* Function name: TestClient                                                 */
/* File name: TestClient.java                                                */
/* Purpose: constructor for the TestClient class                             */
/* Throws: SocketException                                                   */
/* Parameters: propertiesFilePath                                            */
/* Returns:                                                                  */
/* Last modified: 11.07.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
      super( Constants.TEST_MOUNT_PORT,
             propertiesFilePath         );

                                                       /* TestClient */
/*---------------------------------------------------------------------------*/

    }
/*end of TestClient*/


  public
  void

  sendNullProcedureMessage( long transactionId )
/*****************************************************************************/
/* Function name: sendNullProcedureMessage                                   */
/* File name: TestClient.java                                                */
/* Purpose: to test response on a null procedure message                     */
/* Parameters: transactionId                                                 */
/* Returns:                                                                  */
/* Last modified: 30.07.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
      byte[] ibuf = null;
      int ilength = 0;
      InetAddress ipAddressWhereToSend = null;
      int portToSendTo = 0;
      DatagramPacket udpPacket = null;
      Message rpcMessage = null;

                                        /* sendNullProcedureMessage */
/*---------------------------------------------------------------------------*/

      ibuf = new byte[
              nfs.Constants.
                PORTMAPPER_REGISTRATION_UDP_PACKET_DATA_LENGTH ];

      rpcMessage =
        new Message( ibuf );

      rpcMessage.
        putUnsignedInteger( transactionId );
      rpcMessage.
        putUnsignedInteger( rpc.Constants.RPC_CALL );

      rpcMessage.
        putUnsignedInteger(
          rpc.Constants.HIGHEST_RPC_PROTOCOL_VERSION_SUPPORTED );

      rpcMessage.
        putUnsignedInteger( (long) Constants.MOUNTPROG );

      rpcMessage.
        putUnsignedInteger( Constants.MOUNT_VERS );

      rpcMessage.
        putUnsignedInteger( (long) Constants.MOUNTPROC_NULL );
      rpcMessage.
        putEmptyOpaqueAuthentication();
      rpcMessage.
        putEmptyOpaqueAuthentication();

      portToSendTo = (int) Constants.MOUNT_PORT;

      try
        {
          ipAddressWhereToSend =
            InetAddress.getByName(
              rpc.Constants.LOCAL_LOOP_IP_ADDRESS );
        }
      catch( UnknownHostException e )
        {
          System.out.println( e.getMessage() );
          return;                                      /* return ! */
        }
    /*end of try*/

      udpPacket = new
        DatagramPacket( ibuf, ibuf.length,
                        ipAddressWhereToSend,
                        portToSendTo          );

      try
        {
          udpSocket.send( udpPacket,
                          transactionId,
                          "sendNullProcedureMessage" );
        }
      catch( IOException e )
        {
          System.out.println(
            "NFS mount TestClient, " +
            "sendNullProcedureMessage: " +
            "IOException in sending datagram\n" +
            e.getMessage()                              );
        }
    /*end of try-catch*/

    }
/*end of sendNullProcedureMessage*/


  public
  void

  receiveNullProcedureReply()
/*****************************************************************************/
/* Function name: receiveNullProcedureReply                                  */
/* File name: TestClient.java                                                */
/* Purpose: to get an answer from the NFS mount server                       */
/* Parameters:                                                               */
/* Returns:                                                                  */
/* Last modified: 09.06.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
      ParserResponderReturnArguments
        parserResponderReturnArguments;
      boolean registeredOK;
      boolean nowMayProcessTheParametersToRemoteProcedure;
      byte[] byteBuffer = null;
      DatagramPacket udpPacket = null;
                                           /* receiveNullProcedureReply */
/*---------------------------------------------------------------------------*/

      byteBuffer = new byte[ pm.Constants.UDP_PACKET_LENGTH ];

      udpPacket = new
        DatagramPacket( byteBuffer,
                        byteBuffer.length );

      try
        {
          udpSocket.receive( udpPacket );
        }
      catch( IOException e )
        {
          System.out.println(
            "udpSocket.receive: " +
            e.getMessage()          );
        }
    /*end of try-catch*/

      parserResponderReturnArguments = new
        ParserResponderReturnArguments();

      nowMayProcessTheParametersToRemoteProcedure =
        processUDPPacket(
          udpPacket,
          parserResponderReturnArguments      );

      if ( nowMayProcessTheParametersToRemoteProcedure )
        {

          System.out.println( "receiveNullProcedureReply: " +
                            "got reply on null procedure"    );
        }
      else
        System.out.println( "receiveNullProcedureReply: " +
                            "error in receiving reply"       );
    /*end of if on nowMayProcessTheParametersToRemoteProcedure*/

    }
/*end of receiveNullProcedureReply*/


  public
  void

  sendMountRPCMessageToNFSMountServer( long transactionId,
                                       String dirPath      )
/*****************************************************************************/
/* Function name: sendMountRPCMessageToNFSMountServer                        */
/* File name: TestClient.java                                                */
/* Purpose: to create a mount request RPC message and send it                */
/*          to mount server                                                  */
/* Parameters: transactionId                                                 */
/*             dirPath                                                       */
/* Returns:                                                                  */
/* Last modified: 30.07.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
      byte[] ibuf = null;
      int ilength = 0;
      InetAddress ipAddressWhereToSend = null;
      int portToSendTo = 0;
      DatagramPacket udpPacket = null;
      Message rpcMessage = null;

                                /* sendMountRPCMessageToNFSMountServer */
/*---------------------------------------------------------------------------*/

      if (dirPath.length() >
          Constants.MNTPATHLEN)
        {
          System.out.println( "dirPath is too long!" );
          return;                                        /* return ! */
        }
      else
        ;
    /*end of if*/

      ibuf = new byte[
              Constants.
                MOUNT_REQUEST_UDP_PACKET_DATA_LENGTH ];

      rpcMessage =
        new Message( ibuf );

      rpcMessage.
        putUnsignedInteger( transactionId );
      rpcMessage.
        putUnsignedInteger( rpc.Constants.RPC_CALL );
      rpcMessage.
        putUnsignedInteger(
          rpc.Constants.HIGHEST_RPC_PROTOCOL_VERSION_SUPPORTED );
      rpcMessage.
        putUnsignedInteger( (long) mount.Constants.MOUNTPROG );
      rpcMessage.
        putUnsignedInteger( mount.Constants.MOUNT_VERS_HIGH );
      rpcMessage.
        putUnsignedInteger( (long) mount.Constants.MOUNTPROC_MNT );
      rpcMessage.
        putEmptyOpaqueAuthentication();
      rpcMessage.
        putEmptyOpaqueAuthentication();


      try
        {
          rpcMessage.
            putString( dirPath,
                       Constants.MNTPATHLEN );
        }
      catch( ArrayIndexOutOfBoundsException e )
        {
          System.out.println( "dirPath is too long!" );
          return;                                      /* return ! */
        }
      catch( ArrayStoreException e )
        {
          System.out.println( dirPath +
                              "\n" + e.getMessage() );
          return;                                      /* return ! */
        }
    /*end of try-catch*/

      portToSendTo = mount.Constants.MOUNT_PORT;

      try
        {
          ipAddressWhereToSend =
            InetAddress.getByName(
              rpc.Constants.LOCAL_LOOP_IP_ADDRESS );
        }
      catch( UnknownHostException e )
        {
          System.out.println( e.getMessage() );
          return;                                      /* return ! */
        }
    /*end of try*/

      udpPacket = new
        DatagramPacket( ibuf, ibuf.length,
                        ipAddressWhereToSend,
                        portToSendTo          );

      try
        {
          udpSocket.send( udpPacket,
                          transactionId,
                          "sendMountRPCMessageToNFSMountServer" );
        }
      catch( IOException e )
        {
          System.out.println(
            "NFS mount TestClient, " +
            "sendMountRPCMessageToNFSMountServer: " +
            "IOException in sending datagram\n" +
            e.getMessage()                              );
        }
    /*end of try-catch*/

    }
/*end of sendMountRPCMessageToNFSMountServer*/


  public
  void

  sendUnmountAllRPCMessageToMountServer( long transactionId )
/*****************************************************************************/
/* Function name: sendUnmountAllRPCMessageToMountServer                      */
/* File name: TestClient.java                                                */
/* Purpose: to create an unmount all RPC message and send it to mount server */
/* Parameters: transactionId                                                 */
/* Returns:                                                                  */
/* Last modified: 30.07.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
      byte[] ibuf = null;
      int ilength = 0;
      InetAddress ipAddressWhereToSend = null;
      int portToSendTo = 0;
      DatagramPacket udpPacket = null;
      Message rpcMessage = null;

                                /* sendUnmountAllRPCMessageToMountServer */
/*---------------------------------------------------------------------------*/

      ibuf = new byte[
              Constants.
                MOUNT_DUMP_REQUEST_UDP_PACKET_DATA_LENGTH ];

      rpcMessage =
        new Message( ibuf );

      rpcMessage.
        putUnsignedInteger( transactionId );
      rpcMessage.
        putUnsignedInteger( rpc.Constants.RPC_CALL );
      rpcMessage.
        putUnsignedInteger(
          rpc.Constants.HIGHEST_RPC_PROTOCOL_VERSION_SUPPORTED );
      rpcMessage.
        putUnsignedInteger( (long) mount.Constants.MOUNTPROG );
      rpcMessage.
        putUnsignedInteger( mount.Constants.MOUNT_VERS_HIGH );
      rpcMessage.
        putUnsignedInteger( (long) mount.Constants.MOUNTPROC_UMNTALL );
      rpcMessage.
        putEmptyOpaqueAuthentication();
      rpcMessage.
        putEmptyOpaqueAuthentication();

      portToSendTo = mount.Constants.MOUNT_PORT;

      try
        {
          ipAddressWhereToSend =
            InetAddress.getByName(
              rpc.Constants.LOCAL_LOOP_IP_ADDRESS );
        }
      catch( UnknownHostException e )
        {
          System.out.println( e.getMessage() );
          return;                                      /* return ! */
        }
    /*end of try*/

      udpPacket = new
        DatagramPacket( ibuf, ibuf.length,
                        ipAddressWhereToSend,
                        portToSendTo          );

      try
        {
          udpSocket.send( udpPacket,
                          transactionId,
                          "sendUnmountAllRPCMessageToMountServer" );
        }
      catch( IOException e )
        {
          System.out.println(
            "NFS mount TestClient, " +
            "sendUnmountRPCMessageToMountServer: " +
            "IOException in sending datagram\n" +
            e.getMessage()                              );
        }
    /*end of try-catch*/

    }
/*end of sendUnmountAllRPCMessageToMountServer*/


  public
  void

  sendUnmountRPCMessageToMountServer( long transactionId,
                                      String dirPath      )
/*****************************************************************************/
/* Function name: sendUnmountRPCMessageToMountServer                         */
/* File name: TestClient.java                                                */
/* Purpose: to create an unmount RPC message and send it to mount server     */
/* Parameters: transactionId                                                 */
/*             dirPath                                                       */
/* Returns:                                                                  */
/* Last modified: 30.07.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
      byte[] ibuf = null;
      int ilength = 0;
      InetAddress ipAddressWhereToSend = null;
      int portToSendTo = 0;
      DatagramPacket udpPacket = null;
      Message rpcMessage = null;

                                /* sendUnmountRPCMessageToMountServer */
/*---------------------------------------------------------------------------*/

      if (dirPath.length() >
          Constants.MNTPATHLEN)
        {
          System.out.println( "dirPath is too long!" );
          return;                                        /* return ! */
        }
      else
        ;
    /*end of if*/

      ibuf = new byte[
              Constants.
                MOUNT_REQUEST_UDP_PACKET_DATA_LENGTH ];

      rpcMessage =
        new Message( ibuf );

      rpcMessage.
        putUnsignedInteger( transactionId );
      rpcMessage.
        putUnsignedInteger( rpc.Constants.RPC_CALL );
      rpcMessage.
        putUnsignedInteger(
          rpc.Constants.HIGHEST_RPC_PROTOCOL_VERSION_SUPPORTED );
      rpcMessage.
        putUnsignedInteger( (long) mount.Constants.MOUNTPROG );
      rpcMessage.
        putUnsignedInteger( mount.Constants.MOUNT_VERS_HIGH );
      rpcMessage.
        putUnsignedInteger( (long) mount.Constants.MOUNTPROC_UMNT );
      rpcMessage.
        putEmptyOpaqueAuthentication();
      rpcMessage.
        putEmptyOpaqueAuthentication();


      try
        {
          rpcMessage.
            putString( dirPath,
                       Constants.MNTPATHLEN );
        }
      catch( ArrayIndexOutOfBoundsException e )
        {
          System.out.println( "dirPath is too long!" );
          return;                                      /* return ! */
        }
      catch( ArrayStoreException e )
        {
          System.out.println( dirPath +
                              "\n" + e.getMessage() );
          return;                                      /* return ! */
        }
    /*end of try-catch*/

      portToSendTo = mount.Constants.MOUNT_PORT;

      try
        {
          ipAddressWhereToSend =
            InetAddress.getByName(
              rpc.Constants.LOCAL_LOOP_IP_ADDRESS );
        }
      catch( UnknownHostException e )
        {
          System.out.println( e.getMessage() );
          return;                                      /* return ! */
        }
    /*end of try*/

      udpPacket = new
        DatagramPacket( ibuf, ibuf.length,
                        ipAddressWhereToSend,
                        portToSendTo          );

      try
        {
          udpSocket.send( udpPacket,
                          transactionId,
                          "sendUnmountRPCMessageToMountServer" );
        }
      catch( IOException e )
        {
          System.out.println(
            "NFS mount TestClient, " +
            "sendUnmountRPCMessageToMountServer: " +
            "IOException in sending datagram\n" +
            e.getMessage()                              );
        }
    /*end of try-catch*/

    }
/*end of sendUnmountRPCMessageToMountServer*/


  public
  boolean

  analyzeRPCReplyMessageOnMountRequest(
    ParserResponderReturnArguments
      parserResponderReturnArguments,
    FhStatus fhStatus                   )
/*****************************************************************************/
/* Function name: analyzeRPCReplyMessageOnMountRequest                       */
/* File name: TestClient.java                                                */
/* Purpose: to analyze the reply of the NFS mount server on mount request    */
/* Parameters: parserResponderReturnArguments                                */
/*             fhStatus                                                      */
/* Returns: true - if mounted OK, false - otherwise                          */
/* Last modified: 16.06.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
      Fhandle fhandle;
      boolean gotFhandleOK;
      Message rpcMessageWithParametersToRemoteProcedure = null;

                               /* analyzeRPCReplyMessageOnMountRequest */
/*---------------------------------------------------------------------------*/

      rpcMessageWithParametersToRemoteProcedure = new
        Message(
          parserResponderReturnArguments.
            byteArrayContainingParametersToRemoteProcedure );

      fhStatus.status =
        rpcMessageWithParametersToRemoteProcedure.
          getUnsignedInteger();

      if (fhStatus.status == Constants.FHSTATUS_OK)
        {
          fhandle = new Fhandle();
          gotFhandleOK =
            fhandle.getItselfFromRPCMessage(
              rpcMessageWithParametersToRemoteProcedure );
          fhStatus.fhandle = fhandle;
          return gotFhandleOK;
        }
      else
        {
          return false;
        }
    /*end of if*/

    }
/*end of analyzeRPCReplyMessageOnMountRequest*/


  public
  boolean

  receiveFhstatusRPCMessageFromNFSMountServer( FhStatus fhStatus )
/*****************************************************************************/
/* Function name: receiveFhstatusRPCMessageFromNFSMountServer                */
/* File name: TestClient.java                                                */
/* Purpose: to get an answer from the mount                                  */
/* Parameters:                                                               */
/* Returns: true - if mounted OK, false - otherwise                          */
/* Last modified: 16.06.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
      ParserResponderReturnArguments
        parserResponderReturnArguments;
      boolean mountedOK;
      boolean nowMayProcessTheParametersToRemoteProcedure;
      byte[] byteBuffer = null;
      DatagramPacket udpPacket = null;

                          /* receiveFhstatusRPCMessageFromNFSMountServer */
/*---------------------------------------------------------------------------*/

      byteBuffer = new byte[ mount.Constants.UDP_PACKET_LENGTH ];

      udpPacket = new
        DatagramPacket( byteBuffer,
                        byteBuffer.length );

      try
        {
          udpSocket.receive( udpPacket );
        }
      catch( IOException e )
        {
          System.out.println(
            "udpSocket.receive: " +
            e.getMessage()          );
        }
    /*end of try-catch*/

      parserResponderReturnArguments = new
        ParserResponderReturnArguments();

      nowMayProcessTheParametersToRemoteProcedure =
        processUDPPacket(
          udpPacket,
          parserResponderReturnArguments      );

      if ( nowMayProcessTheParametersToRemoteProcedure )
        {
          mountedOK =
            analyzeRPCReplyMessageOnMountRequest(
              parserResponderReturnArguments,
              fhStatus                            );

          return mountedOK;                                /* return ! */
        }
      else
        ;
    /*end of if on nowMayProcessTheParametersToRemoteProcedure*/

      return false;

    }
/*end of receiveFhstatusRPCMessageFromNFSMountServer*/


  public
  boolean

  receiveUnmountReply()
/*****************************************************************************/
/* Function name: receiveUnmountReply                                        */
/* File name: TestClient.java                                                */
/* Purpose: to get an answer from the mount                                  */
/* Parameters:                                                               */
/* Returns: true - if received a good RPC reply message, false - otherwise   */
/* Last modified: 17.06.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
      ParserResponderReturnArguments
        parserResponderReturnArguments;
      boolean unmountedOK;
      boolean nowMayProcessTheParametersToRemoteProcedure;
      byte[] byteBuffer = null;
      DatagramPacket udpPacket = null;

                                                /* receiveUnmountReply */
/*---------------------------------------------------------------------------*/

      byteBuffer = new byte[ mount.Constants.UDP_PACKET_LENGTH ];

      udpPacket = new
        DatagramPacket( byteBuffer,
                        byteBuffer.length );

      try
        {
          udpSocket.receive( udpPacket );
        }
      catch( IOException e )
        {
          System.out.println(
            "udpSocket.receive: " +
            e.getMessage()          );
        }
    /*end of try-catch*/

      parserResponderReturnArguments = new
        ParserResponderReturnArguments();

      nowMayProcessTheParametersToRemoteProcedure =
        processUDPPacket(
          udpPacket,
          parserResponderReturnArguments      );

      if ( nowMayProcessTheParametersToRemoteProcedure )
        return true;
      else
        return false;
    /*end of if on nowMayProcessTheParametersToRemoteProcedure*/

    }
/*end of receiveUnmountReply*/


  public
  void

  run()
/*****************************************************************************/
/* Function name: run                                                        */
/* File name: TestClient.java                                                */
/* Purpose: to test the mount server                                         */
/* Parameters:                                                               */
/* Returns:                                                                  */
/* Last modified: 17.06.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
      FhStatus fhStatus = new FhStatus();
      boolean mountedOK;
      boolean unmountedOK;
      long portNumber = 0;
                                                                 /* run */
/*---------------------------------------------------------------------------*/

System.out.println( "\ntesting null procedure" );

      sendNullProcedureMessage(
        nfs.Constants.INITIAL_TRANSACTION_ID );

      receiveNullProcedureReply();

System.out.println( "\ntesting MOUNT procedure" );

      sendMountRPCMessageToNFSMountServer(
        nfs.Constants.INITIAL_TRANSACTION_ID,
        "/"                                );          /* does exist */

      mountedOK =
        receiveFhstatusRPCMessageFromNFSMountServer(
          fhStatus                                   );

System.out.println( "\n\nrun: mountedOK=" + mountedOK );

      if (mountedOK)
        System.out.println( "\nfhStatus=" +
                            fhStatus.toString() );
      else
        System.out.println( "\nstatus=" +
                            fhStatus.status );
    /*end of if on mountedOK*/

System.out.println( "\ntesting rejection in the MOUNT procedure" );

                                                          /* reject test #1 */
      sendMountRPCMessageToNFSMountServer( 
        nfs.Constants.INITIAL_TRANSACTION_ID,
        "/hfhfh"                           );          /* does not exist */

      mountedOK =
        receiveFhstatusRPCMessageFromNFSMountServer(
          fhStatus                                   );

System.out.println( "\n\nrun: mountedOK=" + mountedOK );

      if (mountedOK)
        System.out.println( "\nfhStatus=" +
                            fhStatus.toString() );
      else
        System.out.println( "\nstatus=" +
                            fhStatus.status );
    /*end of if on mountedOK*/

System.out.println( "\ntesting MOUNT procedure" );

      sendMountRPCMessageToNFSMountServer( 
        nfs.Constants.INITIAL_TRANSACTION_ID,
        "/"                                );          /* does exist */

      mountedOK =
        receiveFhstatusRPCMessageFromNFSMountServer(
          fhStatus                                   );

System.out.println( "\n\nrun: mountedOK=" + mountedOK );

      if (mountedOK)
        System.out.println( "\nfhStatus=" +
                            fhStatus.toString() );
      else
        System.out.println( "\nstatus=" +
                            fhStatus.status );
    /*end of if on mountedOK*/

System.out.println( "\ntesting DUMP mount entries procedure" );

      sendMountRPCMessageToNFSMountServer( 
        nfs.Constants.INITIAL_TRANSACTION_ID,
        "/usr"                                );          /* does exist */

      mountedOK =
        receiveFhstatusRPCMessageFromNFSMountServer(
          fhStatus                                   );

System.out.println( "\n\nrun: mountedOK=" + mountedOK );

      if (mountedOK)
        System.out.println( "\nfhStatus=" +
                            fhStatus.toString() );
      else
        System.out.println( "\nstatus=" +
                            fhStatus.status );
    /*end of if on mountedOK*/
      sendMountRPCMessageToNFSMountServer( 
        nfs.Constants.INITIAL_TRANSACTION_ID,
        "/hdmsdos"                                );          /* does exist */

      mountedOK =
        receiveFhstatusRPCMessageFromNFSMountServer(
          fhStatus                                   );

System.out.println( "\n\nrun: mountedOK=" + mountedOK );

      if (mountedOK)
        System.out.println( "\nfhStatus=" +
                            fhStatus.toString() );
      else
        System.out.println( "\nstatus=" +
                            fhStatus.status );
    /*end of if on mountedOK*/
      sendMountRPCMessageToNFSMountServer( 
        nfs.Constants.INITIAL_TRANSACTION_ID,
        "/home"                                );          /* does exist */

      mountedOK =
        receiveFhstatusRPCMessageFromNFSMountServer(
          fhStatus                                   );

System.out.println( "\n\nrun: mountedOK=" + mountedOK );

      if (mountedOK)
        System.out.println( "\nfhStatus=" +
                            fhStatus.toString() );
      else
        System.out.println( "\nstatus=" +
                            fhStatus.status );
    /*end of if on mountedOK*/
      sendMountRPCMessageToNFSMountServer( 
        nfs.Constants.INITIAL_TRANSACTION_ID,
        "/usr/db"                                );          /* does exist */

      mountedOK =
        receiveFhstatusRPCMessageFromNFSMountServer(
          fhStatus                                   );

System.out.println( "\n\nrun: mountedOK=" + mountedOK );

      if (mountedOK)
        System.out.println( "\nfhStatus=" +
                            fhStatus.toString() );
      else
        System.out.println( "\nstatus=" +
                            fhStatus.status );
    /*end of if on mountedOK*/


System.out.println( "\ntesting UNMOUNT procedure" );

      sendUnmountRPCMessageToMountServer(
        nfs.Constants.INITIAL_TRANSACTION_ID,
        "/"                                );

      unmountedOK =
        receiveUnmountReply();

      if (unmountedOK)
        {
          System.out.println( "received an unmount reply" );
        }
      else
        {
          System.out.println( "NO unmount reply!" );
        }
    /*end of if on unmountedOK*/

System.out.println( "\ntesting UNMOUNT procedure" );

      sendUnmountRPCMessageToMountServer(
        nfs.Constants.INITIAL_TRANSACTION_ID,
        "/"                                );

      unmountedOK =
        receiveUnmountReply();

      if (unmountedOK)
        {
          System.out.println( "received an unmount reply" );
        }
      else
        {
          System.out.println( "NO unmount reply!" );
        }
    /*end of if on unmountedOK*/

System.out.println( "\ntesting ALL UNMOUNT procedure" );

      sendUnmountAllRPCMessageToMountServer(
        nfs.Constants.INITIAL_TRANSACTION_ID );

      unmountedOK =
        receiveUnmountReply();

      if (unmountedOK)
        {
          System.out.println( "received an unmount All reply" );
        }
      else
        {
          System.out.println( "NO unmount All reply!" );
        }
    /*end of if on unmountedOK*/

      udpSocket.close();

  }
/*end of run*/


  public
  static
  void

  main( String[] args )
/*****************************************************************************/
/* Function name: main                                                       */
/* File name: TestClient.java                                                */
/* Purpose: main method for the TestClient class                             */
/* Parameters: agrument strings array                                        */
/* Returns:                                                                  */
/* Last modified: 11.07.99                                                   */
/* Author: Victor Klimov, 1999                                               */
/*****************************************************************************/
    {
      TestClient test = null;
                                                          /* main */
/*---------------------------------------------------------------------------*/

      try
        {
          test = new TestClient( Constants.PROPERTIES_FILE_PATH );
        }
      catch( SocketException e )
        {
          System.out.println(
            "can\'t create io.UdpSocket: " +
            e.getMessage()                      );
          System.exit( 1 );
        }
    /*end of try-catch*/

      test.run();
      System.exit( 0 );

    }
/*end of main*/


} /* end of TestClient class */

/*****************************************************************************/
/* End of file: TestClient.java                                              */
/*****************************************************************************/
