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