X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fmessagebus-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmessagebus%2Fapp%2Fimpl%2FUtilTest.java;fp=opendaylight%2Fmd-sal%2Fmessagebus-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmessagebus%2Fapp%2Fimpl%2FUtilTest.java;h=0000000000000000000000000000000000000000;hb=277612ebea9b441977cdb8460b2e76090df6f9e8;hp=7aebb8fbdd6ac14919c9b1c8d6d5ec8327559f5c;hpb=23fe9ca678ada6263fec5dd996f4025e4a32fcf5;p=controller.git diff --git a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/UtilTest.java b/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/UtilTest.java deleted file mode 100644 index 7aebb8fbdd..0000000000 --- a/opendaylight/md-sal/messagebus-impl/src/test/java/org/opendaylight/controller/messagebus/app/impl/UtilTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2015 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, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.messagebus.app.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.regex.Pattern; - -import org.junit.Test; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; -/** - * @author ppalmar - * - */ -public class UtilTest { - - @Test - public void testResultFor() throws Exception { - { - final String expectedResult = "dummy string"; - RpcResult rpcResult = Util.resultRpcSuccessFor(expectedResult).get(); - assertEquals(expectedResult, rpcResult.getResult()); - assertTrue(rpcResult.isSuccessful()); - assertTrue(rpcResult.getErrors().isEmpty()); - } - { - final Integer expectedResult = 42; - RpcResult rpcResult = Util.resultRpcSuccessFor(expectedResult).get(); - assertEquals(expectedResult, rpcResult.getResult()); - assertTrue(rpcResult.isSuccessful()); - assertTrue(rpcResult.getErrors().isEmpty()); - } - } - - @Test - public void testExpandQname() throws Exception { - // match no path because the list of the allowed paths is empty - { - final List paths = new ArrayList<>(); - final Pattern regexPattern = Pattern.compile(".*"); // match everything - final List matchingPaths = Util.expandQname(paths, regexPattern); - assertTrue(matchingPaths.isEmpty()); - } - - // match no path because of regex pattern - { - final List paths = createSchemaPathList(); - final Pattern regexPattern = Pattern.compile("^@.*"); - final List matchingPaths = Util.expandQname(paths, regexPattern); - assertTrue(matchingPaths.isEmpty()); - } - - // match all paths - { - final List paths = createSchemaPathList(); - final Pattern regexPattern = Pattern.compile(".*"); - final List matchingPaths = Util.expandQname(paths, regexPattern); - assertTrue(matchingPaths.contains(paths.get(0))); - assertTrue(matchingPaths.contains(paths.get(1))); - assertEquals(paths.size(), matchingPaths.size()); - } - - // match one path only - { - final List paths = createSchemaPathList(); - final Pattern regexPattern = Pattern.compile(".*yyy$"); - final List matchingPaths = Util.expandQname(paths, regexPattern); - assertTrue(matchingPaths.contains(paths.get(1))); - assertEquals(1, matchingPaths.size()); - } - } - - private static List createSchemaPathList() { - final QName qname1 = QName.create("urn:odl:xxx", "2015-01-01", "localName"); - final QName qname2 = QName.create("urn:odl:yyy", "2015-01-01", "localName"); - final SchemaPath path1 = SchemaPath.create(true, qname1); - final SchemaPath path2 = SchemaPath.create(true, qname2); - return Arrays.asList(path1, path2); - } -}