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));
}
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()));
}
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));
}
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));
}
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));
}
Aggregations