com.qmetry.qaf.automation.testng.dataprovider.DataProviderUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of qaf Show documentation
Show all versions of qaf Show documentation
Functional test automation framework for web, mobile-web, mobile native and web-service
/*******************************************************************************
* Copyright (c) 2019 Infostretch Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
******************************************************************************/
package com.qmetry.qaf.automation.testng.dataprovider;
import static com.qmetry.qaf.automation.core.ConfigurationManager.getBundle;
import static org.apache.commons.lang.StringUtils.isNotBlank;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.impl.LogFactoryImpl;
import org.json.JSONObject;
import org.testng.annotations.ITestAnnotation;
import com.qmetry.qaf.automation.core.ConfigurationManager;
import com.qmetry.qaf.automation.testng.DataProviderException;
import com.qmetry.qaf.automation.util.PropertyUtil;
import com.qmetry.qaf.automation.util.StringUtil;
/**
* Utility class for TestNG data providers.
*
* - Example Usage: @Test(dataProvider = "csvDataProvider", dataProviderClass
* = DataProviderUtil.class)
*
- Excel Data provider:
*
* - excelDataProvider, excelDataProviderParallel
* Required properties:
*
* - test.<method name>.datafile=<datafile URL>,<optional sheet
* name> If the data is not in in first sheet of workbook then provide
* sheet-name with datafile separated by comma
*
- test.<method name>.data.hasheader=true/false set true to skip
* header row
*
* - excelTableDataProvider, excelTableDataProviderParallel
* provides data from excel sheet marked with data set name
* Required properties:
*
* - test.<method name>.datafile=<datafile URL>,<data set
* name>,<optional sheet name> If the data is not in in first sheet of
* workbook then provide sheet-name with datafile separated by comma
*
*
* - CSV Data provider:
*
* - csvDataProvider, csvDataProviderParallel
* Required property
*
* - test.<method_name>.datafile= <file URL>
*
*
*
* com.qmetry.qaf.automation.testng.dataprovider.DataProviderUtil.java
*
* @author chirag.jayswal
*/
public class DataProviderUtil {
private static final Log logger = LogFactoryImpl.getLog(DataProviderUtil.class);
/**
* Blank values will be considered as null as type is not be identifiable from blank
* @param key
* @param file
* @return
*/
public static List