@@ -0,0 +1,2642 @@
+/*%0A * Copyright (C) 2012 - 2012 NHN Corporation%0A * All rights reserved.%0A *%0A * This file is part of The nGrinder software distribution. Refer to%0A * the file LICENSE which is part of The nGrinder distribution for%0A * licensing details. The nGrinder distribution is available on the%0A * Internet at http://nhnopensource.org/ngrinder%0A *%0A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS%0A * %22AS IS%22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT%0A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS%0A * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE%0A * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,%0A * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES%0A * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR%0A * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)%0A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,%0A * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)%0A * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED%0A * OF THE POSSIBILITY OF SUCH DAMAGE.%0A */%0Apackage org.ngrinder.monitor.agent.collector.process;%0A%0Aimport java.util.concurrent.Callable;%0A%0Aimport org.junit.Test;%0Aimport org.ngrinder.monitor.share.domain.SystemInfo;%0A%0A/**%0A * Class description.%0A *%0A * @author Mavlarn%0A * @since%0A */%0Apublic class SystemMonitorProcessorTest %7B%0A%0A%09@Test%0A%09public void test() %7B%0A%09%09%0A%09%09Callable%3CSystemInfo%3E processor = null;%0A%09%09%0A%09%09final String osSystem = System.getProperty(%22os.name%22);%0A%09%09// ExecutorService executor = Executors.newSingleThreadExecutor();%0A%09%09if (osSystem.toLowerCase().indexOf(%22windows%22) %3E -1) %7B%0A%09%09%09// windows%0A%09%09%09processor = new WindowSystemMonitorProcessor();%0A%09%09%7D else %7B%0A%09%09%09// linux%0A%09%09%09processor = new LinuxSystemMonitorProcessor();%0A%09%09%7D%0A%09%09%0A%09%09try %7B%0A%09%09%09processor.call();%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%7D%0A%0A%09/**%0A%09 * In hudson, there is only one kind of processor can be tested.%0A%09 * In this test, we can test with other OS.%0A%09 * Just use the test to let it run, check the process, but it can not execute and get anything.%0A%09 */%0A%09@Test%0A%09public void testWithOtherOS() %7B%0A%09%09Callable%3CSystemInfo%3E processor = null;%0A%09%09%0A%09%09final String osSystem = System.getProperty(%22os.name%22);%0A%09%09// ExecutorService executor = Executors.newSingleThreadExecutor();%0A%09%09if (osSystem.toLowerCase().indexOf(%22windows%22) %3E -1) %7B%0A%09%09%09// windows%0A%09%09%09processor = new LinuxSystemMonitorProcessor();%0A%09%09%7D else %7B%0A%09%09%09// linux%0A%09%09%09processor = new WindowSystemMonitorProcessor();%0A%09%09%7D%0A%09%09%0A%09%09try %7B%0A%09%09%09processor.call();%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09//just skip, can not execute command one other OS.%0A%09%09%7D%0A%09%7D%0A%0A%7D%0A

Add unit test for controller