1 /*
2 * $Id: NumberUtilsTestCase.java 8077 2007-08-27 20:15:25Z aperepel $
3 * --------------------------------------------------------------------------------------
4 * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5 *
6 * The software in this package is published under the terms of the CPAL v1.0
7 * license, a copy of which has been included with this distribution in the
8 * LICENSE.txt file.
9 */
10
11 package org.mule.util;
12
13 import org.mule.tck.AbstractMuleTestCase;
14
15 import java.util.Calendar;
16
17 public class NumberUtilsTestCase extends AbstractMuleTestCase
18 {
19 static final long l = 1000000000;
20
21 public void testStringToLong()
22 {
23 assertEquals(l, NumberUtils.toLong("1000000000"));
24 }
25
26 public void testLongToLong()
27 {
28 assertEquals(l, NumberUtils.toLong(new Long(l)));
29 }
30
31 public void testIntegerToLong()
32 {
33 assertEquals(l, NumberUtils.toLong(new Integer(1000000000)));
34 }
35
36 public void testIncompatible()
37 {
38 try
39 {
40 NumberUtils.toLong(Calendar.getInstance().getTime());
41 fail();
42 }
43 catch (IllegalArgumentException e)
44 {
45 // expected
46 }
47 }
48
49 public void testNull()
50 {
51 try
52 {
53 // need to cast to Object, otherwise compiler would resolve method to
54 // superclass' implementation
55 NumberUtils.toLong((Object)null);
56 fail();
57 }
58 catch (IllegalArgumentException e)
59 {
60 // expected
61 }
62 }
63
64 }