67
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
package com.nokia.mj.impl.utils;
|
|
20 |
|
|
21 |
import com.nokia.mj.impl.utils.DebugUtils;
|
|
22 |
|
|
23 |
import com.nokia.mj.impl.rt.test.UnitTestSuiteCreator;
|
|
24 |
import j2meunit.framework.Test;
|
|
25 |
import j2meunit.framework.TestCase;
|
|
26 |
import j2meunit.framework.TestMethod;
|
|
27 |
import j2meunit.framework.TestSuite;
|
|
28 |
|
|
29 |
/**
|
|
30 |
* DebugUtils unit tests.
|
|
31 |
*/
|
|
32 |
public class DebugUtilsTests extends TestCase implements UnitTestSuiteCreator
|
|
33 |
{
|
|
34 |
// Create the test suite.
|
|
35 |
public TestSuite createTestSuite(String[] args)
|
|
36 |
{
|
|
37 |
TestSuite suite = new TestSuite(this.getClass().getName());
|
|
38 |
|
|
39 |
suite.addTest(new DebugUtilsTests("TestStackTrace", new TestMethod()
|
|
40 |
{
|
|
41 |
public void run(TestCase tc)
|
|
42 |
{
|
|
43 |
((DebugUtilsTests)tc).testStackTrace();
|
|
44 |
}
|
|
45 |
}));
|
|
46 |
|
|
47 |
return suite;
|
|
48 |
}
|
|
49 |
|
|
50 |
public DebugUtilsTests()
|
|
51 |
{
|
|
52 |
}
|
|
53 |
|
|
54 |
public DebugUtilsTests(String aTestName, TestMethod aTestMethod)
|
|
55 |
{
|
|
56 |
super(aTestName, aTestMethod);
|
|
57 |
}
|
|
58 |
|
|
59 |
// End j2meunit test framework setup
|
|
60 |
|
|
61 |
protected void setUp()
|
|
62 |
{
|
|
63 |
}
|
|
64 |
|
|
65 |
protected void tearDown()
|
|
66 |
{
|
|
67 |
}
|
|
68 |
|
|
69 |
public void testStackTrace()
|
|
70 |
{
|
|
71 |
try
|
|
72 |
{
|
72
|
73 |
String res = DebugUtils.getStackTrace(null);
|
|
74 |
assertTrue("Not null: " + res, res == null);
|
67
|
75 |
|
|
76 |
Exception e1 = new Exception("Test 42");
|
72
|
77 |
res = DebugUtils.getStackTrace(e1);
|
67
|
78 |
boolean ok = res.indexOf("at com.nokia.mj.impl.utils.DebugUtilsTests.testStackTrace") >= 0;
|
|
79 |
assertTrue("Exception didn't contain: " + res, ok);
|
|
80 |
|
|
81 |
}
|
|
82 |
catch (Throwable t)
|
|
83 |
{
|
72
|
84 |
t.printStackTrace();
|
67
|
85 |
assertTrue(t.toString(), false);
|
|
86 |
}
|
|
87 |
}
|
|
88 |
}
|