### Question:
XIntervalSeriesCollection extends AbstractIntervalXYDataset implements IntervalXYDataset, PublicCloneable, Serializable { public void removeSeries(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds."); } XIntervalSeries ts = this.data.get(series); ts.removeChangeListener(this); this.data.remove(series); fireDatasetChanged(); } XIntervalSeriesCollection(); void addSeries(XIntervalSeries series); @Override int getSeriesCount(); XIntervalSeries getSeries(int series); @Override Comparable getSeriesKey(int series); @Override int getItemCount(int series); @Override Number getX(int series, int item); @Override double getStartXValue(int series, int item); @Override double getEndXValue(int series, int item); @Override double getYValue(int series, int item); @Override Number getY(int series, int item); @Override Number getStartX(int series, int item); @Override Number getEndX(int series, int item); @Override Number getStartY(int series, int item); @Override Number getEndY(int series, int item); void removeSeries(int series); void removeSeries(XIntervalSeries series); void removeAllSeries(); @Override boolean equals(Object obj); @Override Object clone();  }### Answer:
@Test public void testRemoveSeries() { XIntervalSeriesCollection c = new XIntervalSeriesCollection(); XIntervalSeries s1 = new XIntervalSeries("s1"); c.addSeries(s1); c.removeSeries(0); assertEquals(0, c.getSeriesCount()); c.addSeries(s1); try { c.removeSeries(-1); fail("IllegalArgumentException should have been thrown on negative key"); } catch (IllegalArgumentException e) { assertEquals("Series index out of bounds.", e.getMessage()); } try { c.removeSeries(1); fail("IllegalArgumentException should have been thrown on key out of range key"); } catch (IllegalArgumentException e) { assertEquals("Series index out of bounds.", e.getMessage()); } }