You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by re...@apache.org on 2009/04/17 04:36:01 UTC

svn commit: r765837 - /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java

Author: regisxu
Date: Fri Apr 17 02:36:00 2009
New Revision: 765837

URL: http://svn.apache.org/viewvc?rev=765837&view=rev
Log:
Apply fix for HARMONY-6092

Since SocketTest.test_getInputStream are failed both on RI and Harmony with the same behaviors, fix the test case to pass on Linux.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java?rev=765837&r1=765836&r2=765837&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java Fri Apr 17 02:36:00 2009
@@ -35,6 +35,7 @@
 import java.net.SocketTimeoutException;
 import java.net.UnknownHostException;
 import java.security.Permission;
+import java.util.Locale;
 
 import org.apache.harmony.luni.net.PlainSocketImpl;
 
@@ -860,19 +861,55 @@
 
         InputStream in = pingClient.getInputStream();
         in.read(new byte[42]);
-
-        // Check EOF
-        assertEquals(-1, in.read());
+        if (isUnix()) {
+            try {
+                in.read();
+                fail("Should throw SocketException");
+            } catch (SocketException e) {
+                // expected
+            }
+        } else {
+            // Check EOF
+            assertEquals(-1, in.read());
+        }
 
         in.close();
 
-        // No exception when reading a closed stream
-        assertEquals(-1, in.read());
+        if (isUnix()) {
+            try {
+                in.read();
+                fail("Should throw SocketException");
+            } catch (SocketException e) {
+                // expected
+            }
+            try {
+                in.read(new byte[5]);
+                fail("Should throw SocketException");
+            } catch (SocketException e) {
+                // expected
+            }
+        } else {
+            // No exception when reading a closed stream
+            assertEquals(-1, in.read());
+            assertEquals(-1, in.read(new byte[5]));
+        }
 
         pingClient.close();
         pingServer.close();
     }
 
+    private boolean isUnix() {
+        String osName = System.getProperty("os.name");
+
+        // only comparing ASCII, so assume english locale
+        osName = (osName == null ? null : osName.toLowerCase(Locale.ENGLISH));
+
+        if (osName != null && osName.startsWith("windows")) { //$NON-NLS-1$
+            return false;
+        }
+        return true;
+    }
+
     /**
      * @tests java.net.Socket#getKeepAlive()
      */



Re: [test] Platform spcific tests

Posted by Regis <xu...@gmail.com>.
Regis wrote:
> Regis wrote:
>> Tim Ellison wrote:
>>> Regis wrote:
>>>> Tim Ellison wrote:
>>>>> Regis wrote:
>>>>>> RI has the different behaviors on Linux and Windows in this test 
>>>>>> case,
>>>>>> and Harmony has the exactly the same behaviors, so I think our
>>>>>> implementation is OK.
>>>>>>
>>>>>> And there are some other similar cases in SocketTest, which failed on
>>>>>> Linux but passed on Windows, I think it's why it is in
>>>>>> exclude.linux.x86.drl. If we fixed them, SocketTest could be moved 
>>>>>> from
>>>>>> exclude list.
>>>>> It wasn't the fact that there is a difference that I object to 
>>>>> here, but
>>>>> the way you have achieved it does not fit in the Harmony architecture.
>>>>>
>>>>> These types of differences are pushed into the native code.  I believe
>>>>> that this should be done here too.
>>>> Our tests are all written in java, I think it's better to keep it. How
>>>> about move these platform depended tests to platform directory, like
>>>> UnixSocketTest or WinSocketTest?
>>>
>>> D'oh, sorry, I had missed that they are tests!
>>>
>>> The platform specific tests are sorted into directories under
>>>   src/test/api        (Java API-based tests)
>>> or
>>>   src/test/impl        (Harmony impl types tests)
>>>
>>>
>>> The test you modified is in
>>>   src/test/api/common
>>>
>>> but if it is platform specific, the relevant parts of the test should be
>>> in one of
>>>   src/test/api/windows
>>> or
>>>   src/test/api/unix
>>>
>>>
>>> Does that make sense?
>>>
>>> Regards,
>>> Tim
>>>
>>>
>>>
>>
>> All right, I'll move them to platform folder.
>>
> 
> The new fix committed at r766631. I'll continue tide-up SocketTest, and 
> try to move it out from exclude list.
> 

I have completed tide-up of SocketTest, and delete it from exclude.linux.x86.drl 
and exclude.linux.x86_64.drl. I tested on Win32 and Linux32, it works fine for 
me, I think it should work on Linux64 as well.

-- 
Best Regards,
Regis.

Re: [test] Platform spcific tests

Posted by Tim Ellison <t....@gmail.com>.
Regis wrote:
> The new fix committed at r766631. I'll continue tide-up SocketTest, and
> try to move it out from exclude list.

Cool!


Re: [test] Platform spcific tests

Posted by Regis <xu...@gmail.com>.
Regis wrote:
> Tim Ellison wrote:
>> Regis wrote:
>>> Tim Ellison wrote:
>>>> Regis wrote:
>>>>> RI has the different behaviors on Linux and Windows in this test case,
>>>>> and Harmony has the exactly the same behaviors, so I think our
>>>>> implementation is OK.
>>>>>
>>>>> And there are some other similar cases in SocketTest, which failed on
>>>>> Linux but passed on Windows, I think it's why it is in
>>>>> exclude.linux.x86.drl. If we fixed them, SocketTest could be moved 
>>>>> from
>>>>> exclude list.
>>>> It wasn't the fact that there is a difference that I object to here, 
>>>> but
>>>> the way you have achieved it does not fit in the Harmony architecture.
>>>>
>>>> These types of differences are pushed into the native code.  I believe
>>>> that this should be done here too.
>>> Our tests are all written in java, I think it's better to keep it. How
>>> about move these platform depended tests to platform directory, like
>>> UnixSocketTest or WinSocketTest?
>>
>> D'oh, sorry, I had missed that they are tests!
>>
>> The platform specific tests are sorted into directories under
>>   src/test/api        (Java API-based tests)
>> or
>>   src/test/impl        (Harmony impl types tests)
>>
>>
>> The test you modified is in
>>   src/test/api/common
>>
>> but if it is platform specific, the relevant parts of the test should be
>> in one of
>>   src/test/api/windows
>> or
>>   src/test/api/unix
>>
>>
>> Does that make sense?
>>
>> Regards,
>> Tim
>>
>>
>>
> 
> All right, I'll move them to platform folder.
> 

The new fix committed at r766631. I'll continue tide-up SocketTest, and try to 
move it out from exclude list.

-- 
Best Regards,
Regis.

Re: [test] Platform spcific tests

Posted by Regis <xu...@gmail.com>.
Tim Ellison wrote:
> Regis wrote:
>> Tim Ellison wrote:
>>> Regis wrote:
>>>> RI has the different behaviors on Linux and Windows in this test case,
>>>> and Harmony has the exactly the same behaviors, so I think our
>>>> implementation is OK.
>>>>
>>>> And there are some other similar cases in SocketTest, which failed on
>>>> Linux but passed on Windows, I think it's why it is in
>>>> exclude.linux.x86.drl. If we fixed them, SocketTest could be moved from
>>>> exclude list.
>>> It wasn't the fact that there is a difference that I object to here, but
>>> the way you have achieved it does not fit in the Harmony architecture.
>>>
>>> These types of differences are pushed into the native code.  I believe
>>> that this should be done here too.
>> Our tests are all written in java, I think it's better to keep it. How
>> about move these platform depended tests to platform directory, like
>> UnixSocketTest or WinSocketTest?
> 
> D'oh, sorry, I had missed that they are tests!
> 
> The platform specific tests are sorted into directories under
>   src/test/api		(Java API-based tests)
> or
>   src/test/impl		(Harmony impl types tests)
> 
> 
> The test you modified is in
>   src/test/api/common
> 
> but if it is platform specific, the relevant parts of the test should be
> in one of
>   src/test/api/windows
> or
>   src/test/api/unix
> 
> 
> Does that make sense?
> 
> Regards,
> Tim
> 
> 
> 

All right, I'll move them to platform folder.

-- 
Best Regards,
Regis.

[test] Platform spcific tests (was: Re: svn commit: r765837 - /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java)

Posted by Tim Ellison <t....@gmail.com>.
Regis wrote:
> Tim Ellison wrote:
>> Regis wrote:
>>> RI has the different behaviors on Linux and Windows in this test case,
>>> and Harmony has the exactly the same behaviors, so I think our
>>> implementation is OK.
>>>
>>> And there are some other similar cases in SocketTest, which failed on
>>> Linux but passed on Windows, I think it's why it is in
>>> exclude.linux.x86.drl. If we fixed them, SocketTest could be moved from
>>> exclude list.
>>
>> It wasn't the fact that there is a difference that I object to here, but
>> the way you have achieved it does not fit in the Harmony architecture.
>>
>> These types of differences are pushed into the native code.  I believe
>> that this should be done here too.
> 
> Our tests are all written in java, I think it's better to keep it. How
> about move these platform depended tests to platform directory, like
> UnixSocketTest or WinSocketTest?

D'oh, sorry, I had missed that they are tests!

The platform specific tests are sorted into directories under
  src/test/api		(Java API-based tests)
or
  src/test/impl		(Harmony impl types tests)


The test you modified is in
  src/test/api/common

but if it is platform specific, the relevant parts of the test should be
in one of
  src/test/api/windows
or
  src/test/api/unix


Does that make sense?

Regards,
Tim



Re: svn commit: r765837 - /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java

Posted by Regis <xu...@gmail.com>.
Tim Ellison wrote:
> Regis wrote:
>> RI has the different behaviors on Linux and Windows in this test case,
>> and Harmony has the exactly the same behaviors, so I think our
>> implementation is OK.
>>
>> And there are some other similar cases in SocketTest, which failed on
>> Linux but passed on Windows, I think it's why it is in 
>> exclude.linux.x86.drl. If we fixed them, SocketTest could be moved from
>> exclude list.
> 
> It wasn't the fact that there is a difference that I object to here, but
> the way you have achieved it does not fit in the Harmony architecture.
> 
> These types of differences are pushed into the native code.  I believe
> that this should be done here too.

Our tests are all written in java, I think it's better to keep it. How about 
move these platform depended tests to platform directory, like UnixSocketTest or 
WinSocketTest?

> 
> Regards,
> Tim
> 
> 
> 
>> Tim Ellison wrote:
>>> Is this necessary? I thought it was already fixed during M9 close down?
>>>
>>> I object to having platform specific Java code like this.  We push these
>>> behavior differences into the native code.
>>>
>>> Regards,
>>> Tim
>>>
>>> regisxu@apache.org wrote:
>>>> Author: regisxu
>>>> Date: Fri Apr 17 02:36:00 2009
>>>> New Revision: 765837
>>>>
>>>> URL: http://svn.apache.org/viewvc?rev=765837&view=rev
>>>> Log:
>>>> Apply fix for HARMONY-6092
>>>>
>>>> Since SocketTest.test_getInputStream are failed both on RI and
>>>> Harmony with the same behaviors, fix the test case to pass on Linux.
>>>>
>>>> Modified:
>>>>    
>>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
>>>>
>>>>
>>>> Modified:
>>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
>>>>
>>>> URL:
>>>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java?rev=765837&r1=765836&r2=765837&view=diff
>>>>
>>>> ==============================================================================
>>>>
>>>> ---
>>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
>>>> (original)
>>>> +++
>>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
>>>> Fri Apr 17 02:36:00 2009
>>>> @@ -35,6 +35,7 @@
>>>>  import java.net.SocketTimeoutException;
>>>>  import java.net.UnknownHostException;
>>>>  import java.security.Permission;
>>>> +import java.util.Locale;
>>>>  
>>>>  import org.apache.harmony.luni.net.PlainSocketImpl;
>>>>  
>>>> @@ -860,19 +861,55 @@
>>>>  
>>>>          InputStream in = pingClient.getInputStream();
>>>>          in.read(new byte[42]);
>>>> -
>>>> -        // Check EOF
>>>> -        assertEquals(-1, in.read());
>>>> +        if (isUnix()) {
>>>> +            try {
>>>> +                in.read();
>>>> +                fail("Should throw SocketException");
>>>> +            } catch (SocketException e) {
>>>> +                // expected
>>>> +            }
>>>> +        } else {
>>>> +            // Check EOF
>>>> +            assertEquals(-1, in.read());
>>>> +        }
>>>>  
>>>>          in.close();
>>>>  
>>>> -        // No exception when reading a closed stream
>>>> -        assertEquals(-1, in.read());
>>>> +        if (isUnix()) {
>>>> +            try {
>>>> +                in.read();
>>>> +                fail("Should throw SocketException");
>>>> +            } catch (SocketException e) {
>>>> +                // expected
>>>> +            }
>>>> +            try {
>>>> +                in.read(new byte[5]);
>>>> +                fail("Should throw SocketException");
>>>> +            } catch (SocketException e) {
>>>> +                // expected
>>>> +            }
>>>> +        } else {
>>>> +            // No exception when reading a closed stream
>>>> +            assertEquals(-1, in.read());
>>>> +            assertEquals(-1, in.read(new byte[5]));
>>>> +        }
>>>>  
>>>>          pingClient.close();
>>>>          pingServer.close();
>>>>      }
>>>>  
>>>> +    private boolean isUnix() {
>>>> +        String osName = System.getProperty("os.name");
>>>> +
>>>> +        // only comparing ASCII, so assume english locale
>>>> +        osName = (osName == null ? null :
>>>> osName.toLowerCase(Locale.ENGLISH));
>>>> +
>>>> +        if (osName != null && osName.startsWith("windows")) {
>>>> //$NON-NLS-1$
>>>> +            return false;
>>>> +        }
>>>> +        return true;
>>>> +    }
>>>> +
>>>>      /**
>>>>       * @tests java.net.Socket#getKeepAlive()
>>>>       */
>>>>
>>>>
>>>>
>>
> 


-- 
Best Regards,
Regis.

Re: svn commit: r765837 - /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java

Posted by Tim Ellison <t....@gmail.com>.
Regis wrote:
> RI has the different behaviors on Linux and Windows in this test case,
> and Harmony has the exactly the same behaviors, so I think our
> implementation is OK.
> 
> And there are some other similar cases in SocketTest, which failed on
> Linux but passed on Windows, I think it's why it is in 
> exclude.linux.x86.drl. If we fixed them, SocketTest could be moved from
> exclude list.

It wasn't the fact that there is a difference that I object to here, but
the way you have achieved it does not fit in the Harmony architecture.

These types of differences are pushed into the native code.  I believe
that this should be done here too.

Regards,
Tim



> Tim Ellison wrote:
>> Is this necessary? I thought it was already fixed during M9 close down?
>>
>> I object to having platform specific Java code like this.  We push these
>> behavior differences into the native code.
>>
>> Regards,
>> Tim
>>
>> regisxu@apache.org wrote:
>>> Author: regisxu
>>> Date: Fri Apr 17 02:36:00 2009
>>> New Revision: 765837
>>>
>>> URL: http://svn.apache.org/viewvc?rev=765837&view=rev
>>> Log:
>>> Apply fix for HARMONY-6092
>>>
>>> Since SocketTest.test_getInputStream are failed both on RI and
>>> Harmony with the same behaviors, fix the test case to pass on Linux.
>>>
>>> Modified:
>>>    
>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
>>>
>>>
>>> Modified:
>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
>>>
>>> URL:
>>> http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java?rev=765837&r1=765836&r2=765837&view=diff
>>>
>>> ==============================================================================
>>>
>>> ---
>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
>>> (original)
>>> +++
>>> harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
>>> Fri Apr 17 02:36:00 2009
>>> @@ -35,6 +35,7 @@
>>>  import java.net.SocketTimeoutException;
>>>  import java.net.UnknownHostException;
>>>  import java.security.Permission;
>>> +import java.util.Locale;
>>>  
>>>  import org.apache.harmony.luni.net.PlainSocketImpl;
>>>  
>>> @@ -860,19 +861,55 @@
>>>  
>>>          InputStream in = pingClient.getInputStream();
>>>          in.read(new byte[42]);
>>> -
>>> -        // Check EOF
>>> -        assertEquals(-1, in.read());
>>> +        if (isUnix()) {
>>> +            try {
>>> +                in.read();
>>> +                fail("Should throw SocketException");
>>> +            } catch (SocketException e) {
>>> +                // expected
>>> +            }
>>> +        } else {
>>> +            // Check EOF
>>> +            assertEquals(-1, in.read());
>>> +        }
>>>  
>>>          in.close();
>>>  
>>> -        // No exception when reading a closed stream
>>> -        assertEquals(-1, in.read());
>>> +        if (isUnix()) {
>>> +            try {
>>> +                in.read();
>>> +                fail("Should throw SocketException");
>>> +            } catch (SocketException e) {
>>> +                // expected
>>> +            }
>>> +            try {
>>> +                in.read(new byte[5]);
>>> +                fail("Should throw SocketException");
>>> +            } catch (SocketException e) {
>>> +                // expected
>>> +            }
>>> +        } else {
>>> +            // No exception when reading a closed stream
>>> +            assertEquals(-1, in.read());
>>> +            assertEquals(-1, in.read(new byte[5]));
>>> +        }
>>>  
>>>          pingClient.close();
>>>          pingServer.close();
>>>      }
>>>  
>>> +    private boolean isUnix() {
>>> +        String osName = System.getProperty("os.name");
>>> +
>>> +        // only comparing ASCII, so assume english locale
>>> +        osName = (osName == null ? null :
>>> osName.toLowerCase(Locale.ENGLISH));
>>> +
>>> +        if (osName != null && osName.startsWith("windows")) {
>>> //$NON-NLS-1$
>>> +            return false;
>>> +        }
>>> +        return true;
>>> +    }
>>> +
>>>      /**
>>>       * @tests java.net.Socket#getKeepAlive()
>>>       */
>>>
>>>
>>>
>>
> 
> 

Re: svn commit: r765837 - /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java

Posted by Regis <xu...@gmail.com>.
RI has the different behaviors on Linux and Windows in this test case, and 
Harmony has the exactly the same behaviors, so I think our implementation is OK.

And there are some other similar cases in SocketTest, which failed on Linux but 
passed on Windows, I think it's why it is in  exclude.linux.x86.drl. If we fixed 
them, SocketTest could be moved from exclude list.


Tim Ellison wrote:
> Is this necessary? I thought it was already fixed during M9 close down?
> 
> I object to having platform specific Java code like this.  We push these
> behavior differences into the native code.
> 
> Regards,
> Tim
> 
> regisxu@apache.org wrote:
>> Author: regisxu
>> Date: Fri Apr 17 02:36:00 2009
>> New Revision: 765837
>>
>> URL: http://svn.apache.org/viewvc?rev=765837&view=rev
>> Log:
>> Apply fix for HARMONY-6092
>>
>> Since SocketTest.test_getInputStream are failed both on RI and Harmony with the same behaviors, fix the test case to pass on Linux.
>>
>> Modified:
>>     harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
>>
>> Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
>> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java?rev=765837&r1=765836&r2=765837&view=diff
>> ==============================================================================
>> --- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java (original)
>> +++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java Fri Apr 17 02:36:00 2009
>> @@ -35,6 +35,7 @@
>>  import java.net.SocketTimeoutException;
>>  import java.net.UnknownHostException;
>>  import java.security.Permission;
>> +import java.util.Locale;
>>  
>>  import org.apache.harmony.luni.net.PlainSocketImpl;
>>  
>> @@ -860,19 +861,55 @@
>>  
>>          InputStream in = pingClient.getInputStream();
>>          in.read(new byte[42]);
>> -
>> -        // Check EOF
>> -        assertEquals(-1, in.read());
>> +        if (isUnix()) {
>> +            try {
>> +                in.read();
>> +                fail("Should throw SocketException");
>> +            } catch (SocketException e) {
>> +                // expected
>> +            }
>> +        } else {
>> +            // Check EOF
>> +            assertEquals(-1, in.read());
>> +        }
>>  
>>          in.close();
>>  
>> -        // No exception when reading a closed stream
>> -        assertEquals(-1, in.read());
>> +        if (isUnix()) {
>> +            try {
>> +                in.read();
>> +                fail("Should throw SocketException");
>> +            } catch (SocketException e) {
>> +                // expected
>> +            }
>> +            try {
>> +                in.read(new byte[5]);
>> +                fail("Should throw SocketException");
>> +            } catch (SocketException e) {
>> +                // expected
>> +            }
>> +        } else {
>> +            // No exception when reading a closed stream
>> +            assertEquals(-1, in.read());
>> +            assertEquals(-1, in.read(new byte[5]));
>> +        }
>>  
>>          pingClient.close();
>>          pingServer.close();
>>      }
>>  
>> +    private boolean isUnix() {
>> +        String osName = System.getProperty("os.name");
>> +
>> +        // only comparing ASCII, so assume english locale
>> +        osName = (osName == null ? null : osName.toLowerCase(Locale.ENGLISH));
>> +
>> +        if (osName != null && osName.startsWith("windows")) { //$NON-NLS-1$
>> +            return false;
>> +        }
>> +        return true;
>> +    }
>> +
>>      /**
>>       * @tests java.net.Socket#getKeepAlive()
>>       */
>>
>>
>>
> 


-- 
Best Regards,
Regis.

Re: svn commit: r765837 - /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java

Posted by Tim Ellison <t....@gmail.com>.
Is this necessary? I thought it was already fixed during M9 close down?

I object to having platform specific Java code like this.  We push these
behavior differences into the native code.

Regards,
Tim

regisxu@apache.org wrote:
> Author: regisxu
> Date: Fri Apr 17 02:36:00 2009
> New Revision: 765837
> 
> URL: http://svn.apache.org/viewvc?rev=765837&view=rev
> Log:
> Apply fix for HARMONY-6092
> 
> Since SocketTest.test_getInputStream are failed both on RI and Harmony with the same behaviors, fix the test case to pass on Linux.
> 
> Modified:
>     harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
> 
> Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java?rev=765837&r1=765836&r2=765837&view=diff
> ==============================================================================
> --- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java (original)
> +++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java Fri Apr 17 02:36:00 2009
> @@ -35,6 +35,7 @@
>  import java.net.SocketTimeoutException;
>  import java.net.UnknownHostException;
>  import java.security.Permission;
> +import java.util.Locale;
>  
>  import org.apache.harmony.luni.net.PlainSocketImpl;
>  
> @@ -860,19 +861,55 @@
>  
>          InputStream in = pingClient.getInputStream();
>          in.read(new byte[42]);
> -
> -        // Check EOF
> -        assertEquals(-1, in.read());
> +        if (isUnix()) {
> +            try {
> +                in.read();
> +                fail("Should throw SocketException");
> +            } catch (SocketException e) {
> +                // expected
> +            }
> +        } else {
> +            // Check EOF
> +            assertEquals(-1, in.read());
> +        }
>  
>          in.close();
>  
> -        // No exception when reading a closed stream
> -        assertEquals(-1, in.read());
> +        if (isUnix()) {
> +            try {
> +                in.read();
> +                fail("Should throw SocketException");
> +            } catch (SocketException e) {
> +                // expected
> +            }
> +            try {
> +                in.read(new byte[5]);
> +                fail("Should throw SocketException");
> +            } catch (SocketException e) {
> +                // expected
> +            }
> +        } else {
> +            // No exception when reading a closed stream
> +            assertEquals(-1, in.read());
> +            assertEquals(-1, in.read(new byte[5]));
> +        }
>  
>          pingClient.close();
>          pingServer.close();
>      }
>  
> +    private boolean isUnix() {
> +        String osName = System.getProperty("os.name");
> +
> +        // only comparing ASCII, so assume english locale
> +        osName = (osName == null ? null : osName.toLowerCase(Locale.ENGLISH));
> +
> +        if (osName != null && osName.startsWith("windows")) { //$NON-NLS-1$
> +            return false;
> +        }
> +        return true;
> +    }
> +
>      /**
>       * @tests java.net.Socket#getKeepAlive()
>       */
> 
> 
>