KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > tests > ViewIdTest


1 // $Id: ViewIdTest.java,v 1.1 2007/07/04 07:29:33 belaban Exp $
2

3 package org.jgroups.tests;
4
5 import junit.framework.Test;
6 import junit.framework.TestCase;
7 import junit.framework.TestSuite;
8 import org.jgroups.ViewId;
9
10 import java.net.InetAddress JavaDoc;
11
12
13 public class ViewIdTest extends TestCase {
14     ViewId v1, v2, v3, v4;
15
16
17     public ViewIdTest(String JavaDoc name) {
18         super(name);
19     }
20
21
22     public void setUp() throws Exception JavaDoc {
23         super.setUp();
24         try {
25             v1=new ViewId(new org.jgroups.stack.IpAddress(InetAddress.getByName("localhost"), 1000), 22);
26             v2=new ViewId(new org.jgroups.stack.IpAddress(InetAddress.getByName("localhost"), 1000), 21);
27             v3=(ViewId)v1.clone();
28         }
29         catch(Exception JavaDoc e) {
30             System.err.println("ViewIdTest.setUp(): " + e);
31         }
32     }
33
34     public void tearDown() throws Exception JavaDoc {
35         super.tearDown();
36         v1=v2=v3=null;
37     }
38
39
40     public void test0() {
41         assertTrue(v1.equals(v2) == false);
42     }
43
44     public void test1() {
45         assertEquals(v1, v3);
46     }
47
48
49     public void test2() {
50         v3=(ViewId)v1.clone();
51         assertEquals(v1, v3);
52     }
53
54
55     public void test3() {
56         assertTrue(v1.compareTo(v3) == 0);
57     }
58
59
60     public void test4() {
61         assertTrue(v1.compareTo(v2) > 0);
62     }
63
64
65     public void test5() {
66         assertTrue(v2.compareTo(v1) < 0);
67     }
68
69
70     public static Test suite() {
71         TestSuite s=new TestSuite(ViewIdTest.class);
72         return s;
73     }
74
75     public static void main(String JavaDoc[] args) {
76         junit.textui.TestRunner.run(suite());
77     }
78 }
79
80
81
Popular Tags