]> git.argeo.org Git - lgpl/argeo-commons.git/blob - osgi/boot/OsgiBootNoRuntimeTest.java
Prepare next development cycle
[lgpl/argeo-commons.git] / osgi / boot / OsgiBootNoRuntimeTest.java
1 /*
2 * Copyright (C) 2007-2012 Mathieu Baudier
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 package org.argeo.osgi.boot;
17
18 import java.io.File;
19 import java.util.List;
20
21 import junit.framework.TestCase;
22
23 import org.argeo.osgi.boot.OsgiBoot;
24
25 /** Tests which do not require a runtime. */
26 public class OsgiBootNoRuntimeTest extends TestCase {
27 public final static String BUNDLES = "src/test/bundles/some;in=*;ex=excluded,"
28 + "src/test/bundles/others;in=**/org.argeo.*";
29
30 /** Tests that location lists are properly parsed. */
31 public void testLocations() {
32 String baseUrl = "file:";
33 String locations = "/mydir/myfile" + File.pathSeparator
34 + "/myotherdir/myotherfile";
35
36 OsgiBoot osgiBoot = new OsgiBoot(null);
37 osgiBoot.setExcludeSvn(true);
38 List urls = osgiBoot.getLocationsUrls(baseUrl, locations);
39 assertEquals(2, urls.size());
40 assertEquals("file:/mydir/myfile", urls.get(0));
41 assertEquals("file:/myotherdir/myotherfile", urls.get(1));
42 }
43
44 /** Tests that bundle lists are properly parsed. */
45 public void testBundles() {
46 String baseUrl = "file:";
47 String bundles = BUNDLES;
48 OsgiBoot osgiBoot = new OsgiBoot(null);
49 osgiBoot.setExcludeSvn(true);
50 List urls = osgiBoot.getBundlesUrls(baseUrl, bundles);
51 for (int i = 0; i < urls.size(); i++)
52 System.out.println(urls.get(i));
53 assertEquals(3, urls.size());
54
55 List jarUrls = osgiBoot.getBundlesUrls(baseUrl,
56 "src/test/bundles/jars;in=*.jar");
57 for (int i = 0; i < jarUrls.size(); i++)
58 System.out.println(jarUrls.get(i));
59 assertEquals(1, jarUrls.size());
60 }
61 }