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 org.junit.Before;
010import org.springframework.context.ConfigurableApplicationContext;
011import org.springframework.context.support.ClassPathXmlApplicationContext;
012
013import javax.xml.stream.XMLStreamException;
014import java.io.IOException;
015
016/**
017 * @author mdurbin
018 */
019public class LegacyFoxmlStorageMigratorTest extends Example1TestSuite {
020
021    private static DummyHandler result;
022
023    private static DummyURLFetcher fetcher;
024
025    @Before
026    public synchronized void processFoxml() throws XMLStreamException, IOException {
027        if (getResult() == null) {
028            final ConfigurableApplicationContext context =
029                    new ClassPathXmlApplicationContext("spring/stored-legacy-foxml.xml");
030            this.result = (DummyHandler) context.getBean("dummyHandler");
031            this.fetcher = (DummyURLFetcher) context.getBean("dummyFetcher");
032            final Migrator m = (Migrator) context.getBean("migrator");
033            m.run();
034            context.close();
035        }
036    }
037
038    @Override
039    protected DummyHandler getResult() {
040        return result;
041    }
042
043    @Override
044    protected DummyURLFetcher getFetcher() {
045        return fetcher;
046    }
047}