aboutsummaryrefslogtreecommitdiffstats
path: root/container-core/src/test/java/com/yahoo/container/core/config/BundleTestUtil.java
blob: f5d3d36eada7f2c49f86abe9cbadd36455866fea (plain) (blame)
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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.core.config;

import com.yahoo.config.FileReference;
import com.yahoo.filedistribution.fileacquirer.FileAcquirer;
import com.yahoo.osgi.Osgi;
import org.osgi.framework.Bundle;
import org.osgi.framework.Version;

import java.util.List;
import java.util.Map;

/**
 * @author gjoranv
 */
public class BundleTestUtil {

    public static final FileReference BUNDLE_1_REF = new FileReference("bundle-1");
    public static final Bundle BUNDLE_1 = new TestBundle(BUNDLE_1_REF.value());
    public static final FileReference BUNDLE_2_REF = new FileReference("bundle-2");
    public static final Bundle BUNDLE_2 = new TestBundle(BUNDLE_2_REF.value(), new Version(2, 0, 0, "SNAPSHOT"));

    public static Map<String, Bundle> testBundles() {
        return Map.of(BUNDLE_1_REF.value(), BUNDLE_1,
                      BUNDLE_2_REF.value(), BUNDLE_2);
    }

    public static class TestBundleInstaller extends FileAcquirerBundleInstaller {

        TestBundleInstaller(FileAcquirer fileAcquirer) {
            super(fileAcquirer);
        }

        @Override
        public List<Bundle> installBundles(FileReference reference, Osgi osgi) {
            return osgi.install(reference.value());
        }

    }

}