On Sat, Aug 1, 2009 at 5:02 AM, Kevin Zhou<zhoukevi...@gmail.com> wrote: > Hi Nathan, > Yes. Actually I do try the String(byte[], String) on z/OS but still fail to > solve the previous failure. As I tested, the Socket on Z returns strings in > platform-dependent encoding, thus the String(byte[]) is adopted.
Why is this even asserting with Strings? Shouldn't the assertions be using byte values for fixtures? > > On Sat, Aug 1, 2009 at 7:16 AM, Nathan Beyer <ndbe...@apache.org> wrote: > >> This code is now platform-dependant. The String(byte[]) assumes the >> bytes are encoded in the platform's default encoding. The code should >> really use String(byte[], String) with a specific encoding. >> >> -Nathan >> >> On Thu, Jul 30, 2009 at 10:29 PM, <zhouke...@apache.org> wrote: >> > Author: zhoukevin >> > Date: Fri Jul 31 03:29:46 2009 >> > New Revision: 799505 >> > >> > URL: http://svn.apache.org/viewvc?rev=799505&view=rev >> > Log: >> > Fix test failure of SocketTest.test_sendUrgentDataI method for z/OS. >> > >> > 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=799505&r1=799504&r2=799505&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 Jul 31 03:29:46 2009 >> > @@ -1582,8 +1582,10 @@ >> > server.close(); >> > >> > receivedString = new String(myBytes, 0, totalBytesRead); >> > - assertEquals("Urgent data was not received with one urgent >> byte", >> > - sendString + (char) urgentByte + sendString, >> receivedString); >> > + assertEquals( >> > + "Urgent data was not received with one urgent byte", >> > + sendString + new String(new byte[] { urgentByte }) + >> sendString, >> > + receivedString); >> > >> > /* >> > * Test 3: Now validate that urgent data is received as expected. >> Expect >> > @@ -1634,7 +1636,8 @@ >> > >> > receivedString = new String(myBytes, 0, totalBytesRead); >> > assertEquals("Urgent data was not received with two urgent >> bytes", >> > - sendString + (char) urgentByte1 + (char) urgentByte2 >> > + sendString >> > + + new String(new byte[] { urgentByte1, >> urgentByte2 }) >> > + sendString, receivedString); >> > >> > /* >> > @@ -1663,8 +1666,8 @@ >> > client.close(); >> > server.close(); >> > >> > - assertEquals("Sole urgent data was not received", (int) >> urgentByte, >> > - byteRead); >> > + assertEquals("Sole urgent data was not received", >> > + (int) (urgentByte & 0xff), byteRead); >> > } >> > >> > /** >> > >> > >> > >> > > > > -- > Best regards, > Yours, Kevin Zhou >