001 package org.hackystat.sensor.xmldata.option; 002 003 import java.util.ArrayList; 004 import java.util.List; 005 006 import org.hackystat.sensor.xmldata.XmlDataController; 007 import org.junit.Assert; 008 import org.junit.Before; 009 import org.junit.Test; 010 011 /** 012 * Tests if the MultiShellOption receives the correct arguments and is processed 013 * as intended. 014 * @author aito 015 * 016 */ 017 public class TestMultiShellOption { 018 /** The instances tested in this test class. */ 019 private Option option = null; 020 private XmlDataController controller = null; 021 022 /** Sets each test case up. */ 023 @Before 024 public void setUp() { 025 this.controller = new XmlDataController(); 026 this.option = OptionFactory.getInstance(this.controller, MultiShellOption.OPTION_NAME, 027 new ArrayList<String>()); 028 } 029 030 /** Tests if the process method sets the correct option values. */ 031 @Test 032 public void testProcess() { 033 Assert.assertEquals("The MultiShell option object was pre-set.", null, this.controller 034 .getOptionObject(Options.MULTI_SHELL)); 035 this.option.process(); 036 Assert.assertEquals("The MultiShell option object was not set to true.", Boolean.TRUE, 037 this.controller.getOptionObject(Options.MULTI_SHELL)); 038 } 039 040 /** 041 * Tests if the isValid method always returns true when no arguments are 042 * specified or false if any arguments are specified. 043 */ 044 @Test 045 public void testIsValid() { 046 List<String> parameters = new ArrayList<String>(); 047 parameters.add("true"); 048 Option incorrectOption = new MultiShellOption(this.controller, parameters); 049 Assert.assertFalse("The incorrect option is not valid.", incorrectOption.isValid()); 050 Assert.assertTrue("The correct option with no arguments returned false.", this.option 051 .isValid()); 052 } 053 }