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 */
006package org.fcrepo.camel.fixity;
007
008import org.apache.camel.CamelContext;
009import org.apache.camel.spring.javaconfig.CamelConfiguration;
010import org.junit.BeforeClass;
011import org.junit.Test;
012import org.junit.runner.RunWith;
013import org.springframework.beans.factory.annotation.Autowired;
014import org.springframework.context.annotation.ComponentScan;
015import org.springframework.context.annotation.Configuration;
016import org.springframework.test.annotation.DirtiesContext;
017import org.springframework.test.context.ContextConfiguration;
018import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
019import org.springframework.test.context.support.AnnotationConfigContextLoader;
020
021import static org.junit.Assert.assertNull;
022
023/**
024 * Test that the route can be disabled.
025 *
026 * @author dbernstein
027 * @since 2021-10-01
028 */
029@RunWith(SpringJUnit4ClassRunner.class)
030@ContextConfiguration(classes = {RouteDisabledTest.ContextConfig.class}, loader = AnnotationConfigContextLoader.class)
031public class RouteDisabledTest {
032
033    @Autowired
034    private CamelContext camelContext;
035
036    @Autowired(required = false)
037    private FcrepoFixityConfig config;
038
039    @BeforeClass
040    public static void beforeClass() {
041        System.setProperty("fixity.enabled", "false");
042    }
043
044    @DirtiesContext
045    @Test
046    public void testFixityDisabled() throws Exception {
047       assertNull("fixity config should be null", config);
048    }
049
050    @Configuration
051    @ComponentScan(resourcePattern = "**/Fcrepo*.class")
052    static class ContextConfig extends CamelConfiguration {
053    }
054
055}
056