### Question:
XYSeriesCollection extends AbstractIntervalXYDataset implements IntervalXYDataset, DomainInfo, RangeInfo, 
        VetoableChangeListener, PublicCloneable, Serializable { public void addSeries(XYSeries series) { ParamChecks.nullNotPermitted(series, "series"); if (getSeriesIndex(series.getKey()) >= 0) { throw new IllegalArgumentException( "This dataset already contains a series with the key " + series.getKey()); } this.data.add(series); series.addChangeListener(this); series.addVetoableChangeListener(this); fireDatasetChanged(); } XYSeriesCollection();  XYSeriesCollection(XYSeries series); @Override DomainOrder getDomainOrder(); void addSeries(XYSeries series); void removeSeries(int series); void removeSeries(XYSeries series); void removeAllSeries(); @Override int getSeriesCount(); List<XYSeries> getSeries(); int indexOf(XYSeries series); XYSeries getSeries(int series); XYSeries getSeries(Comparable key); @Override Comparable getSeriesKey(int series); int getSeriesIndex(Comparable key); @Override int getItemCount(int series); @Override Number getX(int series, int item); @Override Number getStartX(int series, int item); @Override Number getEndX(int series, int item); @Override Number getY(int series, int index); @Override Number getStartY(int series, int item); @Override Number getEndY(int series, int item); @Override boolean equals(Object obj); @Override Object clone(); @Override int hashCode(); @Override double getDomainLowerBound(boolean includeInterval); @Override double getDomainUpperBound(boolean includeInterval); @Override Range getDomainBounds(boolean includeInterval); double getIntervalWidth(); void setIntervalWidth(double width); double getIntervalPositionFactor(); void setIntervalPositionFactor(double factor); boolean isAutoWidth(); void setAutoWidth(boolean b); @Override Range getRangeBounds(boolean includeInterval); @Override double getRangeLowerBound(boolean includeInterval); @Override double getRangeUpperBound(boolean includeInterval); @Override void vetoableChange(PropertyChangeEvent e);  }### Answer:
@Test public void testSerialization() { XYSeries s1 = new XYSeries("Series"); s1.add(1.0, 1.1); XYSeriesCollection c1 = new XYSeriesCollection(); c1.addSeries(s1); XYSeriesCollection c2 = (XYSeriesCollection) TestUtilities.serialised(c1); assertEquals(c1, c2); }
@Test public void testAddSeries() { XYSeriesCollection c = new XYSeriesCollection(); XYSeries s1 = new XYSeries("s1"); c.addSeries(s1); XYSeries s2 = new XYSeries("s1"); try { c.addSeries(s2); fail("Should have thrown IllegalArgumentException on duplicate key"); } catch (IllegalArgumentException e) { assertEquals("This dataset already contains a series with the key s1", e.getMessage()); } assertEquals(1, c.getSeriesCount()); }
@Test public void testRenameSeries() { XYSeries s1 = new XYSeries("S1"); XYSeries s2 = new XYSeries("S2"); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(s1); dataset.addSeries(s2); try { s2.setKey("S1"); fail("Should have thrown IndexOutOfBoundsException on negative key"); } catch (IllegalArgumentException e) { assertEquals("java.beans.PropertyVetoException: Duplicate key", e.getMessage()); } }
@Test public void testSerialization() { XYSeries s1 = new XYSeries("Series"); s1.add(1.0, 1.1); XYSeriesCollection c1 = new XYSeriesCollection(); c1.addSeries(s1); XYSeriesCollection c2 = (XYSeriesCollection) TestUtils.serialised(c1); assertEquals(c1, c2); }