| 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 | @SuppressWarnings("nls") |
| 27 | public class TmfRequestExecutorTest extends TestCase { |
| 28 | |
| 29 | // ------------------------------------------------------------------------ |
| 30 | // Variables |
| 31 | // ------------------------------------------------------------------------ |
| 32 | |
| 33 | // ------------------------------------------------------------------------ |
| 34 | // Housekeeping |
| 35 | // ------------------------------------------------------------------------ |
| 36 | |
| 37 | /** |
| 38 | * @param name the test name |
| 39 | */ |
| 40 | public TmfRequestExecutorTest(String name) { |
| 41 | super(name); |
| 42 | } |
| 43 | |
| 44 | @Override |
| 45 | protected void setUp() throws Exception { |
| 46 | super.setUp(); |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | protected void tearDown() throws Exception { |
| 51 | super.tearDown(); |
| 52 | } |
| 53 | |
| 54 | // ------------------------------------------------------------------------ |
| 55 | // Constructors |
| 56 | // ------------------------------------------------------------------------ |
| 57 | |
| 58 | /** |
| 59 | * Test method for {@link org.eclipse.linuxtools.tmf.request.TmfRequestExecutor#TmfRequestExecutor()}. |
| 60 | */ |
| 61 | public void testTmfRequestExecutor() { |
| 62 | TmfRequestExecutor executor = new TmfRequestExecutor(); |
| 63 | assertEquals("nbPendingRequests", 0, executor.getNbPendingRequests()); |
| 64 | assertFalse("isShutdown", executor.isShutdown()); |
| 65 | assertFalse("isTerminated", executor.isTerminated()); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Test method for {@link org.eclipse.linuxtools.tmf.request.TmfRequestExecutor#TmfRequestExecutor(java.util.concurrent.ExecutorService)}. |
| 70 | */ |
| 71 | public void testTmfRequestExecutorExecutorService() { |
| 72 | TmfRequestExecutor executor = new TmfRequestExecutor(Executors.newCachedThreadPool()); |
| 73 | assertEquals("nbPendingRequests", 0, executor.getNbPendingRequests()); |
| 74 | assertFalse("isShutdown", executor.isShutdown()); |
| 75 | assertFalse("isTerminated", executor.isTerminated()); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Test method for {@link org.eclipse.linuxtools.tmf.request.TmfRequestExecutor#stop()}. |
| 80 | */ |
| 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()); |
| 87 | } |
| 88 | |
| 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() { |
| 97 | // fail("Not yet implemented"); |
| 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() { |
| 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()); |
| 115 | } |
| 116 | |
| 117 | } |