001/* 002 * Licensed to DuraSpace under one or more contributor license agreements. 003 * See the NOTICE file distributed with this work for additional information 004 * regarding copyright ownership. 005 * 006 * DuraSpace licenses this file to you under the Apache License, 007 * Version 2.0 (the "License"); you may not use this file except in 008 * compliance with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.fcrepo.camel.integration; 019 020import static org.osgi.framework.Bundle.ACTIVE; 021import static org.slf4j.LoggerFactory.getLogger; 022import static org.junit.Assert.assertEquals; 023import static org.junit.Assert.assertNotNull; 024import static org.junit.Assert.assertTrue; 025import static org.ops4j.pax.exam.CoreOptions.bundle; 026import static org.ops4j.pax.exam.CoreOptions.maven; 027import static org.ops4j.pax.exam.CoreOptions.mavenBundle; 028import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole; 029import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut; 030import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features; 031import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration; 032import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder; 033import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel; 034import static org.ops4j.pax.exam.util.PathUtils.getBaseDir; 035 036import java.io.File; 037 038import org.apache.camel.test.karaf.AbstractFeatureTest; 039import org.junit.Test; 040import org.junit.runner.RunWith; 041import org.ops4j.pax.exam.Configuration; 042import org.ops4j.pax.exam.ConfigurationManager; 043import org.ops4j.pax.exam.CoreOptions; 044import org.ops4j.pax.exam.Option; 045import org.ops4j.pax.exam.junit.PaxExam; 046import org.ops4j.pax.exam.karaf.options.LogLevelOption.LogLevel; 047import org.slf4j.Logger; 048 049/** 050 * @author Aaron Coburn 051 * @since February 8, 2016 052 */ 053@RunWith(PaxExam.class) 054public class KarafIT extends AbstractFeatureTest { 055 056 private static Logger LOG = getLogger(KarafIT.class); 057 058 @Configuration 059 public Option[] config() { 060 final ConfigurationManager cm = new ConfigurationManager(); 061 final String artifactName = cm.getProperty("project.artifactId") + "-" + cm.getProperty("project.version"); 062 final String fcrepoCamelBundle = "file:" + getBaseDir() + "/target/" + artifactName + ".jar"; 063 final String commonsCodecVersion = cm.getProperty("commons.codec.version"); 064 final String commonsCsvVersion = cm.getProperty("commons.csv.version"); 065 final String dexxVersion = cm.getProperty("dexx.version"); 066 final String httpclientVersion = cm.getProperty("httpclient.version"); 067 final String httpcoreVersion = cm.getProperty("httpcore.version"); 068 final String jsonldVersion = cm.getProperty("jsonld.version"); 069 final String thriftVersion = cm.getProperty("thrift.version"); 070 final String rmiRegistryPort = cm.getProperty("karaf.rmiRegistry.port"); 071 final String rmiServerPort = cm.getProperty("karaf.rmiServer.port"); 072 final String sshPort = cm.getProperty("karaf.ssh.port"); 073 return new Option[] { 074 karafDistributionConfiguration() 075 .frameworkUrl(maven().groupId("org.apache.karaf").artifactId("apache-karaf") 076 .versionAsInProject().type("zip")) 077 .unpackDirectory(new File("target", "exam")) 078 .useDeployFolder(false), 079 logLevel(LogLevel.WARN), 080 keepRuntimeFolder(), 081 configureConsole().ignoreLocalConsole(), 082 CoreOptions.systemProperty("fcrepo-camel-bundle").value(fcrepoCamelBundle), 083 editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiRegistryPort", rmiRegistryPort), 084 editConfigurationFilePut("etc/org.apache.karaf.management.cfg", "rmiServerPort", rmiServerPort), 085 editConfigurationFilePut("etc/org.apache.karaf.shell.cfg", "sshPort", sshPort), 086 features(maven().groupId("org.apache.karaf.features").artifactId("standard") 087 .versionAsInProject().classifier("features").type("xml"), "scr"), 088 features(getCamelKarafFeatureUrl(), "camel-blueprint", "camel-spring", "camel-jackson"), 089 mavenBundle().groupId("org.apache.camel").artifactId("camel-test-karaf").versionAsInProject(), 090 mavenBundle().groupId("commons-codec").artifactId("commons-codec").version(commonsCodecVersion), 091 mavenBundle().groupId("org.apache.commons").artifactId("commons-csv").version(commonsCsvVersion), 092 mavenBundle().groupId("org.apache.commons").artifactId("commons-lang3").versionAsInProject(), 093 mavenBundle().groupId("org.apache.httpcomponents").artifactId("httpclient-osgi").versionAsInProject(), 094 mavenBundle().groupId("org.apache.httpcomponents").artifactId("httpcore-osgi").versionAsInProject(), 095 mavenBundle().groupId("org.apache.jena").artifactId("jena-osgi").versionAsInProject(), 096 mavenBundle().groupId("com.github.jsonld-java").artifactId("jsonld-java").version(jsonldVersion), 097 mavenBundle().groupId("org.apache.thrift").artifactId("libthrift").version(thriftVersion), 098 mavenBundle().groupId("org.fcrepo.client").artifactId("fcrepo-java-client").versionAsInProject(), 099 mavenBundle().groupId("com.github.andrewoma.dexx").artifactId("collection").version(dexxVersion), 100 bundle(fcrepoCamelBundle).start() 101 }; 102 } 103 104 @Test 105 public void testInstallation() throws Exception { 106 assertTrue(featuresService.isInstalled(featuresService.getFeature("camel-core"))); 107 assertNotNull(bundleContext); 108 assertEquals(ACTIVE, bundleContext.getBundle(System.getProperty("fcrepo-camel-bundle")).getState()); 109 } 110}