2 * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.aaa.shiro.authorization;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertNotNull;
14 import com.google.common.collect.Sets;
15 import java.util.Collection;
16 import org.junit.Test;
19 * A few basic test cases for the DefualtRBACRules singleton container.
21 * @author Ryan Goulding (ryandgoulding@gmail.com)
24 public class DefaultRBACRulesTest {
27 public void testGetInstance() {
28 assertNotNull(DefaultRBACRules.getInstance());
29 assertEquals(DefaultRBACRules.getInstance(), DefaultRBACRules.getInstance());
33 public void testGetRBACRules() {
34 Collection<RBACRule> rbacRules = DefaultRBACRules.getInstance().getRBACRules();
35 assertNotNull(rbacRules);
37 // check that a copy was returned
38 int originalSize = rbacRules.size();
39 rbacRules.add(RBACRule.createAuthorizationRule("fakeurl/*", Sets.newHashSet("admin")));
40 assertEquals(originalSize, DefaultRBACRules.getInstance().getRBACRules().size());