import com.google.common.collect.ImmutableSet;
import java.util.EventListener;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
public class ListenerRegistryTest {
-
private TestEventListener testEventListener;
private ExtendedTestEventListener extendedTestEventListener;
private ListenerRegistry<TestEventListener> registry;
- @Rule
- public ExpectedException expException = ExpectedException.none();
-
@Before
public void init() {
testEventListener = new TestEventListener() {};
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.yangtools.yang.stmt;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import java.net.URI;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.common.Revision;
private DataSchemaNode tempThirdChild;
private CaseSchemaNode tempChoice;
- @Rule
- public ExpectedException expectedEx = ExpectedException.none();
-
@Before
public void setup() throws Exception {
schema = StmtTestUtils.parseYangSources("/case-test");
}
@Test
- public void testInferenceExceptionChoice() throws Exception {
- expectedEx.expect(ReactorException.class);
- schema = StmtTestUtils.parseYangSources("/case-test/case-test-exceptions/choice");
+ public void testInferenceExceptionChoice() {
+ assertThrows(ReactorException.class,
+ () -> StmtTestUtils.parseYangSources("/case-test/case-test-exceptions/choice"));
}
@Test
public void testInferenceExceptionCase() throws Exception {
- expectedEx.expect(ReactorException.class);
- schema = StmtTestUtils.parseYangSources("/case-test/case-test-exceptions/case");
+ assertThrows(ReactorException.class,
+ () -> StmtTestUtils.parseYangSources("/case-test/case-test-exceptions/case"));
}
}
\ No newline at end of file
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Collection;
import org.junit.After;
import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
private final PrintStream stdout = System.out;
private final ByteArrayOutputStream output = new ByteArrayOutputStream();
- @Rule
- public ExpectedException expectedEx = ExpectedException.none();
-
@Before
public void setUp() throws UnsupportedEncodingException {
System.setOut(new PrintStream(output, true, "UTF-8"));
}
@Test
- public void missingElementException() throws Exception {
- expectedEx.expect(SomeModifiersUnresolvedException.class);
-
- TestUtils.loadModules(getClass().getResource("/substatement-validator/missing-element").toURI());
+ public void missingElementException() {
+ assertThrows(SomeModifiersUnresolvedException.class, () -> TestUtils.loadModules(
+ SubstatementValidatorTest.class.getResource("/substatement-validator/missing-element").toURI()));
}
@Test
@Test
public void bug4310test() throws Exception {
- expectedEx.expect(SomeModifiersUnresolvedException.class);
- TestUtils.loadModules(getClass().getResource("/substatement-validator/bug-4310").toURI());
+ assertThrows(SomeModifiersUnresolvedException.class, () -> TestUtils.loadModules(
+ SubstatementValidatorTest.class.getResource("/substatement-validator/bug-4310").toURI()));
}
}
\ No newline at end of file