/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013, 2017 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+
import com.google.common.base.Throwables;
import com.google.common.collect.Maps;
import java.util.HashMap;
assertEquals(serviceQName, ObjectNameUtil.getServiceQName(serviceReferenceON));
assertEquals(refName, ObjectNameUtil.getReferenceName(serviceReferenceON));
assertEquals(transaction, ObjectNameUtil.getTransactionName(serviceReferenceON));
- assertEquals(ObjectNameUtil.createReadOnlyServiceON(serviceQName, refName), ObjectNameUtil.withoutTransactionName(serviceReferenceON));
+ assertEquals(ObjectNameUtil.createReadOnlyServiceON(serviceQName, refName),
+ ObjectNameUtil.withoutTransactionName(serviceReferenceON));
serviceReferenceON = ObjectNameUtil.createReadOnlyServiceON(serviceQName, refName);
assertFalse(serviceReferenceON.isPattern());
@Test
public void testChecks() throws Exception {
- final ObjectName on = ObjectNameUtil.createON("customDomain", ObjectNameUtil.TYPE_KEY, ObjectNameUtil.TYPE_MODULE);
-
- assertFailure(new Runnable() {
- @Override
- public void run() {
- ObjectNameUtil.checkTypeOneOf(on, ObjectNameUtil.TYPE_RUNTIME_BEAN, ObjectNameUtil.TYPE_CONFIG_TRANSACTION);
- }
- }, IllegalArgumentException.class);
-
- assertFailure(new Runnable() {
- @Override
- public void run() {
- ObjectNameUtil.checkType(on, ObjectNameUtil.TYPE_RUNTIME_BEAN);
- }
- }, IllegalArgumentException.class);
-
- assertFailure(new Runnable() {
- @Override
- public void run() {
- ObjectNameUtil.checkDomain(on);
- }
- }, IllegalArgumentException.class);
+ final ObjectName on = ObjectNameUtil.createON("customDomain", ObjectNameUtil.TYPE_KEY,
+ ObjectNameUtil.TYPE_MODULE);
+
+ assertFailure(() -> ObjectNameUtil.checkTypeOneOf(on, ObjectNameUtil.TYPE_RUNTIME_BEAN,
+ ObjectNameUtil.TYPE_CONFIG_TRANSACTION), IllegalArgumentException.class);
+
+ assertFailure(() -> ObjectNameUtil.checkType(on, ObjectNameUtil.TYPE_RUNTIME_BEAN),
+ IllegalArgumentException.class);
+
+ assertFailure(() -> ObjectNameUtil.checkDomain(on), IllegalArgumentException.class);
}
+ @SuppressWarnings("IllegalCatch")
private void assertFailure(final Runnable test, final Class<? extends Exception> ex) {
try {
test.run();
- } catch(Exception e) {
+ } catch (final Exception e) {
assertTrue("Failed with wrong exception: " + Throwables.getStackTraceAsString(e),
e.getClass().isAssignableFrom(ex));
return;