add test for variables with inheritance
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@819309 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/sigil/common/core.tests/src/org/apache/felix/sigil/core/ConfigTest.java b/sigil/common/core.tests/src/org/apache/felix/sigil/core/ConfigTest.java
index 17c9450..f8132d1 100644
--- a/sigil/common/core.tests/src/org/apache/felix/sigil/core/ConfigTest.java
+++ b/sigil/common/core.tests/src/org/apache/felix/sigil/core/ConfigTest.java
@@ -22,7 +22,7 @@
import java.io.IOException;
import java.net.URI;
-import java.util.Set;
+import java.util.Collection;
import junit.framework.TestCase;
@@ -40,7 +40,10 @@
static final URI base = URI.create( "test/ConfigTest/sigil.properties" );
-
+ static {
+ System.setProperty( "bar.version", "2.0.0" );
+ }
+
public ConfigTest( String name )
{
super( name );
@@ -54,14 +57,6 @@
ISigilBundle bundle = project.getDefaultBundle();
IBundleModelElement info = bundle.getBundleInfo();
- checkImports( info.getImports() );
-
- //IBundleModelElement requirements = project.getRequirements();
- }
-
-
- private void checkImports( Set<IPackageImport> imports )
- {
PackageImport foo = new PackageImport();
foo.setPackageName( "foo" );
foo.setVersions( VersionRange.parseVersionRange( "1.0.0" ) );
@@ -72,9 +67,37 @@
baz.setPackageName( "baz" );
baz.setVersions( VersionRange.parseVersionRange( "[3.0.0, 4.0.0)" ) );
+ Collection<IPackageImport> imports = info.getImports();
+
assertTrue( foo.toString(), imports.contains( foo ) );
assertTrue( bar.toString(), imports.contains( bar ) );
assertTrue( baz.toString(), imports.contains( baz ) );
+ //IBundleModelElement requirements = project.getRequirements();
+ }
+
+ public void testInherited() throws IOException {
+
+ IBldProject project = BldFactory.getProject( base.resolve( "inheritance/foo/sigil.properties" ) );
+
+ ISigilBundle bundle = project.getDefaultBundle();
+ IBundleModelElement info = bundle.getBundleInfo();
+
+ Collection<IPackageImport> imports = info.getImports();
+ assertEquals( 1, imports.size() );
+ IPackageImport i = imports.iterator().next();
+ assertEquals( "org.bar", i.getPackageName() );
+ assertEquals( VersionRange.parseVersionRange("2.0.0"), i.getVersions() );
+
+// project = BldFactory.getProject( base.resolve( "inheritance/foo/sigil.properties" ), true );
+//
+// bundle = project.getDefaultBundle();
+// info = bundle.getBundleInfo();
+//
+// imports = info.getImports();
+// assertEquals( 1, imports.size() );
+// i = imports.iterator().next();
+// assertEquals( "org.bar", i.getPackageName() );
+// assertEquals( VersionRange.parseVersionRange("2.0.0"), i.getVersions() );
}
}
diff --git a/sigil/common/core.tests/test/ConfigTest/inheritance/foo/sigil.properties b/sigil/common/core.tests/test/ConfigTest/inheritance/foo/sigil.properties
new file mode 100644
index 0000000..b840da7
--- /dev/null
+++ b/sigil/common/core.tests/test/ConfigTest/inheritance/foo/sigil.properties
@@ -0,0 +1,2 @@
+-bundles: org.foo
+-imports: org.bar
\ No newline at end of file
diff --git a/sigil/common/core.tests/test/ConfigTest/inheritance/sigil-defaults.properties b/sigil/common/core.tests/test/ConfigTest/inheritance/sigil-defaults.properties
new file mode 100644
index 0000000..088c716
--- /dev/null
+++ b/sigil/common/core.tests/test/ConfigTest/inheritance/sigil-defaults.properties
@@ -0,0 +1 @@
+package;org.bar.*: ${bar.version:-1.0.0}
\ No newline at end of file