Unit tests for controller RequestException
[controller.git] / opendaylight / md-sal / cds-access-api / src / test / java / org / opendaylight / controller / cluster / access / concepts / RuntimeRequestExceptionTest.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.access.concepts;
9
10 import static org.junit.Assert.assertFalse;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13
14 import org.junit.Test;
15
16 public class RuntimeRequestExceptionTest extends RequestExceptionTest<RuntimeRequestException> {
17
18     private static final RequestException OBJECT = new RuntimeRequestException(
19             "RuntimeRequestExeption dummy message", new Throwable("throwable dummy message"));
20
21     @Override
22     protected void isRetriable() {
23         assertFalse(OBJECT.isRetriable());
24     }
25
26     @Override
27     protected void checkMessage() {
28         String message = OBJECT.getMessage();
29         assertTrue("RuntimeRequestExeption dummy message".equals(message));
30         message = OBJECT.getCause().getMessage();
31         assertTrue("throwable dummy message".equals(message));
32         assertNotNull(OBJECT.getCause());
33     }
34
35     @Test(expected = NullPointerException.class)
36     public void testFail() {
37         try {
38             //check cause can not be null
39             new RuntimeRequestException("dummy message", null);
40         } catch (final NullPointerException ex) {
41             //check message can not be null
42             new RuntimeRequestException(null, new Throwable("dummy throwable"));
43         }
44     }
45
46 }