01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.catalina.tribes.test.channel;
18:
19: import junit.framework.*;
20: import org.apache.catalina.tribes.group.*;
21: import org.apache.catalina.tribes.ChannelInterceptor;
22: import org.apache.catalina.tribes.ChannelException;
23:
24: /**
25: * <p>Title: </p>
26: *
27: * <p>Description: </p>
28: *
29: * <p>Company: </p>
30: *
31: * @author not attributable
32: * @version 1.0
33: */
34: public class TestChannelOptionFlag extends TestCase {
35: GroupChannel channel = null;
36:
37: protected void setUp() throws Exception {
38: super .setUp();
39: channel = new GroupChannel();
40: }
41:
42: protected void tearDown() throws Exception {
43: super .tearDown();
44: if (channel != null)
45: try {
46: channel.stop(channel.DEFAULT);
47: } catch (Exception ignore) {
48: }
49: channel = null;
50: }
51:
52: public void testOptionConflict() throws Exception {
53: boolean error = false;
54: channel.setOptionCheck(true);
55: ChannelInterceptor i = new TestInterceptor();
56: i.setOptionFlag(128);
57: channel.addInterceptor(i);
58: i = new TestInterceptor();
59: i.setOptionFlag(128);
60: channel.addInterceptor(i);
61: try {
62: channel.start(channel.DEFAULT);
63: } catch (ChannelException x) {
64: if (x.getMessage().indexOf("option flag conflict") >= 0)
65: error = true;
66: }
67: assertEquals(true, error);
68: }
69:
70: public void testOptionNoConflict() throws Exception {
71: boolean error = false;
72: channel.setOptionCheck(true);
73: ChannelInterceptor i = new TestInterceptor();
74: i.setOptionFlag(128);
75: channel.addInterceptor(i);
76: i = new TestInterceptor();
77: i.setOptionFlag(64);
78: channel.addInterceptor(i);
79: i = new TestInterceptor();
80: i.setOptionFlag(256);
81: channel.addInterceptor(i);
82: try {
83: channel.start(channel.DEFAULT);
84: } catch (ChannelException x) {
85: if (x.getMessage().indexOf("option flag conflict") >= 0)
86: error = true;
87: }
88: assertEquals(false, error);
89: }
90:
91: public static class TestInterceptor extends ChannelInterceptorBase {
92:
93: }
94:
95: }
|