blob: eaa0f3b51ed9504fc7dd2290c6b65bb03ee01df0 [file] [log] [blame]
Felix Meschberger3f9e4da2009-08-17 07:52:39 +00001/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.apache.felix.cm;
20
21
Felix Meschberger63e7ab12012-07-02 14:10:43 +000022import java.io.File;
Felix Meschberger3f9e4da2009-08-17 07:52:39 +000023import java.io.IOException;
24import java.io.InputStream;
25import java.net.URL;
Felix Meschberger63e7ab12012-07-02 14:10:43 +000026import java.security.cert.X509Certificate;
Felix Meschberger3f9e4da2009-08-17 07:52:39 +000027import java.util.Dictionary;
28import java.util.Enumeration;
Felix Meschberger63e7ab12012-07-02 14:10:43 +000029import java.util.List;
30import java.util.Map;
Felix Meschberger3f9e4da2009-08-17 07:52:39 +000031
32import org.osgi.framework.Bundle;
33import org.osgi.framework.BundleContext;
34import org.osgi.framework.BundleException;
35import org.osgi.framework.ServiceReference;
Felix Meschberger63e7ab12012-07-02 14:10:43 +000036import org.osgi.framework.Version;
Felix Meschberger3f9e4da2009-08-17 07:52:39 +000037
38
39public class MockBundle implements Bundle
40{
41
42 private final BundleContext context;
43 private final String location;
44
45
46 public MockBundle( BundleContext context, String location )
47 {
48 this.context = context;
49 this.location = location;
50 }
51
52
53 public Enumeration findEntries( String arg0, String arg1, boolean arg2 )
54 {
Felix Meschberger3f9e4da2009-08-17 07:52:39 +000055 return null;
56 }
57
58
59 public BundleContext getBundleContext()
60 {
61 return context;
62 }
63
64
65 public long getBundleId()
66 {
67 return 0;
68 }
69
70
71 public URL getEntry( String arg0 )
72 {
Felix Meschberger3f9e4da2009-08-17 07:52:39 +000073 return null;
74 }
75
76
77 public Enumeration getEntryPaths( String arg0 )
78 {
Felix Meschberger3f9e4da2009-08-17 07:52:39 +000079 return null;
80 }
81
82
83 public Dictionary getHeaders()
84 {
Felix Meschberger3f9e4da2009-08-17 07:52:39 +000085 return null;
86 }
87
88
89 public Dictionary getHeaders( String arg0 )
90 {
Felix Meschberger3f9e4da2009-08-17 07:52:39 +000091 return null;
92 }
93
94
95 public long getLastModified()
96 {
Felix Meschberger3f9e4da2009-08-17 07:52:39 +000097 return 0;
98 }
99
100
101 public String getLocation()
102 {
103 return location;
104 }
105
106
107 public ServiceReference[] getRegisteredServices()
108 {
Felix Meschberger3f9e4da2009-08-17 07:52:39 +0000109 return null;
110 }
111
112
113 public URL getResource( String arg0 )
114 {
Felix Meschberger3f9e4da2009-08-17 07:52:39 +0000115 return null;
116 }
117
118
Felix Meschbergere9502bd2012-07-02 14:57:33 +0000119 public Enumeration getResources( String arg0 )
Felix Meschberger3f9e4da2009-08-17 07:52:39 +0000120 {
Felix Meschberger3f9e4da2009-08-17 07:52:39 +0000121 return null;
122 }
123
124
125 public ServiceReference[] getServicesInUse()
126 {
Felix Meschberger3f9e4da2009-08-17 07:52:39 +0000127 return null;
128 }
129
130
131 public int getState()
132 {
Felix Meschberger3f9e4da2009-08-17 07:52:39 +0000133 return 0;
134 }
135
136
137 public String getSymbolicName()
138 {
Felix Meschberger3f9e4da2009-08-17 07:52:39 +0000139 return null;
140 }
141
142
143 public boolean hasPermission( Object arg0 )
144 {
Felix Meschberger3f9e4da2009-08-17 07:52:39 +0000145 return false;
146 }
147
148
149 public Class loadClass( String arg0 ) throws ClassNotFoundException
150 {
Felix Meschbergere9502bd2012-07-02 14:57:33 +0000151 throw new ClassNotFoundException( arg0 );
Felix Meschberger3f9e4da2009-08-17 07:52:39 +0000152 }
153
154
Felix Meschbergere9502bd2012-07-02 14:57:33 +0000155 public void start()
Felix Meschberger3f9e4da2009-08-17 07:52:39 +0000156 {
Felix Meschberger3f9e4da2009-08-17 07:52:39 +0000157 }
158
159
Felix Meschbergere9502bd2012-07-02 14:57:33 +0000160 public void stop()
Felix Meschberger3f9e4da2009-08-17 07:52:39 +0000161 {
Felix Meschberger3f9e4da2009-08-17 07:52:39 +0000162 }
163
164
Felix Meschbergere9502bd2012-07-02 14:57:33 +0000165 public void uninstall()
Felix Meschberger3f9e4da2009-08-17 07:52:39 +0000166 {
Felix Meschberger3f9e4da2009-08-17 07:52:39 +0000167 }
168
169
Felix Meschbergere9502bd2012-07-02 14:57:33 +0000170 public void update()
Felix Meschberger3f9e4da2009-08-17 07:52:39 +0000171 {
Felix Meschberger3f9e4da2009-08-17 07:52:39 +0000172 }
173
174
175 public void update( InputStream arg0 ) throws BundleException
176 {
Felix Meschbergere9502bd2012-07-02 14:57:33 +0000177 if ( arg0 != null )
178 {
179 try
180 {
181 arg0.close();
182 }
183 catch ( IOException ioe )
184 {
185 throw new BundleException( ioe.getMessage(), ioe );
186 }
187 }
Felix Meschberger3f9e4da2009-08-17 07:52:39 +0000188 }
189
Felix Meschbergerabb0bc22012-05-30 11:07:49 +0000190
Felix Meschbergere9502bd2012-07-02 14:57:33 +0000191 public void start( int options )
Felix Meschbergerabb0bc22012-05-30 11:07:49 +0000192 {
Felix Meschbergerabb0bc22012-05-30 11:07:49 +0000193 }
194
195
Felix Meschbergere9502bd2012-07-02 14:57:33 +0000196 public void stop( int options )
Felix Meschbergerabb0bc22012-05-30 11:07:49 +0000197 {
Felix Meschbergerabb0bc22012-05-30 11:07:49 +0000198 }
199
Felix Meschberger63e7ab12012-07-02 14:10:43 +0000200
201 public int compareTo( Bundle o )
202 {
Felix Meschberger63e7ab12012-07-02 14:10:43 +0000203 return 0;
204 }
205
206
Felix Meschbergere9502bd2012-07-02 14:57:33 +0000207 // Framework 1.5 additions
208
Felix Meschberger63e7ab12012-07-02 14:10:43 +0000209 public Map<X509Certificate, List<X509Certificate>> getSignerCertificates( int signersType )
210 {
Felix Meschbergere9502bd2012-07-02 14:57:33 +0000211 throw new AbstractMethodError( "Not supported on Framework API 1.4; added in Framework API 1.5" );
Felix Meschberger63e7ab12012-07-02 14:10:43 +0000212 }
213
214
215 public Version getVersion()
216 {
Felix Meschbergere9502bd2012-07-02 14:57:33 +0000217 throw new AbstractMethodError( "Not supported on Framework API 1.4; added in Framework API 1.5" );
Felix Meschberger63e7ab12012-07-02 14:10:43 +0000218 }
219
220
Felix Meschbergere9502bd2012-07-02 14:57:33 +0000221 // Framework 1.6 additions
222
Felix Meschberger63e7ab12012-07-02 14:10:43 +0000223 public <A> A adapt( Class<A> type )
224 {
Felix Meschbergere9502bd2012-07-02 14:57:33 +0000225 throw new AbstractMethodError( "Not supported on Framework API 1.4; added in Framework API 1.6" );
Felix Meschberger63e7ab12012-07-02 14:10:43 +0000226 }
227
228
229 public File getDataFile( String filename )
230 {
Felix Meschbergere9502bd2012-07-02 14:57:33 +0000231 throw new AbstractMethodError( "Not supported on Framework API 1.4; added in Framework API 1.6" );
Felix Meschberger63e7ab12012-07-02 14:10:43 +0000232 }
233
Felix Meschberger3f9e4da2009-08-17 07:52:39 +0000234}