This is the mail archive of the mauve-discuss@sources.redhat.com mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Purpose of .net.SocketTest test_BasicServer #12


Can someone examine the following testcase in the .net.Socket package and let me know what it is designed to test.  I'm unsure about the garbage collector comment, but it would appear that the purpose of the test is to connect to the local Echo server at port #7, and then test the getInputStream() and getOutputStream() methods.  However, it then expects an IOException, and why I'm not sure.  On some of our unix hosts that I'm using, we *do* get an exception within the test, but the exception is on the 'new Socket("127.0.0.1", 7)' statement because the Echo server wasn't running at the time.  However, in this case the Mauve harness check still reported this test as 'PASS' because of the catch code.  My gut feeling is that the test is not designed to test the Echo server but rather to test the Input and Output methods; however, I'll leave it up to bigger minds to make the final determination.

Thanks for the help

Steve Murry
SAS Institute, Inc. 


    // This test is incorrect.  You cannot rely on System.gc() causing
    // the garbage collector to run.
    try {
      sock = new Socket("127.0.0.1", 7);
      InputStream sin = null;
      OutputStream sout = null;

      // create 10 refs and make sure finalize() is invoked.
      for (int i = 0; i < 10; i++) {
        sin = sock.getInputStream();
        sout = sock.getOutputStream();
      }
      harness.fail("Error : test_BasicServer failed - 12 " +
                   "exception was not thrown");
    }
    catch (IOException e) {
      harness.check(true);
    }
    finally {
      try {
        if (sock != null)
          sock.close();
      } catch(IOException ignored) {}
    }

    // invoke finalize()
    System.gc();


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]