001    package org.hackystat.sensorshell.usermap;
002    
003    import java.io.File;
004    
005    import junit.framework.TestCase;
006    
007    import org.hackystat.sensorshell.SensorShell;
008    
009    /**
010     * Tests the SensorShellMap class. It ensures that instantiation and use can be done correctly. A
011     * dummy UserMap.xml is inputted for instantiation and a dummy user SensorShell is gotten using the
012     * SensorShellMap functionality.
013     * 
014     * @author Julie Ann Sakuda
015     */
016    public class TestSensorShellMap extends TestCase {
017    
018      private String tool = "test";
019      private String toolAccount = "dummyaccount";
020    
021      /**
022       * Tests usage of the SensorShellMap class.
023       * 
024       * @throws Exception if errors occur.
025       */
026      public void testUserShell() throws Exception {
027        SensorShellMap sensorShellMap = new SensorShellMap(this.tool, new File(System
028            .getProperty("usermaptestfile")));
029    
030        // Test that the tool account exists
031        assertTrue("Tool account dummyaccount should exist", sensorShellMap.hasUserShell(toolAccount));
032        
033        // Test for successful acquisition of user's SensorShell instance
034        SensorShell userShell = sensorShellMap.getUserShell(this.toolAccount);
035        assertNotNull("Checking successful acquisition of user SensorShell", userShell);
036        
037        // Test that only one instance per user is created
038        assertSame("Should only be creating one sensorshell instance", userShell, sensorShellMap
039            .getUserShell(toolAccount));
040      }
041    }