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.camel.integration;
017
018import static org.slf4j.LoggerFactory.getLogger;
019import static org.junit.Assert.assertTrue;
020import static org.ops4j.pax.exam.CoreOptions.maven;
021import static org.ops4j.pax.exam.CoreOptions.bundle;
022import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole;
023import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
024import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
025import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
026import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
027
028import java.io.File;
029
030import javax.inject.Inject;
031
032import org.apache.karaf.features.FeaturesService;
033import org.junit.Test;
034import org.junit.runner.RunWith;
035import org.ops4j.pax.exam.Configuration;
036import org.ops4j.pax.exam.ConfigurationManager;
037import org.ops4j.pax.exam.Option;
038import org.ops4j.pax.exam.junit.PaxExam;
039import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel;
040import org.slf4j.Logger;
041
042/**
043 * @author Aaron Coburn
044 * @since February 8, 2016
045 */
046@RunWith(PaxExam.class)
047public class KarafIT {
048
049    private static Logger LOG = getLogger(KarafIT.class);
050
051    @Inject
052    protected FeaturesService featuresService;
053
054    @Configuration
055    public Option[] config() {
056        final ConfigurationManager cm = new ConfigurationManager();
057        final String fcrepoFeatures = "file:" + cm.getProperty("project.build.outputDirectory") + "/features.xml";
058        return new Option[] {
059            karafDistributionConfiguration()
060                .frameworkUrl(maven().groupId("org.apache.karaf").artifactId("apache-karaf")
061                        .versionAsInProject().type("zip"))
062                .unpackDirectory(new File("target", "exam"))
063                .useDeployFolder(false),
064            logLevel(LogLevel.WARN),
065            keepRuntimeFolder(),
066            configureConsole().ignoreLocalConsole(),
067            features(maven().groupId("org.apache.karaf.features").artifactId("standard")
068                        .versionAsInProject().classifier("features").type("xml"), "scr"),
069            features(maven().groupId("org.apache.camel.karaf").artifactId("apache-camel")
070                        .type("xml").classifier("features").versionAsInProject(), "camel-blueprint"),
071            features(bundle(fcrepoFeatures).start(), "fcrepo-camel")
072       };
073    }
074
075    @Test
076    public void testInstallation() throws Exception {
077        assertTrue(featuresService.isInstalled(featuresService.getFeature("camel-core")));
078        assertTrue(featuresService.isInstalled(featuresService.getFeature("fcrepo-camel")));
079    }
080}