01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.transport.jms;
19:
20: import javax.jms.Destination;
21: import javax.jms.MessageConsumer;
22: import javax.jms.MessageProducer;
23: import javax.jms.Session;
24:
25: import org.easymock.classextension.EasyMock;
26: import org.junit.Assert;
27: import org.junit.Test;
28:
29: public class PooledSessionTest extends Assert {
30:
31: @Test
32: public void testPooledSession() throws Exception {
33:
34: Session sess = EasyMock.createMock(Session.class);
35: Destination dest = EasyMock.createMock(Destination.class);
36: MessageProducer mproducer = EasyMock
37: .createMock(MessageProducer.class);
38: MessageConsumer mconsumer = EasyMock
39: .createMock(MessageConsumer.class);
40:
41: PooledSession ps = new PooledSession(sess, dest, mproducer,
42: mconsumer);
43:
44: assertTrue(ps.session().equals(sess));
45: assertTrue(ps.destination().equals(dest));
46: assertTrue(ps.consumer().equals(mconsumer));
47: assertTrue(ps.producer().equals(mproducer));
48:
49: MessageConsumer mcons = EasyMock
50: .createMock(MessageConsumer.class);
51: assertFalse(mconsumer.equals(mcons));
52:
53: ps.consumer(mcons);
54:
55: assertTrue(ps.consumer().equals(mcons));
56:
57: Destination mdest = EasyMock.createMock(Destination.class);
58: assertFalse(dest.equals(mdest));
59:
60: ps.destination(mdest);
61: assertTrue(mdest.equals(ps.destination()));
62: }
63: }
|