You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by ab...@apache.org on 2013/12/03 14:39:36 UTC

svn commit: r1547388 - in /incubator/celix/trunk/framework/private: resources-test/manifest.txt resources-test/manifest_sections.txt src/manifest.c test/manifest_test.cpp

Author: abroekhuis
Date: Tue Dec  3 13:39:35 2013
New Revision: 1547388

URL: http://svn.apache.org/r1547388
Log:
CELIX-93: Applied patch and added test cases to verify behaviour.

Added:
    incubator/celix/trunk/framework/private/resources-test/manifest.txt
    incubator/celix/trunk/framework/private/resources-test/manifest_sections.txt
Modified:
    incubator/celix/trunk/framework/private/src/manifest.c
    incubator/celix/trunk/framework/private/test/manifest_test.cpp

Added: incubator/celix/trunk/framework/private/resources-test/manifest.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/resources-test/manifest.txt?rev=1547388&view=auto
==============================================================================
--- incubator/celix/trunk/framework/private/resources-test/manifest.txt (added)
+++ incubator/celix/trunk/framework/private/resources-test/manifest.txt Tue Dec  3 13:39:35 2013
@@ -0,0 +1,4 @@
+Bundle-SymbolicName: client
+Bundle-Version: 1.0.0
+library: client
+Import-Service: server

Added: incubator/celix/trunk/framework/private/resources-test/manifest_sections.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/resources-test/manifest_sections.txt?rev=1547388&view=auto
==============================================================================
--- incubator/celix/trunk/framework/private/resources-test/manifest_sections.txt (added)
+++ incubator/celix/trunk/framework/private/resources-test/manifest_sections.txt Tue Dec  3 13:39:35 2013
@@ -0,0 +1,10 @@
+Bundle-SymbolicName: client
+Bundle-Version: 1.0.0
+library: client
+Import-Service: server
+
+Name: a
+a: 1
+
+Name: b
+b: 1

Modified: incubator/celix/trunk/framework/private/src/manifest.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/manifest.c?rev=1547388&r1=1547387&r2=1547388&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/manifest.c (original)
+++ incubator/celix/trunk/framework/private/src/manifest.c Tue Dec  3 13:39:35 2013
@@ -174,6 +174,7 @@ celix_status_t manifest_read(manifest_pt
 			}
 			manifest_readAttributes(manifest, attributes, file);
 
+			name = NULL;
 			skipEmptyLines = true;
 		}
 		apr_pool_destroy(subpool);

Modified: incubator/celix/trunk/framework/private/test/manifest_test.cpp
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/test/manifest_test.cpp?rev=1547388&r1=1547387&r2=1547388&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/test/manifest_test.cpp (original)
+++ incubator/celix/trunk/framework/private/test/manifest_test.cpp Tue Dec  3 13:39:35 2013
@@ -33,6 +33,7 @@
 
 extern "C" {
 #include "manifest.h"
+#include "hash_map.h"
 }
 
 int main(int argc, char** argv) {
@@ -54,5 +55,126 @@ TEST_GROUP(manifest) {
 	}
 };
 
+TEST(manifest, createFromFile) {
+    char *manifestFile = "../../celix/framework/private/resources-test/manifest.txt";
+    manifest_pt manifest = NULL;
+//    properties_pt properties = properties_create();
+    properties_pt properties = (properties_pt) 0x40;
+    void *ov = (void *) 0x00;
+
+    mock()
+        .expectOneCall("properties_create")
+        .andReturnValue(properties);
+    mock()
+        .expectOneCall("properties_set")
+        .withParameter("properties", properties)
+        .withParameter("key", "Bundle-SymbolicName")
+        .withParameter("value", "client")
+        .andReturnValue(ov);
+    mock()
+        .expectOneCall("properties_set")
+        .withParameter("properties", properties)
+        .withParameter("key", "Bundle-Version")
+        .withParameter("value", "1.0.0")
+        .andReturnValue(ov);
+    mock()
+        .expectOneCall("properties_set")
+        .withParameter("properties", properties)
+        .withParameter("key", "library")
+        .withParameter("value", "client")
+        .andReturnValue(ov);
+    mock()
+        .expectOneCall("properties_set")
+        .withParameter("properties", properties)
+        .withParameter("key", "Import-Service")
+        .withParameter("value", "server")
+        .andReturnValue(ov);
+    mock()
+        .expectOneCall("properties_destroy")
+        .withParameter("properties", properties);
 
+    manifest_createFromFile(pool, manifestFile, &manifest);
+}
+
+TEST(manifest, createFromFileWithSections) {
+    char *manifestFile = "../../celix/framework/private/resources-test/manifest_sections.txt";
+    manifest_pt manifest = NULL;
+//    properties_pt properties = properties_create();
+    properties_pt properties = (properties_pt) 0x40;
+    properties_pt properties2 = (properties_pt) 0x41;
+    properties_pt properties3 = (properties_pt) 0x42;
+    void *ov = (void *) 0x00;
+
+    mock()
+        .expectOneCall("properties_create")
+        .andReturnValue(properties);
+    mock()
+        .expectOneCall("properties_set")
+        .withParameter("properties", properties)
+        .withParameter("key", "Bundle-SymbolicName")
+        .withParameter("value", "client")
+        .andReturnValue(ov);
+    mock()
+        .expectOneCall("properties_set")
+        .withParameter("properties", properties)
+        .withParameter("key", "Bundle-Version")
+        .withParameter("value", "1.0.0")
+        .andReturnValue(ov);
+    mock()
+        .expectOneCall("properties_set")
+        .withParameter("properties", properties)
+        .withParameter("key", "library")
+        .withParameter("value", "client")
+        .andReturnValue(ov);
+    mock()
+        .expectOneCall("properties_set")
+        .withParameter("properties", properties)
+        .withParameter("key", "Import-Service")
+        .withParameter("value", "server")
+        .andReturnValue(ov);
+    mock()
+        .expectOneCall("properties_create")
+        .andReturnValue(properties2);
+    mock()
+        .expectOneCall("properties_set")
+        .withParameter("properties", properties2)
+        .withParameter("key", "a")
+        .withParameter("value", "1")
+        .andReturnValue(ov);
+    mock()
+        .expectOneCall("properties_create")
+        .andReturnValue(properties3);
+    mock()
+        .expectOneCall("properties_set")
+        .withParameter("properties", properties3)
+        .withParameter("key", "b")
+        .withParameter("value", "1")
+        .andReturnValue(ov);
+    mock()
+        .expectOneCall("properties_get")
+        .withParameter("properties", properties)
+        .withParameter("key", "Bundle-SymbolicName")
+        .andReturnValue("bsn");
+    mock()
+        .expectOneCall("properties_destroy")
+        .withParameter("properties", properties);
+
+    manifest_createFromFile(pool, manifestFile, &manifest);
+
+    properties_pt main = manifest_getMainAttributes(manifest);
+    POINTERS_EQUAL(properties, main);
+
+    char *name = manifest_getValue(manifest, "Bundle-SymbolicName");
+    STRCMP_EQUAL("bsn", name);
+
+    hash_map_pt map = NULL;
+    manifest_getEntries(manifest, &map);
+    LONGS_EQUAL(2, hashMap_size(map));
+
+    properties_pt actual = (properties_pt) hashMap_get(map, (void *) "a");
+    POINTERS_EQUAL(properties2, actual);
+
+    actual = (properties_pt) hashMap_get(map, (void *) "b");
+    POINTERS_EQUAL(properties3, actual);
+}