1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.seasar.uruma.rcp.unit; |
17 | |
|
18 | |
import java.io.IOException; |
19 | |
import java.io.InputStream; |
20 | |
import java.net.URL; |
21 | |
import java.util.ArrayList; |
22 | |
import java.util.Collections; |
23 | |
import java.util.Dictionary; |
24 | |
import java.util.Enumeration; |
25 | |
import java.util.Properties; |
26 | |
|
27 | |
import org.osgi.framework.Bundle; |
28 | |
import org.osgi.framework.BundleContext; |
29 | |
import org.osgi.framework.BundleException; |
30 | |
import org.osgi.framework.ServiceReference; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | 16 | public class MockBundle implements Bundle { |
38 | |
static final String SYMBOLIC_NAME = "org.seasar.uruma.rcp.core"; |
39 | |
|
40 | |
protected MockBundleContext context; |
41 | |
|
42 | |
public Enumeration<?> findEntries(final String path, |
43 | |
final String filePattern, final boolean recurse) { |
44 | 0 | URL url = getClass().getClassLoader().getResource( |
45 | |
getClass().getName() + ".class"); |
46 | 0 | if (url != null) { |
47 | 0 | ArrayList<URL> entries = new ArrayList<URL>(); |
48 | 0 | entries.add(url); |
49 | 0 | return Collections.enumeration(entries); |
50 | |
} else { |
51 | 0 | return getEmptyEnumeration(); |
52 | |
} |
53 | |
} |
54 | |
|
55 | |
public BundleContext getBundleContext() { |
56 | 0 | if (context == null) { |
57 | 0 | context = new MockBundleContext(this); |
58 | |
} |
59 | 0 | return context; |
60 | |
} |
61 | |
|
62 | |
public long getBundleId() { |
63 | 0 | return 0; |
64 | |
} |
65 | |
|
66 | |
public URL getEntry(final String path) { |
67 | 0 | return null; |
68 | |
} |
69 | |
|
70 | |
public Enumeration<?> getEntryPaths(final String path) { |
71 | 0 | return getEmptyEnumeration(); |
72 | |
} |
73 | |
|
74 | |
public Dictionary<?, ?> getHeaders() { |
75 | 0 | return new Properties(); |
76 | |
} |
77 | |
|
78 | |
public Dictionary<?, ?> getHeaders(final String locale) { |
79 | 0 | return new Properties(); |
80 | |
} |
81 | |
|
82 | |
public long getLastModified() { |
83 | 0 | return 0; |
84 | |
} |
85 | |
|
86 | |
public String getLocation() { |
87 | 0 | return null; |
88 | |
} |
89 | |
|
90 | |
public ServiceReference[] getRegisteredServices() { |
91 | 0 | return null; |
92 | |
} |
93 | |
|
94 | |
public URL getResource(final String name) { |
95 | 0 | return null; |
96 | |
} |
97 | |
|
98 | |
public Enumeration<?> getResources(final String name) throws IOException { |
99 | 0 | return getEmptyEnumeration(); |
100 | |
} |
101 | |
|
102 | |
public ServiceReference[] getServicesInUse() { |
103 | 0 | return null; |
104 | |
} |
105 | |
|
106 | |
public int getState() { |
107 | 0 | return 0; |
108 | |
} |
109 | |
|
110 | |
public String getSymbolicName() { |
111 | 16 | return SYMBOLIC_NAME; |
112 | |
} |
113 | |
|
114 | |
public boolean hasPermission(final Object permission) { |
115 | 0 | return true; |
116 | |
} |
117 | |
|
118 | |
public Class<?> loadClass(final String name) throws ClassNotFoundException { |
119 | 0 | return Class.forName(name); |
120 | |
} |
121 | |
|
122 | |
public void start() throws BundleException { |
123 | |
|
124 | 0 | } |
125 | |
|
126 | |
public void start(final int options) throws BundleException { |
127 | |
|
128 | 0 | } |
129 | |
|
130 | |
public void stop() throws BundleException { |
131 | |
|
132 | 0 | } |
133 | |
|
134 | |
public void stop(final int options) throws BundleException { |
135 | |
|
136 | 0 | } |
137 | |
|
138 | |
public void uninstall() throws BundleException { |
139 | |
|
140 | 0 | } |
141 | |
|
142 | |
public void update() throws BundleException { |
143 | |
|
144 | 0 | } |
145 | |
|
146 | |
public void update(final InputStream in) throws BundleException { |
147 | |
|
148 | 0 | } |
149 | |
|
150 | |
@SuppressWarnings("unchecked") |
151 | |
protected Enumeration<?> getEmptyEnumeration() { |
152 | 0 | return Collections.enumeration(Collections.EMPTY_LIST); |
153 | |
} |
154 | |
} |