@Test
public void testToArray() {

  String[] oneString = Lists.toArray(Collections.singletonList("foo"), String.class);
  assertEquals(1, oneString.length);
  assertEquals("foo", oneString[0]);
  oneString = Lists.toArray(Collections.<String>singletonList(null), String.class);
  assertEquals(1, oneString.length);
  assertNull(oneString[0]);
  String[] emptyOut = Lists.toArray(Collections.<String>emptyList(), String.class);
  assertNotNull(emptyOut);
  assertEquals(0, emptyOut.length);
  String[] nulOut = Lists.<String>toArray(null, String.class);
  assertNotNull(nulOut);
  assertEquals(0, nulOut.length);
}