edu.sdsc.inca
Class AgentTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by edu.sdsc.inca.AgentTest
All Implemented Interfaces:
junit.framework.Test

public class AgentTest
extends junit.framework.TestCase

Tester class for Agent. Other tests are in the AgentClientTest class.

Author:
Shava Smallen <ssmallen@sdsc.edu>

Nested Class Summary
static class AgentTest.MockDepot
          A mockobject for the depot to that is used from the AgentClientTest.
 
Field Summary
static int HIGH_LEVEL
           
static int LOW_LEVEL
           
static java.lang.String REPOSITORY
           
static java.lang.String RESOURCES_FILE
           
static java.lang.String TEST_RESOURCE
           
 
Constructor Summary
AgentTest()
           
 
Method Summary
 void createAgent(boolean auth, boolean repository)
          Start up the agent server
static boolean hasGlobusServer()
          Return true if there is a system property inca.test.globus indicating a GRAM and GridFTP server is available to test Globus related functionality
static boolean hasMyProxyServer()
          Return true if there is a system property inca.test.proxy indicating a MyProxy server is available to test proxy related functionality
static boolean hasSshServer()
          Return true if there is a system property inca.test.ssh indicating a SSH server is available to test SSH related functionality
static boolean isRunningTest()
          Return true if there is a sytem property inca.test=1 indicating to run the heavier duty agent tests
 void setUp()
          Create a configuration for the agent and clean out the agent temporary files.
 void startReporterManager()
          Start up a remote reporter manager and wait for it to register
 java.lang.String[] submitSuite(java.lang.String suitePath, int numReports)
          Submit a suite to the agent and configure a mock depot to receive the reports and return them
 void tearDown()
          Cleanup the agent if it was started
 void testCheckReporterManagerStaging()
          Tests the controller's checkReporterManagerStaging function.
 void testDeleteSuites()
          Tests the controller's distributeSubcriptions function.
 void testDistributeSuites()
          Tests the controller's distributeSubcriptions function.
 void testDistributeSuitesAuth()
          Same as testDistributeSuites but with authentication
 void testRegister()
          Test the register task
 void testRegisterAuth()
          Test the register task
 void testRepositoriesPersistence()
          Create a Agent object and configure it with a repositories file.
 void testResourceConfigPersistence()
          1) Start up a fresh agent and check there are no resources configured 2) Save the sample resources to the tempdir and start a new agent and check the sample resources is available 3) Save a new blank resources file in the agent and check the timestamp r) Configure the agent with a password and set a new resources file to be saved with encryption and then read it back in and verify the resource is there.
 void testSuitePersistence()
          Create an Agent object and save a suite.
 void testUpgradeResources()
          Tests the controller's upgradeReporterManager function.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RESOURCES_FILE

public static final java.lang.String RESOURCES_FILE
See Also:
Constant Field Values

TEST_RESOURCE

public static final java.lang.String TEST_RESOURCE
See Also:
Constant Field Values

REPOSITORY

public static final java.lang.String REPOSITORY
See Also:
Constant Field Values

LOW_LEVEL

public static final int LOW_LEVEL
See Also:
Constant Field Values

HIGH_LEVEL

public static final int HIGH_LEVEL
See Also:
Constant Field Values
Constructor Detail

AgentTest

public AgentTest()
Method Detail

createAgent

public void createAgent(boolean auth,
                        boolean repository)
                 throws java.lang.Exception
Start up the agent server

Parameters:
auth - Configure the agent with authentication
repository - Configure the agent with a temporary repository
Throws:
java.lang.Exception - if trouble creating new agent server

isRunningTest

public static boolean isRunningTest()
Return true if there is a sytem property inca.test=1 indicating to run the heavier duty agent tests

Returns:
True if heavier duty agent tests should be run; otherwise false

hasMyProxyServer

public static boolean hasMyProxyServer()
Return true if there is a system property inca.test.proxy indicating a MyProxy server is available to test proxy related functionality

Returns:
True if proxy related tests should be run; false otherwise

hasGlobusServer

public static boolean hasGlobusServer()
Return true if there is a system property inca.test.globus indicating a GRAM and GridFTP server is available to test Globus related functionality

Returns:
True if Globus related tests should be run; false otherwise

hasSshServer

public static boolean hasSshServer()
Return true if there is a system property inca.test.ssh indicating a SSH server is available to test SSH related functionality

Returns:
True if SSH related tests should be run; false otherwise

setUp

public void setUp()
           throws java.lang.Exception
Create a configuration for the agent and clean out the agent temporary files.

Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception

startReporterManager

public void startReporterManager()
                          throws java.lang.InterruptedException
Start up a remote reporter manager and wait for it to register

Throws:
java.lang.InterruptedException - if receives interrupt

submitSuite

public java.lang.String[] submitSuite(java.lang.String suitePath,
                                      int numReports)
                               throws java.lang.Exception
Submit a suite to the agent and configure a mock depot to receive the reports and return them

Parameters:
suitePath - The suite to submit to the agent.
numReports - The number of reports to have the mock depot receive
Returns:
A list of received reports from the mock depot
Throws:
java.lang.Exception - if trouble sending suite to agent

tearDown

public void tearDown()
              throws java.lang.Exception
Cleanup the agent if it was started

Overrides:
tearDown in class junit.framework.TestCase
Throws:
java.lang.Exception

testCheckReporterManagerStaging

public void testCheckReporterManagerStaging()
                                     throws java.lang.Exception
Tests the controller's checkReporterManagerStaging function.

Throws:
java.lang.Exception - if problem running test

testDeleteSuites

public void testDeleteSuites()
                      throws java.lang.Exception
Tests the controller's distributeSubcriptions function. Should start up a reporter manager and a depot to receive the reports.

Throws:
java.lang.Exception - if problem running test

testDistributeSuites

public void testDistributeSuites()
                          throws java.lang.Exception
Tests the controller's distributeSubcriptions function. Should start up a reporter manager and a depot to receive the reports.

Throws:
java.lang.Exception - if problem running test

testDistributeSuitesAuth

public void testDistributeSuitesAuth()
                              throws java.lang.Exception
Same as testDistributeSuites but with authentication

Throws:
java.lang.Exception - if problem running test

testRegisterAuth

public void testRegisterAuth()
                      throws java.lang.Exception
Test the register task

Throws:
java.lang.Exception - if problem running test

testRegister

public void testRegister()
                  throws java.lang.Exception
Test the register task

Throws:
java.lang.Exception - if problem running test

testRepositoriesPersistence

public void testRepositoriesPersistence()
                                 throws java.lang.Exception
Create a Agent object and configure it with a repositories file. Create a new Agent object and verify the repositories is there. Set a new repositories list and check the timestamp on the repositories file.

Throws:
java.lang.Exception - if problem running test

testResourceConfigPersistence

public void testResourceConfigPersistence()
                                   throws java.lang.Exception
1) Start up a fresh agent and check there are no resources configured 2) Save the sample resources to the tempdir and start a new agent and check the sample resources is available 3) Save a new blank resources file in the agent and check the timestamp r) Configure the agent with a password and set a new resources file to be saved with encryption and then read it back in and verify the resource is there.

Throws:
java.lang.Exception - if problem running test

testSuitePersistence

public void testSuitePersistence()
                          throws java.lang.Exception
Create an Agent object and save a suite. Start a new agent object and verify the suite is there. Save a delete series change to the suite and verify the timestamp and number of series.

Throws:
java.lang.Exception - if problem running test

testUpgradeResources

public void testUpgradeResources()
                          throws java.lang.Exception
Tests the controller's upgradeReporterManager function.

Throws:
java.lang.Exception - if problem running test