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.migration.foxml; 017 018import org.apache.commons.io.FileUtils; 019import org.junit.Assert; 020import org.junit.After; 021import org.junit.Before; 022import org.junit.Test; 023 024import java.io.File; 025import java.io.IOException; 026import java.io.UnsupportedEncodingException; 027 028/** 029 * @author mikedurbin 030 */ 031public class LegacyFSIDResolverTest { 032 033 private LegacyFSIDResolver idResolver; 034 035 private File tempDir; 036 037 @Before 038 public void setup() throws IOException { 039 tempDir = File.createTempFile("tempfile", "basedir"); 040 tempDir.delete(); 041 tempDir.mkdir(); 042 idResolver = new LegacyFSIDResolver(tempDir); 043 } 044 045 @Test 046 public void testIDMapping() throws UnsupportedEncodingException { 047 Assert.assertEquals("example:1+DS2+DS2.0", idResolver.getInternalIdForFile(new File("example_1+DS2+DS2.0"))); 048 } 049 050 @After 051 public void cleanup() throws IOException { 052 FileUtils.deleteDirectory(tempDir); 053 } 054}