View Javadoc

1   package uk.ac.rdg.resc.jstyx.client;
2   
3   import java.net.InetSocketAddress;
4   import java.io.FileOutputStream;
5   import java.util.Hashtable;
6   
7   import org.apache.log4j.Logger;
8   
9   import uk.ac.rdg.resc.jstyx.StyxUtils;
10  import uk.ac.rdg.resc.jstyx.types.*;
11  import uk.ac.rdg.resc.jstyx.messages.*;
12  import uk.ac.rdg.resc.jstyx.client.*;
13  
14  /***
15   * Simple test harness for the JStyx library
16   * @author  jdb
17   */
18  public class TestClient extends CStyxFileChangeAdapter
19  {
20      private static final Logger log = Logger.getLogger(TestClient.class);
21      
22      private static final String HOSTNAME = "localhost";
23      private static final int PORT = 7777;
24      
25      private static StyxConnection conn = null;
26      private static CStyxFile file;
27      private static long fid = -1;
28      private static long openFid = -1;
29      private static int mode = -1;
30      
31      public static void main(String[] args)
32      {
33          try
34          {
35              conn = new StyxConnection(HOSTNAME, PORT);
36              conn.connect();
37              //Thread.sleep(200);
38              //conn.close();
39              //file = new CStyxFile(conn, "bbe.txt");
40              //file.addChangeListener(new TestClient());
41              //Thread.sleep(1000);
42              //file.refreshAsync();
43              //file.openAsync(StyxUtils.OREAD);
44              //file.refreshAsync();
45              //System.out.println("file length = " + file.getLength());
46              //System.out.println("last modified = " + file.getLastModified());
47              //Thread.sleep(1000);
48          }
49          catch(Throwable e)
50          {
51              e.printStackTrace();
52          }
53          finally
54          {
55              System.err.println("In finally block");
56              if (conn != null)
57              {
58                  conn.close();
59              }
60          }
61      }
62      
63      public void fileOpen(CStyxFile file, int mode)
64      {
65          System.out.println("File is open with mode " + mode);
66      }
67      
68      public void statChanged(CStyxFile file, DirEntry newDirEntry)
69      {
70          System.out.println("Stat changed!");
71      }
72      
73  }