blob: 4ad41306c95615fec7e23e84a8bbf8b829964168 (
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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
// 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.container.bundle.MockBundle;
import org.osgi.framework.Bundle;
import org.osgi.framework.Version;
import org.osgi.framework.wiring.BundleCapability;
import org.osgi.framework.wiring.BundleRequirement;
import org.osgi.framework.wiring.BundleRevision;
import org.osgi.framework.wiring.BundleWiring;
import org.osgi.resource.Capability;
import org.osgi.resource.Requirement;
import java.util.List;
/**
* @author gjoranv
*/
public class TestBundle extends MockBundle {
private static final BundleRevision revision = new TestBundleRevision();
private final String symbolicName;
private final Version version;
boolean started = false;
public TestBundle(String symbolicName) {
this(symbolicName, BundleVersion);
}
public TestBundle(String symbolicName, Version version) {
this.symbolicName = symbolicName;
this.version = version;
}
@Override
public void start() {
started = true;
}
@Override
public String getSymbolicName() {
return symbolicName;
}
@Override
public Version getVersion() {
return version;
}
@SuppressWarnings("unchecked")
@Override
public <T> T adapt(Class<T> type) {
if (type.equals(BundleRevision.class)) {
return (T) revision;
} else {
throw new UnsupportedOperationException();
}
}
static class TestBundleRevision implements BundleRevision {
// Ensure this is not seen as a fragment bundle.
@Override
public int getTypes() {
return 0;
}
@Override
public String getSymbolicName() {
throw new UnsupportedOperationException();
}
@Override
public Version getVersion() {
throw new UnsupportedOperationException();
}
@Override
public List<BundleCapability> getDeclaredCapabilities(String namespace) {
throw new UnsupportedOperationException();
}
@Override
public List<BundleRequirement> getDeclaredRequirements(String namespace) {
throw new UnsupportedOperationException();
}
@Override
public BundleWiring getWiring() {
throw new UnsupportedOperationException();
}
@Override
public List<Capability> getCapabilities(String namespace) {
throw new UnsupportedOperationException();
}
@Override
public List<Requirement> getRequirements(String namespace) {
throw new UnsupportedOperationException();
}
@Override
public Bundle getBundle() {
throw new UnsupportedOperationException();
}
}
}
|