You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2018/05/27 18:36:52 UTC
[09/51] [partial] celix git commit: CELIX-424: Cleans up the
directory structure. Moves all libraries to the libs subdir and all bundles
to the bundles subdir
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/framework/private/mock/service_tracker_customizer_mock.c
----------------------------------------------------------------------
diff --git a/framework/private/mock/service_tracker_customizer_mock.c b/framework/private/mock/service_tracker_customizer_mock.c
deleted file mode 100644
index 9a9aae6..0000000
--- a/framework/private/mock/service_tracker_customizer_mock.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * service_tracker_customizer_mock.c
- *
- * \date Feb 7, 2013
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include "CppUTestExt/MockSupport_c.h"
-
-#include "service_tracker_customizer_private.h"
-
-celix_status_t serviceTrackerCustomizer_create(void *handle,
- adding_callback_pt addingFunction, added_callback_pt addedFunction,
- modified_callback_pt modifiedFunction, removed_callback_pt removedFunction,
- service_tracker_customizer_pt *customizer) {
- mock_c()->actualCall("serviceTrackerCustomizer_create")
- ->withPointerParameters("handle", handle)
- ->withPointerParameters("addingFunction", addingFunction)
- ->withPointerParameters("addedFunction", addedFunction)
- ->withPointerParameters("modifiedFunction", modifiedFunction)
- ->withPointerParameters("removedFunction", removedFunction)
- ->withOutputParameter("customizer", customizer);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t serviceTrackerCustomizer_destroy(service_tracker_customizer_pt customizer) {
- mock_c()->actualCall("serviceTrackerCustomizer_destroy")
- ->withPointerParameters("customizer", customizer);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t serviceTrackerCustomizer_getHandle(service_tracker_customizer_pt customizer, void **handle) {
- mock_c()->actualCall("serviceTrackerCustomizer_getHandle")
- ->withPointerParameters("customizer", customizer)
- ->withOutputParameter("handle", handle);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t serviceTrackerCustomizer_getAddingFunction(service_tracker_customizer_pt customizer, adding_callback_pt *function) {
- mock_c()->actualCall("serviceTrackerCustomizer_getAddingFunction")
- ->withPointerParameters("customizer", customizer)
- ->withOutputParameter("function", (void **) function);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t serviceTrackerCustomizer_getAddedFunction(service_tracker_customizer_pt customizer, added_callback_pt *function) {
- mock_c()->actualCall("serviceTrackerCustomizer_getAddedFunction")
- ->withPointerParameters("customizer", customizer)
- ->withOutputParameter("function", (void **) function);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t serviceTrackerCustomizer_getModifiedFunction(service_tracker_customizer_pt customizer, modified_callback_pt *function) {
- mock_c()->actualCall("serviceTrackerCustomizer_getModifiedFunction")
- ->withPointerParameters("customizer", customizer)
- ->withOutputParameter("function", (void **) function);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t serviceTrackerCustomizer_getRemovedFunction(service_tracker_customizer_pt customizer, removed_callback_pt *function) {
- mock_c()->actualCall("serviceTrackerCustomizer_getRemovedFunction")
- ->withPointerParameters("customizer", customizer)
- ->withOutputParameter("function", (void **) function);
- return mock_c()->returnValue().value.intValue;
-}
-
-
-
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/framework/private/mock/version_mock.c
----------------------------------------------------------------------
diff --git a/framework/private/mock/version_mock.c b/framework/private/mock/version_mock.c
deleted file mode 100644
index 79517aa..0000000
--- a/framework/private/mock/version_mock.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * version_mock.c
- *
- * \date Feb 11, 2013
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include "CppUTestExt/MockSupport_c.h"
-
-#include "version.h"
-
-celix_status_t version_createVersion(int major, int minor, int micro, char * qualifier, version_pt *version) {
- mock_c()->actualCall("version_createVersion")
- ->withIntParameters("major", major)
- ->withIntParameters("minor", minor)
- ->withIntParameters("micro", micro)
- ->withStringParameters("qualifier", qualifier)
- ->withOutputParameter("version", version);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t version_destroy(version_pt version) {
- mock_c()->actualCall("version_destroy")
- ->withPointerParameters("version", version);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t version_clone(version_pt version, version_pt *clone) {
- mock_c()->actualCall("version_clone")
- ->withPointerParameters("version", version)
- ->withOutputParameter("clone", clone);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t version_createVersionFromString(const char * versionStr, version_pt *version) {
- mock_c()->actualCall("version_createVersionFromString")
- ->withStringParameters("versionStr", versionStr)
- ->withOutputParameter("version", (void **) version);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t version_createEmptyVersion(version_pt *version) {
- mock_c()->actualCall("version_createEmptyVersion")
- ->withOutputParameter("version", (void **) version);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t version_getMajor(version_pt version, int *major) {
- mock_c()->actualCall("version_getMajor")
- ->withPointerParameters("version", version)
- ->withOutputParameter("major", major);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t version_getMinor(version_pt version, int *minor) {
- mock_c()->actualCall("version_getMinor")
- ->withPointerParameters("version", version)
- ->withOutputParameter("minor", minor);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t version_getMicro(version_pt version, int *micro) {
- mock_c()->actualCall("version_getMicro")
- ->withPointerParameters("version", version)
- ->withOutputParameter("micro", micro);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t version_getQualifier(version_pt version, const char **qualifier) {
- mock_c()->actualCall("version_getQualifier")
- ->withPointerParameters("version", version)
- ->withOutputParameter("qualifier", qualifier);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t version_compareTo(version_pt version, version_pt compare, int *result) {
- mock_c()->actualCall("version_compareTo")
- ->withPointerParameters("version", version)
- ->withPointerParameters("compare", compare)
- ->withOutputParameter("result", result);
- return CELIX_SUCCESS;
-}
-
-
-celix_status_t version_toString(version_pt version, char **string) {
- mock_c()->actualCall("version_toString")
- ->withPointerParameters("version", version)
- ->withOutputParameter("string", string);
- return mock_c()->returnValue().value.intValue;
-}
-
-
-
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/framework/private/mock/version_range_mock.c
----------------------------------------------------------------------
diff --git a/framework/private/mock/version_range_mock.c b/framework/private/mock/version_range_mock.c
deleted file mode 100644
index 36826a7..0000000
--- a/framework/private/mock/version_range_mock.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * version_range_mock.c
- *
- * \date Feb 11, 2013
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include "CppUTestExt/MockSupport_c.h"
-
-#include "version_range.h"
-
-celix_status_t versionRange_createVersionRange(version_pt low, bool isLowInclusive, version_pt high, bool isHighInclusive, version_range_pt *versionRange) {
- mock_c()->actualCall("versionRange_createVersionRange")
- ->withPointerParameters("low", low)
- ->withIntParameters("isLowInclusive", isLowInclusive)
- ->withPointerParameters("high", high)
- ->withIntParameters("isHighInclusive", isHighInclusive)
- ->withOutputParameter("versionRange", versionRange);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t versionRange_destroy(version_range_pt range) {
- mock_c()->actualCall("versionRange_destroy")
- ->withPointerParameters("range", range);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t versionRange_createInfiniteVersionRange(version_range_pt *range) {
- mock_c()->actualCall("versionRange_createInfiniteVersionRange")
- ->withOutputParameter("range", (void **) range);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t versionRange_isInRange(version_range_pt versionRange, version_pt version, bool *inRange) {
- mock_c()->actualCall("versionRange_isInRange")
- ->withPointerParameters("versionRange", versionRange)
- ->withPointerParameters("version", version)
- ->withOutputParameter("inRange", (int *) inRange);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t versionRange_parse(const char * rangeStr, version_range_pt *range) {
- mock_c()->actualCall("versionRange_parse")
- ->withStringParameters("rangeStr", rangeStr)
- ->withOutputParameter("range", (void **) range);
- return mock_c()->returnValue().value.intValue;
-}
-
-
-
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/framework/private/mock/wire_mock.c
----------------------------------------------------------------------
diff --git a/framework/private/mock/wire_mock.c b/framework/private/mock/wire_mock.c
deleted file mode 100644
index 017f861..0000000
--- a/framework/private/mock/wire_mock.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * wire_mock.c
- *
- * \date Feb 11, 2013
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include "CppUTestExt/MockSupport_c.h"
-
-#include "wire.h"
-
-celix_status_t wire_create(module_pt importer, requirement_pt requirement,
- module_pt exporter, capability_pt capability, wire_pt *wire) {
- mock_c()->actualCall("wire_create")
- ->withPointerParameters("importer", importer)
- ->withPointerParameters("requirement", requirement)
- ->withPointerParameters("exporter", exporter)
- ->withPointerParameters("capability", capability)
- ->withOutputParameter("wire", wire);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t wire_destroy(wire_pt wire) {
- mock_c()->actualCall("wire_destroy")
- ->withPointerParameters("wire", wire);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t wire_getCapability(wire_pt wire, capability_pt *capability) {
- mock_c()->actualCall("wire_getCapability")
- ->withPointerParameters("wire", wire)
- ->withOutputParameter("capability", (void**) capability);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t wire_getRequirement(wire_pt wire, requirement_pt *requirement) {
- mock_c()->actualCall("wire_getRequirement")
- ->withPointerParameters("wire", wire)
- ->withOutputParameter("requirement", (void**) requirement);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t wire_getImporter(wire_pt wire, module_pt *importer) {
- mock_c()->actualCall("wire_getImporter")
- ->withPointerParameters("wire", wire)
- ->withOutputParameter("importer", (void**) importer);
- return mock_c()->returnValue().value.intValue;
-}
-
-celix_status_t wire_getExporter(wire_pt wire, module_pt *exporter) {
- mock_c()->actualCall("wire_getExporter")
- ->withPointerParameters("wire", wire)
- ->withOutputParameter("exporter", (void**) exporter);
- return mock_c()->returnValue().value.intValue;
-}
-
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/framework/private/resources-test/NOTE
----------------------------------------------------------------------
diff --git a/framework/private/resources-test/NOTE b/framework/private/resources-test/NOTE
deleted file mode 100644
index 149201e..0000000
--- a/framework/private/resources-test/NOTE
+++ /dev/null
@@ -1,24 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-All files in this directory are licensed to the Apache Software Foundation (as included above).
-Normally source/txt files should include this header but for Manifest files this is not possible.
-The following files do not include the header:
-* manifest_sections.txt
-* manifest.txt
-
-This note is added to explicitly mention that the same licensing applies to these files as to any other having the header.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/framework/private/resources-test/manifest.txt
----------------------------------------------------------------------
diff --git a/framework/private/resources-test/manifest.txt b/framework/private/resources-test/manifest.txt
deleted file mode 100644
index 72e7005..0000000
--- a/framework/private/resources-test/manifest.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-Bundle-SymbolicName: client
-Bundle-Version: 1.0.0
-library: client
-Import-Service: server
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/framework/private/resources-test/manifest_sections.txt
----------------------------------------------------------------------
diff --git a/framework/private/resources-test/manifest_sections.txt b/framework/private/resources-test/manifest_sections.txt
deleted file mode 100644
index 2777e9b..0000000
--- a/framework/private/resources-test/manifest_sections.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-Bundle-SymbolicName: client
-Bundle-Version: 1.0.0
-library: client
-Import-Service: server
-
-Name: a
-
-aa: 1
-ab: 2
-
-Name: b
-ba: 3
-bb: 4
-
-Name: two words
-white space: 5
-
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/framework/private/test/attribute_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/attribute_test.cpp b/framework/private/test/attribute_test.cpp
deleted file mode 100644
index feba87c..0000000
--- a/framework/private/test/attribute_test.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * attribute_test.cpp
- *
- * \date Feb 11, 2013
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "CppUTest/TestHarness.h"
-#include "CppUTest/TestHarness_c.h"
-#include "CppUTest/CommandLineTestRunner.h"
-#include "CppUTestExt/MockSupport.h"
-
-extern "C" {
-#include "attribute_private.h"
-#include "celix_log.h"
-
-framework_logger_pt logger = (framework_logger_pt) 0x42;
-}
-
-int main(int argc, char** argv) {
- return RUN_ALL_TESTS(argc, argv);
-}
-
-static char* my_strdup(const char* s){
- if(s==NULL){
- return NULL;
- }
-
- size_t len = strlen(s);
-
- char *d = (char*) calloc (len + 1,sizeof(char));
-
- if (d == NULL){
- return NULL;
- }
-
- strncpy (d,s,len);
- return d;
-}
-
-TEST_GROUP(attribute) {
- void setup(void) {
- }
-
- void teardown() {
- mock().checkExpectations();
- mock().clear();
- }
-};
-
-TEST(attribute, create) {
- char * key = (char*) my_strdup("key");
- char * value = (char*) my_strdup("value");
-
- attribute_pt attribute = NULL;
- celix_status_t status = attribute_create(key, value, &attribute);
- STRCMP_EQUAL(key, attribute->key);
- STRCMP_EQUAL(value, attribute->value);
- LONGS_EQUAL(CELIX_SUCCESS, status);
-
- mock().expectOneCall("framework_logCode")
- .withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- status = attribute_create(NULL, NULL, NULL);
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
-
- attribute_destroy(attribute);
-}
-
-TEST(attribute, getKey) {
- char key[] = "key";
- char value[] = "value";
-
- attribute_pt attribute = (attribute_pt) malloc(sizeof(*attribute));
- attribute->key = key;
- attribute->value = value;
-
- char *actual = NULL;
- attribute_getKey(attribute, &actual);
- STRCMP_EQUAL(key, actual);
-
- free(attribute);
-}
-
-TEST(attribute, getValue) {
- char key[] = "key";
- char value[] = "value";
-
- attribute_pt attribute = (attribute_pt) malloc(sizeof(*attribute));
- attribute->key = key;
- attribute->value = value;
-
- char *actual = NULL;
- attribute_getValue(attribute, &actual);
- STRCMP_EQUAL(value, actual);
-
- free(attribute);
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/framework/private/test/bundle_archive_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/bundle_archive_test.cpp b/framework/private/test/bundle_archive_test.cpp
deleted file mode 100644
index 0948608..0000000
--- a/framework/private/test/bundle_archive_test.cpp
+++ /dev/null
@@ -1,312 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * bundle_archive_test.cpp
- *
- * \date Feb 11, 2013
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <unistd.h>
-#include <string.h>
-
-#include "CppUTest/TestHarness.h"
-#include "CppUTest/TestHarness_c.h"
-#include "CppUTest/CommandLineTestRunner.h"
-#include "CppUTestExt/MockSupport.h"
-
-extern "C" {
-#include "bundle_archive.h"
-framework_logger_pt logger = (framework_logger_pt) 0x42;
-}
-
-int main(int argc, char** argv) {
- return RUN_ALL_TESTS(argc, argv);
-}
-
-//----------------------TESTGROUP DEFINES----------------------
-
-TEST_GROUP(bundle_archive) {
- bundle_archive_pt bundle_archive;
- char * bundle_path; //uses the default build shell bundle
- char * alternate_bundle_path;//alternative bundle, if shell bundle not found
- char cache_path[512]; //a local cache folder
-
- void setup(void) {
- char cwd[512];
- bundle_archive = NULL;
- bundle_path = (char*) "../shell/shell.zip"; //uses the default build shell bundle
- alternate_bundle_path = (char*) "../log_service/log_service.zip"; //alternative bundle, if shell bundle not found
- snprintf(cache_path, sizeof(cache_path), "%s/.cache", getcwd(cwd, sizeof(cwd))); //a local cache folder
- struct stat file_stat;
-
- if (stat(bundle_path, &file_stat) < 0) {
- if (stat(alternate_bundle_path, &file_stat) < 0) {
- FAIL("failed to find needed test bundle");
- } else {
- bundle_path = alternate_bundle_path;
- }
- }
- }
-
- void teardown() {
- mock().checkExpectations();
- mock().clear();
- }
-};
-
-//----------------------TEST DEFINES----------------------
-//WARNING: if one test fails, it does not clean up properly,
-//causing most if not all of the subsequent tests to also fail
-
-TEST(bundle_archive, create) {
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_archive = (bundle_archive_pt) 0x42;
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleArchive_create(cache_path, 5, bundle_path, NULL, &bundle_archive));
-
- bundle_archive = NULL;
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 5, bundle_path, NULL, &bundle_archive));
- CHECK(bundle_archive != NULL);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
-}
-
-TEST(bundle_archive, createSystemBundleArchive) {
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_archive = (bundle_archive_pt) 0x42;
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleArchive_createSystemBundleArchive(&bundle_archive ));
-
- bundle_archive = NULL;
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_createSystemBundleArchive(&bundle_archive));
- CHECK(bundle_archive != NULL);
-
- //LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
-}
-
-TEST(bundle_archive, recreate) {
- char * get_root;
- char * get_location;
- bundle_archive_pt recr_archive = NULL;
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 5, bundle_path, NULL, &bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_recreate(cache_path, &recr_archive));
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getArchiveRoot(recr_archive, &get_root));
- STRCMP_EQUAL(cache_path, get_root);
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getLocation(recr_archive, &get_location));
- STRCMP_EQUAL(bundle_path, get_location);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(recr_archive));
-}
-
-TEST(bundle_archive, getId) {
- long get_id;
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, -42, bundle_path, NULL, &bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getId(bundle_archive, &get_id));
- LONGS_EQUAL(-42, get_id);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
- bundle_archive = NULL;
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 666, bundle_path, NULL, &bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getId(bundle_archive, &get_id));
- LONGS_EQUAL(666, get_id);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
-}
-
-TEST(bundle_archive, getLocation) {
- char * get_loc;
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 1, bundle_path, NULL, &bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getLocation(bundle_archive, &get_loc));
- STRCMP_EQUAL(bundle_path, get_loc);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
-}
-
-TEST(bundle_archive, getArchiveRoot) {
- char * get_root;
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 1, bundle_path, NULL, &bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getArchiveRoot(bundle_archive, &get_root));
- STRCMP_EQUAL(cache_path, get_root);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
-}
-
-TEST(bundle_archive, getCurrentRevisionNumber) {
- long get_rev_num;
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 1, bundle_path, NULL, &bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getCurrentRevisionNumber(bundle_archive, &get_rev_num));
- LONGS_EQUAL(0, get_rev_num);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_revise(bundle_archive, bundle_path, NULL));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getCurrentRevisionNumber(bundle_archive,
- &get_rev_num));
- LONGS_EQUAL(1, get_rev_num);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_revise(bundle_archive, bundle_path, NULL));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getCurrentRevisionNumber(bundle_archive, &get_rev_num));
- LONGS_EQUAL(2, get_rev_num);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
-}
-
-TEST(bundle_archive, getCurrentRevision) {
- long get_rev_num;
- bundle_revision_pt get_rev;
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 1, bundle_path, NULL, &bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getCurrentRevision(bundle_archive, &get_rev));
- bundleRevision_getNumber(get_rev, &get_rev_num);
- LONGS_EQUAL(0, get_rev_num);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_revise(bundle_archive, bundle_path, NULL));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getCurrentRevision(bundle_archive, &get_rev));
- bundleRevision_getNumber(get_rev, &get_rev_num);
- LONGS_EQUAL(1, get_rev_num);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
-}
-
-TEST(bundle_archive, getRevision) {
- long get_rev_num;
- bundle_revision_pt get_rev;
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 1, bundle_path, NULL, &bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_revise(bundle_archive, bundle_path, NULL));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_revise(bundle_archive, bundle_path, NULL));
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getRevision(bundle_archive, 0, &get_rev));
- bundleRevision_getNumber(get_rev, &get_rev_num);
- LONGS_EQUAL(0, get_rev_num);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getRevision(bundle_archive, 2, &get_rev));
- bundleRevision_getNumber(get_rev, &get_rev_num);
- LONGS_EQUAL(2, get_rev_num);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getRevision(bundle_archive, 1, &get_rev));
- bundleRevision_getNumber(get_rev, &get_rev_num);
- LONGS_EQUAL(1, get_rev_num);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
-}
-
-TEST(bundle_archive, set_getPersistentState) {
- bundle_state_e get;
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 1, bundle_path, NULL, &bundle_archive));
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_setPersistentState(bundle_archive, OSGI_FRAMEWORK_BUNDLE_UNKNOWN));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getPersistentState(bundle_archive, &get));
- LONGS_EQUAL(OSGI_FRAMEWORK_BUNDLE_INSTALLED, get);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_setPersistentState(bundle_archive, OSGI_FRAMEWORK_BUNDLE_ACTIVE));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getPersistentState(bundle_archive, &get));
- LONGS_EQUAL(OSGI_FRAMEWORK_BUNDLE_ACTIVE, get);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_setPersistentState(bundle_archive, OSGI_FRAMEWORK_BUNDLE_STARTING));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getPersistentState(bundle_archive, &get));
- LONGS_EQUAL(OSGI_FRAMEWORK_BUNDLE_STARTING, get);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_setPersistentState(bundle_archive, OSGI_FRAMEWORK_BUNDLE_UNINSTALLED));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getPersistentState(bundle_archive, &get));
- LONGS_EQUAL(OSGI_FRAMEWORK_BUNDLE_UNINSTALLED, get);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
-}
-
-TEST(bundle_archive, set_getRefreshCount) {
- long get_refresh_num;
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 1, bundle_path, NULL, &bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getRefreshCount(bundle_archive, &get_refresh_num));
- LONGS_EQUAL(0, get_refresh_num);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_setRefreshCount(bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getRefreshCount(bundle_archive, &get_refresh_num));
- LONGS_EQUAL(0, get_refresh_num);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
-}
-
-TEST(bundle_archive, get_setLastModified) {
- time_t set_time;
- time_t get_time;
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 1, bundle_path, NULL, &bundle_archive));
-
- time(&set_time);
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_setLastModified(bundle_archive, set_time));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getLastModified(bundle_archive, &get_time));
- CHECK(set_time == get_time);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
-}
-
-//CANT seem to find a way to test this static function
-/*TEST(bundle_archive, readLastModified) {
- mock().expectOneCall("framework_logCode");
-
- time_t set_time;
- time_t get_time;
- bundle_archive_pt recr_archive = NULL;
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_create(cache_path, 1, bundle_path, NULL, &bundle_archive));
-
- time(&set_time);
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_setLastModified(bundle_archive, set_time));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_recreate(cache_path, &recr_archive));
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_getLastModified(recr_archive, &get_time));
- LONGS_EQUAL(set_time, get_time);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_closeAndDelete(bundle_archive));
- //LONGS_EQUAL(CELIX_SUCCESS, bundleArchive_destroy(bundle_archive));
-}*/
-
-TEST(bundle_archive, rollbackRevise) {
- bool get;
- bundleArchive_rollbackRevise(NULL, &get);
-
- LONGS_EQUAL(true, get);
-
-}
-
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/framework/private/test/bundle_cache_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/bundle_cache_test.cpp b/framework/private/test/bundle_cache_test.cpp
deleted file mode 100644
index 13e0e80..0000000
--- a/framework/private/test/bundle_cache_test.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * bundle_cache_test.cpp
- *
- * \date Feb 11, 2013
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "CppUTest/TestHarness.h"
-#include "CppUTest/TestHarness_c.h"
-#include "CppUTest/CommandLineTestRunner.h"
-#include "CppUTestExt/MockSupport.h"
-
-extern "C" {
-#include "bundle_cache_private.h"
-#include "celix_log.h"
-
-framework_logger_pt logger = (framework_logger_pt) 0x42;
-}
-
-int main(int argc, char** argv) {
- return RUN_ALL_TESTS(argc, argv);
-}
-
-TEST_GROUP(bundle_cache) {
- void setup(void) {
- }
-
- void teardown() {
- mock().checkExpectations();
- mock().clear();
- }
-};
-
-TEST(bundle_cache, create) {
- properties_pt configuration = (properties_pt) 0x10;
-
- mock().expectOneCall("properties_get")
- .withParameter("properties", configuration)
- .withParameter("key", "org.osgi.framework.storage")
- .andReturnValue((char *) NULL);
-
- bundle_cache_pt cache = NULL;
- LONGS_EQUAL(CELIX_SUCCESS, bundleCache_create(configuration, &cache));
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleCache_destroy(&cache));
-}
-
-TEST(bundle_cache, deleteTree) {
- bundle_cache_pt cache = (bundle_cache_pt) malloc(sizeof(*cache));
- char cacheDir[] = "bundle_cache_test_directory";
- char cacheDir2[] = "bundle_cache_test_directory/testdir";
- char cacheFile[] = "bundle_cache_test_directory/tempXXXXXX";
- cache->cacheDir = cacheDir;
-
- int rv = 0;
- rv += mkdir(cacheDir, S_IRWXU);
- rv += mkdir(cacheDir2, S_IRWXU);
-
- /* Check previous mkdir calls were fine*/
- LONGS_EQUAL(rv,0);
-
- //mkstemp opens the file for safety, but bundlecache_delete needs to reopen the file
- umask(0033);
- int fd = mkstemp(cacheFile);
- if(fd>=0){
- close(fd);
- }
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleCache_delete(cache));
-
- free(cache);
-}
-
-TEST(bundle_cache, getArchive) {
- bundle_cache_pt cache = (bundle_cache_pt) malloc(sizeof(*cache));
- char cacheDir[] = "bundle_cache_test_directory";
- cache->cacheDir = cacheDir;
-
- char bundle0[] = "bundle_cache_test_directory/bundle0";
- char bundle1[] = "bundle_cache_test_directory/bundle1";
- int rv = 0;
- rv += mkdir(cacheDir, S_IRWXU);
- rv += mkdir(bundle0, S_IRWXU);
- rv += mkdir(bundle1, S_IRWXU);
-
- /* Check previous mkdir calls were fine*/
- LONGS_EQUAL(rv,0);
-
- bundle_archive_pt archive = (bundle_archive_pt) 0x10;
- mock().expectOneCall("bundleArchive_recreate")
- .withParameter("archiveRoot", bundle1)
- .withOutputParameterReturning("bundle_archive", &archive, sizeof(archive))
- .andReturnValue(CELIX_SUCCESS);
-
- array_list_pt archives = NULL;
- LONGS_EQUAL(CELIX_SUCCESS, bundleCache_getArchives(cache, &archives));
-
- CHECK(archives);
- LONGS_EQUAL(1, arrayList_size(archives));
- POINTERS_EQUAL(archive, arrayList_get(archives, 0));
-
- rmdir(bundle0);
- rmdir(bundle1);
- rmdir(cacheDir);
- arrayList_destroy(archives);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleCache_getArchives(cache, &archives));
-
- arrayList_destroy(archives);
- rmdir(cacheDir);
- free(cache);
-}
-
-TEST(bundle_cache, createArchive) {
- bundle_cache_pt cache = (bundle_cache_pt) malloc(sizeof(*cache));
- char cacheDir[] = "bundle_cache_test_directory";
- cache->cacheDir = cacheDir;
-
- char archiveRoot[] = "bundle_cache_test_directory/bundle1";
- int id = 1;
- char location[] = "test.zip";
- bundle_archive_pt archive = (bundle_archive_pt) 0x10;
- mock().expectOneCall("bundleArchive_create")
- .withParameter("archiveRoot", archiveRoot)
- .withParameter("id", id)
- .withParameter("location", location)
- .withParameter("inputFile", (char *) NULL)
- .withOutputParameterReturning("bundle_archive", &archive, sizeof(archive))
- .andReturnValue(CELIX_SUCCESS);
-
- bundle_archive_pt actual;
- bundleCache_createArchive(cache, 1l, location, NULL, &actual);
- POINTERS_EQUAL(archive, actual);
-
- free(cache);
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/framework/private/test/bundle_context_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/bundle_context_test.cpp b/framework/private/test/bundle_context_test.cpp
deleted file mode 100644
index 21abb80..0000000
--- a/framework/private/test/bundle_context_test.cpp
+++ /dev/null
@@ -1,620 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * bundle_context_test.cpp
- *
- * \date Sep 14, 2015
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "CppUTest/TestHarness.h"
-#include "CppUTest/TestHarness_c.h"
-#include "CppUTest/CommandLineTestRunner.h"
-#include "CppUTestExt/MockSupport.h"
-
-extern "C" {
-#include "bundle_context_private.h"
-#include "celix_log.h"
-
-framework_logger_pt logger = (framework_logger_pt) 0x42;
-}
-
-int main(int argc, char** argv) {
- return RUN_ALL_TESTS(argc, argv);
-}
-
-TEST_GROUP(bundle_context) {
- void setup(void) {
- }
-
- void teardown() {
- mock().checkExpectations();
- mock().clear();
- }
-};
-
-TEST(bundle_context, create) {
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
-
- bundle_context_pt context = NULL;
- bundleContext_create(framework, logger, bundle, &context);
- POINTERS_EQUAL(framework, context->framework)
- POINTERS_EQUAL(bundle, context->bundle)
-
- bundleContext_create(NULL, logger, NULL, &context);
-
- bundleContext_destroy(context);
-}
-
-TEST(bundle_context, destroy) {
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
- bundle_context_pt context = NULL;
- bundleContext_create((framework_pt) 0x10, (framework_logger_pt)(0x30), (bundle_pt)(0x20), &context);
-
- celix_status_t status = bundleContext_destroy(context);
- LONGS_EQUAL(CELIX_SUCCESS, status);
-
- status = bundleContext_destroy(NULL);
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
-}
-
-TEST(bundle_context, getBundle) {
- mock().expectNCalls(2, "framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
- context->framework = framework;
- context->bundle = bundle;
-
- celix_status_t status;
- bundle_pt actualBundle = NULL;
- status = bundleContext_getBundle(context, &actualBundle);
- LONGS_EQUAL(CELIX_SUCCESS, status);
- POINTERS_EQUAL(bundle, actualBundle);
-
- framework_pt actualFramework = NULL;
- status = bundleContext_getFramework(context, &actualFramework);
- LONGS_EQUAL(CELIX_SUCCESS, status);
- POINTERS_EQUAL(framework, actualFramework);
-
- actualBundle = NULL;
- status = bundleContext_getBundle(NULL, &actualBundle);
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
-
- actualFramework = NULL;
- status = bundleContext_getFramework(NULL, &actualFramework);
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
-
- free(context);
-}
-
-TEST(bundle_context, installBundle) {
- bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
- context->framework = framework;
- context->bundle = bundle;
-
- char location[] = "test.zip";
- bundle_pt installedBundle = (bundle_pt) 0x40;
- mock().expectOneCall("fw_installBundle")
- .withParameter("framework", framework)
- .withParameter("location", location)
- .withParameter("inputFile", (char *) NULL)
- .withOutputParameterReturning("bundle", &installedBundle, sizeof(installedBundle))
- .andReturnValue(CELIX_SUCCESS);
-
- bundle_pt actualInstalledBundle = NULL;
- celix_status_t status = bundleContext_installBundle(context, location, &actualInstalledBundle);
- LONGS_EQUAL(CELIX_SUCCESS, status);
- POINTERS_EQUAL(installedBundle, actualInstalledBundle);
-
- free(context);
-}
-
-TEST(bundle_context, installBundle2) {
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
- context->framework = framework;
- context->bundle = bundle;
-
- char location[] = "test.zip";
- char inputFile[] = "input.zip";
- bundle_pt installedBundle = (bundle_pt) 0x40;
- mock().expectOneCall("fw_installBundle")
- .withParameter("framework", framework)
- .withParameter("location", location)
- .withParameter("inputFile", inputFile)
- .withOutputParameterReturning("bundle", &installedBundle, sizeof(installedBundle))
- .andReturnValue(CELIX_SUCCESS);
-
- bundle_pt actualInstalledBundle = NULL;
- celix_status_t status = bundleContext_installBundle2(context, location, inputFile, &actualInstalledBundle);
- LONGS_EQUAL(CELIX_SUCCESS, status);
- POINTERS_EQUAL(installedBundle, actualInstalledBundle);
-
- actualInstalledBundle = NULL;
- status = bundleContext_installBundle2(NULL, location, inputFile, &actualInstalledBundle);
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
-
- free(context);
-}
-
-TEST(bundle_context, registerService) {
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
- context->framework = framework;
- context->bundle = bundle;
-
- char serviceName[] = "service";
- void *service = (void *) 0x40;
- properties_pt properties = (properties_pt) 0x50;
- service_registration_pt registration = (service_registration_pt) 0x60;
-
- mock().expectOneCall("fw_registerService")
- .withParameter("framework", framework)
- .withParameter("bundle", bundle)
- .withParameter("serviceName", serviceName)
- .withParameter("service", service)
- .withParameter("properties", properties)
- .withOutputParameterReturning("registration", ®istration, sizeof(registration))
- .andReturnValue(CELIX_SUCCESS);
-
- service_registration_pt actualRegistration = NULL;
- celix_status_t status = bundleContext_registerService(context, serviceName, service, properties, &actualRegistration);
- LONGS_EQUAL(CELIX_SUCCESS, status);
- POINTERS_EQUAL(registration, actualRegistration);
-
- actualRegistration = NULL;
- status = bundleContext_registerService(NULL, serviceName, service, properties, &actualRegistration);
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
-
- free(context);
-}
-
-TEST(bundle_context, registerServiceFactory) {
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
- context->framework = framework;
- context->bundle = bundle;
-
- char serviceName[] = "service";
- service_factory_pt serviceFactory = (service_factory_pt) 0x40;
- properties_pt properties = (properties_pt) 0x50;
- service_registration_pt registration = (service_registration_pt) 0x60;
-
- mock().expectOneCall("fw_registerServiceFactory")
- .withParameter("framework", framework)
- .withParameter("bundle", bundle)
- .withParameter("serviceName", serviceName)
- .withParameter("serviceFactory", serviceFactory)
- .withParameter("properties", properties)
- .withOutputParameterReturning("registration", ®istration, sizeof(registration))
- .andReturnValue(CELIX_SUCCESS);
-
- service_registration_pt actualRegistration = NULL;
- celix_status_t status = bundleContext_registerServiceFactory(context, serviceName, serviceFactory, properties, &actualRegistration);
- LONGS_EQUAL(CELIX_SUCCESS, status);
- POINTERS_EQUAL(registration, actualRegistration);
-
- actualRegistration = NULL;
- status = bundleContext_registerServiceFactory(NULL, serviceName, serviceFactory, properties, &actualRegistration);
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
-
- free(context);
-}
-
-TEST(bundle_context, getServiceReferences) {
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
- context->framework = framework;
- context->bundle = bundle;
-
- char serviceName[] = "service";
- char filter[] = "";
- array_list_pt references = (array_list_pt) 0x40;
-
- mock().expectOneCall("fw_getServiceReferences")
- .withParameter("framework", framework)
- .withParameter("bundle", bundle)
- .withParameter("serviceName", serviceName)
- .withParameter("filter", filter)
- .withOutputParameterReturning("references", &references, sizeof(references))
- .andReturnValue(CELIX_SUCCESS);
-
- array_list_pt actualReferences = NULL;
- celix_status_t status = bundleContext_getServiceReferences(context, serviceName, filter, &actualReferences);
- LONGS_EQUAL(CELIX_SUCCESS, status);
- POINTERS_EQUAL(references, actualReferences);
-
- actualReferences = NULL;
- status = bundleContext_getServiceReferences(NULL, serviceName, filter, &actualReferences);
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
-
- free(context);
-}
-
-TEST(bundle_context, getServiceReference) {
- mock().expectNCalls(3, "framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
- context->framework = framework;
- context->bundle = bundle;
-
- char serviceName[] = "service";
- array_list_pt references = NULL;
- arrayList_create(&references);
- service_reference_pt reference = (service_reference_pt) 0x40;
- arrayList_add(references, reference);
-
- mock().expectOneCall("fw_getServiceReferences")
- .withParameter("framework", framework)
- .withParameter("bundle", bundle)
- .withParameter("serviceName", serviceName)
- .withParameter("filter", (char *) NULL)
- .withOutputParameterReturning("references", &references, sizeof(references))
- .andReturnValue(CELIX_SUCCESS);
-
- service_reference_pt actualReference = NULL;
- LONGS_EQUAL(CELIX_SUCCESS, bundleContext_getServiceReference(context, serviceName, &actualReference));
- POINTERS_EQUAL(reference, actualReference);
-
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleContext_getServiceReference(NULL, serviceName, &actualReference));
- actualReference = NULL;
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleContext_getServiceReference(context, NULL, &actualReference));
-
- free(context);
-}
-
-TEST(bundle_context, ungetServiceReference) {
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
- context->framework = framework;
- context->bundle = bundle;
- service_reference_pt reference = (service_reference_pt) 0x30;
-
- mock().expectOneCall("framework_ungetServiceReference")
- .withParameter("framework", framework)
- .withParameter("bundle", bundle)
- .withParameter("reference", reference);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleContext_ungetServiceReference(context, reference));
-
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleContext_ungetServiceReference(context, NULL));
-
- free(context);
-}
-
-TEST(bundle_context, getService) {
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
- context->framework = framework;
- context->bundle = bundle;
-
- service_reference_pt serviceReference = (service_reference_pt) 0x30;
- void *service = (void *) 0x40;
-
- mock().expectOneCall("fw_getService")
- .withParameter("framework", framework)
- .withParameter("bundle", bundle)
- .withParameter("reference", serviceReference)
- .withOutputParameterReturning("service", &service, sizeof(service))
- .andReturnValue(CELIX_SUCCESS);
-
- void *actualService = NULL;
- celix_status_t status = bundleContext_getService(context, serviceReference, &actualService);
- LONGS_EQUAL(CELIX_SUCCESS, status);
- POINTERS_EQUAL(service, actualService);
-
- actualService = NULL;
- status = bundleContext_getService(context, NULL, &actualService);
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
-
- free(context);
-}
-
-TEST(bundle_context, ungetService) {
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
- context->framework = framework;
- context->bundle = bundle;
-
- service_reference_pt serviceReference = (service_reference_pt) 0x30;
- bool result = true;
-
- mock().expectOneCall("framework_ungetService")
- .withParameter("framework", framework)
- .withParameter("bundle", bundle)
- .withParameter("reference", serviceReference)
- .withOutputParameterReturning("result", &result, sizeof(result))
- .andReturnValue(CELIX_SUCCESS);
-
- bool actualResult = false;
- celix_status_t status = bundleContext_ungetService(context, serviceReference, &actualResult);
- LONGS_EQUAL(CELIX_SUCCESS, status);
- LONGS_EQUAL(result, actualResult);
-
- actualResult = false;
- status = bundleContext_ungetService(context, NULL, &actualResult);
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
-
- free(context);
-}
-
-TEST(bundle_context, getBundles) {
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
- context->framework = framework;
- context->bundle = bundle;
-
- array_list_pt bundles = (array_list_pt) 0x40;
-
- mock().expectOneCall("framework_getBundles")
- .withParameter("framework", framework)
- .andReturnValue(bundles);
-
- array_list_pt actualBundles = NULL;
- celix_status_t status = bundleContext_getBundles(context, &actualBundles);
- LONGS_EQUAL(CELIX_SUCCESS, status);
- POINTERS_EQUAL(bundles, actualBundles);
-
- actualBundles = NULL;
- status = bundleContext_getBundles(NULL, &actualBundles);
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
-
- free(context);
-}
-
-TEST(bundle_context, getBundleById) {
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
- context->framework = framework;
- context->bundle = bundle;
-
- bundle_pt result = (bundle_pt) 0x40;
- int id = 1;
-
- mock().expectOneCall("framework_getBundleById")
- .withParameter("framework", framework)
- .withParameter("id", id)
- .andReturnValue(result);
-
- bundle_pt actualBundle = NULL;
- celix_status_t status = bundleContext_getBundleById(context, id, &actualBundle);
- LONGS_EQUAL(CELIX_SUCCESS, status);
- POINTERS_EQUAL(result, actualBundle);
-
- actualBundle = NULL;
- status = bundleContext_getBundleById(NULL, id, &actualBundle);
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
-
- free(context);
-}
-
-TEST(bundle_context, addServiceListener) {
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
- context->framework = framework;
- context->bundle = bundle;
-
- service_listener_pt listener = (service_listener_pt) 0x30;
- char filter[] = "";
- mock().expectOneCall("fw_addServiceListener")
- .withParameter("framework", framework)
- .withParameter("bundle", bundle)
- .withParameter("listener", listener)
- .withParameter("filter", filter)
- .andReturnValue(CELIX_SUCCESS);
-
- celix_status_t status = bundleContext_addServiceListener(context, listener, filter);
- LONGS_EQUAL(CELIX_SUCCESS, status);
-
- status = bundleContext_addServiceListener(context, NULL, filter);
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
-
- free(context);
-}
-
-TEST(bundle_context, removeServiceListener) {
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
- context->framework = framework;
- context->bundle = bundle;
-
- service_listener_pt listener = (service_listener_pt) 0x30;
- mock().expectOneCall("fw_removeServiceListener")
- .withParameter("framework", framework)
- .withParameter("bundle", bundle)
- .withParameter("listener", listener)
- .andReturnValue(CELIX_SUCCESS);
-
- celix_status_t status = bundleContext_removeServiceListener(context, listener);
- LONGS_EQUAL(CELIX_SUCCESS, status);
-
- status = bundleContext_removeServiceListener(context, NULL);
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
-
- free(context);
-}
-
-TEST(bundle_context, addBundleListener) {
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
- context->framework = framework;
- context->bundle = bundle;
-
- bundle_listener_pt listener = (bundle_listener_pt) 0x30;
- mock().expectOneCall("fw_addBundleListener")
- .withParameter("framework", framework)
- .withParameter("bundle", bundle)
- .withParameter("listener", listener)
- .andReturnValue(CELIX_SUCCESS);
-
- celix_status_t status = bundleContext_addBundleListener(context, listener);
- LONGS_EQUAL(CELIX_SUCCESS, status);
-
- status = bundleContext_addBundleListener(context, NULL);
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
-
- free(context);
-}
-
-TEST(bundle_context, removeBundleListener) {
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
- context->framework = framework;
- context->bundle = bundle;
-
- bundle_listener_pt listener = (bundle_listener_pt) 0x30;
- mock().expectOneCall("fw_removeBundleListener")
- .withParameter("framework", framework)
- .withParameter("bundle", bundle)
- .withParameter("listener", listener)
- .andReturnValue(CELIX_SUCCESS);
-
- celix_status_t status = bundleContext_removeBundleListener(context, listener);
- LONGS_EQUAL(CELIX_SUCCESS, status);
-
- status = bundleContext_removeBundleListener(context, NULL);
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
-
- free(context);
-}
-
-TEST(bundle_context, addFrameworkListener){
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
- context->framework = framework;
- context->bundle = bundle;
- framework_listener_pt listener = (framework_listener_pt) 0x30;
-
- mock().expectOneCall("fw_addframeworkListener")
- .withParameter("framework", framework)
- .withParameter("bundle", bundle)
- .withParameter("listener", listener);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleContext_addFrameworkListener(context, listener));
-
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleContext_addFrameworkListener(context, NULL));
-
- free(context);
-}
-
-TEST(bundle_context, removeFrameworkListener){
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
- context->framework = framework;
- context->bundle = bundle;
- framework_listener_pt listener = (framework_listener_pt) 0x30;
-
- mock().expectOneCall("fw_removeframeworkListener")
- .withParameter("framework", framework)
- .withParameter("bundle", bundle)
- .withParameter("listener", listener);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleContext_removeFrameworkListener(context, listener));
-
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleContext_removeFrameworkListener(context, NULL));
-
- free(context);
-}
-
-TEST(bundle_context, getProperty) {
- mock().expectOneCall("framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_context_pt context = (bundle_context_pt) malloc(sizeof(*context));
- framework_pt framework = (framework_pt) 0x10;
- bundle_pt bundle = (bundle_pt) 0x20;
- context->framework = framework;
- context->bundle = bundle;
-
- char *name = (char *) "property";
- char *value = (char *) "value";
- mock().expectOneCall("fw_getProperty")
- .withParameter("framework", framework)
- .withParameter("name", name)
- .withStringParameter("defaultValue", NULL)
- .withOutputParameterReturning("value", &value, sizeof(value))
- .andReturnValue(CELIX_SUCCESS);
-
- const char *actualValue = NULL;
- celix_status_t status = bundleContext_getProperty(context, name, &actualValue);
- LONGS_EQUAL(CELIX_SUCCESS, status);
- STRCMP_EQUAL(value, actualValue);
-
- actualValue = NULL;
- status = bundleContext_getProperty(context, NULL, &actualValue);
-
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, status);
- free(context);
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/3bce889b/framework/private/test/bundle_revision_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/bundle_revision_test.cpp b/framework/private/test/bundle_revision_test.cpp
deleted file mode 100644
index 5e9320d..0000000
--- a/framework/private/test/bundle_revision_test.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * bundle_revision_test.cpp
- *
- * \date Feb 11, 2013
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "CppUTest/TestHarness.h"
-#include "CppUTest/TestHarness_c.h"
-#include "CppUTest/CommandLineTestRunner.h"
-#include "CppUTestExt/MockSupport.h"
-
-extern "C" {
-#include "bundle_revision_private.h"
-#include "celix_log.h"
-
-framework_logger_pt logger = (framework_logger_pt) 0x10;
-}
-
-int main(int argc, char** argv) {
- return RUN_ALL_TESTS(argc, argv);
-}
-
-TEST_GROUP(bundle_revision) {
- void setup(void) {
- }
-
- void teardown() {
- mock().checkExpectations();
- mock().clear();
- }
-};
-
-TEST(bundle_revision, create) {
- char root[] = "bundle_revision_test";
- 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("filename", "bundle_revision_test/META-INF/MANIFEST.MF")
- .withOutputParameterReturning("manifest", &manifest, sizeof(manifest))
- .andReturnValue(CELIX_SUCCESS);
-
- bundle_revision_pt revision = NULL;
- LONGS_EQUAL(CELIX_SUCCESS, bundleRevision_create(root, location, revisionNr, inputFile, &revision));
- LONGS_EQUAL(revisionNr, revision->revisionNr);
- STRCMP_EQUAL(root, revision->root);
- STRCMP_EQUAL(location, revision->location);
-
- mock().expectOneCall("manifest_destroy");
- LONGS_EQUAL(CELIX_SUCCESS, bundleRevision_destroy(revision));
-}
-
-TEST(bundle_revision, createWithInput) {
- char root[] = "bundle_revision_test";
- 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);
-
- mock().expectOneCall("manifest_createFromFile")
- .withParameter("filename", "bundle_revision_test/META-INF/MANIFEST.MF")
- .withOutputParameterReturning("manifest", &manifest, sizeof(manifest))
- .andReturnValue(CELIX_SUCCESS);
-
- bundle_revision_pt revision = NULL;
- LONGS_EQUAL(CELIX_SUCCESS, bundleRevision_create(root, location, revisionNr, inputFile, &revision));
- LONGS_EQUAL(revisionNr, revision->revisionNr);
- STRCMP_EQUAL(root, revision->root);
- STRCMP_EQUAL(location, revision->location);
-
- mock().expectOneCall("manifest_destroy");
- LONGS_EQUAL(CELIX_SUCCESS, bundleRevision_destroy(revision));
-}
-
-TEST(bundle_revision, getters) {
- mock().expectNCalls(5, "framework_logCode").withParameter("code", CELIX_ILLEGAL_ARGUMENT);
-
- bundle_revision_pt revision = (bundle_revision_pt) malloc(sizeof(*revision));
- char root[] = "bundle_revision_test";
- char location[] = "test_bundle.zip";
- long revisionNr = 1l;
- manifest_pt expectedManifest = (manifest_pt) 0x42;
- array_list_pt handles = NULL;
- arrayList_create(&handles);
- revision->root = root;
- revision->location = location;
- revision->revisionNr = revisionNr;
- revision->manifest = expectedManifest;
- revision->libraryHandles = handles;
-
- const char *actualRoot = NULL;
- const char *actualLocation = NULL;
- long actualRevisionNr = 0l;
- manifest_pt actualManifest = NULL;
- array_list_pt actualHandles = NULL;
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleRevision_getNumber(revision, &actualRevisionNr));
- LONGS_EQUAL(revisionNr, actualRevisionNr);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleRevision_getLocation(revision, &actualLocation));
- STRCMP_EQUAL(location, actualLocation);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleRevision_getRoot(revision, &actualRoot));
- STRCMP_EQUAL(root, actualRoot);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleRevision_getManifest(revision, &actualManifest));
- POINTERS_EQUAL(expectedManifest, actualManifest);
-
- LONGS_EQUAL(CELIX_SUCCESS, bundleRevision_getHandles(revision, &actualHandles));
- POINTERS_EQUAL(handles, actualHandles);
-
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleRevision_getNumber(NULL, &actualRevisionNr));
-
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleRevision_getLocation(NULL, &actualLocation));
-
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleRevision_getRoot(NULL, &actualRoot));
-
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleRevision_getManifest(NULL, &actualManifest));
-
- LONGS_EQUAL(CELIX_ILLEGAL_ARGUMENT, bundleRevision_getHandles(NULL, &actualHandles));
-
- arrayList_destroy(handles);
- free(revision);
-}