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: */package org.apache.geronimo.clustering.wadi;
17:
18: import java.util.HashMap;
19:
20: import org.codehaus.wadi.group.Peer;
21:
22: import com.agical.rmock.extension.junit.RMockTestCase;
23:
24: /**
25: *
26: * @version $Rev$ $Date$
27: */
28: public class RemoteNodeTest extends RMockTestCase {
29:
30: private Peer peer;
31: private NodeService nodeService;
32: private NodeConnectionInfo connectionInfo;
33:
34: @Override
35: protected void setUp() throws Exception {
36: peer = (Peer) mock(Peer.class);
37: peer.getName();
38: modify().multiplicity(expect.from(0)).returnValue("name");
39:
40: peer.getLocalStateMap();
41: modify().returnValue(new HashMap());
42:
43: nodeService = (NodeService) mock(NodeService.class);
44:
45: connectionInfo = new NodeConnectionInfo("host", 1);
46: }
47:
48: public void testGetName() throws Exception {
49: startVerification();
50: RemoteNode remoteNode = new RemoteNode(peer, nodeService);
51:
52: assertEquals(peer.getName(), remoteNode.getName());
53: }
54:
55: public void testGetHost() throws Exception {
56: nodeService.getConnectionInfo();
57: modify().returnValue(connectionInfo);
58:
59: startVerification();
60: RemoteNode remoteNode = new RemoteNode(peer, nodeService);
61:
62: assertEquals(connectionInfo.getHost(), remoteNode.getHost());
63: }
64:
65: public void testGetPort() throws Exception {
66: nodeService.getConnectionInfo();
67: modify().returnValue(connectionInfo);
68:
69: startVerification();
70: RemoteNode remoteNode = new RemoteNode(peer, nodeService);
71:
72: assertEquals(connectionInfo.getPort(), remoteNode.getPort());
73: }
74:
75: public void testConnectionInfoIsInitializedOnlyOnce()
76: throws Exception {
77: nodeService.getConnectionInfo();
78: modify().returnValue(connectionInfo);
79:
80: startVerification();
81: RemoteNode remoteNode = new RemoteNode(peer, nodeService);
82:
83: assertEquals(connectionInfo.getHost(), remoteNode.getHost());
84: assertEquals(connectionInfo.getPort(), remoteNode.getPort());
85: }
86:
87: }
|