blob: a1e533158b5f9907c9d7a0d90f79fe39025aef66 (
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
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.osgi.provider.model;
import com.yahoo.container.bundle.BundleInstantiationSpecification;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* @author gjoranv
*/
public class ComponentModelTest {
@Test
public void create_from_instantiation_spec() {
ComponentModel model = new ComponentModel(
BundleInstantiationSpecification.fromStrings("id", "class", "bundle"));
verifyBundleSpec(model);
}
@Test(expected = IllegalArgumentException.class)
public void require_exception_upon_null_instantiation_spec() throws Exception {
ComponentModel model = new ComponentModel(null);
}
@Test
public void create_from_instantiation_spec_and_config_id() throws Exception {
ComponentModel model = new ComponentModel(
BundleInstantiationSpecification.fromStrings("id", "class", "bundle"), "configId");
verifyBundleSpec(model);
assertEquals("configId", model.configId);
}
@Test
public void create_from_strings() throws Exception {
ComponentModel model = new ComponentModel("id", "class", "bundle", "configId");
verifyBundleSpec(model);
assertEquals("configId", model.configId);
}
private void verifyBundleSpec(ComponentModel model) {
assertEquals("id", model.getComponentId().stringValue());
assertEquals("class", model.getClassId().stringValue());
assertEquals("bundle", model.bundleInstantiationSpec.bundle.stringValue());
}
}
|