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