Skip to content

Commit

Permalink
Lets test against a real jbos-fuse-full distro
Browse files Browse the repository at this point in the history
  • Loading branch information
chirino committed Oct 1, 2015
1 parent 0b6d63c commit 9426f24
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 91 deletions.
Expand Up @@ -42,7 +42,7 @@ protected Object doExecute() throws Exception {
protected abstract void doExecute(Service service) throws Exception;

protected void display(PatchResult result) {
int l1 = 0, l2 = 0, l3 = 0;
int l1 = 1, l2 = 1, l3 = 1;
for (BundleUpdate update : result.getUpdates()) {
if (stripSymbolicName(update.getSymbolicName()).length() > l1) {
l1 = stripSymbolicName(update.getSymbolicName()).length();
Expand Down
73 changes: 35 additions & 38 deletions patch/patch-itests/pom.xml
Expand Up @@ -37,7 +37,9 @@

<!-- Properties -->
<properties>
<karaf.home>${project.build.directory}/apache-karaf-${karaf-version}</karaf.home>
<fuse-base-level-version>6.2.0.redhat-142</fuse-base-level-version>
<fuse-rollup-version>6.2.1.redhat-039</fuse-rollup-version>
<karaf.home>${project.build.directory}/jboss-fuse-${fuse-base-level-version}</karaf.home>
</properties>

<dependencies>
Expand Down Expand Up @@ -128,23 +130,42 @@
<version>${maven-dependency-plugin-version}</version>
<executions>
<execution>
<id>unpack-karaf</id>
<id>unpack-fuse-full</id>
<phase>process-test-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.apache.karaf</groupId>
<artifactId>apache-karaf</artifactId>
<version>${karaf-version}</version>
<type>tar.gz</type>
<groupId>org.jboss.fuse</groupId>
<artifactId>jboss-fuse-full</artifactId>
<version>${fuse-base-level-version}</version>
<type>zip</type>
<outputDirectory>${project.build.directory}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
<execution>
<id>get-rollup</id>
<phase>process-test-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.jboss.fuse</groupId>
<artifactId>jboss-fuse-full</artifactId>
<version>${fuse-rollup-version}</version>
<type>zip</type>
<outputDirectory>${project.build.directory}</outputDirectory>
<destFileName>jboss-fuse-full-rollup.zip</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
Expand All @@ -161,10 +182,14 @@
<copy todir="${karaf.home}/etc" overwrite="true">
<fileset dir="${project.build.directory}/test-classes/etc"/>
</copy>
<copy todir="${karaf.home}/fabric" overwrite="true">
<fileset dir="${project.build.directory}/test-classes/fabric"/>
</copy>
<zip destfile="${karaf.home}/patches/jboss-fuse-full-6.2.0-baseline.zip">
<replaceregexp
file="${karaf.home}/etc/org.apache.karaf.features.cfg"
match="\/patch-features\/[^\/]+\/"
replace="/patch-features/${project.version}/"
/>
<echo file="${karaf.home}/etc/org.apache.karaf.features.cfg" append="true" message="featuresBootAsynchronous = false"/>

<zip destfile="${karaf.home}/patches/jboss-fuse-full-${fuse-base-level-version}-baseline.zip">
<fileset dir="${karaf.home}">
<include name="bin/**" />
<include name="etc/**" />
Expand All @@ -177,34 +202,6 @@
</execution>
</executions>
</plugin>
<!--
Add all necessary bundles to the test Karaf container
-->
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>features-maven-plugin</artifactId>
<version>${karaf-version}</version>
<executions>
<execution>
<id>add-features-to-repo</id>
<phase>generate-resources</phase>
<goals>
<goal>add-features-to-repo</goal>
</goals>
<configuration>
<descriptors>
<descriptor>mvn:org.apache.karaf.assemblies.features/standard/${karaf-version}/xml/features</descriptor>
<descriptor>mvn:io.fabric8.patch/patch-features/${project.version}/xml/features</descriptor>
</descriptors>
<features>
<feature>scr</feature>
<feature>patch</feature>
</features>
<repository>${karaf.home}/system</repository>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
Expand Down
@@ -0,0 +1,85 @@
/**
* Copyright 2005-2015 Red Hat, Inc.
* <p/>
* Red Hat licenses this file to you under the Apache License, version
* 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package io.fabric8.patch.itests;

import io.fabric8.api.gravia.ServiceLocator;
import io.fabric8.common.util.IOHelpers;
import io.fabric8.itests.support.CommandSupport;
import org.apache.felix.gogo.commands.Action;
import org.apache.felix.gogo.commands.basic.AbstractCommand;
import org.apache.felix.service.command.Function;
import org.apache.felix.utils.version.VersionCleaner;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.osgi.metadata.OSGiManifestBuilder;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.Asset;
import org.jboss.shrinkwrap.api.exporter.ZipExporter;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.osgi.framework.Bundle;
import org.osgi.util.tracker.ServiceTracker;
import org.slf4j.Logger;

import java.io.File;
import java.io.InputStream;

/**
* Tests installing full distro as a rollup.
*/
@RunWith(Arquillian.class)
public class DistroAsRollupPatchTest extends AbstractPatchCommandIntegrationTest {

// Patch name
private static final File KARAF_HOME = new File(System.getProperty("karaf.home"));
private static final File ROLLUP_FILE = new File(KARAF_HOME, "../jboss-fuse-full-rollup.zip");

@Deployment
public static JavaArchive createdeployment() throws Exception {
final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar");
archive.addClass(ServiceLocator.class);
archive.addClass(IOHelpers.class);
archive.addClass(DistroAsRollupPatchTest.class);
archive.addPackage(ServiceTracker.class.getPackage());
archive.addPackages(true, OSGiManifestBuilder.class.getPackage());
archive.addPackage(CommandSupport.class.getPackage());
archive.addClass(VersionCleaner.class);
archive.setManifest(new Asset() {
public InputStream openStream() {
OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
builder.addBundleSymbolicName(archive.getName());
builder.addBundleManifestVersion(2);
builder.addImportPackages(Bundle.class, Logger.class);
builder.addImportPackages(AbstractCommand.class, Action.class, Function.class);
builder.addImportPackage("org.apache.felix.service.command;status=provisional");
return builder.openStream();
}
});
return archive;
}

@Ignore
@Test
public void testInstallRollupPatch() throws Exception {

CommandSupport.executeCommand(String.format("patch:add %s", ROLLUP_FILE.toURI().toURL()));
String result = CommandSupport.executeCommand("patch:install jboss-fuse-full-rollup");
System.out.println(result);

}
}

This file was deleted.

This file was deleted.

0 comments on commit 9426f24

Please sign in to comment.