KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cintoo > messages > error > TestErrorCode


1 /*
2  * Copyright 2006 cintoo, Berlin, Germany
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package cintoo.messages.error;
17
18 import org.testng.annotations.*;
19 import org.testng.Assert;
20
21 public class TestErrorCode {
22   @Test
23   public void testBean() {
24     ErrorCode code = new ErrorCode(12345);
25     Assert.assertEquals(code.getError(), "12345", "ErrorCode return correct error");
26   }
27
28   @Test
29   public void testHashCode() {
30     Assert.assertEquals(ErrorCode.error(12345).hashCode(), 12345, "ErrorCode has correct hashCode");
31   }
32
33   @Test
34   public void testEquals() {
35     Assert.assertTrue(!(ErrorCode.error(12345).equals(null)), "ErrorCode equals is false for null");
36     Assert.assertTrue(!(ErrorCode.error(12345).equals("12345")), "ErrorCode equals is false for String");
37   }
38
39   @Test
40   public void testErrorFactory() {
41     Assert.assertEquals(ErrorCode.error(12345), new ErrorCode(12345), "Factory returns correct error code");
42   }
43 }
Popular Tags