KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > jms > core > support > JmsGatewaySupportTests


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.springframework.jms.core.support;
17
18 import java.util.ArrayList JavaDoc;
19 import java.util.List JavaDoc;
20
21 import javax.jms.ConnectionFactory JavaDoc;
22
23 import junit.framework.TestCase;
24 import org.easymock.MockControl;
25
26 import org.springframework.jms.core.JmsTemplate;
27
28 /**
29  * @author Mark Pollack
30  * @since 24.9.2004
31  */

32 public class JmsGatewaySupportTests extends TestCase {
33
34     public void testJmsGatewaySupportWithConnectionFactory() throws Exception JavaDoc {
35         MockControl connectionFactoryControl = MockControl.createControl(ConnectionFactory JavaDoc.class);
36         ConnectionFactory JavaDoc mockConnectionFactory = (ConnectionFactory JavaDoc) connectionFactoryControl.getMock();
37         connectionFactoryControl.replay();
38         final List JavaDoc test = new ArrayList JavaDoc();
39         JmsGatewaySupport gateway = new JmsGatewaySupport() {
40             protected void initGateway() {
41                 test.add("test");
42             }
43         };
44         gateway.setConnectionFactory(mockConnectionFactory);
45         gateway.afterPropertiesSet();
46         assertEquals("Correct ConnectionFactory", mockConnectionFactory, gateway.getConnectionFactory());
47         assertEquals("Correct JmsTemplate", mockConnectionFactory, gateway.getJmsTemplate().getConnectionFactory());
48         assertEquals("initGatway called", test.size(), 1);
49         connectionFactoryControl.verify();
50         
51     }
52     public void testJmsGatewaySupportWithJmsTemplate() throws Exception JavaDoc {
53         JmsTemplate template = new JmsTemplate();
54         final List JavaDoc test = new ArrayList JavaDoc();
55         JmsGatewaySupport gateway = new JmsGatewaySupport() {
56             protected void initGateway() {
57                 test.add("test");
58             }
59         };
60         gateway.setJmsTemplate(template);
61         gateway.afterPropertiesSet();
62         assertEquals("Correct JmsTemplate", template, gateway.getJmsTemplate());
63         assertEquals("initGateway called", test.size(), 1);
64     }
65
66 }
67
Popular Tags