X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=common%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fxmlrouter%2Fcommon%2FIdTest.java;fp=common%2Fsrc%2Ftest%2Fjava%2Forg%2Fwamblee%2Fxmlrouter%2Fcommon%2FIdTest.java;h=183d885f2fdd8eb05c9d842000adfbec8a739aa1;hb=19413a6699295b4bbebc1b3bdb9838fd4370e581;hp=0000000000000000000000000000000000000000;hpb=f77e29e9ae2505009ffc9270f4c4adfde331fa62;p=xmlrouter diff --git a/common/src/test/java/org/wamblee/xmlrouter/common/IdTest.java b/common/src/test/java/org/wamblee/xmlrouter/common/IdTest.java new file mode 100644 index 0000000..183d885 --- /dev/null +++ b/common/src/test/java/org/wamblee/xmlrouter/common/IdTest.java @@ -0,0 +1,45 @@ +/* + * Copyright 2005-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wamblee.xmlrouter.common; + +import static junit.framework.Assert.*; + +import org.junit.Test; + +public class IdTest { + + @Test + public void testGetSet() { + Id id = new Id(100L); + assertEquals(100L, id.getId()); + } + + @Test + public void testEqualsHashCodeCompare() { + Id id1 = new Id(100L); + Id id2 = new Id(200L); + Id id3 = new Id(100L); + assertEquals(id1, id3); + assertFalse(id1.equals(id2)); + assertFalse(id1.equals(null)); + assertFalse(id1.equals("hello")); + assertEquals(id1.hashCode(), id3.hashCode()); + + assertTrue(id1.compareTo(id2) < 0); + assertTrue(id2.compareTo(id1) > 0); + assertEquals(0, id1.compareTo(id3)); + } +}