aboutsummaryrefslogtreecommitdiffstats
path: root/standalone-container/src/test/java/com/yahoo/container/standalone/StandaloneSubscriberTest.java
blob: 9747e7790f8635c8dd317e2eb0b4c8464082a0b1 (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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container.standalone;

import com.yahoo.config.ConfigInstance;
import com.yahoo.container.ComponentsConfig;
import com.yahoo.container.di.config.ApplicationBundlesConfig;
import com.yahoo.container.di.config.PlatformBundlesConfig;
import com.yahoo.container.di.config.Subscriber;
import com.yahoo.vespa.config.ConfigKey;
import org.junit.Ignore;
import org.junit.Test;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import static com.yahoo.container.standalone.StandaloneContainer.withContainerModel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

/**
 * @author Tony Vaagenes
 * @author ollivir
 */
public class StandaloneSubscriberTest {
    private static ConfigKey<ConfigInstance> platformBundlesKey = key("platform-bundles");
    private static ConfigKey<ConfigInstance> applicationBundlesKey = key("application-bundles");
    private static ConfigKey<ConfigInstance> componentsKey = key("components");

    private static ConfigKey<ConfigInstance> key(String name) {
        return new ConfigKey<>(name, "container", "container");
    }

    @Test
    @Ignore
    public void standalone_subscriber() throws Exception {
        withContainerModel("<container version=\"1.0\"></container>", root -> {
            Set<ConfigKey<ConfigInstance>> keys = new HashSet<>();
            keys.add(platformBundlesKey);
            keys.add(applicationBundlesKey);
            keys.add(componentsKey);
            Subscriber subscriber = new StandaloneSubscriberFactory(root).getSubscriber(keys, "standalone");
            Map<ConfigKey<ConfigInstance>, ConfigInstance> config = subscriber.config();
            assertEquals(2, config.size());

            PlatformBundlesConfig platformBundlesConfig = (PlatformBundlesConfig) config.get(platformBundlesKey);
            ApplicationBundlesConfig applicationBundlesConfig = (ApplicationBundlesConfig) config.get(applicationBundlesKey);
            ComponentsConfig componentsConfig = (ComponentsConfig) config.get(componentsKey);

            assertEquals(0, platformBundlesConfig.bundlePaths().size());
            assertEquals(0, applicationBundlesConfig.bundles().size());
            assertTrue(componentsConfig.components().size() > 10);
            return null;
        });
    }
}