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 | ||
5c00c0b7 FC |
15 | import java.util.concurrent.Executors; |
16 | ||
d18dd09b ASL |
17 | import junit.framework.TestCase; |
18 | ||
5c00c0b7 FC |
19 | import org.eclipse.linuxtools.tmf.request.TmfRequestExecutor; |
20 | ||
d18dd09b ASL |
21 | /** |
22 | * <b><u>TmfRequestExecutorTest</u></b> | |
23 | * | |
24 | * Test suite for the TmfRequestExecutor class. | |
25 | */ | |
3b38ea61 | 26 | @SuppressWarnings("nls") |
d18dd09b ASL |
27 | public class TmfRequestExecutorTest extends TestCase { |
28 | ||
5c00c0b7 FC |
29 | // ------------------------------------------------------------------------ |
30 | // Variables | |
31 | // ------------------------------------------------------------------------ | |
32 | ||
33 | // ------------------------------------------------------------------------ | |
34 | // Housekeeping | |
35 | // ------------------------------------------------------------------------ | |
36 | ||
d18dd09b | 37 | /** |
5c00c0b7 | 38 | * @param name the test name |
d18dd09b ASL |
39 | */ |
40 | public TmfRequestExecutorTest(String name) { | |
41 | super(name); | |
42 | } | |
43 | ||
5c00c0b7 | 44 | @Override |
d18dd09b ASL |
45 | protected void setUp() throws Exception { |
46 | super.setUp(); | |
47 | } | |
48 | ||
5c00c0b7 | 49 | @Override |
d18dd09b ASL |
50 | protected void tearDown() throws Exception { |
51 | super.tearDown(); | |
52 | } | |
53 | ||
5c00c0b7 FC |
54 | // ------------------------------------------------------------------------ |
55 | // Constructors | |
56 | // ------------------------------------------------------------------------ | |
d18dd09b ASL |
57 | |
58 | /** | |
59 | * Test method for {@link org.eclipse.linuxtools.tmf.request.TmfRequestExecutor#TmfRequestExecutor()}. | |
60 | */ | |
61 | public void testTmfRequestExecutor() { | |
5c00c0b7 | 62 | TmfRequestExecutor executor = new TmfRequestExecutor(); |
5c00c0b7 FC |
63 | assertEquals("nbPendingRequests", 0, executor.getNbPendingRequests()); |
64 | assertFalse("isShutdown", executor.isShutdown()); | |
65 | assertFalse("isTerminated", executor.isTerminated()); | |
d18dd09b ASL |
66 | } |
67 | ||
68 | /** | |
5c00c0b7 | 69 | * Test method for {@link org.eclipse.linuxtools.tmf.request.TmfRequestExecutor#TmfRequestExecutor(java.util.concurrent.ExecutorService)}. |
d18dd09b | 70 | */ |
5c00c0b7 FC |
71 | public void testTmfRequestExecutorExecutorService() { |
72 | TmfRequestExecutor executor = new TmfRequestExecutor(Executors.newCachedThreadPool()); | |
5c00c0b7 FC |
73 | assertEquals("nbPendingRequests", 0, executor.getNbPendingRequests()); |
74 | assertFalse("isShutdown", executor.isShutdown()); | |
75 | assertFalse("isTerminated", executor.isTerminated()); | |
d18dd09b ASL |
76 | } |
77 | ||
2fb2eb37 | 78 | /** |
5c00c0b7 | 79 | * Test method for {@link org.eclipse.linuxtools.tmf.request.TmfRequestExecutor#stop()}. |
2fb2eb37 | 80 | */ |
5c00c0b7 FC |
81 | public void testStop() { |
82 | TmfRequestExecutor executor = new TmfRequestExecutor(); | |
83 | executor.stop(); | |
84 | assertEquals("nbPendingRequests", 0, executor.getNbPendingRequests()); | |
85 | assertTrue("isShutdown", executor.isShutdown()); | |
86 | assertTrue("isTerminated", executor.isTerminated()); | |
2fb2eb37 | 87 | } |
d18dd09b | 88 | |
ff4ed569 FC |
89 | // ------------------------------------------------------------------------ |
90 | // execute | |
91 | // ------------------------------------------------------------------------ | |
92 | ||
93 | /** | |
94 | * Test method for {@link org.eclipse.linuxtools.tmf.request.TmfRequestExecutor#execute(java.lang.Runnable)}. | |
95 | */ | |
96 | public void testExecute() { | |
5c00c0b7 | 97 | // fail("Not yet implemented"); |
ff4ed569 FC |
98 | } |
99 | ||
100 | // ------------------------------------------------------------------------ | |
101 | // toString | |
102 | // ------------------------------------------------------------------------ | |
103 | ||
104 | /** | |
105 | * Test method for {@link org.eclipse.linuxtools.tmf.request.TmfRequestExecutor#toString()}. | |
106 | */ | |
107 | public void testToString() { | |
949dc2c6 FC |
108 | // TmfRequestExecutor executor1 = new TmfRequestExecutor(); |
109 | // String expected1 = "[TmfRequestExecutor(DelegatedExecutorService)]"; | |
110 | // assertEquals("toString", expected1, executor1.toString()); | |
111 | // | |
112 | // TmfRequestExecutor executor2 = new TmfRequestExecutor(Executors.newCachedThreadPool()); | |
113 | // String expected2 = "[TmfRequestExecutor(ThreadPoolExecutor)]"; | |
114 | // assertEquals("toString", expected2, executor2.toString()); | |
ff4ed569 | 115 | } |
d18dd09b ASL |
116 | |
117 | } |