]> git.argeo.org Git - lgpl/argeo-commons.git/blob - osgi/runtime/org.argeo.osgi.boot/src/test/java/org/argeo/osgi/boot/OsgiBootNoRuntimeTest.java
Fix OSGi boot
[lgpl/argeo-commons.git] / osgi / runtime / org.argeo.osgi.boot / src / test / java / org / argeo / osgi / boot / OsgiBootNoRuntimeTest.java
1 /*
2 * Copyright (C) 2010 Mathieu Baudier <mbaudier@argeo.org>
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package org.argeo.osgi.boot;
18
19 import java.io.File;
20 import java.util.List;
21
22 import junit.framework.TestCase;
23
24 import org.argeo.osgi.boot.OsgiBoot;
25
26 /** Tests which do not require a runtime. */
27 public class OsgiBootNoRuntimeTest extends TestCase {
28 public final static String BUNDLES = "src/test/bundles/some;in=*;ex=excluded,"
29 + "src/test/bundles/others;in=**/org.argeo.*";
30
31 /** Tests that location lists are properly parsed. */
32 public void testLocations() {
33 String baseUrl = "file:";
34 String locations = "/mydir/myfile" + File.pathSeparator
35 + "/myotherdir/myotherfile";
36
37 OsgiBoot osgiBoot = new OsgiBoot(null);
38 osgiBoot.setExcludeSvn(true);
39 List urls = osgiBoot.getLocationsUrls(baseUrl, locations);
40 assertEquals(2, urls.size());
41 assertEquals("file:/mydir/myfile", urls.get(0));
42 assertEquals("file:/myotherdir/myotherfile", urls.get(1));
43 }
44
45 /** Tests that bundle lists are properly parsed. */
46 public void testBundles() {
47 String baseUrl = "file:";
48 String bundles = BUNDLES;
49 OsgiBoot osgiBoot = new OsgiBoot(null);
50 osgiBoot.setExcludeSvn(true);
51 List urls = osgiBoot.getBundlesUrls(baseUrl, bundles);
52 for (int i = 0; i < urls.size(); i++)
53 System.out.println(urls.get(i));
54 assertEquals(3, urls.size());
55
56 List jarUrls = osgiBoot.getBundlesUrls(baseUrl,
57 "src/test/bundles/jars;in=*.jar");
58 for (int i = 0; i < jarUrls.size(); i++)
59 System.out.println(jarUrls.get(i));
60 assertEquals(1, jarUrls.size());
61 }
62 }