From 8aff33feec283d7a17c63b136ce96610e87dbdf6 Mon Sep 17 00:00:00 2001 From: fhanik Date: Tue, 22 May 2007 15:52:14 +0000 Subject: [PATCH] Added domain membership test git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@540616 13f79535-47bb-0310-9956-ffa450edef68 --- .../test/interceptors/TestDomainInterceptor.java | 125 +++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 test/org/apache/catalina/tribes/test/interceptors/TestDomainInterceptor.java diff --git a/test/org/apache/catalina/tribes/test/interceptors/TestDomainInterceptor.java b/test/org/apache/catalina/tribes/test/interceptors/TestDomainInterceptor.java new file mode 100644 index 000000000..5b1950415 --- /dev/null +++ b/test/org/apache/catalina/tribes/test/interceptors/TestDomainInterceptor.java @@ -0,0 +1,125 @@ +/* + * 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.test.interceptors; + +import java.io.Serializable; + +import org.apache.catalina.tribes.Channel; +import org.apache.catalina.tribes.ChannelListener; +import org.apache.catalina.tribes.Member; +import org.apache.catalina.tribes.group.GroupChannel; +import org.apache.catalina.tribes.group.interceptors.DomainFilterInterceptor; +import junit.framework.TestCase; +import junit.framework.TestResult; +import junit.framework.TestSuite; + +public class TestDomainInterceptor extends TestCase { + + GroupChannel[] channels = null; + DomainFilterInterceptor[] domainitcs = null; + TestListener[] test = null; + int channelCount = 4; + Thread[] threads = null; + byte[] commonDomain = new byte[] {1,1,1,1}; + byte[] oddDomain = new byte[] {2,1,1,1}; + protected void setUp() throws Exception { + System.out.println("Setup"); + super.setUp(); + channels = new GroupChannel[channelCount]; + domainitcs = new DomainFilterInterceptor[channelCount]; + test = new TestListener[channelCount]; + threads = new Thread[channelCount]; + for ( int i=0; i0?commonDomain:oddDomain); + domainitcs[i] = new DomainFilterInterceptor(); + domainitcs[i].setDomain(i>0?commonDomain:oddDomain); + channels[i].addInterceptor(domainitcs[i]); + test[i] = new TestListener(i); + channels[i].addChannelListener(test[i]); + final int j = i; + threads[i] = new Thread() { + public void run() { + try { + channels[j].start(Channel.DEFAULT); + Thread.sleep(50); + } catch (Exception x) { + x.printStackTrace(); + } + } + }; + } + for ( int i=0; i