View Javadoc
1 // re/mind - Remote Reminder Software 2 // Copyright (C) 2002 Moritz Petersen 3 // 4 // This program is free software; you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation; either version 2 of the License, or 7 // (at your option) any later version. 8 // 9 // This program is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with this program; if not, write to the Free Software 16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 // 18 // $Id: UniqueNumberTest.java,v 1.1 2002/09/29 19:33:23 powerpete Exp $ 19 package de.jface.remind.core; 20 21 import junit.framework.TestCase; 22 23 /*** 24 * @author Moritz Petersen. 25 * @version $Revision: 1.1 $ 26 */ 27 public class UniqueNumberTest 28 extends TestCase 29 { 30 public UniqueNumberTest(String name) 31 { 32 super(name); 33 } 34 35 protected void setUp() 36 { 37 UniqueNumber.reset(); 38 } 39 40 protected void tearDown() 41 { 42 UniqueNumber.reset(); 43 } 44 45 public void testCreateNew() 46 throws Exception 47 { 48 UniqueNumber instance = UniqueNumber.newInstance(123); 49 50 assertEquals(123, instance.longValue()); 51 } 52 53 public void testCreateExistingWithAllowModify() 54 throws Exception 55 { 56 UniqueNumber first = UniqueNumber.newInstance(123); 57 UniqueNumber second = UniqueNumber.newInstance(123, true); 58 59 assertTrue(first.longValue() != second.longValue()); 60 } 61 62 public void testCreateExistingWithoutAllowModify() 63 throws Exception 64 { 65 UniqueNumber first = UniqueNumber.newInstance(123); 66 67 try 68 { 69 UniqueNumber second = UniqueNumber.newInstance(123, false); 70 71 fail("An IllegalUniqueNumberException should have been thrown."); 72 } 73 catch (IllegalUniqueNumberException e) 74 { 75 assertTrue(true); 76 } 77 } 78 79 public void testGetInstance() 80 throws Exception 81 { 82 assertTrue(UniqueNumber.getInstance(123) == null); 83 84 UniqueNumber expected = UniqueNumber.newInstance(123); 85 UniqueNumber instance = UniqueNumber.getInstance(123); 86 87 assertTrue(expected == instance); 88 } 89 }

This page was automatically generated by Maven