Search in sources :

Example 1 with RangeDataConfig

use of com.axway.ats.agent.core.threading.data.config.RangeDataConfig in project ats-framework by Axway.

the class DisabledTest_MultiThreadedActionHandlerWithParameterizedInputData method paremterizedVariousDataPositive.

@Test
public void paremterizedVariousDataPositive() throws Exception {
    LoaderDataConfig loaderDataConfig = new LoaderDataConfig();
    loaderDataConfig.addParameterConfig(new RangeDataConfig("fileName", "file{0}.txt", 1, 300));
    loaderDataConfig.addParameterConfig(new RangeDataConfig("fileName", "file{0}.txt", 1, 300));
    loaderDataConfig.addParameterConfig(new RangeDataConfig("milliseconds", 1, 4));
    AllAtOncePattern pattern = new AllAtOncePattern(5, true);
    QueueExecutionStatistics.getInstance().initActionExecutionResults("test 1");
    actionHandler.executeActions("IP", "test 1", -1, actionRequests, pattern, loaderDataConfig);
    //check the strings
    assertEquals(10, ParameterizedInputActionClass.getAddedStringsCount());
    for (int i = 1; i < 6; i++) {
        assertEquals(2, (int) ParameterizedInputActionClass.addedStrings.get("file" + i + ".txt"));
    }
    //check the integers
    assertEquals(4, ParameterizedInputActionClass.addedLongs.size());
    for (int i = 1; i < 5; i++) {
        assertTrue(ParameterizedInputActionClass.addedLongs.contains(new Long(i)));
    }
}
Also used : RangeDataConfig(com.axway.ats.agent.core.threading.data.config.RangeDataConfig) AllAtOncePattern(com.axway.ats.agent.core.threading.patterns.AllAtOncePattern) LoaderDataConfig(com.axway.ats.agent.core.threading.data.config.LoaderDataConfig) Test(org.junit.Test)

Example 2 with RangeDataConfig

use of com.axway.ats.agent.core.threading.data.config.RangeDataConfig in project ats-framework by Axway.

the class Test_ParameterDataProviderFactory method createIntegerRangeProvider.

@Test
public void createIntegerRangeProvider() throws AgentException {
    RangeDataConfig rangeConfig = new RangeDataConfig("param1", 10, 20);
    ParameterDataProvider dataProvider = ParameterDataProviderFactory.createDataProvider(rangeConfig);
    assertEquals(IntegerRangeParameterDataProvider.class, dataProvider.getClass());
    ArgumentValue generatedValue = dataProvider.getValue(new ArrayList<ArgumentValue>());
    assertEquals("param1", generatedValue.getName());
    assertEquals(10, 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 3 with RangeDataConfig

use of com.axway.ats.agent.core.threading.data.config.RangeDataConfig 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 4 with RangeDataConfig

use of com.axway.ats.agent.core.threading.data.config.RangeDataConfig in project ats-framework by Axway.

the class ParameterDataProviderFactory method createDataProvider.

/**
     * Create a data provider based on a configuration provider
     *
     * @param parameterConfig the configuration based on which to create the provider
     * @return the newly created provider
     * @throws ParameterDataProviderNotSupportedException if the provider is not supported
     * @throws ParameterDataProviderInitalizationException if there is an error during provider initialization
     */
public static ParameterDataProvider createDataProvider(ParameterDataConfig parameterConfig) throws ParameterDataProviderNotSupportedException, ParameterDataProviderInitalizationException {
    ParameterDataProvider parameterDataProvider;
    Class<?> parameterConfigClass = parameterConfig.getClass();
    if (parameterConfigClass == RangeDataConfig.class) {
        RangeDataConfig rangeDataConfig = (RangeDataConfig) parameterConfig;
        //choose the right one, based on the arguments
        if (rangeDataConfig.getStaticValue() != null) {
            parameterDataProvider = new StringRangeParameterDataProvider(rangeDataConfig.getParameterName(), rangeDataConfig.getStaticValue(), (Integer) rangeDataConfig.getRangeStart(), (Integer) rangeDataConfig.getRangeEnd(), parameterConfig.getParameterProviderLevel());
        } else {
            parameterDataProvider = new IntegerRangeParameterDataProvider(rangeDataConfig.getParameterName(), (Integer) rangeDataConfig.getRangeStart(), (Integer) rangeDataConfig.getRangeEnd(), parameterConfig.getParameterProviderLevel());
        }
    } else if (parameterConfigClass == ListDataConfig.class) {
        ListDataConfig listDataConfig = (ListDataConfig) parameterConfig;
        parameterDataProvider = new ListParameterDataProvider(listDataConfig.getParameterName(), listDataConfig.getValues(), listDataConfig.getParameterProviderLevel());
    } else if (parameterConfigClass == FileNamesDataConfig.class) {
        FileNamesDataConfig fileNamesDataConfig = (FileNamesDataConfig) parameterConfig;
        parameterDataProvider = new FileNamesParameterDataProvider(fileNamesDataConfig.getParameterName(), fileNamesDataConfig.getFileContainers(), fileNamesDataConfig.getRecursiveSearch(), fileNamesDataConfig.getReturnFullPath(), fileNamesDataConfig.getParameterProviderLevel());
    } else if (parameterConfigClass == UsernameDataConfig.class) {
        UsernameDataConfig nameDataConfig = (UsernameDataConfig) parameterConfig;
        if (nameDataConfig.getValues() != null) {
            parameterDataProvider = new ListParameterDataProvider(nameDataConfig.getParameterName(), nameDataConfig.getValues(), nameDataConfig.getParameterProviderLevel(), UsernameDataConfig.class);
        } else {
            parameterDataProvider = new StringRangeParameterDataProvider(nameDataConfig.getParameterName(), nameDataConfig.getStaticValue(), (Integer) nameDataConfig.getRangeStart(), (Integer) nameDataConfig.getRangeEnd(), parameterConfig.getParameterProviderLevel(), UsernameDataConfig.class);
        }
    } else if (parameterConfigClass.getGenericSuperclass() == CustomParameterDataConfig.class) {
        // custom data provider
        CustomParameterDataConfig customDataConfig = (CustomParameterDataConfig) parameterConfig;
        try {
            // find the constructor of the custom data provider
            Constructor<? extends CustomParameterDataProvider> constructor = customDataConfig.getDataProviderClass().getDeclaredConstructor(String.class, Map.class, ParameterProviderLevel.class);
            // call the constructor of the custom data provider
            parameterDataProvider = (CustomParameterDataProvider) constructor.newInstance(customDataConfig.getParameterName(), customDataConfig.getControlTokens(), customDataConfig.getParameterProviderLevel());
        } catch (Exception e) {
            throw new ParameterDataProviderNotSupportedException(parameterConfigClass);
        }
    } else {
        throw new ParameterDataProviderNotSupportedException(parameterConfigClass);
    }
    //initialize the newly created provider
    parameterDataProvider.initialize();
    //and return it back to the caller
    return parameterDataProvider;
}
Also used : RangeDataConfig(com.axway.ats.agent.core.threading.data.config.RangeDataConfig) FileNamesDataConfig(com.axway.ats.agent.core.threading.data.config.FileNamesDataConfig) UsernameDataConfig(com.axway.ats.agent.core.threading.data.config.UsernameDataConfig) ParameterDataProviderNotSupportedException(com.axway.ats.agent.core.threading.exceptions.ParameterDataProviderNotSupportedException) ParameterDataProviderInitalizationException(com.axway.ats.agent.core.threading.exceptions.ParameterDataProviderInitalizationException) CustomParameterDataConfig(com.axway.ats.agent.core.threading.data.config.CustomParameterDataConfig) ParameterDataProviderNotSupportedException(com.axway.ats.agent.core.threading.exceptions.ParameterDataProviderNotSupportedException) ListDataConfig(com.axway.ats.agent.core.threading.data.config.ListDataConfig)

Example 5 with RangeDataConfig

use of com.axway.ats.agent.core.threading.data.config.RangeDataConfig in project ats-framework by Axway.

the class DisabledTest_MultiThreadedActionHandlerWithParameterizedInputData method paremterizedIntegerDataPositive.

@Test
public void paremterizedIntegerDataPositive() throws Exception {
    LoaderDataConfig loaderDataConfig = new LoaderDataConfig();
    loaderDataConfig.addParameterConfig(new RangeDataConfig("milliseconds", 1, 300));
    AllAtOncePattern pattern = new AllAtOncePattern(5, true);
    QueueExecutionStatistics.getInstance().initActionExecutionResults("test 1");
    actionHandler.executeActions("IP", "test 1", -1, actionRequests, pattern, loaderDataConfig);
    assertEquals(5, ParameterizedInputActionClass.addedLongs.size());
    for (int i = 1; i < 6; i++) {
        assertTrue(ParameterizedInputActionClass.addedLongs.contains(new Long(i)));
    }
}
Also used : RangeDataConfig(com.axway.ats.agent.core.threading.data.config.RangeDataConfig) AllAtOncePattern(com.axway.ats.agent.core.threading.patterns.AllAtOncePattern) LoaderDataConfig(com.axway.ats.agent.core.threading.data.config.LoaderDataConfig) Test(org.junit.Test)

Aggregations

RangeDataConfig (com.axway.ats.agent.core.threading.data.config.RangeDataConfig)8 Test (org.junit.Test)7 LoaderDataConfig (com.axway.ats.agent.core.threading.data.config.LoaderDataConfig)5 AllAtOncePattern (com.axway.ats.agent.core.threading.patterns.AllAtOncePattern)5 BaseTest (com.axway.ats.agent.core.BaseTest)2 ArgumentValue (com.axway.ats.agent.core.action.ArgumentValue)2 CustomParameterDataConfig (com.axway.ats.agent.core.threading.data.config.CustomParameterDataConfig)1 FileNamesDataConfig (com.axway.ats.agent.core.threading.data.config.FileNamesDataConfig)1 ListDataConfig (com.axway.ats.agent.core.threading.data.config.ListDataConfig)1 UsernameDataConfig (com.axway.ats.agent.core.threading.data.config.UsernameDataConfig)1 ParameterDataProviderInitalizationException (com.axway.ats.agent.core.threading.exceptions.ParameterDataProviderInitalizationException)1 ParameterDataProviderNotSupportedException (com.axway.ats.agent.core.threading.exceptions.ParameterDataProviderNotSupportedException)1