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.integration.connector.file; 019 020import org.fcrepo.kernel.api.models.FedoraResource; 021 022import org.junit.Test; 023 024import javax.jcr.Node; 025import javax.jcr.RepositoryException; 026import javax.jcr.Session; 027 028import static org.fcrepo.kernel.modeshape.utils.FedoraTypesUtils.getJcrNode; 029import static com.google.common.collect.Iterators.size; 030import static org.junit.Assert.assertEquals; 031 032/** 033 * @author Mike Durbin 034 */ 035 036public class ReadOnlyExternalPropertiesFedoraFileSystemConnectorIT extends AbstractFedoraFileSystemConnectorIT { 037 038 @Override 039 protected String federationName() { 040 return "readonly-federated"; 041 } 042 043 @Override 044 protected String getFederationRoot() { 045 return getReadOnlyFederationRoot(); 046 } 047 048 @Override 049 protected String testDirPath() { 050 return "/" + federationName(); 051 } 052 053 @Override 054 protected String testFilePath() { 055 return "/" + federationName() + "/repo.xml"; 056 } 057 058 @Test 059 public void verifyThatPropertiesAreExternal() throws RepositoryException { 060 final Session session = repo.login(); 061 try { 062 final FedoraResource object = nodeService.find(session, testFilePath()); 063 assertEquals( 064 "There should be exactly as many visible nodes as actual files (ie, no hidden sidecar files).", 065 fileForNode().getParentFile().list().length, getChildCount(getJcrNode(object).getParent())); 066 } finally { 067 session.logout(); 068 } 069 } 070 071 protected int getChildCount(final Node node) throws RepositoryException { 072 return size(node.getNodes()); 073 } 074 075}