Persistent Object Package Test Case Documentation



Description

In order to facilitate and demonstrate to users some of the basic operations and functionality that the Persistent Object package provides, a test case have been included with the tar package.  This allows users to both look at and leverage some of the code in place and, at the same time, be familiar with the responses of the client and server(s).

The main conponents of the test application include: The test application is designed and implemented such that users can test it as a stand-alone Java application and as a Java Applet.

Java Application Test

In a Java-enabled environment, a user can run the test application by typing:
java TestClient  arg0  arg1  arg2  arg3  arg4  arg5 
Sets port number 
Should be 7010 
Y sets debug flag to true, 
false otherwise 
Y sets testing mode to Java application  Y to test Saving  Y to test Loading  Name of the object (arbitrary) 

Example: java TestClient 7010 Y Y Y n testObj 
       (Saves object named "testObj" with the debug option on) 

Java Applet Test

The Java applet test can be run with either a Java-enabled browser (such as Netscape or Internet Explorer), Appletviewer or applications with comparable capabilities.

The setting of application parameters takes place in the html file.

Example:

<applet code=TestClient.class width=1 height=1>  
<param name="Server"  value="www-cad.eecs.berkeley.edu">  
                                     <! Name of server applet resides> 
<param name="Debug"    value="Y">        <! Y sets debug flag to true> 
<param name="TestSave" value="n">       <! Y tests save functionality> 
<param name="TestLoad" value="Y">       <! Y tests load functionality> 
<param name="LocName"  value="testObj">  
                          <! Location name variable specified by user> 
</applet> 

(Loads object named "testObj" from the server www-cad.eecs.berkeley.edu with the debug option on) 

Test Case and Code Explanation

(from TestClient.java)

    DirObject dSetup = new DirObject();   // creates object for server set-up 
    dSetup.setPort(port);        // sets the port number 
    dSetup.setDebug(debug);      // sets the debug (message) flag 

    if (testSave == true){ 
       
      String testSaveStr = new String(); 
     
      for (int i=0; i<1500; i++){ 
        testSaveStr += TestData.data.charAt(i); 
      } 
      DataObject testSaveDataObject = new DataObject(loc, testSaveStr); 

      DirObject rootDir = new DirObject();  // creates "hollow" Directory 
      DirObject tempDir = new DirObject();  // objects 
      rootDir.getRoot();                    // load root directory 
      tempDir.load("/temp");                // load temp directory  
                                            // which is situated below 
                                            // root, as indicated by the 
                                            // "/" prefix 

      rootDir.attach(tempDir);              // attach the dir to root 
      tempDir.attach(testSaveDataObject);   // attach the target DataObject 
      rootDir.save();                       // save root directory 
                                            //   the save propogates to  
                                            //   all the objects attached 
    } 

    if (testLoad == true){ 

      DataObject testLoadDataObject = new DataObject(); 
      testLoadDataObject.load("/temp/" + loc); 
                  // loads the object at /temp/some_name 
                  // (root->temp->object_name 
       
      System.out.println("\n" + testLoadDataObject.getContent()); 
    } 

Database Browser

In order to facilitate a more intuitive and user-friendly way of perusing and accessing the contents in the data server, the class PO_DBDialog, is provided as a part of the package. It is a graphical user interface which allows users to traverse the database hierarchy. It also allows users to overload the access (accessContent) and save (saveEntry) methods in order to achieve application-/object- specific needs.

Here are the test code required to initialize and display the database dialog window:

For traversal only:

  PO_DBDialog d = new PO_DBDialog(some_name); 
  d.show(); 

For traversing and saving a PersistentObject:

  DirObject someObj = new DirObject(some_name); 
  PO_DBDialog pd = new PO_DBDialog(some_name, PO_DBDialog.SAVE, someObj); 
  pd.show();



Feedback: Francis Chan ( fchan@eecs.berkeley.edu  

Modified: May 8, 1997