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/11/26 10:04:58 UTC
svn commit: r1545573 - in /incubator/celix/trunk/framework: ./
private/include/ private/integration-test/
private/integration-test/test_bundle1/
private/integration-test/test_bundle1/src/
private/integration-test/test_launcher/ private/integration-test...
Author: abroekhuis
Date: Tue Nov 26 09:04:57 2013
New Revision: 1545573
URL: http://svn.apache.org/r1545573
Log:
Added initial setup for integration testing.
Added:
incubator/celix/trunk/framework/private/integration-test/
incubator/celix/trunk/framework/private/integration-test/CMakeLists.txt
incubator/celix/trunk/framework/private/integration-test/test_bundle1/
incubator/celix/trunk/framework/private/integration-test/test_bundle1/CMakeLists.txt
incubator/celix/trunk/framework/private/integration-test/test_bundle1/src/
incubator/celix/trunk/framework/private/integration-test/test_bundle1/src/activator.c
incubator/celix/trunk/framework/private/integration-test/test_launcher/
incubator/celix/trunk/framework/private/integration-test/test_launcher/CMakeLists.txt
incubator/celix/trunk/framework/private/integration-test/test_launcher/src/
incubator/celix/trunk/framework/private/integration-test/test_launcher/src/launcher.c
Modified:
incubator/celix/trunk/framework/CMakeLists.txt
incubator/celix/trunk/framework/private/include/framework_private.h
incubator/celix/trunk/framework/private/src/framework.c
Modified: incubator/celix/trunk/framework/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/CMakeLists.txt?rev=1545573&r1=1545572&r2=1545573&view=diff
==============================================================================
--- incubator/celix/trunk/framework/CMakeLists.txt (original)
+++ incubator/celix/trunk/framework/CMakeLists.txt Tue Nov 26 09:04:57 2013
@@ -339,5 +339,7 @@ if (FRAMEWORK)
SETUP_TARGET_FOR_COVERAGE(bundle_cache_test_c bundle_cache_test ${CMAKE_BINARY_DIR}/coverage/bundle_cache_test)
SETUP_TARGET_FOR_COVERAGE(bundle_archive_test_c bundle_archive_test ${CMAKE_BINARY_DIR}/coverage/bundle_archive_test)
SETUP_TARGET_FOR_COVERAGE(attribute_test_c attribute_test ${CMAKE_BINARY_DIR}/coverage/attribute_test)
+
+ add_subdirectory(private/integration-test)
endif (FRAMEWORK_TESTS)
endif (FRAMEWORK)
Modified: incubator/celix/trunk/framework/private/include/framework_private.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/framework_private.h?rev=1545573&r1=1545572&r2=1545573&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/framework_private.h (original)
+++ incubator/celix/trunk/framework/private/include/framework_private.h Tue Nov 26 09:04:57 2013
@@ -28,6 +28,8 @@
#ifndef FRAMEWORK_PRIVATE_H_
#define FRAMEWORK_PRIVATE_H_
+#include <apr_thread_cond.h>
+
#include "framework.h"
#include "manifest.h"
@@ -42,6 +44,43 @@
#include "framework_listener.h"
#include "service_registration.h"
#include "bundle_context.h"
+#include "bundle_cache.h"
+
+struct framework {
+ struct bundle * bundle;
+ hash_map_pt installedBundleMap;
+ hash_map_pt installRequestMap;
+ array_list_pt serviceListeners;
+ array_list_pt bundleListeners;
+ array_list_pt frameworkListeners;
+
+ long nextBundleId;
+ struct serviceRegistry * registry;
+ bundle_cache_pt cache;
+
+ apr_thread_cond_t *shutdownGate;
+ apr_thread_cond_t *condition;
+
+ apr_thread_mutex_t *installRequestLock;
+ apr_thread_mutex_t *mutex;
+ apr_thread_mutex_t *bundleLock;
+
+ apr_os_thread_t globalLockThread;
+ array_list_pt globalLockWaitersList;
+ int globalLockCount;
+
+ bool interrupted;
+ bool shutdown;
+
+ apr_pool_t *mp;
+
+ properties_pt configurationMap;
+
+ array_list_pt requests;
+ apr_thread_cond_t *dispatcher;
+ apr_thread_mutex_t *dispatcherLock;
+ apr_thread_t *dispatcherThread;
+};
celix_status_t framework_start(framework_pt framework);
void framework_stop(framework_pt framework);
Added: incubator/celix/trunk/framework/private/integration-test/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/integration-test/CMakeLists.txt?rev=1545573&view=auto
==============================================================================
--- incubator/celix/trunk/framework/private/integration-test/CMakeLists.txt (added)
+++ incubator/celix/trunk/framework/private/integration-test/CMakeLists.txt Tue Nov 26 09:04:57 2013
@@ -0,0 +1,19 @@
+# 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.
+
+add_subdirectory(test_bundle1)
+add_subdirectory(test_launcher)
\ No newline at end of file
Added: incubator/celix/trunk/framework/private/integration-test/test_bundle1/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/integration-test/test_bundle1/CMakeLists.txt?rev=1545573&view=auto
==============================================================================
--- incubator/celix/trunk/framework/private/integration-test/test_bundle1/CMakeLists.txt (added)
+++ incubator/celix/trunk/framework/private/integration-test/test_bundle1/CMakeLists.txt Tue Nov 26 09:04:57 2013
@@ -0,0 +1,23 @@
+# 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.
+
+SET_HEADER(BUNDLE_SYMBOLICNAME "apache_celix_test_bundle1")
+SET_HEADERS("Bundle-Name: Apache Celix TestBundle1")
+
+bundle(test_bundle1 SOURCES src/activator)
+include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
+target_link_libraries(test_bundle1 celix_framework)
\ No newline at end of file
Added: incubator/celix/trunk/framework/private/integration-test/test_bundle1/src/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/integration-test/test_bundle1/src/activator.c?rev=1545573&view=auto
==============================================================================
--- incubator/celix/trunk/framework/private/integration-test/test_bundle1/src/activator.c (added)
+++ incubator/celix/trunk/framework/private/integration-test/test_bundle1/src/activator.c Tue Nov 26 09:04:57 2013
@@ -0,0 +1,81 @@
+/**
+ *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.
+ */
+/*
+ * activator.c
+ *
+ * \date Aug 20, 2010
+ * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <apr_general.h>
+
+#include "bundle_activator.h"
+#include "bundle_context.h"
+#include "framework_listener.h"
+
+struct userData {
+ framework_listener_pt listener;
+};
+
+celix_status_t test_frameworkEvent(void *listener, framework_event_pt event);
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+ apr_pool_t *pool;
+ celix_status_t status = bundleContext_getMemoryPool(context, &pool);
+ if (status == CELIX_SUCCESS) {
+ *userData = apr_palloc(pool, sizeof(struct userData));
+ ((struct userData *)(*userData))->listener = NULL;
+ } else {
+ status = CELIX_START_ERROR;
+ }
+ return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+ struct userData * activator = (struct userData *) userData;
+ apr_pool_t *pool;
+
+ bundleContext_getMemoryPool(context, &pool);
+
+ activator->listener = apr_palloc(pool, sizeof(*activator->listener));
+ activator->listener->pool = pool;
+ activator->listener->handle = activator;
+ activator->listener->frameworkEvent = test_frameworkEvent;
+ bundleContext_addFrameworkListener(context, activator->listener);
+
+ return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+ struct userData * data = (struct userData *) userData;
+
+ // do not remove listener, fw should remove it.
+
+ return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+ return CELIX_SUCCESS;
+}
+
+celix_status_t test_frameworkEvent(void *listener, framework_event_pt event) {
+ return CELIX_SUCCESS;
+}
Added: incubator/celix/trunk/framework/private/integration-test/test_launcher/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/integration-test/test_launcher/CMakeLists.txt?rev=1545573&view=auto
==============================================================================
--- incubator/celix/trunk/framework/private/integration-test/test_launcher/CMakeLists.txt (added)
+++ incubator/celix/trunk/framework/private/integration-test/test_launcher/CMakeLists.txt Tue Nov 26 09:04:57 2013
@@ -0,0 +1,22 @@
+# 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.
+add_executable(test_launcher src/launcher)
+
+target_link_libraries(test_launcher celix_framework)
+include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
+include_directories("${PROJECT_SOURCE_DIR}/framework/public/include")
+include_directories("${PROJECT_SOURCE_DIR}/framework/private/include")
Added: incubator/celix/trunk/framework/private/integration-test/test_launcher/src/launcher.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/integration-test/test_launcher/src/launcher.c?rev=1545573&view=auto
==============================================================================
--- incubator/celix/trunk/framework/private/integration-test/test_launcher/src/launcher.c (added)
+++ incubator/celix/trunk/framework/private/integration-test/test_launcher/src/launcher.c Tue Nov 26 09:04:57 2013
@@ -0,0 +1,95 @@
+/**
+ *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.
+ */
+/*
+ * launcher.c
+ *
+ * \date Mar 23, 2010
+ * \author <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <apr_general.h>
+#include <apr_strings.h>
+#include <unistd.h>
+
+#include "framework_private.h"
+#include "properties.h"
+#include "bundle_context.h"
+#include "bundle.h"
+#include "linked_list_iterator.h"
+#include "celix_log.h"
+
+int main(void) {
+ apr_status_t rv = APR_SUCCESS;
+ apr_status_t s = APR_SUCCESS;
+ properties_pt config = NULL;
+ char *autoStart = NULL;
+ apr_pool_t *pool = NULL;
+ bundle_pt fwBundle = NULL;
+
+ rv = apr_initialize();
+ if (rv != APR_SUCCESS) {
+ return CELIX_START_ERROR;
+ }
+ apr_pool_t *memoryPool;
+ s = apr_pool_create(&memoryPool, NULL);
+ if (s != APR_SUCCESS) {
+ return CELIX_START_ERROR;
+ }
+
+ struct framework * framework = NULL;
+ celix_status_t status = CELIX_SUCCESS;
+ status = framework_create(&framework, memoryPool, config);
+ if (status == CELIX_SUCCESS) {
+ status = fw_init(framework);
+ if (status == CELIX_SUCCESS) {
+ // Start the system bundle
+ framework_getFrameworkBundle(framework, &fwBundle);
+ bundle_start(fwBundle);
+ bundle_context_pt context = NULL;
+ bundle_getContext(fwBundle, &context);
+
+ // do some stuff
+ bundle_pt bundle = NULL;
+ status = CELIX_DO_IF(status, bundleContext_installBundle(context, "../test_bundle1/test_bundle1.zip", &bundle));
+ status = CELIX_DO_IF(status, bundle_start(bundle));
+
+ // Stop the system bundle, sleep a bit to let stuff settle down
+ sleep(5);
+ bundle_stop(fwBundle);
+
+ framework_destroy(framework);
+ }
+ }
+
+ if (status != CELIX_SUCCESS) {
+ framework_logIfError(status, NULL, "Failed to run test");
+ }
+
+ apr_pool_destroy(memoryPool);
+ apr_terminate();
+
+ printf("LAUNCHER: Exit\n");
+
+ return 0;
+}
+
Modified: incubator/celix/trunk/framework/private/src/framework.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1545573&r1=1545572&r2=1545573&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Tue Nov 26 09:04:57 2013
@@ -33,7 +33,6 @@
#include <apr_file_io.h>
#include <apr_general.h>
#include <apr_strings.h>
-#include <apr_thread_cond.h>
#include <apr_thread_mutex.h>
#include <apr_thread_proc.h>
#include <apr_uuid.h>
@@ -64,42 +63,6 @@
#include "service_registration.h"
#include "celix_log.h"
-struct framework {
- struct bundle * bundle;
- hash_map_pt installedBundleMap;
- hash_map_pt installRequestMap;
- array_list_pt serviceListeners;
- array_list_pt bundleListeners;
- array_list_pt frameworkListeners;
-
- long nextBundleId;
- struct serviceRegistry * registry;
- bundle_cache_pt cache;
-
- apr_thread_cond_t *shutdownGate;
- apr_thread_cond_t *condition;
-
- apr_thread_mutex_t *installRequestLock;
- apr_thread_mutex_t *mutex;
- apr_thread_mutex_t *bundleLock;
-
- apr_os_thread_t globalLockThread;
- array_list_pt globalLockWaitersList;
- int globalLockCount;
-
- bool interrupted;
- bool shutdown;
-
- apr_pool_t *mp;
-
- properties_pt configurationMap;
-
- array_list_pt requests;
- apr_thread_cond_t *dispatcher;
- apr_thread_mutex_t *dispatcherLock;
- apr_thread_t *dispatcherThread;
-};
-
typedef celix_status_t (*create_function_pt)(bundle_context_pt context, void **userData);
typedef celix_status_t (*start_function_pt)(void * handle, bundle_context_pt context);
typedef celix_status_t (*stop_function_pt)(void * handle, bundle_context_pt context);
@@ -710,7 +673,8 @@ celix_status_t fw_startBundle(framework_
if (handle == NULL) {
char err[256];
sprintf(err, "library could not be opened: %s", fw_getLastError());
- error = err;
+ // #TODO this is wrong
+ // error = err;
status = CELIX_BUNDLE_EXCEPTION;
}