Search in sources :

Example 1 with MeasurementException

use of javax.measure.MeasurementException in project unit-api by unitsofmeasurement.

the class ExceptionsTest method testMeasurementExceptionWithMessageAndCause.

@Test(expected = MeasurementException.class)
public void testMeasurementExceptionWithMessageAndCause() {
    Exception cause = new IllegalStateException();
    MeasurementException e = new MeasurementException("state error", cause);
    assertEquals("state error", e.getMessage());
    assertEquals(cause, e.getCause());
    throw e;
}
Also used : MeasurementException(javax.measure.MeasurementException) IncommensurableException(javax.measure.IncommensurableException) MeasurementException(javax.measure.MeasurementException) UnconvertibleException(javax.measure.UnconvertibleException) Test(org.junit.Test)

Example 2 with MeasurementException

use of javax.measure.MeasurementException in project unit-api by unitsofmeasurement.

the class ExceptionsTest method testDefaultConstructor.

@Test(expected = MeasurementException.class)
public void testDefaultConstructor() {
    MeasurementException e = new TestException();
    assertNull(e.getMessage());
    assertNull(e.getCause());
    throw e;
}
Also used : MeasurementException(javax.measure.MeasurementException) Test(org.junit.Test)

Example 3 with MeasurementException

use of javax.measure.MeasurementException in project unit-api by unitsofmeasurement.

the class ExceptionsTest method testMeasurementException.

@Test(expected = MeasurementException.class)
public void testMeasurementException() {
    MeasurementException e = new MeasurementException("error");
    assertEquals("error", e.getMessage());
    assertNull(e.getCause());
    throw e;
}
Also used : MeasurementException(javax.measure.MeasurementException) Test(org.junit.Test)

Aggregations

MeasurementException (javax.measure.MeasurementException)3 Test (org.junit.Test)3 IncommensurableException (javax.measure.IncommensurableException)1 UnconvertibleException (javax.measure.UnconvertibleException)1