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