
java.fedora.server.test.RepositoryReaderTest Maven / Gradle / Ivy
Show all versions of fcrepo-client Show documentation
/*
* -----------------------------------------------------------------------------
*
* License and Copyright: The contents of this file are subject to the
* Apache License, Version 2.0 (the "License"); you may not use
* this file except in compliance with the License. You may obtain a copy of
* the License at
* http://www.fedora-commons.org/licenses.
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The entire file consists of original code.
* Copyright © 2008 Fedora Commons, Inc.
*
Copyright © 2002-2007 The Rector and Visitors of the University of
* Virginia and Cornell University
* All rights reserved.
*
* -----------------------------------------------------------------------------
*/
package fedora.server.test;
import java.io.File;
import java.util.HashMap;
import junit.framework.TestCase;
import fedora.common.Constants;
import fedora.server.Server;
import fedora.server.storage.BDefReader;
import fedora.server.storage.BMechReader;
import fedora.server.storage.DirectoryBasedRepositoryReader;
import fedora.server.storage.DOReader;
import fedora.server.storage.translation.DOTranslatorImpl;
import fedora.server.storage.translation.METSLikeDODeserializer;
import fedora.server.storage.translation.METSLikeDOSerializer;
/**
*
* Title: RepositoryReaderTest.java
* Description: Tests the implementation of the RepositoryReader
* interface, DirectoryBasedRepositoryReader.
*
* @author [email protected]
* @version $Id: RepositoryReaderTest.java 5313 2006-12-06 12:14:27Z cwilper $
*/
public class RepositoryReaderTest
extends TestCase {
private File m_repoDir;
private DirectoryBasedRepositoryReader m_repoReader;
public RepositoryReaderTest(String fedoraHome, String label) {
super(label);
m_repoDir=new File(new File(fedoraHome), "demo");
}
public void setUp() {
try {
String mets="metslikefedora1";
HashMap sers=new HashMap();
sers.put(mets, new METSLikeDOSerializer());
HashMap desers=new HashMap();
desers.put(mets, new METSLikeDODeserializer());
DOTranslatorImpl translator=new DOTranslatorImpl(sers, desers);
m_repoReader= new DirectoryBasedRepositoryReader(m_repoDir,
translator, mets, mets, "UTF-8");
} catch (Exception e) {
System.out.println("ERROR: " + e.getClass().getName() + ": " + e.getMessage());
}
}
public void testList() {
try {
String[] pids=m_repoReader.listObjectPIDs(null);
System.out.println("Repository has " + pids.length + " objects.");
} catch (Exception e) {
System.out.println("ERROR: " + e.getClass().getName() + ": " + e.getMessage());
}
}
public void testGetReader() {
try {
String[] pids=m_repoReader.listObjectPIDs(null);
for (int i=0; i