Author: kkolinko
Date: Sat Nov  7 15:57:16 2015
New Revision: 1713149

URL: http://svn.apache.org/viewvc?rev=1713149&view=rev
Log:
Align test class with Tomcat 7.
- CHANNEL_COUNT is a constant
- Ensuring that n values are the same as [0]==[1], [1]==[2], [2]==[3] is the 
same as [0]==[1], [0]==[2], [0]==[3], but error message becomes more clear.

Modified:
    
tomcat/tc6.0.x/trunk/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java

Modified: 
tomcat/tc6.0.x/trunk/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java?rev=1713149&r1=1713148&r2=1713149&view=diff
==============================================================================
--- 
tomcat/tc6.0.x/trunk/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java
 (original)
+++ 
tomcat/tc6.0.x/trunk/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java
 Sat Nov  7 15:57:16 2015
@@ -29,18 +29,18 @@ import org.apache.catalina.tribes.group.
 
 public class TestNonBlockingCoordinator {
 
+    private static final int CHANNEL_COUNT = 10;
+
     private GroupChannel[] channels = null;
     private NonBlockingCoordinator[] coordinators = null;
-    private final int channelCount = 10;
-    private Thread[] threads = null;
 
     @Before
     public void setUp() throws Exception {
         System.out.println("Setup");
-        channels = new GroupChannel[channelCount];
-        coordinators = new NonBlockingCoordinator[channelCount];
-        threads = new Thread[channelCount];
-        for ( int i=0; i<channelCount; i++ ) {
+        channels = new GroupChannel[CHANNEL_COUNT];
+        coordinators = new NonBlockingCoordinator[CHANNEL_COUNT];
+        Thread[] threads = new Thread[CHANNEL_COUNT];
+        for ( int i=0; i<CHANNEL_COUNT; i++ ) {
             channels[i] = new GroupChannel();
             coordinators[i] = new NonBlockingCoordinator();
             channels[i].addInterceptor(coordinators[i]);
@@ -59,10 +59,10 @@ public class TestNonBlockingCoordinator
             };
         }
         TesterUtil.addRandomDomain(channels);
-        for (int i = 0; i < channelCount; i++) {
+        for (int i = 0; i < CHANNEL_COUNT; i++) {
             threads[i].start();
         }
-        for (int i = 0; i < channelCount; i++) {
+        for (int i = 0; i < CHANNEL_COUNT; i++) {
             threads[i].join();
         }
         Thread.sleep(1000);
@@ -70,9 +70,9 @@ public class TestNonBlockingCoordinator
 
     @Test
     public void testCoord1() throws Exception {
-        for (int i = 1; i < channelCount; i++) {
-            assertEquals("Message count expected to be equal.",
-                    channels[i - 1].getMembers().length,
+        int expectedCount = channels[0].getMembers().length;
+        for (int i = 1; i < CHANNEL_COUNT; i++) {
+            assertEquals("Message count expected to be equal.", expectedCount,
                     channels[i].getMembers().length);
         }
         Member member = coordinators[0].getCoordinator();
@@ -85,10 +85,10 @@ public class TestNonBlockingCoordinator
                 /* Ignore */
             }
         }
-        for (int i=0; i<channelCount; i++ ) {
-            assertEquals(member,coordinators[i].getCoordinator());
+        for (int i = 0; i < CHANNEL_COUNT; i++) {
+            assertEquals(member, coordinators[i].getCoordinator());
         }
-        System.out.println("Coordinator[1] is:"+member);
+        System.out.println("Coordinator[1] is:" + member);
     }
 
     @Test
@@ -96,7 +96,7 @@ public class TestNonBlockingCoordinator
         Member member = coordinators[1].getCoordinator();
         System.out.println("Coordinator[2a] is:" + member);
         int index = -1;
-        for ( int i=0; i<channelCount; i++ ) {
+        for ( int i=0; i<CHANNEL_COUNT; i++ ) {
             if ( channels[i].getLocalMember(false).equals(member) ) {
                 System.out.println("Shutting down:" + 
channels[i].getLocalMember(true).toString());
                 channels[i].stop(Channel.DEFAULT);
@@ -112,7 +112,7 @@ public class TestNonBlockingCoordinator
         }
         System.out.println("Member 
count:"+channels[index].getMembers().length);
         member = coordinators[index].getCoordinator();
-        for (int i = 1; i < channelCount; i++) {
+        for (int i = 1; i < CHANNEL_COUNT; i++) {
             if (i != dead) {
                 assertEquals(member, coordinators[i].getCoordinator());
             }
@@ -123,7 +123,7 @@ public class TestNonBlockingCoordinator
     @After
     public void tearDown() throws Exception {
         System.out.println("tearDown");
-        for ( int i=0; i<channelCount; i++ ) {
+        for ( int i=0; i<CHANNEL_COUNT; i++ ) {
             channels[i].stop(Channel.DEFAULT);
         }
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to