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.ws.rm;
19:
20: import org.apache.cxf.endpoint.Endpoint;
21: import org.easymock.classextension.EasyMock;
22: import org.easymock.classextension.IMocksControl;
23: import org.junit.After;
24: import org.junit.Assert;
25: import org.junit.Before;
26: import org.junit.Test;
27:
28: /**
29: *
30: */
31: public class AbstractEndpointTest extends Assert {
32:
33: private IMocksControl control;
34: private RMEndpoint rme;
35:
36: @Before
37: public void setUp() {
38: control = EasyMock.createNiceControl();
39: rme = control.createMock(RMEndpoint.class);
40: }
41:
42: @After
43: public void tearDown() {
44: control.verify();
45: }
46:
47: @Test
48: public void testAccessors() {
49: Endpoint ae = control.createMock(Endpoint.class);
50: EasyMock.expect(rme.getApplicationEndpoint()).andReturn(ae);
51: RMManager mgr = control.createMock(RMManager.class);
52: EasyMock.expect(rme.getManager()).andReturn(mgr);
53: control.replay();
54: AbstractEndpoint tested = new AbstractEndpoint(rme);
55: assertSame(rme, tested.getReliableEndpoint());
56: assertSame(ae, tested.getEndpoint());
57: assertSame(mgr, tested.getManager());
58: }
59:
60: @Test
61: public void testGenerateSequenceIdentifier() {
62: RMManager mgr = control.createMock(RMManager.class);
63: EasyMock.expect(rme.getManager()).andReturn(mgr);
64: SequenceIdentifierGenerator generator = control
65: .createMock(SequenceIdentifierGenerator.class);
66: EasyMock.expect(mgr.getIdGenerator()).andReturn(generator);
67: Identifier id = control.createMock(Identifier.class);
68: EasyMock.expect(generator.generateSequenceIdentifier())
69: .andReturn(id);
70: control.replay();
71: AbstractEndpoint tested = new AbstractEndpoint(rme);
72: assertSame(id, tested.generateSequenceIdentifier());
73: control.verify();
74: }
75: }
|