[tomcat7] 02/03: Disable unit tests depending on network access
Miguel Landaeta
nomadium at moszumanska.debian.org
Sat Mar 28 13:01:39 UTC 2015
This is an automated email from the git hooks/post-receive script.
nomadium pushed a commit to branch master
in repository tomcat7.
commit 430b296d0a53a07df9e07338906194fcabfbc3c2
Author: Miguel Landaeta <nomadium at debian.org>
Date: Wed Mar 25 18:50:42 2015 -0300
Disable unit tests depending on network access
---
debian/changelog | 2 +-
...ble-unit-tests-depending-on-network-access.path | 1150 ++++++++++++++++++++
2 files changed, 1151 insertions(+), 1 deletion(-)
diff --git a/debian/changelog b/debian/changelog
index 3759bb5..f5884b8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-tomcat7 (7.0.59-2) experimental; urgency=medium
+tomcat7 (7.0.59-2) UNRELEASED; urgency=medium
* Fix FTBFS due to some X509 certificates provided by upstream expired
and were causing failures in unit tests as well, so they were
diff --git a/debian/patches/0024-disable-unit-tests-depending-on-network-access.path b/debian/patches/0024-disable-unit-tests-depending-on-network-access.path
new file mode 100644
index 0000000..71b3a91
--- /dev/null
+++ b/debian/patches/0024-disable-unit-tests-depending-on-network-access.path
@@ -0,0 +1,1150 @@
+Description: Disable unit tests that depends on network access
+ After fixing a FTBFS bug (#789519), I noticed this package kept
+ failing to build due to some failing test when is built in an
+ environment without network access.
+ tomcat7 (7.0.56-2) unstable; urgency=medium
+Author: Miguel Landaeta <nomadium at debian.org>
+Forwarded: no
+Last-Update: 2015-03-27
+
+diff --git a/test/org/apache/catalina/session/TestStandardSession.java b/test/org/apache/catalina/session/TestStandardSession.java
+index 1d9e448..d042be1 100644
+--- a/test/org/apache/catalina/session/TestStandardSession.java
++++ b/test/org/apache/catalina/session/TestStandardSession.java
+@@ -27,6 +27,7 @@ import javax.servlet.http.HttpSession;
+
+ import org.junit.Assert;
+ import org.junit.Test;
++import org.junit.Ignore;
+
+ import org.apache.catalina.Context;
+ import org.apache.catalina.ha.tcp.SimpleTcpCluster;
+@@ -39,7 +40,7 @@ public class TestStandardSession extends TomcatBaseTest {
+ /**
+ * Test session.invalidate() in a clustered environment.
+ */
+- @Test
++ @Ignore("it fails when tested in chroots without network like pbuilder")
+ public void testBug56578a() throws Exception {
+ doTestInvalidate(true);
+ }
+diff --git a/test/org/apache/catalina/tribes/group/TestGroupChannelMemberArrival.java b/test/org/apache/catalina/tribes/group/TestGroupChannelMemberArrival.java
+deleted file mode 100644
+index 3e5d022..0000000
+--- a/test/org/apache/catalina/tribes/group/TestGroupChannelMemberArrival.java
++++ /dev/null
+@@ -1,183 +0,0 @@
+-/*
+- * Licensed to the Apache Software Foundation (ASF) under one or more
+- * contributor license agreements. See the NOTICE file distributed with
+- * this work for additional information regarding copyright ownership.
+- * The ASF licenses this file to You under the Apache License, Version 2.0
+- * (the "License"); you may not use this file except in compliance with
+- * the License. You may obtain a copy of the License at
+- *
+- * http://www.apache.org/licenses/LICENSE-2.0
+- *
+- * Unless required by applicable law or agreed to in writing, software
+- * distributed under the License is distributed on an "AS IS" BASIS,
+- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+- * See the License for the specific language governing permissions and
+- * limitations under the License.
+- */
+-package org.apache.catalina.tribes.group;
+-
+-import java.util.ArrayList;
+-
+-import static org.junit.Assert.assertEquals;
+-
+-import org.junit.After;
+-import org.junit.Before;
+-import org.junit.Test;
+-
+-import org.apache.catalina.tribes.Channel;
+-import org.apache.catalina.tribes.ManagedChannel;
+-import org.apache.catalina.tribes.Member;
+-import org.apache.catalina.tribes.MembershipListener;
+-import org.apache.catalina.tribes.TesterUtil;
+-
+-public class TestGroupChannelMemberArrival {
+- private static int count = 10;
+- private ManagedChannel[] channels = new ManagedChannel[count];
+- private TestMbrListener[] listeners = new TestMbrListener[count];
+-
+- @Before
+- public void setUp() throws Exception {
+- for (int i = 0; i < channels.length; i++) {
+- channels[i] = new GroupChannel();
+- channels[i].getMembershipService().setPayload( ("Channel-" + (i + 1)).getBytes("ASCII"));
+- listeners[i] = new TestMbrListener( ("Listener-" + (i + 1)));
+- channels[i].addMembershipListener(listeners[i]);
+- }
+- TesterUtil.addRandomDomain(channels);
+- }
+-
+- @Test
+- public void testMemberArrival() throws Exception {
+- //purpose of this test is to make sure that we have received all the members
+- //that we can expect before the start method returns
+- Thread[] threads = new Thread[channels.length];
+- for (int i=0; i<channels.length; i++ ) {
+- final Channel channel = channels[i];
+- Thread t = new Thread() {
+- @Override
+- public void run() {
+- try {
+- channel.start(Channel.DEFAULT);
+- }catch ( Exception x ) {
+- throw new RuntimeException(x);
+- }
+- }
+- };
+- threads[i] = t;
+- }
+- for (int i = 0; i < threads.length; i++) {
+- threads[i].start();
+- }
+- for (int i = 0; i < threads.length; i++) {
+- threads[i].join();
+- }
+- Thread.sleep(5000);
+- System.out.println(System.currentTimeMillis()
+- + " All channels started.");
+- for (int i = listeners.length - 1; i >= 0; i--) {
+- TestMbrListener listener = listeners[i];
+- synchronized (listener.members) {
+- assertEquals("Checking member arrival length (" + listener.name
+- + ")", channels.length - 1, listener.members.size());
+- }
+- }
+- System.out.println(System.currentTimeMillis()
+- + " Members arrival counts checked.");
+- }
+-
+- @After
+- public void tearDown() throws Exception {
+-
+- for (int i = 0; i < channels.length; i++) {
+- try {
+- channels[i].stop(Channel.DEFAULT);
+- } catch (Exception ignore) {
+- // Ignore
+- }
+- }
+- }
+-
+- public static class TestMbrListener
+- implements MembershipListener {
+- public String name = null;
+- public TestMbrListener(String name) {
+- this.name = name;
+- }
+-
+- public ArrayList<Member> members = new ArrayList<Member>(1);
+-
+- @Override
+- public void memberAdded(Member member) {
+- String msg;
+- int count;
+- synchronized (members) {
+- if (!members.contains(member)) {
+- members.add(member);
+- msg = "member added";
+- } else {
+- msg = "member added called, but member is already in the list";
+- }
+- count = members.size();
+- }
+- report(msg, member, count);
+- }
+-
+- @Override
+- public void memberDisappeared(Member member) {
+- String msg;
+- int count;
+- synchronized (members) {
+- if (members.contains(member)) {
+- members.remove(member);
+- msg = "member disappeared";
+- } else {
+- msg = "member disappeared called, but there is no such member in the list";
+- }
+- count = members.size();
+- }
+- report(msg, member, count);
+- }
+-
+- private void report(String event, Member member, int count) {
+- StringBuilder message = new StringBuilder(100);
+- message.append(System.currentTimeMillis());
+- message.append(' ');
+- message.append(name);
+- message.append(':');
+- message.append(event);
+- message.append(", has ");
+- message.append(count);
+- message.append(" members now. Member:[");
+- message.append("host: ");
+- appendByteArrayToString(message, member.getHost());
+- message.append(", port: ");
+- message.append(member.getPort());
+- message.append(", id: ");
+- appendByteArrayToString(message, member.getUniqueId());
+- message.append(", payload: ");
+- try {
+- message.append(new String(member.getPayload(), "ASCII"));
+- } catch (Exception x) {
+- message.append("unknown");
+- }
+- Thread t = Thread.currentThread();
+- message.append("]; Thread:").append(t.getName()).append(", hash:")
+- .append(t.hashCode());
+- System.out.println(message);
+- }
+-
+- private void appendByteArrayToString(StringBuilder sb, byte[] input) {
+- if (input == null) {
+- sb.append("null");
+- return;
+- }
+- for (int i = 0; i < input.length; i++) {
+- if (i > 0) {
+- sb.append('.');
+- }
+- sb.append(input[i] & 0xFF);
+- }
+- }
+- }
+-
+-}
+diff --git a/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java b/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java
+deleted file mode 100644
+index 04035e2..0000000
+--- a/test/org/apache/catalina/tribes/group/TestGroupChannelSenderConnections.java
++++ /dev/null
+@@ -1,186 +0,0 @@
+-/*
+- * Licensed to the Apache Software Foundation (ASF) under one or more
+- * contributor license agreements. See the NOTICE file distributed with
+- * this work for additional information regarding copyright ownership.
+- * The ASF licenses this file to You under the Apache License, Version 2.0
+- * (the "License"); you may not use this file except in compliance with
+- * the License. You may obtain a copy of the License at
+- *
+- * http://www.apache.org/licenses/LICENSE-2.0
+- *
+- * Unless required by applicable law or agreed to in writing, software
+- * distributed under the License is distributed on an "AS IS" BASIS,
+- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+- * See the License for the specific language governing permissions and
+- * limitations under the License.
+- */
+-package org.apache.catalina.tribes.group;
+-
+-import java.io.Serializable;
+-import java.util.ArrayList;
+-import java.util.HashMap;
+-import java.util.Random;
+-import java.util.concurrent.atomic.AtomicInteger;
+-
+-import static org.junit.Assert.fail;
+-
+-import org.junit.After;
+-import org.junit.Before;
+-import org.junit.Test;
+-
+-import org.apache.catalina.startup.LoggingBaseTest;
+-import org.apache.catalina.tribes.Channel;
+-import org.apache.catalina.tribes.ChannelListener;
+-import org.apache.catalina.tribes.ManagedChannel;
+-import org.apache.catalina.tribes.Member;
+-import org.apache.catalina.tribes.TesterUtil;
+-import org.apache.catalina.tribes.transport.ReplicationTransmitter;
+-
+-public class TestGroupChannelSenderConnections extends LoggingBaseTest {
+- private static final int count = 2;
+- private ManagedChannel[] channels = new ManagedChannel[count];
+- private TestMsgListener[] listeners = new TestMsgListener[count];
+-
+- @Before
+- @Override
+- public void setUp() throws Exception {
+- super.setUp();
+- for (int i = 0; i < channels.length; i++) {
+- channels[i] = new GroupChannel();
+- channels[i].getMembershipService().setPayload( ("Channel-" + (i + 1)).getBytes("ASCII"));
+- listeners[i] = new TestMsgListener( ("Listener-" + (i + 1)));
+- channels[i].addChannelListener(listeners[i]);
+- }
+- TesterUtil.addRandomDomain(channels);
+- for (int i = 0; i < channels.length; i++) {
+- channels[i].start(Channel.SND_RX_SEQ|Channel.SND_TX_SEQ);
+- }
+- }
+-
+- public void sendMessages(long delay, long sleep) throws Exception {
+- resetMessageCounters();
+- Member local = channels[0].getLocalMember(true);
+- Member dest = channels[1].getLocalMember(true);
+- int n = 3;
+- log.info("Sending " + n + " messages from [" + local.getName()
+- + "] to [" + dest.getName() + "] with delay of " + delay
+- + " ms between them.");
+- for (int i = 0; i < n; i++) {
+- channels[0].send(new Member[] { dest }, new TestMsg(), 0);
+- boolean last = (i == n - 1);
+- if (!last && delay > 0) {
+- Thread.sleep(delay);
+- }
+- }
+- log.info("Messages sent. Waiting no more than " + (sleep / 1000)
+- + " seconds for them to be received");
+- long startTime = System.currentTimeMillis();
+- int countReceived;
+- while ((countReceived = getReceivedMessageCount()) != n) {
+- long time = System.currentTimeMillis();
+- if ((time - startTime) > sleep) {
+- fail("Only " + countReceived + " out of " + n
+- + " messages have been received in " + (sleep / 1000)
+- + " seconds");
+- break;
+- }
+- Thread.sleep(100);
+- }
+- }
+-
+- @Test
+- public void testConnectionLinger() throws Exception {
+- sendMessages(0,15000);
+- }
+-
+- @Test
+- public void testKeepAliveCount() throws Exception {
+- log.info("Setting keep alive count to 0");
+- for (int i = 0; i < channels.length; i++) {
+- ReplicationTransmitter t = (ReplicationTransmitter)channels[0].getChannelSender();
+- t.getTransport().setKeepAliveCount(0);
+- }
+- sendMessages(1000,15000);
+- }
+-
+- @Test
+- public void testKeepAliveTime() throws Exception {
+- log.info("Setting keep alive count to 1 second");
+- for (int i = 0; i < channels.length; i++) {
+- ReplicationTransmitter t = (ReplicationTransmitter)channels[0].getChannelSender();
+- t.getTransport().setKeepAliveTime(1000);
+- }
+- sendMessages(2000,15000);
+- }
+-
+- @After
+- @Override
+- public void tearDown() throws Exception {
+- try {
+- for (int i = 0; i < channels.length; i++) {
+- channels[i].stop(Channel.DEFAULT);
+- }
+- } finally {
+- super.tearDown();
+- }
+- }
+-
+- private void resetMessageCounters() {
+- for (TestMsgListener listener: listeners) {
+- listener.reset();
+- }
+- }
+-
+- private int getReceivedMessageCount() {
+- int count = 0;
+- for (TestMsgListener listener: listeners) {
+- count += listener.getReceivedCount();
+- }
+- return count;
+- }
+-
+- // Test message. The message size is random.
+- public static class TestMsg implements Serializable {
+- private static final long serialVersionUID = 1L;
+- private static Random r = new Random();
+- private HashMap<Integer, ArrayList<Object>> map =
+- new HashMap<Integer, ArrayList<Object>>();
+- public TestMsg() {
+- int size = Math.abs(r.nextInt() % 200);
+- for (int i=0; i<size; i++ ) {
+- int length = Math.abs(r.nextInt() %65000);
+- ArrayList<Object> list = new ArrayList<Object>(length);
+- map.put(Integer.valueOf(i),list);
+- }
+- }
+- }
+-
+- public class TestMsgListener implements ChannelListener {
+- private final String name;
+- private final AtomicInteger counter = new AtomicInteger();
+- public TestMsgListener(String name) {
+- this.name = name;
+- }
+-
+- public void reset() {
+- counter.set(0);
+- }
+-
+- public int getReceivedCount() {
+- return counter.get();
+- }
+-
+- @Override
+- public void messageReceived(Serializable msg, Member sender) {
+- counter.incrementAndGet();
+- log.info("["+name+"] Received message:"+msg+" from " + sender.getName());
+- }
+-
+- @Override
+- public boolean accept(Serializable msg, Member sender) {
+- return true;
+- }
+-
+- }
+-
+-}
+diff --git a/test/org/apache/catalina/tribes/group/TestGroupChannelStartStop.java b/test/org/apache/catalina/tribes/group/TestGroupChannelStartStop.java
+index 4c73469..1e0c4f1 100644
+--- a/test/org/apache/catalina/tribes/group/TestGroupChannelStartStop.java
++++ b/test/org/apache/catalina/tribes/group/TestGroupChannelStartStop.java
+@@ -21,6 +21,7 @@ import static org.junit.Assert.assertEquals;
+ import org.junit.After;
+ import org.junit.Before;
+ import org.junit.Test;
++import org.junit.Ignore;
+
+ import org.apache.catalina.tribes.Channel;
+ import org.apache.catalina.tribes.transport.ReceiverBase;
+@@ -43,7 +44,7 @@ public class TestGroupChannelStartStop {
+ try {channel.stop(Channel.DEFAULT);}catch (Exception ignore){ /* Ignore */ }
+ }
+
+- @Test
++ @Ignore("it fails when tested in chroots without network like pbuilder")
+ public void testDoubleFullStart() throws Exception {
+ int count = 0;
+ try {
+@@ -64,7 +65,7 @@ public class TestGroupChannelStartStop {
+ ((ReceiverBase)channel.getChannelReceiver()).setMaxThreads(1);
+ }
+
+- @Test
++ @Ignore("it fails when tested in chroots without network like pbuilder")
+ public void testDoublePartialStart() throws Exception {
+ //try to double start the RX
+ int count = 0;
+@@ -134,7 +135,7 @@ public class TestGroupChannelStartStop {
+ channel.stop(Channel.DEFAULT);
+ }
+
+- @Test
++ @Ignore("it fails when tested in chroots without network like pbuilder")
+ public void testUdpReceiverStart() throws Exception {
+ ReceiverBase rb = (ReceiverBase)channel.getChannelReceiver();
+ rb.setUdpPort(udpPort);
+diff --git a/test/org/apache/catalina/tribes/group/interceptors/TestDomainFilterInterceptor.java b/test/org/apache/catalina/tribes/group/interceptors/TestDomainFilterInterceptor.java
+deleted file mode 100644
+index f6f422d..0000000
+--- a/test/org/apache/catalina/tribes/group/interceptors/TestDomainFilterInterceptor.java
++++ /dev/null
+@@ -1,129 +0,0 @@
+-/*
+- * Licensed to the Apache Software Foundation (ASF) under one or more
+- * contributor license agreements. See the NOTICE file distributed with
+- * this work for additional information regarding copyright ownership.
+- * The ASF licenses this file to You under the Apache License, Version 2.0
+- * (the "License"); you may not use this file except in compliance with
+- * the License. You may obtain a copy of the License at
+- *
+- * http://www.apache.org/licenses/LICENSE-2.0
+- *
+- * Unless required by applicable law or agreed to in writing, software
+- * distributed under the License is distributed on an "AS IS" BASIS,
+- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+- * See the License for the specific language governing permissions and
+- * limitations under the License.
+- */
+-package org.apache.catalina.tribes.group.interceptors;
+-
+-import java.util.ArrayList;
+-
+-import static org.junit.Assert.assertEquals;
+-
+-import org.junit.After;
+-import org.junit.Before;
+-import org.junit.Test;
+-
+-import org.apache.catalina.tribes.Channel;
+-import org.apache.catalina.tribes.ManagedChannel;
+-import org.apache.catalina.tribes.Member;
+-import org.apache.catalina.tribes.MembershipListener;
+-import org.apache.catalina.tribes.group.GroupChannel;
+-import org.apache.catalina.tribes.util.UUIDGenerator;
+-
+-public class TestDomainFilterInterceptor {
+- private static int count = 10;
+- private ManagedChannel[] channels = new ManagedChannel[count];
+- private TestMbrListener[] listeners = new TestMbrListener[count];
+-
+- @Before
+- public void setUp() throws Exception {
+- for (int i = 0; i < channels.length; i++) {
+- channels[i] = new GroupChannel();
+- channels[i].getMembershipService().setPayload( ("Channel-" + (i + 1)).getBytes("ASCII"));
+- listeners[i] = new TestMbrListener( ("Listener-" + (i + 1)));
+- channels[i].addMembershipListener(listeners[i]);
+- DomainFilterInterceptor filter = new DomainFilterInterceptor();
+- filter.setDomain(UUIDGenerator.randomUUID(false));
+- channels[i].addInterceptor(filter);
+- }
+- }
+-
+- public void clear() {
+- for (int i = 0; i < channels.length; i++) {
+- listeners[i].members.clear();
+- }
+- }
+-
+- @Test
+- public void testMemberArrival() throws Exception {
+- //purpose of this test is to make sure that we have received all the members
+- //that we can expect before the start method returns
+- Thread[] threads = new Thread[channels.length];
+- for (int i=0; i<channels.length; i++ ) {
+- final Channel channel = channels[i];
+- Thread t = new Thread() {
+- @Override
+- public void run() {
+- try {
+- channel.start(Channel.DEFAULT);
+- }catch ( Exception x ) {
+- throw new RuntimeException(x);
+- }
+- }
+- };
+- threads[i] = t;
+- }
+- for (int i=0; i<threads.length; i++ ) threads[i].start();
+- for (int i=0; i<threads.length; i++ ) threads[i].join();
+- System.out.println("All channels started.");
+- for (int i=listeners.length-1; i>=0; i-- ) assertEquals("Checking member arrival length",0,listeners[i].members.size());
+- }
+-
+- @After
+- public void tearDown() throws Exception {
+-
+- for (int i = 0; i < channels.length; i++) {
+- try {
+- channels[i].stop(Channel.DEFAULT);
+- } catch (Exception ignore) {
+- // Ignore
+- }
+- }
+- }
+-
+- public static class TestMbrListener
+- implements MembershipListener {
+- public String name = null;
+- public TestMbrListener(String name) {
+- this.name = name;
+- }
+-
+- public ArrayList<Member> members = new ArrayList<Member>();
+- @Override
+- public void memberAdded(Member member) {
+- if (!members.contains(member)) {
+- members.add(member);
+- try {
+- System.out.println(name + ":member added[" + new String(member.getPayload(), "ASCII") + "; Thread:"+Thread.currentThread().getName()+"]");
+- } catch (Exception x) {
+- System.out.println(name + ":member added[unknown]");
+- }
+- }
+- }
+-
+- @Override
+- public void memberDisappeared(Member member) {
+- if (members.contains(member)) {
+- members.remove(member);
+- try {
+- System.out.println(name + ":member disappeared[" + new String(member.getPayload(), "ASCII") + "; Thread:"+Thread.currentThread().getName()+"]");
+- } catch (Exception x) {
+- System.out.println(name + ":member disappeared[unknown]");
+- }
+- }
+- }
+-
+- }
+-
+-}
+diff --git a/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java b/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java
+deleted file mode 100644
+index a3464e4..0000000
+--- a/test/org/apache/catalina/tribes/group/interceptors/TestNonBlockingCoordinator.java
++++ /dev/null
+@@ -1,131 +0,0 @@
+-/*
+- * Licensed to the Apache Software Foundation (ASF) under one or more
+- * contributor license agreements. See the NOTICE file distributed with
+- * this work for additional information regarding copyright ownership.
+- * The ASF licenses this file to You under the Apache License, Version 2.0
+- * (the "License"); you may not use this file except in compliance with
+- * the License. You may obtain a copy of the License at
+- *
+- * http://www.apache.org/licenses/LICENSE-2.0
+- *
+- * Unless required by applicable law or agreed to in writing, software
+- * distributed under the License is distributed on an "AS IS" BASIS,
+- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+- * See the License for the specific language governing permissions and
+- * limitations under the License.
+- */
+-package org.apache.catalina.tribes.group.interceptors;
+-
+-import static org.junit.Assert.assertEquals;
+-
+-import org.junit.After;
+-import org.junit.Before;
+-import org.junit.Test;
+-
+-import org.apache.catalina.tribes.Channel;
+-import org.apache.catalina.tribes.Member;
+-import org.apache.catalina.tribes.TesterUtil;
+-import org.apache.catalina.tribes.group.GroupChannel;
+-
+-public class TestNonBlockingCoordinator {
+-
+- private static final int CHANNEL_COUNT = 10;
+-
+- private GroupChannel[] channels = null;
+- private NonBlockingCoordinator[] coordinators = null;
+-
+- @Before
+- public void setUp() throws Exception {
+- System.out.println("Setup");
+- 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]);
+- channels[i].addInterceptor(new TcpFailureDetector());
+- final int j = i;
+- threads[i] = new Thread() {
+- @Override
+- public void run() {
+- try {
+- channels[j].start(Channel.DEFAULT);
+- Thread.sleep(50);
+- } catch (Exception x) {
+- x.printStackTrace();
+- }
+- }
+- };
+- }
+- TesterUtil.addRandomDomain(channels);
+- for (int i = 0; i < CHANNEL_COUNT; i++) {
+- threads[i].start();
+- }
+- for (int i = 0; i < CHANNEL_COUNT; i++) {
+- threads[i].join();
+- }
+- Thread.sleep(1000);
+- }
+-
+- @Test
+- public void testCoord1() throws Exception {
+- 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();
+- int cnt = 0;
+- while (member == null && (cnt++ < 100)) {
+- try {
+- Thread.sleep(100);
+- member = coordinators[0].getCoordinator();
+- } catch (Exception x) {
+- /* Ignore */
+- }
+- }
+- for (int i = 0; i < CHANNEL_COUNT; i++) {
+- assertEquals(member, coordinators[i].getCoordinator());
+- }
+- System.out.println("Coordinator[1] is:" + member);
+- }
+-
+- @Test
+- public void testCoord2() throws Exception {
+- Member member = coordinators[1].getCoordinator();
+- System.out.println("Coordinator[2a] is:" + member);
+- int index = -1;
+- 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);
+- index = i;
+- }
+- }
+- int dead = index;
+- Thread.sleep(1000);
+- if (index == 0) {
+- index = 1;
+- } else {
+- index = 0;
+- }
+- System.out.println("Member count:"+channels[index].getMembers().length);
+- member = coordinators[index].getCoordinator();
+- for (int i = 1; i < CHANNEL_COUNT; i++) {
+- if (i != dead) {
+- assertEquals(member, coordinators[i].getCoordinator());
+- }
+- }
+- System.out.println("Coordinator[2b] is:" + member);
+- }
+-
+- @After
+- public void tearDown() throws Exception {
+- System.out.println("tearDown");
+- for ( int i=0; i<CHANNEL_COUNT; i++ ) {
+- channels[i].stop(Channel.DEFAULT);
+- }
+- }
+-
+-}
+diff --git a/test/org/apache/catalina/tribes/group/interceptors/TestOrderInterceptor.java b/test/org/apache/catalina/tribes/group/interceptors/TestOrderInterceptor.java
+deleted file mode 100644
+index b21fa1a..0000000
+--- a/test/org/apache/catalina/tribes/group/interceptors/TestOrderInterceptor.java
++++ /dev/null
+@@ -1,197 +0,0 @@
+-/*
+- * Licensed to the Apache Software Foundation (ASF) under one or more
+- * contributor license agreements. See the NOTICE file distributed with
+- * this work for additional information regarding copyright ownership.
+- * The ASF licenses this file to You under the Apache License, Version 2.0
+- * (the "License"); you may not use this file except in compliance with
+- * the License. You may obtain a copy of the License at
+- *
+- * http://www.apache.org/licenses/LICENSE-2.0
+- *
+- * Unless required by applicable law or agreed to in writing, software
+- * distributed under the License is distributed on an "AS IS" BASIS,
+- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+- * See the License for the specific language governing permissions and
+- * limitations under the License.
+- */
+-package org.apache.catalina.tribes.group.interceptors;
+-
+-import java.io.Serializable;
+-import java.util.Queue;
+-import java.util.concurrent.ConcurrentLinkedQueue;
+-import java.util.concurrent.atomic.AtomicInteger;
+-
+-import static org.junit.Assert.assertFalse;
+-import static org.junit.Assert.fail;
+-
+-import org.junit.After;
+-import org.junit.Before;
+-import org.junit.Test;
+-
+-import org.apache.catalina.tribes.Channel;
+-import org.apache.catalina.tribes.ChannelException;
+-import org.apache.catalina.tribes.ChannelListener;
+-import org.apache.catalina.tribes.ChannelMessage;
+-import org.apache.catalina.tribes.Member;
+-import org.apache.catalina.tribes.TesterUtil;
+-import org.apache.catalina.tribes.group.ChannelInterceptorBase;
+-import org.apache.catalina.tribes.group.GroupChannel;
+-import org.apache.catalina.tribes.group.InterceptorPayload;
+-
+-public class TestOrderInterceptor {
+-
+- GroupChannel[] channels = null;
+- OrderInterceptor[] orderitcs = null;
+- MangleOrderInterceptor[] mangleitcs = null;
+- TestListener[] test = null;
+- int channelCount = 2;
+- Thread[] threads = null;
+-
+- @Before
+- public void setUp() throws Exception {
+- System.out.println("Setup");
+- channels = new GroupChannel[channelCount];
+- orderitcs = new OrderInterceptor[channelCount];
+- mangleitcs = new MangleOrderInterceptor[channelCount];
+- test = new TestListener[channelCount];
+- threads = new Thread[channelCount];
+- for ( int i=0; i<channelCount; i++ ) {
+- channels[i] = new GroupChannel();
+-
+- orderitcs[i] = new OrderInterceptor();
+- mangleitcs[i] = new MangleOrderInterceptor();
+- orderitcs[i].setExpire(Long.MAX_VALUE);
+- channels[i].addInterceptor(orderitcs[i]);
+- channels[i].addInterceptor(mangleitcs[i]);
+- test[i] = new TestListener(i);
+- channels[i].addChannelListener(test[i]);
+- final int j = i;
+- threads[i] = new Thread() {
+- @Override
+- public void run() {
+- try {
+- channels[j].start(Channel.DEFAULT);
+- Thread.sleep(50);
+- } catch (Exception x) {
+- x.printStackTrace();
+- }
+- }
+- };
+- }
+- TesterUtil.addRandomDomain(channels);
+- for ( int i=0; i<channelCount; i++ ) threads[i].start();
+- for ( int i=0; i<channelCount; i++ ) threads[i].join();
+- Thread.sleep(1000);
+- }
+-
+- @Test
+- public void testOrder1() throws Exception {
+- Member[] dest = channels[0].getMembers();
+- final AtomicInteger value = new AtomicInteger(0);
+- for ( int i=0; i<100; i++ ) {
+- channels[0].send(dest,Integer.valueOf(value.getAndAdd(1)),0);
+- }
+- Thread.sleep(5000);
+- for ( int i=0; i<test.length; i++ ) {
+- assertFalse(test[i].fail);
+- }
+- }
+-
+- @Test
+- public void testOrder2() throws Exception {
+- final Member[] dest = channels[0].getMembers();
+- final AtomicInteger value = new AtomicInteger(0);
+- final Queue<Exception> exceptionQueue = new ConcurrentLinkedQueue<Exception>();
+- Runnable run = new Runnable() {
+- @Override
+- public void run() {
+- for (int i = 0; i < 100; i++) {
+- try {
+- synchronized (channels[0]) {
+- channels[0].send(dest, Integer.valueOf(value.getAndAdd(1)), 0);
+- }
+- }catch ( Exception x ) {
+- exceptionQueue.add(x);
+- }
+- }
+- }
+- };
+- Thread[] threads = new Thread[5];
+- for (int i=0;i<threads.length;i++) {
+- threads[i] = new Thread(run);
+- }
+- for (int i=0;i<threads.length;i++) {
+- threads[i].start();
+- }
+- for (int i=0;i<threads.length;i++) {
+- threads[i].join();
+- }
+- if (!exceptionQueue.isEmpty()) {
+- fail("Exception while sending in threads: "
+- + exceptionQueue.remove().toString());
+- }
+- Thread.sleep(5000);
+- for ( int i=0; i<test.length; i++ ) {
+- assertFalse(test[i].fail);
+- }
+- }
+-
+- @After
+- public void tearDown() throws Exception {
+- System.out.println("tearDown");
+- for ( int i=0; i<channelCount; i++ ) {
+- channels[i].stop(Channel.DEFAULT);
+- }
+- }
+-
+- public static void main(String[] args) {
+- org.junit.runner.JUnitCore.main(TestOrderInterceptor.class.getName());
+- }
+-
+- public static class TestListener implements ChannelListener {
+- int id = -1;
+- public TestListener(int id) {
+- this.id = id;
+- }
+- int cnt = 0;
+- int total = 0;
+- volatile boolean fail = false;
+- @Override
+- public synchronized void messageReceived(Serializable msg, Member sender) {
+- total++;
+- Integer i = (Integer)msg;
+- if ( i.intValue() != cnt ) fail = true;
+- else cnt++;
+- System.out.println("Listener["+id+"] Message received:"+i+" Count:"+total+" Fail:"+fail);
+-
+- }
+-
+- @Override
+- public boolean accept(Serializable msg, Member sender) {
+- return (msg instanceof Integer);
+- }
+- }
+-
+- public static class MangleOrderInterceptor extends ChannelInterceptorBase {
+- ChannelMessage hold = null;
+- Member[] dest = null;
+- @Override
+- public synchronized void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException {
+- if ( hold == null ) {
+- //System.out.println("Skipping message:"+msg);
+- hold = (ChannelMessage)msg.deepclone();
+- dest = new Member[destination.length];
+- System.arraycopy(destination,0,dest,0,dest.length);
+- } else {
+- //System.out.println("Sending message:"+msg);
+- super.sendMessage(destination,msg,payload);
+- //System.out.println("Sending message:"+hold);
+- super.sendMessage(dest,hold,null);
+- hold = null;
+- dest = null;
+- }
+- }
+- }
+-
+-
+-}
+diff --git a/test/org/apache/catalina/tribes/group/interceptors/TestTcpFailureDetector.java b/test/org/apache/catalina/tribes/group/interceptors/TestTcpFailureDetector.java
+deleted file mode 100644
+index cff47c2..0000000
+--- a/test/org/apache/catalina/tribes/group/interceptors/TestTcpFailureDetector.java
++++ /dev/null
+@@ -1,177 +0,0 @@
+-/*
+- * Licensed to the Apache Software Foundation (ASF) under one or more
+- * contributor license agreements. See the NOTICE file distributed with
+- * this work for additional information regarding copyright ownership.
+- * The ASF licenses this file to You under the Apache License, Version 2.0
+- * (the "License"); you may not use this file except in compliance with
+- * the License. You may obtain a copy of the License at
+- *
+- * http://www.apache.org/licenses/LICENSE-2.0
+- *
+- * Unless required by applicable law or agreed to in writing, software
+- * distributed under the License is distributed on an "AS IS" BASIS,
+- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+- * See the License for the specific language governing permissions and
+- * limitations under the License.
+- */
+-package org.apache.catalina.tribes.group.interceptors;
+-
+-import java.util.ArrayList;
+-
+-import static org.junit.Assert.assertEquals;
+-import static org.junit.Assert.fail;
+-
+-import org.junit.After;
+-import org.junit.Before;
+-import org.junit.Test;
+-
+-import org.apache.catalina.tribes.ByteMessage;
+-import org.apache.catalina.tribes.Channel;
+-import org.apache.catalina.tribes.ChannelException;
+-import org.apache.catalina.tribes.ManagedChannel;
+-import org.apache.catalina.tribes.Member;
+-import org.apache.catalina.tribes.MembershipListener;
+-import org.apache.catalina.tribes.TesterUtil;
+-import org.apache.catalina.tribes.group.GroupChannel;
+-
+-/**
+- * <p>Title: </p>
+- *
+- * <p>Description: </p>
+- *
+- * <p>Company: </p>
+- *
+- * @author not attributable
+- * @version 1.0
+- */
+-public class TestTcpFailureDetector {
+- private TcpFailureDetector tcpFailureDetector1 = null;
+- private TcpFailureDetector tcpFailureDetector2 = null;
+- private ManagedChannel channel1 = null;
+- private ManagedChannel channel2 = null;
+- private TestMbrListener mbrlist1 = null;
+- private TestMbrListener mbrlist2 = null;
+-
+- @Before
+- public void setUp() throws Exception {
+- channel1 = new GroupChannel();
+- channel2 = new GroupChannel();
+- channel1.getMembershipService().setPayload("Channel-1".getBytes("ASCII"));
+- channel2.getMembershipService().setPayload("Channel-2".getBytes("ASCII"));
+- mbrlist1 = new TestMbrListener("Channel-1");
+- mbrlist2 = new TestMbrListener("Channel-2");
+- tcpFailureDetector1 = new TcpFailureDetector();
+- tcpFailureDetector2 = new TcpFailureDetector();
+- channel1.addInterceptor(tcpFailureDetector1);
+- channel2.addInterceptor(tcpFailureDetector2);
+- channel1.addMembershipListener(mbrlist1);
+- channel2.addMembershipListener(mbrlist2);
+- TesterUtil.addRandomDomain(new ManagedChannel[] {channel1, channel2});
+- }
+-
+- public void clear() {
+- mbrlist1.members.clear();
+- mbrlist2.members.clear();
+- }
+-
+- @Test
+- public void testTcpSendFailureMemberDrop() throws Exception {
+- System.out.println("testTcpSendFailureMemberDrop()");
+- clear();
+- channel1.start(Channel.DEFAULT);
+- channel2.start(Channel.DEFAULT);
+- //Thread.sleep(1000);
+- assertEquals("Expecting member count to be equal",mbrlist1.members.size(),mbrlist2.members.size());
+- channel2.stop(Channel.SND_RX_SEQ);
+- ByteMessage msg = new ByteMessage(new byte[1024]);
+- try {
+- channel1.send(channel1.getMembers(), msg, 0);
+- fail("Message send should have failed.");
+- } catch ( ChannelException x ) {
+- // Ignore
+- }
+- assertEquals("Expecting member count to not be equal",mbrlist1.members.size()+1,mbrlist2.members.size());
+- channel1.stop(Channel.DEFAULT);
+- channel2.stop(Channel.DEFAULT);
+- }
+-
+- @Test
+- public void testTcpFailureMemberAdd() throws Exception {
+- System.out.println("testTcpFailureMemberAdd()");
+- clear();
+- channel1.start(Channel.DEFAULT);
+- channel2.start(Channel.SND_RX_SEQ);
+- channel2.start(Channel.SND_TX_SEQ);
+- channel2.start(Channel.MBR_RX_SEQ);
+- channel2.stop(Channel.SND_RX_SEQ);
+- channel2.start(Channel.MBR_TX_SEQ);
+- //Thread.sleep(1000);
+- assertEquals("Expecting member count to not be equal",mbrlist1.members.size()+1,mbrlist2.members.size());
+- channel1.stop(Channel.DEFAULT);
+- channel2.stop(Channel.DEFAULT);
+- }
+-
+- @Test
+- public void testTcpMcastFail() throws Exception {
+- System.out.println("testTcpMcastFail()");
+- clear();
+- channel1.start(Channel.DEFAULT);
+- channel2.start(Channel.DEFAULT);
+- //Thread.sleep(1000);
+- assertEquals("Expecting member count to be equal",mbrlist1.members.size(),mbrlist2.members.size());
+- channel2.stop(Channel.MBR_TX_SEQ);
+- ByteMessage msg = new ByteMessage(new byte[1024]);
+- try {
+- Thread.sleep(5000);
+- assertEquals("Expecting member count to be equal",mbrlist1.members.size(),mbrlist2.members.size());
+- channel1.send(channel1.getMembers(), msg, 0);
+- } catch ( ChannelException x ) {
+- fail("Message send should have succeeded.");
+- }
+- channel1.stop(Channel.DEFAULT);
+- channel2.stop(Channel.DEFAULT);
+- }
+-
+- @After
+- public void tearDown() throws Exception {
+- tcpFailureDetector1 = null;
+- tcpFailureDetector2 = null;
+- try { channel1.stop(Channel.DEFAULT);}catch (Exception ignore){ /* Ignore */ }
+- channel1 = null;
+- try { channel2.stop(Channel.DEFAULT);}catch (Exception ignore){ /* Ignore */ }
+- channel2 = null;
+- }
+-
+- public static class TestMbrListener implements MembershipListener {
+- public String name = null;
+- public TestMbrListener(String name) {
+- this.name = name;
+- }
+- public ArrayList<Member> members = new ArrayList<Member>();
+- @Override
+- public void memberAdded(Member member) {
+- if ( !members.contains(member) ) {
+- members.add(member);
+- try{
+- System.out.println(name + ":member added[" + new String(member.getPayload(), "ASCII") + "]");
+- }catch ( Exception x ) {
+- System.out.println(name + ":member added[unknown]");
+- }
+- }
+- }
+-
+- @Override
+- public void memberDisappeared(Member member) {
+- if ( members.contains(member) ) {
+- members.remove(member);
+- try{
+- System.out.println(name + ":member disappeared[" + new String(member.getPayload(), "ASCII") + "]");
+- }catch ( Exception x ) {
+- System.out.println(name + ":member disappeared[unknown]");
+- }
+- }
+- }
+-
+- }
+-
+-}
+diff --git a/test/org/apache/catalina/tribes/test/TribesTestSuite.java b/test/org/apache/catalina/tribes/test/TribesTestSuite.java
+index a626300..c0f57ad 100644
+--- a/test/org/apache/catalina/tribes/test/TribesTestSuite.java
++++ b/test/org/apache/catalina/tribes/test/TribesTestSuite.java
+@@ -20,14 +20,14 @@ import org.junit.runner.RunWith;
+ import org.junit.runners.Suite;
+ import org.junit.runners.Suite.SuiteClasses;
+
+-import org.apache.catalina.tribes.group.TestGroupChannelMemberArrival;
++//import org.apache.catalina.tribes.group.TestGroupChannelMemberArrival;
+ import org.apache.catalina.tribes.group.TestGroupChannelOptionFlag;
+-import org.apache.catalina.tribes.group.TestGroupChannelSenderConnections;
++//import org.apache.catalina.tribes.group.TestGroupChannelSenderConnections;
+ import org.apache.catalina.tribes.group.TestGroupChannelStartStop;
+-import org.apache.catalina.tribes.group.interceptors.TestDomainFilterInterceptor;
+-import org.apache.catalina.tribes.group.interceptors.TestNonBlockingCoordinator;
+-import org.apache.catalina.tribes.group.interceptors.TestOrderInterceptor;
+-import org.apache.catalina.tribes.group.interceptors.TestTcpFailureDetector;
++//import org.apache.catalina.tribes.group.interceptors.TestDomainFilterInterceptor;
++//import org.apache.catalina.tribes.group.interceptors.TestNonBlockingCoordinator;
++//import org.apache.catalina.tribes.group.interceptors.TestOrderInterceptor;
++//import org.apache.catalina.tribes.group.interceptors.TestTcpFailureDetector;
+ import org.apache.catalina.tribes.io.TestXByteBuffer;
+ import org.apache.catalina.tribes.membership.TestMemberImplSerialization;
+ import org.apache.catalina.tribes.test.channel.TestDataIntegrity;
+@@ -42,12 +42,12 @@ import org.apache.catalina.tribes.test.channel.TestUdpPackages;
+ TestDataIntegrity.class, TestMulticastPackages.class,
+ TestRemoteProcessException.class, TestUdpPackages.class,
+ // o.a.catalina.tribes.test.interceptors
+- TestNonBlockingCoordinator.class, TestOrderInterceptor.class,
++ //TestNonBlockingCoordinator.class, TestOrderInterceptor.class,
+ // o.a.catalina.tribes.test.io
+- TestGroupChannelSenderConnections.class, TestXByteBuffer.class,
++ /*TestGroupChannelSenderConnections.class,*/ TestXByteBuffer.class,
+ // o.a.catalina.tribes.test.membership
+- TestMemberImplSerialization.class, TestDomainFilterInterceptor.class,
+- TestGroupChannelMemberArrival.class, TestTcpFailureDetector.class })
++ TestMemberImplSerialization.class/*, TestDomainFilterInterceptor.class,
++ TestGroupChannelMemberArrival.class, TestTcpFailureDetector.class*/ })
+ public class TribesTestSuite {
+
+ }
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/tomcat7.git
More information about the pkg-java-commits
mailing list