001/** 002 * The contents of this file are subject to the license and copyright 003 * detailed in the LICENSE and NOTICE files at the root of the source 004 * tree. 005 * 006 */ 007package org.fcrepo.migration; 008 009import java.io.IOException; 010 011import javax.xml.stream.XMLStreamException; 012 013import org.junit.Before; 014import org.junit.Test; 015import org.springframework.context.ConfigurableApplicationContext; 016import org.springframework.context.support.ClassPathXmlApplicationContext; 017 018/** 019 * A series of tests that cover all the features used in processing 020 * FOXML exported using the context=archive option. 021 * @author mdurbin 022 */ 023public class ExportedArchiveFoxmlMigratorTest extends Example1TestSuite { 024 025 private static DummyHandler result; 026 027 private static DummyURLFetcher fetcher; 028 029 @Before 030 public synchronized void processFoxml() throws XMLStreamException, IOException { 031 if (getResult() == null) { 032 final ConfigurableApplicationContext context = 033 new ClassPathXmlApplicationContext("spring/exported-foxml.xml"); 034 this.result = (DummyHandler) context.getBean("dummyHandler"); 035 this.fetcher = (DummyURLFetcher) context.getBean("dummyFetcher"); 036 final Migrator m = (Migrator) context.getBean("migrator"); 037 m.run(); 038 context.close(); 039 } 040 } 041 042 @Override 043 protected DummyHandler getResult() { 044 return result; 045 } 046 047 @Override 048 protected DummyURLFetcher getFetcher() { 049 return fetcher; 050 } 051 052 @Test (expected = IllegalStateException.class) 053 public void testTempFileRemoval() throws IOException { 054 getResult().dsVersions.get(4).getContent(); 055 } 056}