Example usage for org.jfree.data UnknownKeyException getMessage

List of usage examples for org.jfree.data UnknownKeyException getMessage

Introduction

In this page you can find the example usage for org.jfree.data UnknownKeyException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.jfree.data.xy.XYSeriesCollectionTest.java

/**
 * Some checks for the getSeries(Comparable) method.
 *//*from  ww  w .ja  v a2 s.  c o  m*/
@Test
public void testGetSeriesByKey() {
    XYSeriesCollection c = new XYSeriesCollection();
    XYSeries s1 = new XYSeries("s1");
    c.addSeries(s1);
    assertEquals("s1", c.getSeries("s1").getKey());

    try {
        c.getSeries("s2");
        fail("Should have thrown UnknownKeyException on unknown key");
    } catch (UnknownKeyException e) {
        assertEquals("Key not found: s2", e.getMessage());
    }

    try {
        c.getSeries(null);
        fail("Should have thrown IndexOutOfBoundsException on null key");
    } catch (IllegalArgumentException e) {
        assertEquals("Null 'key' argument.", e.getMessage());
    }
}