forked from jboss-fuse/fabric8
/
DistroAsRollupPatchTest.java
85 lines (77 loc) · 3.44 KB
/
DistroAsRollupPatchTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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);
}
}