@Test
public void testWithEmptyList() {

  try {
    List<String> list = new ArrayList<String>();
    String[] arr = GenericsUtil.toArray(list);
    fail("Empty array should throw exception");
    System.out.println(arr); //use arr so that compiler will not complain
  }catch (IndexOutOfBoundsException ex) {
    //test case is successful
  }
}