001/* 002 * Licensed to DuraSpace under one or more contributor license agreements. 003 * See the NOTICE file distributed with this work for additional information 004 * regarding copyright ownership. 005 * 006 * DuraSpace licenses this file to you under the Apache License, 007 * Version 2.0 (the "License"); you may not use this file except in 008 * compliance with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.fcrepo.auth.webac; 019 020import static org.fcrepo.auth.webac.URIConstants.WEBAC_MODE_READ; 021import static org.fcrepo.auth.webac.URIConstants.WEBAC_MODE_WRITE; 022import static org.junit.Assert.assertFalse; 023import static org.junit.Assert.assertTrue; 024 025import java.net.URI; 026 027import org.junit.Test; 028 029/** 030 * @author peichman 031 */ 032public class WebACPermissionTest { 033 034 private static final URI resourceA = URI.create("http://localhost:8080/fcrepo/test"); 035 036 private static final URI resourceB = URI.create("http://localhost:8080/fcrepo/test2"); 037 038 @Test 039 public void testEquality() { 040 final WebACPermission p1 = new WebACPermission(WEBAC_MODE_READ, resourceA); 041 final WebACPermission p2 = new WebACPermission(WEBAC_MODE_READ, resourceA); 042 assertTrue(p1.implies(p2)); 043 assertTrue(p2.implies(p1)); 044 } 045 046 @Test 047 public void testInequalityOfResources() { 048 final WebACPermission p1 = new WebACPermission(WEBAC_MODE_READ, resourceA); 049 final WebACPermission p2 = new WebACPermission(WEBAC_MODE_READ, resourceB); 050 assertFalse(p1.implies(p2)); 051 assertFalse(p2.implies(p1)); 052 } 053 054 @Test 055 public void testInequalityOfModes() { 056 final WebACPermission p1 = new WebACPermission(WEBAC_MODE_READ, resourceA); 057 final WebACPermission p2 = new WebACPermission(WEBAC_MODE_WRITE, resourceA); 058 assertFalse(p1.implies(p2)); 059 assertFalse(p2.implies(p1)); 060 } 061 062}