Author: pero Date: Thu Jan 5 11:32:21 2006 New Revision: 366254 URL: http://svn.apache.org/viewcvs?rev=366254&view=rev Log: Activate junit tests
Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/io/XByteBuffer.java tomcat/container/tc5.5.x/modules/cluster/test/build.xml tomcat/container/tc5.5.x/modules/cluster/test/src/share/org/apache/catalina/cluster/io/XByteBufferTest.java tomcat/container/tc5.5.x/modules/cluster/test/src/share/org/apache/catalina/cluster/tcp/DataSenderTest.java Modified: tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/io/XByteBuffer.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/io/XByteBuffer.java?rev=366254&r1=366253&r2=366254&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/io/XByteBuffer.java (original) +++ tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/io/XByteBuffer.java Thu Jan 5 11:32:21 2006 @@ -346,7 +346,7 @@ + END_DATA.length]; System.arraycopy(START_DATA, 0, result, 0, START_DATA.length); System.arraycopy(toBytes(ClusterMessage.FLAG_FORBIDDEN), 0, result, START_DATA.length, 4); - System.arraycopy(toBytes(data.length), 0, result, START_DATA.length, 8); + System.arraycopy(toBytes(data.length), 0, result, START_DATA.length + 4, 4); System.arraycopy(data, 0, result, START_DATA.length + 8, data.length); System.arraycopy(END_DATA, 0, result, START_DATA.length + 8 + data.length, END_DATA.length); Modified: tomcat/container/tc5.5.x/modules/cluster/test/build.xml URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/test/build.xml?rev=366254&r1=366253&r2=366254&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/cluster/test/build.xml (original) +++ tomcat/container/tc5.5.x/modules/cluster/test/build.xml Thu Jan 5 11:32:21 2006 @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="ISO-8859-1"?> <!-- @author Peter Rossbach --> <project name="Tomcat: Cluster Testcases" basedir="." default="test"> - <property file="../../../../build.properties" /> - <property file="../../../../jakarta-tomcat-5/build.properties.default" /> + <property file="../../../../build/build.properties" /> + <property file="../../../../build/build.properties.default" /> <property name="test.report.logs" value="logs/reports" /> <property name="test.results" value="logs/test-results" /> @@ -14,7 +14,7 @@ <property name="compile.encoding" value="ISO-8859-1" /> <property name="build.dir" value="build/test" /> <property name="src.dir" value="src/share" /> - <property name="catalina.home" value="../../../../jakarta-tomcat-5/build" /> + <property name="catalina.home" value="../../../../build/build" /> <!-- Build the classpath --> <path id="project.classpath"> Modified: tomcat/container/tc5.5.x/modules/cluster/test/src/share/org/apache/catalina/cluster/io/XByteBufferTest.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/test/src/share/org/apache/catalina/cluster/io/XByteBufferTest.java?rev=366254&r1=366253&r2=366254&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/cluster/test/src/share/org/apache/catalina/cluster/io/XByteBufferTest.java (original) +++ tomcat/container/tc5.5.x/modules/cluster/test/src/share/org/apache/catalina/cluster/io/XByteBufferTest.java Thu Jan 5 11:32:21 2006 @@ -82,12 +82,14 @@ for (byte i = 1; i < 4; i++) { data = b.extractPackage(true); d = data.getMessage(); - assertEquals(i, d[0]); + assertEquals("wrong message content",i, d[0]); } } /** - * @return + * create three message inside one byte buffer + * @return three clustermessage at one byte array + * @see XByteBuffer#createDataPackage(byte[]) * @throws IOException */ private byte[] createMessage() throws IOException { @@ -105,7 +107,7 @@ /** * Test the type convertes to and from byte array */ - public void testTypeconverter() { + public void testTypeConverter() { byte[] d = XByteBuffer.toBytes(Integer.MAX_VALUE); assertEquals(4, d.length); assertEquals(Integer.MAX_VALUE, XByteBuffer.toInt(d, 0)); Modified: tomcat/container/tc5.5.x/modules/cluster/test/src/share/org/apache/catalina/cluster/tcp/DataSenderTest.java URL: http://svn.apache.org/viewcvs/tomcat/container/tc5.5.x/modules/cluster/test/src/share/org/apache/catalina/cluster/tcp/DataSenderTest.java?rev=366254&r1=366253&r2=366254&view=diff ============================================================================== --- tomcat/container/tc5.5.x/modules/cluster/test/src/share/org/apache/catalina/cluster/tcp/DataSenderTest.java (original) +++ tomcat/container/tc5.5.x/modules/cluster/test/src/share/org/apache/catalina/cluster/tcp/DataSenderTest.java Thu Jan 5 11:32:21 2006 @@ -133,15 +133,16 @@ ClusterData data = new ClusterData("test", "123",new byte[]{ 1,2,3 }, System.currentTimeMillis() ); sender.writeData(data) ; ByteArrayOutputStream stream = (ByteArrayOutputStream)sender.getSocket().getOutputStream(); - assertEquals(21,stream.size()); + assertEquals(25,stream.size()); ByteArrayInputStream istream = (ByteArrayInputStream)sender.getSocket().getInputStream(); - assertEquals(-1,istream.read()); + assertEquals(6,istream.read()); MockSocket socket =((MockSocket)sender.getSocket()); socket.reset(); + sender.setWaitForAck(true); socket.setReadIOException(true); try { sender.writeData(data); - fail("Missing Ack IOExcpetion") ; + fail("Missing Ack IOException") ; } catch (IOException ioe) {} ; socket.reset(); socket.setReadIOException(false); @@ -165,7 +166,7 @@ ClusterData data = new ClusterData("test", "123",new byte[]{ 1,2,3 }, System.currentTimeMillis() ); sender.writeData(data) ; ByteArrayOutputStream stream = (ByteArrayOutputStream)sender.getSocket().getOutputStream(); - assertEquals(21,stream.size()); + assertEquals(25,stream.size()); ByteArrayInputStream istream = (ByteArrayInputStream)sender.getSocket().getInputStream(); assertEquals(3,TcpReplicationThread.ACK_COMMAND.length); assertEquals(TcpReplicationThread.ACK_COMMAND[0],istream.read()); @@ -177,7 +178,7 @@ * Check close socket fro keep alive handling is correct (number of request and timeout * @throws Exception */ - public void testcheckKeepAlive() throws Exception { + public void testCheckKeepAlive() throws Exception { DataSender sender = createMockDataSender() ; assertFalse(sender.checkKeepAlive()) ; sender.setKeepAliveMaxRequestCount(1); @@ -222,6 +223,7 @@ public void testPushMessageRetryFailure() throws Exception { InetAddress host = InetAddress.getByName("127.0.0.1"); DataSender sender = new MockDataSender("catalina",host, 3434); + sender.setResend(true); sender.openSocket() ; ((MockSocket)sender.getSocket()).setWriteIOException(true); assertPushMessage(sender); @@ -230,15 +232,33 @@ } /** + * Test socket closed after socket write failure without retry + * @throws Exception + */ + public void testPushMessageFailure() throws Exception { + InetAddress host = InetAddress.getByName("127.0.0.1"); + DataSender sender = new MockDataSender("catalina",host, 3434); + sender.openSocket() ; + ((MockSocket)sender.getSocket()).setWriteIOException(true); + try { + assertPushMessage(sender); + fail("No IOException is thrown"); + } catch (IOException ioe) {} + assertFalse(sender.isConnected()); + assertEquals(1,sender.getSocketOpenCounter()); + assertEquals(1,sender.getSocketCloseCounter()); + } + + /** * @param sender * @throws IOException */ private void assertPushMessage(DataSender sender) throws IOException { ByteArrayOutputStream stream = pushMessage(sender); - assertEquals(21,stream.size()); - assertEquals(1,sender.getKeepAliveCount()); - assertEquals(1,sender.getNrOfRequests()); - assertEquals(0,sender.getProcessingTime()); + assertEquals("message format is wrong",25,stream.size()); + assertEquals("socket is not at keep alive mode",1,sender.getKeepAliveCount()); + assertEquals("no stats or wrong number of request message counter",1,sender.getNrOfRequests()); + assertEquals("to long operation",0,sender.getProcessingTime()); assertEquals(Long.MAX_VALUE,sender.getMinProcessingTime()); } @@ -250,7 +270,7 @@ private ByteArrayOutputStream pushMessage(DataSender sender) throws IOException { ClusterData data = new ClusterData("unique-id", "123",new byte[]{ 1,2,3 }, System.currentTimeMillis() ); sender.pushMessage(data ); - assertTrue(sender.isConnected()); + assertTrue("sender is not connect after message pushed!",sender.isConnected()); ByteArrayOutputStream stream = (ByteArrayOutputStream)sender.getSocket().getOutputStream(); return stream; } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]