1
2
3
4
5
6
7 package org.mule.util;
8
9 import org.mule.tck.junit4.AbstractMuleTestCase;
10
11 import java.util.Calendar;
12
13 import org.junit.Test;
14
15 import static org.junit.Assert.assertEquals;
16 import static org.junit.Assert.fail;
17
18 public class NumberUtilsTestCase extends AbstractMuleTestCase
19 {
20 static final long l = 1000000000;
21
22 @Test
23 public void testStringToLong()
24 {
25 assertEquals(l, NumberUtils.toLong("1000000000"));
26 }
27
28 @Test
29 public void testLongToLong()
30 {
31 assertEquals(l, NumberUtils.toLong(new Long(l)));
32 }
33
34 @Test
35 public void testIntegerToLong()
36 {
37 assertEquals(l, NumberUtils.toLong(new Integer(1000000000)));
38 }
39
40 @Test
41 public void testIncompatible()
42 {
43 try
44 {
45 NumberUtils.toLong(Calendar.getInstance().getTime());
46 fail();
47 }
48 catch (IllegalArgumentException e)
49 {
50
51 }
52 }
53
54 @Test
55 public void testNull()
56 {
57 try
58 {
59
60
61 NumberUtils.toLong((Object)null);
62 fail();
63 }
64 catch (IllegalArgumentException e)
65 {
66
67 }
68 }
69
70 }