lundi 23 novembre 2015

how to get rid of array list error in selenium using data driven?

i am trying to do data driven code in selenium. in my file that takes data from excel is giving me warnings for array list. if i solve it by changing arraylist or arraylist, it is not working. Even supression is not working. i have also tried by giving wild card using . still the warnings are not getting removed. below is my code:

package testscript;
import org.testng.annotations.Test;
import org.testng.AssertJUnit;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Iterator;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;


public class dataprovider {

 static keywords key;

 //public static void main(String[]args) throws Exception
 @Test
public void leadTest() throws Exception
 {
  key =new keywords();
  ArrayList data=new ArrayList();
  FileInputStream file=new FileInputStream("F:\\java programming\\eclipse\\darwish1\\darwishdatadriven\\src\\testresource\\data\\LeadSuite1.xlsx");
  XSSFWorkbook workbook=new XSSFWorkbook(file);
  XSSFSheet sheet =workbook.getSheet("TestSteps");
  Iterator row= sheet.iterator();
  while(row.hasNext())
  {
   Row rowIterator=(Row) row.next();
   Iterator cellItr=rowIterator.cellIterator();
   while(cellItr.hasNext())
   {
    Cell cells=(Cell) cellItr.next();
    switch (cells.getCellType())
    {
     case Cell.CELL_TYPE_STRING:
     data.add(cells.getStringCellValue());
     break;

     case Cell.CELL_TYPE_BOOLEAN:

     data.add(cells.getBooleanCellValue());
     break;

     case Cell.CELL_TYPE_NUMERIC:
     data.add(cells.getNumericCellValue());
     break;

    }

   }

  }

here is the problem:

Description Resource    Path    Location    Type
ArrayList is a raw type. References to generic type ArrayList<E> should be parameterized    dataprovider.java   /darwishdatadriven/src/testscript   line 23 Java Problem
ArrayList is a raw type. References to generic type ArrayList<E> should be parameterized    dataprovider.java   /darwishdatadriven/src/testscript   line 23 Java Problem
Iterator is a raw type. References to generic type Iterator<E> should be parameterized  dataprovider.java   /darwishdatadriven/src/testscript   line 27 Java Problem
Iterator is a raw type. References to generic type Iterator<E> should be parameterized  dataprovider.java   /darwishdatadriven/src/testscript   line 31 Java Problem
Resource leak: 'workbook' is never closed   dataprovider.java   /darwishdatadriven/src/testscript   line 25 Java Problem
The import java.io.FileNotFoundException is never used  keywords.java   /darwishdatadriven/src/testscript   line 4  Java Problem
Type safety: The method add(Object) belongs to the raw type ArrayList. References to generic type ArrayList<E> should be parameterized  dataprovider.java   /darwishdatadriven/src/testscript   line 38 Java Problem
Type safety: The method add(Object) belongs to the raw type ArrayList. References to generic type ArrayList<E> should be parameterized  dataprovider.java   /darwishdatadriven/src/testscript   line 43 Java Problem
Type safety: The method add(Object) belongs to the raw type ArrayList. References to generic type ArrayList<E> should be parameterized  dataprovider.java   /darwishdatadriven/src/testscript   line 47 Java Problem

Aucun commentaire:

Enregistrer un commentaire