01: // $Id: ViewIdTest.java,v 1.4 2005/05/30 16:15:06 belaban Exp $
02:
03: package org.jgroups.tests;
04:
05: import junit.framework.Test;
06: import junit.framework.TestCase;
07: import junit.framework.TestSuite;
08: import org.jgroups.ViewId;
09:
10: import java.net.InetAddress;
11:
12: public class ViewIdTest extends TestCase {
13: ViewId v1, v2, v3, v4;
14:
15: public ViewIdTest(String name) {
16: super (name);
17: }
18:
19: public void setUp() throws Exception {
20: super .setUp();
21: try {
22: v1 = new ViewId(new org.jgroups.stack.IpAddress(InetAddress
23: .getByName("localhost"), 1000), 22);
24: v2 = new ViewId(new org.jgroups.stack.IpAddress(InetAddress
25: .getByName("localhost"), 1000), 21);
26: v3 = (ViewId) v1.clone();
27: } catch (Exception e) {
28: System.err.println("ViewIdTest.setUp(): " + e);
29: }
30: }
31:
32: public void tearDown() throws Exception {
33: super .tearDown();
34: v1 = v2 = v3 = null;
35: }
36:
37: public void test0() {
38: assertTrue(v1.equals(v2) == false);
39: }
40:
41: public void test1() {
42: assertEquals(v1, v3);
43: }
44:
45: public void test2() {
46: v3 = (ViewId) v1.clone();
47: assertEquals(v1, v3);
48: }
49:
50: public void test3() {
51: assertTrue(v1.compareTo(v3) == 0);
52: }
53:
54: public void test4() {
55: assertTrue(v1.compareTo(v2) > 0);
56: }
57:
58: public void test5() {
59: assertTrue(v2.compareTo(v1) < 0);
60: }
61:
62: public static Test suite() {
63: TestSuite s = new TestSuite(ViewIdTest.class);
64: return s;
65: }
66:
67: public static void main(String[] args) {
68: junit.textui.TestRunner.run(suite());
69: }
70: }
|