Search in sources :

Example 11 with ArgumentValue

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

the class Test_ParameterDataProviderFactory method createFileNamesProvider.

@Test
public void createFileNamesProvider() throws AgentException, URISyntaxException {
    URL testFileURL = Test_ParameterDataProviderFactory.class.getResource("/testfolder/classloader.html");
    File testFile = new File(testFileURL.toURI());
    FileNamesDataConfig fileNamesConfig = new FileNamesDataConfig("param1", testFile.getParent(), true, ParameterProviderLevel.PER_INVOCATION);
    ParameterDataProvider dataProvider = ParameterDataProviderFactory.createDataProvider(fileNamesConfig);
    assertEquals(FileNamesParameterDataProvider.class, dataProvider.getClass());
    ArgumentValue generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertTrue(((String) generatedValue.getValue()).endsWith(".html"));
}
Also used : FileNamesDataConfig(com.axway.ats.agent.core.threading.data.config.FileNamesDataConfig) ArgumentValue(com.axway.ats.agent.core.action.ArgumentValue) File(java.io.File) URL(java.net.URL) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 12 with ArgumentValue

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

the class Test_ListParameterDataProvider method perInvocationGeneration.

@Test
public void perInvocationGeneration() {
    List<String> values = new ArrayList<String>();
    for (int i = 10; i < 20; i++) {
        values.add("value" + i);
    }
    ListParameterDataProvider dataProvider = new ListParameterDataProvider("param1", values, ParameterProviderLevel.PER_INVOCATION);
    ArgumentValue generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertEquals("value10", generatedValue.getValue());
    //make sure only one instance per thread is returned
    generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertEquals("value11", generatedValue.getValue());
}
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 13 with ArgumentValue

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

the class Test_ParameterDataProviderFactory method createStringRangeProvider.

@Test
public void createStringRangeProvider() throws AgentException {
    RangeDataConfig rangeConfig = new RangeDataConfig("param1", "user{0}@test.com", 10, 20);
    ParameterDataProvider dataProvider = ParameterDataProviderFactory.createDataProvider(rangeConfig);
    assertEquals(StringRangeParameterDataProvider.class, dataProvider.getClass());
    ArgumentValue generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertEquals("user10@test.com", generatedValue.getValue());
}
Also used : RangeDataConfig(com.axway.ats.agent.core.threading.data.config.RangeDataConfig) ArgumentValue(com.axway.ats.agent.core.action.ArgumentValue) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 14 with ArgumentValue

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

the class Test_ParameterDataProviderFactory method createListProvider.

@Test
public void createListProvider() throws AgentException, URISyntaxException {
    ListDataConfig listDataConfig = new ListDataConfig("param1", new String[] { "test1", "test2" }, ParameterProviderLevel.PER_INVOCATION);
    ParameterDataProvider dataProvider = ParameterDataProviderFactory.createDataProvider(listDataConfig);
    assertEquals(ListParameterDataProvider.class, dataProvider.getClass());
    ArgumentValue generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertEquals("test1", generatedValue.getValue());
}
Also used : ListDataConfig(com.axway.ats.agent.core.threading.data.config.ListDataConfig) ArgumentValue(com.axway.ats.agent.core.action.ArgumentValue) Test(org.junit.Test) BaseTest(com.axway.ats.agent.core.BaseTest)

Example 15 with ArgumentValue

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

the class Test_IntegerRangeParameterDataProvider method perThreadGeneration.

@Test
public void perThreadGeneration() {
    IntegerRangeParameterDataProvider dataProvider = new IntegerRangeParameterDataProvider("param1", 10, 20, ParameterProviderLevel.PER_THREAD_STATIC);
    ArgumentValue generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertEquals(10, generatedValue.getValue());
    //make sure only one instance per thread is returned
    generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertEquals(10, generatedValue.getValue());
}
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