Author: abroekhuis
Date: Wed Dec  4 21:25:27 2013
New Revision: 1547922

URL: http://svn.apache.org/r1547922
Log:
CELIX-92: Applied patch, fixed tests and removed now obsolete method from the 
framework.

Modified:
    incubator/celix/trunk/framework/CMakeLists.txt
    incubator/celix/trunk/framework/private/include/bundle_revision_private.h
    incubator/celix/trunk/framework/private/mock/bundle_mock.c
    incubator/celix/trunk/framework/private/mock/bundle_revision_mock.c
    incubator/celix/trunk/framework/private/mock/manifest_mock.c
    incubator/celix/trunk/framework/private/src/bundle.c
    incubator/celix/trunk/framework/private/src/bundle_revision.c
    incubator/celix/trunk/framework/private/src/framework.c
    incubator/celix/trunk/framework/private/test/bundle_revision_test.cpp
    incubator/celix/trunk/framework/private/test/bundle_test.cpp
    incubator/celix/trunk/framework/public/include/bundle.h
    incubator/celix/trunk/framework/public/include/bundle_revision.h

Modified: incubator/celix/trunk/framework/CMakeLists.txt
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/CMakeLists.txt?rev=1547922&r1=1547921&r2=1547922&view=diff
==============================================================================
--- incubator/celix/trunk/framework/CMakeLists.txt (original)
+++ incubator/celix/trunk/framework/CMakeLists.txt Wed Dec  4 21:25:27 2013
@@ -245,6 +245,7 @@ if (FRAMEWORK) 
                        private/mock/framework_mock.c
                        private/mock/module_mock.c
                        private/mock/bundle_archive_mock.c
+                       private/mock/bundle_revision_mock.c
                        private/mock/resolver_mock.c
                        private/mock/version_mock.c
                        private/src/utils.c
@@ -256,6 +257,7 @@ if (FRAMEWORK) 
                add_executable(bundle_revision_test 
                        private/test/bundle_revision_test.cpp
                        private/mock/miniunz_mock.c
+                       private/mock/manifest_mock.c
                        private/src/bundle_revision.c
                        private/src/celix_errorcodes.c
             private/src/celix_log.c)

Modified: 
incubator/celix/trunk/framework/private/include/bundle_revision_private.h
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/bundle_revision_private.h?rev=1547922&r1=1547921&r2=1547922&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/bundle_revision_private.h 
(original)
+++ incubator/celix/trunk/framework/private/include/bundle_revision_private.h 
Wed Dec  4 21:25:27 2013
@@ -34,6 +34,7 @@ struct bundleRevision {
        long revisionNr;
        char *root;
        char *location;
+       manifest_pt manifest;
 };
 
 #endif /* BUNDLE_REVISION_PRIVATE_H_ */

Modified: incubator/celix/trunk/framework/private/mock/bundle_mock.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/mock/bundle_mock.c?rev=1547922&r1=1547921&r2=1547922&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/mock/bundle_mock.c (original)
+++ incubator/celix/trunk/framework/private/mock/bundle_mock.c Wed Dec  4 
21:25:27 2013
@@ -74,14 +74,6 @@ celix_status_t bundle_setActivator(bundl
        return mock_c()->returnValue().value.intValue;
 }
 
-celix_status_t bundle_getManifest(bundle_pt bundle, manifest_pt *manifest) {
-       return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t bundle_setManifest(bundle_pt bundle, manifest_pt manifest) {
-       return mock_c()->returnValue().value.intValue;
-}
-
 celix_status_t bundle_getContext(bundle_pt bundle, bundle_context_pt *context) 
{
        return mock_c()->returnValue().value.intValue;
 }

Modified: incubator/celix/trunk/framework/private/mock/bundle_revision_mock.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/mock/bundle_revision_mock.c?rev=1547922&r1=1547921&r2=1547922&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/mock/bundle_revision_mock.c 
(original)
+++ incubator/celix/trunk/framework/private/mock/bundle_revision_mock.c Wed Dec 
 4 21:25:27 2013
@@ -47,5 +47,8 @@ celix_status_t bundleRevision_getRoot(bu
        return mock_c()->returnValue().value.intValue;
 }
 
-
+celix_status_t bundleRevision_getManifest(bundle_revision_pt revision, 
manifest_pt *manifest) {
+    mock_c()->actualCall("bundle_getCurrentModule");
+    return mock_c()->returnValue().value.intValue;
+}
 

Modified: incubator/celix/trunk/framework/private/mock/manifest_mock.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/mock/manifest_mock.c?rev=1547922&r1=1547921&r2=1547922&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/mock/manifest_mock.c (original)
+++ incubator/celix/trunk/framework/private/mock/manifest_mock.c Wed Dec  4 
21:25:27 2013
@@ -28,12 +28,17 @@
 #include "manifest.h"
 
 celix_status_t manifest_create(apr_pool_t *pool, manifest_pt *manifest) {
-       mock_c()->actualCall("bundle_getCurrentModule");
+       mock_c()->actualCall("manifest_create")
+        ->withPointerParameters("pool", pool)
+        ->_andPointerOutputParameters("manifest", (void **) manifest);
        return mock_c()->returnValue().value.intValue;
 }
 
 celix_status_t manifest_createFromFile(apr_pool_t *pool, char *filename, 
manifest_pt *manifest) {
-       mock_c()->actualCall("bundle_getCurrentModule");
+    mock_c()->actualCall("manifest_createFromFile")
+        ->withPointerParameters("pool", pool)
+        ->withStringParameters("filename", filename)
+        ->_andPointerOutputParameters("manifest", (void **) manifest);
        return mock_c()->returnValue().value.intValue;
 }
 

Modified: incubator/celix/trunk/framework/private/src/bundle.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle.c?rev=1547922&r1=1547921&r2=1547922&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle.c Wed Dec  4 21:25:27 
2013
@@ -36,6 +36,7 @@
 #include "version.h"
 #include "array_list.h"
 #include "bundle_archive.h"
+#include "bundle_revision.h"
 #include "resolver.h"
 #include "utils.h"
 #include "celix_log.h"
@@ -77,8 +78,6 @@ celix_status_t bundle_create(bundle_pt *
                        (*bundle)->lockThread = 0;
 
                        resolver_addModule(module);
-
-                       (*bundle)->manifest = NULL;
         }
        }
 
@@ -216,20 +215,15 @@ celix_status_t bundle_setState(bundle_pt
        return CELIX_SUCCESS;
 }
 
-celix_status_t bundle_getManifest(bundle_pt bundle, manifest_pt *manifest) {
-       *manifest = bundle->manifest;
-       return CELIX_SUCCESS;
-}
-
-celix_status_t bundle_setManifest(bundle_pt bundle, manifest_pt manifest) {
-       bundle->manifest = manifest;
-       return CELIX_SUCCESS;
-}
-
 celix_status_t bundle_createModule(bundle_pt bundle, module_pt *module) {
        celix_status_t status = CELIX_SUCCESS;
+       bundle_archive_pt archive = NULL;
+       bundle_revision_pt revision = NULL;
        manifest_pt headerMap = NULL;
-       status = getManifest(bundle->archive, bundle->memoryPool, &headerMap);
+
+       status = CELIX_DO_IF(status, bundle_getArchive(bundle, &archive));
+       status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, 
&revision));
+       status = CELIX_DO_IF(status, bundleRevision_getManifest(revision, 
&headerMap));
        if (status == CELIX_SUCCESS) {
         long bundleId;
         status = bundleArchive_getId(bundle->archive, &bundleId);

Modified: incubator/celix/trunk/framework/private/src/bundle_revision.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle_revision.c?rev=1547922&r1=1547921&r2=1547922&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_revision.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_revision.c Wed Dec  4 
21:25:27 2013
@@ -63,6 +63,9 @@ celix_status_t bundleRevision_create(apr
                 revision->root = apr_pstrdup(pool, root);
                 revision->location = apr_pstrdup(pool, location);
                 *bundle_revision = revision;
+
+                char *manifest = apr_pstrcat(pool, revision->root, 
"/META-INF/MANIFEST.MF", NULL);
+                               status = manifest_createFromFile(pool, 
manifest, &revision->manifest);
             }
         }
     }
@@ -115,3 +118,16 @@ celix_status_t bundleRevision_getRoot(bu
 
        return status;
 }
+
+celix_status_t bundleRevision_getManifest(bundle_revision_pt revision, 
manifest_pt *manifest) {
+       celix_status_t status = CELIX_SUCCESS;
+       if (revision == NULL) {
+               status = CELIX_ILLEGAL_ARGUMENT;
+       } else {
+               *manifest = revision->manifest;
+       }
+
+       framework_logIfError(status, NULL, "Failed to get manifest");
+
+       return status;
+}

Modified: incubator/celix/trunk/framework/private/src/framework.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1547922&r1=1547921&r2=1547922&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Wed Dec  4 21:25:27 
2013
@@ -56,6 +56,7 @@
 #include "service_registry.h"
 #include "bundle_cache.h"
 #include "bundle_archive.h"
+#include "bundle_revision.h"
 #include "bundle_context.h"
 #include "linked_list_iterator.h"
 #include "service_reference.h"
@@ -607,6 +608,7 @@ celix_status_t fw_startBundle(framework_
        long revisionNumber;
        activator_pt activator = NULL;
        bundle_archive_pt archive = NULL;
+       bundle_revision_pt revision = NULL;
        apr_pool_t *bundlePool = NULL;
        char *error = NULL;
 
@@ -654,8 +656,8 @@ celix_status_t fw_startBundle(framework_
 
                 status = CELIX_DO_IF(status, bundle_getArchive(bundle, 
&archive));
                 status = CELIX_DO_IF(status, bundle_getMemoryPool(bundle, 
&bundlePool));
-                status = CELIX_DO_IF(status, getManifest(archive, bundlePool, 
&manifest));
-                status = CELIX_DO_IF(status, bundle_setManifest(bundle, 
manifest));
+                status = CELIX_DO_IF(status, 
bundleArchive_getCurrentRevision(archive, &revision));
+                status = CELIX_DO_IF(status, 
bundleRevision_getManifest(revision, &manifest));
                 if (status == CELIX_SUCCESS) {
                     library = manifest_getValue(manifest, HEADER_LIBRARY);
                 }
@@ -1610,36 +1612,6 @@ void fw_serviceChanged(framework_pt fram
 //     return status;
 //}
 
-celix_status_t getManifest(bundle_archive_pt archive, apr_pool_t *pool, 
manifest_pt *manifest) {
-       celix_status_t status = CELIX_SUCCESS;
-       char mf[256];
-       long refreshCount;
-       char *archiveRoot;
-       long revisionNumber;
-
-       status = bundleArchive_getRefreshCount(archive, &refreshCount);
-       if (status == CELIX_SUCCESS) {
-               status = bundleArchive_getArchiveRoot(archive, &archiveRoot);
-               if (status == CELIX_SUCCESS) {
-                       status = 
bundleArchive_getCurrentRevisionNumber(archive, &revisionNumber);
-                       if (status == CELIX_SUCCESS) {
-                               if (status == CELIX_SUCCESS) {
-                                       sprintf(mf, 
"%s/version%ld.%ld/META-INF/MANIFEST.MF",
-                                                       archiveRoot,
-                                                       refreshCount,
-                                                       revisionNumber
-                                                       );
-                                       status = manifest_createFromFile(pool, 
mf, manifest);
-                               }
-                       }
-               }
-       }
-
-       framework_logIfError(status, NULL, "Failed to get manifest");
-
-       return status;
-}
-
 long framework_getNextBundleId(framework_pt framework) {
        long id = framework->nextBundleId;
        framework->nextBundleId++;

Modified: incubator/celix/trunk/framework/private/test/bundle_revision_test.cpp
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/test/bundle_revision_test.cpp?rev=1547922&r1=1547921&r2=1547922&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/test/bundle_revision_test.cpp 
(original)
+++ incubator/celix/trunk/framework/private/test/bundle_revision_test.cpp Wed 
Dec  4 21:25:27 2013
@@ -59,11 +59,17 @@ TEST(bundle_revision, create) {
        char location[] = "test_bundle.zip";
        char *inputFile = NULL;
        long revisionNr = 1l;
+       manifest_pt manifest = (manifest_pt) 0x42;
 
        mock().expectOneCall("extractBundle")
                        .withParameter("bundleName", location)
                        .withParameter("revisionRoot", root)
                        .andReturnValue(CELIX_SUCCESS);
+       mock().expectOneCall("manifest_createFromFile")
+            .withParameter("pool", pool)
+            .withParameter("filename", 
"bundle_revision_test/META-INF/MANIFEST.MF")
+            .andOutputParameter("manifest", manifest)
+            .andReturnValue(CELIX_SUCCESS);
 
        bundle_revision_pt revision = NULL;
        celix_status_t status = bundleRevision_create(pool, root, location, 
revisionNr, inputFile, &revision);
@@ -78,11 +84,18 @@ TEST(bundle_revision, createWithInput) {
        char location[] = "test_bundle.zip";
        char inputFile[] = "from_somewhere.zip";
        long revisionNr = 1l;
+       manifest_pt manifest = (manifest_pt) 0x42;
 
        mock().expectOneCall("extractBundle")
-                       .withParameter("bundleName", inputFile)
-                       .withParameter("revisionRoot", root)
-                       .andReturnValue(CELIX_SUCCESS);
+        .withParameter("bundleName", inputFile)
+        .withParameter("revisionRoot", root)
+        .andReturnValue(CELIX_SUCCESS);
+
+       mock().expectOneCall("manifest_createFromFile")
+        .withParameter("pool", pool)
+        .withParameter("filename", "bundle_revision_test/META-INF/MANIFEST.MF")
+        .andOutputParameter("manifest", manifest)
+        .andReturnValue(CELIX_SUCCESS);
 
        bundle_revision_pt revision = NULL;
        celix_status_t status = bundleRevision_create(pool, root, location, 
revisionNr, inputFile, &revision);
@@ -92,18 +105,21 @@ TEST(bundle_revision, createWithInput) {
        STRCMP_EQUAL(location, revision->location);
 }
 
-TEST(bundle_revision, getNumber) {
+TEST(bundle_revision, getters) {
        bundle_revision_pt revision = (bundle_revision_pt) apr_palloc(pool, 
sizeof(*revision));
        char root[] = "bundle_revision_test";
        char location[] = "test_bundle.zip";
        long revisionNr = 1l;
+       manifest_pt expected = (manifest_pt) 0x42;
        revision->root = root;
        revision->location = location;
        revision->revisionNr = revisionNr;
+       revision->manifest = expected;
 
        char *actualRoot = NULL;
        char *actualLocation = NULL;
        long actualRevisionNr = 0l;
+       manifest_pt actualManifest = NULL;
        celix_status_t status = CELIX_SUCCESS;
 
        status = bundleRevision_getNumber(revision, &actualRevisionNr);
@@ -118,6 +134,10 @@ TEST(bundle_revision, getNumber) {
        LONGS_EQUAL(CELIX_SUCCESS, status);
        STRCMP_EQUAL(root, actualRoot);
 
+       status = bundleRevision_getManifest(revision, &actualManifest);
+    LONGS_EQUAL(CELIX_SUCCESS, status);
+    POINTERS_EQUAL(expected, actualManifest);
+
        status = bundleRevision_getNumber(NULL, &actualRevisionNr);
        LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
 
@@ -126,5 +146,7 @@ TEST(bundle_revision, getNumber) {
 
        status = bundleRevision_getRoot(NULL, &actualRoot);
        LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
-}
 
+       status = bundleRevision_getManifest(NULL, &actualManifest);
+       LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
+}

Modified: incubator/celix/trunk/framework/private/test/bundle_test.cpp
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/test/bundle_test.cpp?rev=1547922&r1=1547921&r2=1547922&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/test/bundle_test.cpp (original)
+++ incubator/celix/trunk/framework/private/test/bundle_test.cpp Wed Dec  4 
21:25:27 2013
@@ -295,27 +295,6 @@ TEST(bundle, setState) {
        POINTERS_EQUAL(BUNDLE_INSTALLED, bundle->state);
 }
 
-TEST(bundle, getManifest) {
-       bundle_pt bundle = (bundle_pt) apr_palloc(pool, sizeof(*bundle));
-       manifest_pt manifest = (manifest_pt) 0x10;
-       bundle->manifest = manifest;
-
-       manifest_pt actual = NULL;
-       celix_status_t status = bundle_getManifest(bundle, &actual);
-       LONGS_EQUAL(CELIX_SUCCESS, status);
-       POINTERS_EQUAL(manifest, actual);
-}
-
-TEST(bundle, setManifest) {
-       bundle_pt bundle = (bundle_pt) apr_palloc(pool, sizeof(*bundle));
-       bundle->manifest = NULL;
-
-       manifest_pt manifest = (manifest_pt) 0x10;
-       celix_status_t status = bundle_setManifest(bundle, manifest);
-       LONGS_EQUAL(CELIX_SUCCESS, status);
-       POINTERS_EQUAL(manifest, bundle->manifest);
-}
-
 TEST(bundle, start) {
        bundle_pt bundle = (bundle_pt) apr_palloc(pool, sizeof(*bundle));
        framework_pt framework = (framework_pt) 0x10;

Modified: incubator/celix/trunk/framework/public/include/bundle.h
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/bundle.h?rev=1547922&r1=1547921&r2=1547922&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/bundle.h (original)
+++ incubator/celix/trunk/framework/public/include/bundle.h Wed Dec  4 21:25:27 
2013
@@ -53,8 +53,6 @@ FRAMEWORK_EXPORT void * bundle_getHandle
 FRAMEWORK_EXPORT void bundle_setHandle(bundle_pt bundle, void * handle);
 FRAMEWORK_EXPORT activator_pt bundle_getActivator(bundle_pt bundle);
 FRAMEWORK_EXPORT celix_status_t bundle_setActivator(bundle_pt bundle, 
activator_pt activator);
-FRAMEWORK_EXPORT celix_status_t bundle_getManifest(bundle_pt bundle, 
manifest_pt *manifest);
-FRAMEWORK_EXPORT celix_status_t bundle_setManifest(bundle_pt bundle, 
manifest_pt manifest);
 FRAMEWORK_EXPORT celix_status_t bundle_getContext(bundle_pt bundle, 
bundle_context_pt *context);
 FRAMEWORK_EXPORT celix_status_t bundle_setContext(bundle_pt bundle, 
bundle_context_pt context);
 FRAMEWORK_EXPORT celix_status_t bundle_getEntry(bundle_pt bundle, char * name, 
apr_pool_t *pool, char **entry);

Modified: incubator/celix/trunk/framework/public/include/bundle_revision.h
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/bundle_revision.h?rev=1547922&r1=1547921&r2=1547922&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/bundle_revision.h (original)
+++ incubator/celix/trunk/framework/public/include/bundle_revision.h Wed Dec  4 
21:25:27 2013
@@ -33,6 +33,7 @@
 #include <apr_pools.h>
 
 #include "celix_errno.h"
+#include "manifest.h"
 
 /**
  * Typedef for bundle_revision_pt.
@@ -98,6 +99,18 @@ celix_status_t bundleRevision_getLocatio
  */
 celix_status_t bundleRevision_getRoot(bundle_revision_pt revision, char 
**root);
 
+/**
+ * Retrieves the manifest of the given revision.
+ *
+ * @param revision The revision to get the manifest for.
+ * @param[out] manifest The manifest.
+ *
+ * @return Status code indication failure or success:
+ *             - CELIX_SUCCESS when no errors are encountered.
+ *             - CELIX_ILLEGAL_ARGUMENT If <code>revision</code> is illegal.
+ */
+celix_status_t bundleRevision_getManifest(bundle_revision_pt revision, 
manifest_pt *manifest);
+
 #endif /* BUNDLE_REVISION_H_ */
 
 /**


Reply via email to