001/** 002 * Copyright 2015 DuraSpace, Inc. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.fcrepo.integration.connector.file; 017 018import org.fcrepo.kernel.api.models.FedoraResource; 019 020import org.junit.Test; 021 022import javax.jcr.Node; 023import javax.jcr.RepositoryException; 024import javax.jcr.Session; 025 026import static com.google.common.collect.Iterators.size; 027import static org.junit.Assert.assertEquals; 028 029/** 030 * @author Mike Durbin 031 */ 032 033public class ReadOnlyExternalPropertiesFedoraFileSystemConnectorIT extends AbstractFedoraFileSystemConnectorIT { 034 035 @Override 036 protected String federationName() { 037 return "readonly-federated"; 038 } 039 040 @Override 041 protected String getFederationRoot() { 042 return getReadOnlyFederationRoot(); 043 } 044 045 @Override 046 protected String testDirPath() { 047 return "/" + federationName(); 048 } 049 050 @Override 051 protected String testFilePath() { 052 return "/" + federationName() + "/repo.xml"; 053 } 054 055 @Test 056 public void verifyThatPropertiesAreExternal() throws RepositoryException { 057 final Session session = repo.login(); 058 try { 059 final FedoraResource object = nodeService.find(session, testFilePath()); 060 assertEquals( 061 "There should be exactly as many visible nodes as actual files (ie, no hidden sidecar files).", 062 fileForNode().getParentFile().list().length, getChildCount(object.getNode().getParent())); 063 } finally { 064 session.logout(); 065 } 066 } 067 068 protected int getChildCount(final Node node) throws RepositoryException { 069 return size(node.getNodes()); 070 } 071 072}