use of com.axway.ats.agent.core.action.ArgumentValue in project ats-framework by Axway.
the class Test_FileNamesParameterDataProvider method perThreadGenerationRecursive.
@Test
public void perThreadGenerationRecursive() throws AgentException {
FileNamesParameterDataProvider dataProvider = new FileNamesParameterDataProvider("param1", fileContainers, false, true, ParameterProviderLevel.PER_THREAD);
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
generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
assertEquals("param1", generatedValue.getName());
assertFalse(((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 whenRangeEndIsReachedProviderGoesBackToRangeStartJustFileName.
@Test
public void whenRangeEndIsReachedProviderGoesBackToRangeStartJustFileName() throws AgentException {
FileNamesParameterDataProvider dataProvider = new FileNamesParameterDataProvider("param1", fileContainers, false, false, 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(dataProvider.getParameterName(), 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 testSimpleFileNameRegex.
@Test
public void testSimpleFileNameRegex() throws AgentException {
List<FileContainer> fileContainers = new ArrayList<FileContainer>();
fileContainers.add(new FileContainer(folderName, 100, ".ea.*ml"));
FileNamesParameterDataProvider fileNamesDP = new FileNamesParameterDataProvider("fileNameParam", fileContainers, false, false, ParameterProviderLevel.PER_THREAD);
fileNamesDP.initialize();
ArgumentValue previousValue = new ArgumentValue("fileNamePart", "read");
List<ArgumentValue> previousValues = new ArrayList<ArgumentValue>();
previousValues.add(previousValue);
ArgumentValue generatedValue = fileNamesDP.getValue(previousValues);
String value = (String) generatedValue.getValue();
assertTrue(value.matches("readme.html$"));
// now we expect the next file for the current thread to be same as the previous
generatedValue = fileNamesDP.getValue(previousValues);
assertTrue(((String) generatedValue.getValue()).equals(value));
}
use of com.axway.ats.agent.core.action.ArgumentValue in project ats-framework by Axway.
the class Test_FileNamesParameterDataProvider method testGenerateNewValuePerThreadStatic.
@Test
public void testGenerateNewValuePerThreadStatic() throws AgentException {
FileNamesParameterDataProvider fileNamesDP = new FileNamesParameterDataProvider("fileNameParam", fileContainers, false, true, ParameterProviderLevel.PER_THREAD_STATIC);
fileNamesDP.initialize();
// simulating threads with IDs 1 and 2
ArgumentValue arg1 = fileNamesDP.generateNewValuePerThreadStatic(1, new ArrayList<ArgumentValue>());
ArgumentValue arg2 = fileNamesDP.generateNewValuePerThreadStatic(2, new ArrayList<ArgumentValue>());
ArgumentValue arg12 = fileNamesDP.generateNewValuePerThreadStatic(1, new ArrayList<ArgumentValue>());
ArgumentValue arg22 = fileNamesDP.generateNewValuePerThreadStatic(2, new ArrayList<ArgumentValue>());
// each thread must have only one value
// the files in the directory are 2 so the 2 threads must have different values
assertTrue(!arg1.getValue().equals(arg2.getValue()));
assertTrue(arg1.getValue().equals(arg12.getValue()));
assertTrue(!arg12.getValue().equals(arg22.getValue()));
assertTrue(arg2.getValue().equals(arg22.getValue()));
// the files in the directory are 2 so the 3-rd thread must have the same value as the first one
ArgumentValue arg3 = fileNamesDP.generateNewValuePerThreadStatic(3, new ArrayList<ArgumentValue>());
ArgumentValue arg32 = fileNamesDP.generateNewValuePerThreadStatic(3, new ArrayList<ArgumentValue>());
assertTrue(!arg2.getValue().equals(arg3.getValue()));
assertTrue(arg1.getValue().equals(arg3.getValue()));
assertTrue(arg3.getValue().equals(arg32.getValue()));
}
use of com.axway.ats.agent.core.action.ArgumentValue in project ats-framework by Axway.
the class Test_FileNamesParameterDataProvider method testComplexFileNameRegex.
@Test
public void testComplexFileNameRegex() throws AgentException {
List<FileContainer> fileContainers = new ArrayList<FileContainer>();
fileContainers.add(new FileContainer(folderName, 100, "${fileNamePart}.*"));
FileNamesParameterDataProvider fileNamesDP = new FileNamesParameterDataProvider("fileNameParam", fileContainers, false, true, ParameterProviderLevel.PER_THREAD);
fileNamesDP.initialize();
ArgumentValue previousValue = new ArgumentValue("fileNamePart", "read");
List<ArgumentValue> previousValues = new ArrayList<ArgumentValue>();
previousValues.add(previousValue);
ArgumentValue generatedValue = fileNamesDP.getValue(previousValues);
String value = (String) generatedValue.getValue();
assertTrue(value.matches(".*[\\\\/]readme.html$"));
// now we expect the next file for the current thread to be same as the previous
generatedValue = fileNamesDP.getValue(previousValues);
assertTrue(((String) generatedValue.getValue()).equals(value));
}
Aggregations