KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > filter > BadDummyPolicyConfigTest


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.filter;
19
20 import org.apache.commons.logging.Log;
21 import org.apache.commons.logging.LogFactory;
22
23 import junit.framework.TestCase;
24
25 /**
26  *
27  * @version $Revision: 1.1 $
28  */

29 public class BadDummyPolicyConfigTest extends TestCase {
30
31     protected static final Log log = LogFactory.getLog(BadDummyPolicyConfigTest.class);
32     protected DummyPolicy policy = new DummyPolicy();
33     
34     public void testNoDestinationSpecified() throws Exception JavaDoc {
35         DummyPolicyEntry entry = new DummyPolicyEntry();
36         entry.setDescription("cheese");
37         
38         assertFailsToSetEntries(entry);
39     }
40     
41     public void testNoValueSpecified() throws Exception JavaDoc {
42         DummyPolicyEntry entry = new DummyPolicyEntry();
43         entry.setTopic("FOO.BAR");
44         
45         assertFailsToSetEntries(entry);
46     }
47     
48     public void testValidEntry() throws Exception JavaDoc {
49         DummyPolicyEntry entry = new DummyPolicyEntry();
50         entry.setDescription("cheese");
51         entry.setTopic("FOO.BAR");
52         
53         entry.afterPropertiesSet();
54     }
55
56     protected void assertFailsToSetEntries(DummyPolicyEntry entry) throws Exception JavaDoc {
57         try {
58             entry.afterPropertiesSet();
59         }
60         catch (IllegalArgumentException JavaDoc e) {
61             log.info("Worked! Caught expected exception: " + e);
62         }
63     }
64 }
65
Popular Tags