Search in sources :

Example 26 with ArgumentValue

use of com.axway.ats.agent.core.action.ArgumentValue in project ats-framework by Axway.

the class Test_FileNamesParameterDataProvider method perInvocationGenerationNonRecursive.

@Test
public void perInvocationGenerationNonRecursive() throws AgentException {
    FileNamesParameterDataProvider dataProvider = new FileNamesParameterDataProvider("param1", fileContainers, false, true, ParameterProviderLevel.PER_INVOCATION);
    dataProvider.initialize();
    ArgumentValue generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertTrue(((String) generatedValue.getValue()).matches(".*[\\\\/](classloader|readme).html"));
    String firstValue = (String) generatedValue.getValue();
    //make sure new instance is returned for the new invocation
    generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertFalse(((String) generatedValue.getValue()).equals(firstValue));
    //make sure we go back to the beginning
    generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertTrue(((String) generatedValue.getValue()).equals(firstValue));
}
Also used : ArrayList(java.util.ArrayList) ArgumentValue(com.axway.ats.agent.core.action.ArgumentValue) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 27 with ArgumentValue

use of com.axway.ats.agent.core.action.ArgumentValue in project ats-framework by Axway.

the class Test_FileNamesParameterDataProvider method testGenerateNewValuePerThread.

@Test
public void testGenerateNewValuePerThread() throws AgentException {
    FileNamesParameterDataProvider fileNamesDP = new FileNamesParameterDataProvider("fileNameParam", fileContainers, false, true, ParameterProviderLevel.PER_THREAD);
    fileNamesDP.initialize();
    // simulating threads with IDs 1 and 2
    ArgumentValue arg1 = fileNamesDP.generateNewValuePerThread(1, new ArrayList<ArgumentValue>());
    ArgumentValue arg2 = fileNamesDP.generateNewValuePerThread(2, new ArrayList<ArgumentValue>());
    ArgumentValue arg12 = fileNamesDP.generateNewValuePerThread(1, new ArrayList<ArgumentValue>());
    ArgumentValue arg22 = fileNamesDP.generateNewValuePerThread(2, new ArrayList<ArgumentValue>());
    // the first values for the 2 threads must be the same
    assertTrue(arg1.getValue().equals(arg2.getValue()));
    // the second values too
    assertTrue(arg12.getValue().equals(arg22.getValue()));
    // check if the first and second values for each thread are different
    assertTrue(!arg1.getValue().equals(arg12.getValue()));
    assertTrue(!arg2.getValue().equals(arg22.getValue()));
}
Also used : ArgumentValue(com.axway.ats.agent.core.action.ArgumentValue) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 28 with ArgumentValue

use of com.axway.ats.agent.core.action.ArgumentValue in project ats-framework by Axway.

the class Test_FileNamesParameterDataProvider method perThreadStaticGeneration.

@Test
public void perThreadStaticGeneration() throws AgentException {
    FileNamesParameterDataProvider dataProvider = new FileNamesParameterDataProvider("param1", fileContainers, false, true, ParameterProviderLevel.PER_THREAD_STATIC);
    dataProvider.initialize();
    ArgumentValue generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertTrue(((String) generatedValue.getValue()).matches(".*[\\\\/](classloader|readme).html$"));
    String firstValue = (String) generatedValue.getValue();
    // now we expect the next file for the current thread to be same as the previous
    generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertTrue(((String) generatedValue.getValue()).equals(firstValue));
}
Also used : ArrayList(java.util.ArrayList) ArgumentValue(com.axway.ats.agent.core.action.ArgumentValue) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 29 with ArgumentValue

use of com.axway.ats.agent.core.action.ArgumentValue in project ats-framework by Axway.

the class Test_FileNamesParameterDataProvider method whenRangeEndIsReachedProviderGoesBackToRangeStart.

@Test
public void whenRangeEndIsReachedProviderGoesBackToRangeStart() throws AgentException {
    FileNamesParameterDataProvider dataProvider = new FileNamesParameterDataProvider("param1", fileContainers, false, true, ParameterProviderLevel.PER_INVOCATION);
    dataProvider.initialize();
    ArgumentValue generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertTrue(((String) generatedValue.getValue()).matches(".*[\\\\/](classloader|readme).html"));
    String firstValue = (String) generatedValue.getValue();
    //make sure new instance is returned for the new invocation
    generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertFalse(((String) generatedValue.getValue()).equals(firstValue));
    //make sure we go back to the beginning
    generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertTrue(((String) generatedValue.getValue()).equals(firstValue));
}
Also used : ArrayList(java.util.ArrayList) ArgumentValue(com.axway.ats.agent.core.action.ArgumentValue) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 30 with ArgumentValue

use of com.axway.ats.agent.core.action.ArgumentValue in project ats-framework by Axway.

the class Test_FileNamesParameterDataProvider method perInvocationGenerationRecursiveJustFileName.

@Test
public void perInvocationGenerationRecursiveJustFileName() throws AgentException {
    FileNamesParameterDataProvider dataProvider = new FileNamesParameterDataProvider("param1", fileContainers, true, false, ParameterProviderLevel.PER_INVOCATION);
    dataProvider.initialize();
    ArgumentValue generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertTrue(((String) generatedValue.getValue()).matches("(classloader|readme|release\\-notes).html"));
    String firstValue = (String) generatedValue.getValue();
    //make sure new instance is returned for the new invocation
    generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertFalse(((String) generatedValue.getValue()).equals(firstValue));
}
Also used : ArrayList(java.util.ArrayList) ArgumentValue(com.axway.ats.agent.core.action.ArgumentValue) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Aggregations

ArgumentValue (com.axway.ats.agent.core.action.ArgumentValue)33 BaseTest (com.axway.ats.agent.core.BaseTest)32 Test (org.junit.Test)32 ArrayList (java.util.ArrayList)25 RangeDataConfig (com.axway.ats.agent.core.threading.data.config.RangeDataConfig)2 HashMap (java.util.HashMap)2 FileNamesDataConfig (com.axway.ats.agent.core.threading.data.config.FileNamesDataConfig)1 ListDataConfig (com.axway.ats.agent.core.threading.data.config.ListDataConfig)1 File (java.io.File)1 URL (java.net.URL)1 Pattern (java.util.regex.Pattern)1