geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject cvs commit: incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/net/protocol/file FileProtocolTest.java
Date Tue, 02 Sep 2003 07:52:44 GMT
jdillon     2003/09/02 00:52:44

  Modified:    modules/common/src/test/org/apache/geronimo/common/net/protocol/file
                        FileProtocolTest.java
  Log:
   o Re-enabled testGetOutputStream() modified to only use getContentLength()
     to verify sizes so that the URL connection has a chance to sync the fd
     if running on windows
  
  Revision  Changes    Path
  1.3       +20 -16    incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/net/protocol/file/FileProtocolTest.java
  
  Index: FileProtocolTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/net/protocol/file/FileProtocolTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FileProtocolTest.java	2 Sep 2003 03:47:40 -0000	1.2
  +++ FileProtocolTest.java	2 Sep 2003 07:52:44 -0000	1.3
  @@ -75,7 +75,8 @@
    * @version $Revision$ $Date$
    */
   public class FileProtocolTest
  -        extends TestCase {
  +    extends TestCase
  +{
       static {
           //
           // Have to install factory to make sure that our file handler is used
  @@ -198,40 +199,43 @@
               // OK
           }
       }
  -
  -    public void testFoo() throws Exception {
  +    
  +    public void testSyncFDUpdatesFileLength() throws Exception {
           File foo = File.createTempFile("TestFileLength", ".tmp");
           FileOutputStream fos = new FileOutputStream(foo);
           OutputStream out = new BufferedOutputStream(fos);
           try {
               out.write(new byte[10]);
               out.flush();
  -//            out.close();
  +            // out.close();
               fos.getFD().sync(); // this is required on Windows for foo.length to be updated
               assertEquals(10, foo.length());
           } finally {
               foo.delete();
           }
       }
  -
  -    /*
  -     * This test fails on Windows because File.length() is not updated until the
  -     * OutputStream is closed or the underlying FileDescriptor sync()'ed
  -     */
  -    public void XtestGetOutputStream() throws Exception {
  +    
  +    public void testGetOutputStream() throws Exception {
           URLConnection c = fileURL.openConnection();
           OutputStream output = c.getOutputStream();
  -
  +        
           int length = 8;
           writeSomeBytes(output, length);
  -        output.close();
  -        assertEquals(length, file.length());
  +        
  +        // Do not check file length, may fail on windows
  +        // assertEquals(length, file.length());
  +        
  +        // This should work, as the connection should sync the fd
           assertEquals(length, c.getContentLength());
   
           writeSomeBytes(output, length);
  -        assertEquals(length * 2, file.length());
  +        
  +        // Do not check file length, may fail on windows
  +        // assertEquals(length * 2, file.length());
  +        
  +        // This should work, as the connection should sync the fd
           assertEquals(length * 2, c.getContentLength());
  -
  +        
           try {
               output.close();
               writeSomeBytes(output, 1);
  
  
  

Mime
View raw message