Commit | Line | Data |
---|---|---|
d18dd09b ASL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2009, 2010 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Francois Chouinard - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.tmf.tests.request; | |
14 | ||
15 | import java.util.concurrent.Executors; | |
16 | ||
17 | import junit.framework.TestCase; | |
18 | ||
19 | import org.eclipse.linuxtools.tmf.request.TmfRequestExecutor; | |
20 | ||
21 | /** | |
22 | * <b><u>TmfRequestExecutorTest</u></b> | |
23 | * | |
24 | * Test suite for the TmfRequestExecutor class. | |
25 | */ | |
26 | public class TmfRequestExecutorTest extends TestCase { | |
27 | ||
28 | // ------------------------------------------------------------------------ | |
29 | // Variables | |
30 | // ------------------------------------------------------------------------ | |
31 | ||
32 | // ------------------------------------------------------------------------ | |
33 | // Housekeeping | |
34 | // ------------------------------------------------------------------------ | |
35 | ||
36 | /** | |
37 | * @param name the test name | |
38 | */ | |
39 | public TmfRequestExecutorTest(String name) { | |
40 | super(name); | |
41 | } | |
42 | ||
43 | @Override | |
44 | protected void setUp() throws Exception { | |
45 | super.setUp(); | |
46 | } | |
47 | ||
48 | @Override | |
49 | protected void tearDown() throws Exception { | |
50 | super.tearDown(); | |
51 | } | |
52 | ||
53 | // ------------------------------------------------------------------------ | |
54 | // Constructors | |
55 | // ------------------------------------------------------------------------ | |
56 | ||
57 | /** | |
58 | * Test method for {@link org.eclipse.linuxtools.tmf.request.TmfRequestExecutor#TmfRequestExecutor()}. | |
59 | */ | |
60 | public void testTmfRequestExecutor() { | |
61 | TmfRequestExecutor executor = new TmfRequestExecutor(); | |
62 | assertEquals("nbPendingRequests", 0, executor.getNbPendingRequests()); | |
63 | assertFalse("isShutdown", executor.isShutdown()); | |
64 | assertFalse("isTerminated", executor.isTerminated()); | |
65 | } | |
66 | ||
67 | /** | |
68 | * Test method for {@link org.eclipse.linuxtools.tmf.request.TmfRequestExecutor#TmfRequestExecutor(java.util.concurrent.ExecutorService)}. | |
69 | */ | |
70 | public void testTmfRequestExecutorExecutorService() { | |
71 | TmfRequestExecutor executor = new TmfRequestExecutor(Executors.newCachedThreadPool()); | |
72 | assertEquals("nbPendingRequests", 0, executor.getNbPendingRequests()); | |
73 | assertFalse("isShutdown", executor.isShutdown()); | |
74 | assertFalse("isTerminated", executor.isTerminated()); | |
75 | } | |
76 | ||
77 | /** | |
78 | * Test method for {@link org.eclipse.linuxtools.tmf.request.TmfRequestExecutor#stop()}. | |
79 | */ | |
80 | public void testStop() { | |
81 | TmfRequestExecutor executor = new TmfRequestExecutor(); | |
82 | executor.stop(); | |
83 | assertEquals("nbPendingRequests", 0, executor.getNbPendingRequests()); | |
84 | assertTrue("isShutdown", executor.isShutdown()); | |
85 | assertTrue("isTerminated", executor.isTerminated()); | |
86 | } | |
87 | ||
88 | // ------------------------------------------------------------------------ | |
89 | // execute | |
90 | // ------------------------------------------------------------------------ | |
91 | ||
92 | /** | |
93 | * Test method for {@link org.eclipse.linuxtools.tmf.request.TmfRequestExecutor#execute(java.lang.Runnable)}. | |
94 | */ | |
95 | public void testExecute() { | |
96 | // fail("Not yet implemented"); | |
97 | } | |
98 | ||
99 | // ------------------------------------------------------------------------ | |
100 | // toString | |
101 | // ------------------------------------------------------------------------ | |
102 | ||
103 | /** | |
104 | * Test method for {@link org.eclipse.linuxtools.tmf.request.TmfRequestExecutor#toString()}. | |
105 | */ | |
106 | public void testToString() { | |
107 | // TmfRequestExecutor executor1 = new TmfRequestExecutor(); | |
108 | // String expected1 = "[TmfRequestExecutor(DelegatedExecutorService)]"; | |
109 | // assertEquals("toString", expected1, executor1.toString()); | |
110 | // | |
111 | // TmfRequestExecutor executor2 = new TmfRequestExecutor(Executors.newCachedThreadPool()); | |
112 | // String expected2 = "[TmfRequestExecutor(ThreadPoolExecutor)]"; | |
113 | // assertEquals("toString", expected2, executor2.toString()); | |
114 | } | |
115 | ||
116 | } |