Richard S. Hall | 85bafab | 2009-07-13 13:25:46 +0000 | [diff] [blame^] | 1 | /* |
| 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 | */ |
| 19 | |
| 20 | package org.cauldron.bld.core; |
| 21 | |
| 22 | import java.io.IOException; |
| 23 | import java.net.URI; |
| 24 | import java.util.Set; |
| 25 | |
| 26 | import junit.framework.TestCase; |
| 27 | |
| 28 | import org.cauldron.bld.config.BldFactory; |
| 29 | import org.cauldron.bld.config.IBldProject; |
| 30 | import org.cauldron.bld.core.internal.model.osgi.PackageImport; |
| 31 | import org.cauldron.sigil.model.common.VersionRange; |
| 32 | import org.cauldron.sigil.model.eclipse.ISigilBundle; |
| 33 | import org.cauldron.sigil.model.osgi.IBundleModelElement; |
| 34 | import org.cauldron.sigil.model.osgi.IPackageImport; |
| 35 | |
| 36 | public class ConfigTest extends TestCase { |
| 37 | |
| 38 | static final URI base = URI.create("test/ConfigTest/sigil.properties"); |
| 39 | |
| 40 | public ConfigTest(String name) { |
| 41 | super(name); |
| 42 | } |
| 43 | |
| 44 | public void testSimple() throws IOException { |
| 45 | IBldProject project = BldFactory.getProject(base.resolve("test1.properties")); |
| 46 | |
| 47 | ISigilBundle bundle = project.getDefaultBundle(); |
| 48 | IBundleModelElement info = bundle.getBundleInfo(); |
| 49 | |
| 50 | checkImports(info.getImports()); |
| 51 | |
| 52 | //IBundleModelElement requirements = project.getRequirements(); |
| 53 | } |
| 54 | |
| 55 | private void checkImports(Set<IPackageImport> imports) { |
| 56 | PackageImport foo = new PackageImport(); |
| 57 | foo.setPackageName("foo"); |
| 58 | foo.setVersions(VersionRange.parseVersionRange("1.0.0")); |
| 59 | PackageImport bar = new PackageImport(); |
| 60 | bar.setPackageName( "bar" ); |
| 61 | bar.setVersions(VersionRange.parseVersionRange("[2.2.2, 3.3.3]")); |
| 62 | PackageImport baz = new PackageImport(); |
| 63 | baz.setPackageName( "baz" ); |
| 64 | baz.setVersions(VersionRange.parseVersionRange("[3.0.0, 4.0.0)")); |
| 65 | |
| 66 | assertTrue(foo.toString(), imports.contains(foo)); |
| 67 | assertTrue(bar.toString(), imports.contains(bar)); |
| 68 | assertTrue(baz.toString(), imports.contains(baz)); |
| 69 | } |
| 70 | |
| 71 | } |