a1d6f55fa202670be3d1f64507d8da3bb1c5a390
[WeStealzYourDataz.git] / test / uk / ac / ntu / n0521366 / wsyd / libs / WSYD_Member_Comparator_UserIDTest.java
1 /*
2  * The MIT License
3  *
4  * Copyright 2015 Eddie Berrisford-Lynch <n0521366@ntu.ac.uk>.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 package uk.ac.ntu.n0521366.wsyd.libs;
25
26 import java.text.MessageFormat;
27 import org.junit.After;
28 import org.junit.AfterClass;
29 import org.junit.Before;
30 import org.junit.BeforeClass;
31 import org.junit.Test;
32 import static org.junit.Assert.*;
33
34 /**
35  *
36  * @author TJ <hacker@iam.tj>
37  */
38 public class WSYD_Member_Comparator_UserIDTest {
39     WSYD_Member_Comparator_UserID instance;
40     Long user1;
41
42     public WSYD_Member_Comparator_UserIDTest() {
43     }
44     
45     @BeforeClass
46     public static void setUpClass() {
47     }
48     
49     @AfterClass
50     public static void tearDownClass() {
51     }
52     
53     @Before
54     public void setUp() {
55         instance = new WSYD_Member_Comparator_UserID();
56         user1 = (long) 42;
57     }
58     
59     @After
60     public void tearDown() {
61     }
62
63     /**
64      * Test of compare method, of class WSYD_Member_Comparator_UserID.
65      */
66     @Test
67     public void testCompare() {
68         System.out.println(MessageFormat.format("{0}.compare(value, value)", instance.getClass().getName()));
69         assertEquals(0, instance.compare(user1, new Long(42)));
70         assertEquals(-1, instance.compare(user1, new Long(43)));
71         assertEquals(1, instance.compare(user1, new Long(41)));
72     }
73     
74     
75     @Test (expected=NullPointerException.class)    
76     public void testNPEuser1() {
77         System.out.println(MessageFormat.format("{0}.compare(null, value)", instance.getClass().getName()));
78         instance.compare(user1, null);
79     }
80     
81     @Test (expected=NullPointerException.class)    
82     public void testNPEuser2() {
83         System.out.println(MessageFormat.format("{0}.compare(value, null)", instance.getClass().getName()));
84         instance.compare(null, user1);
85     }
86     
87     @Test (expected=NullPointerException.class)
88     public void testNPEboth() {
89         System.out.println(MessageFormat.format("{0}.compare(null,null)", instance.getClass().getName()));
90         instance.compare(null, null);
91     }
92 }