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 2021/06/28 19:42:54 UTC
[celix] 03/07: Removes unused pubsub mock stuff
This is an automated email from the ASF dual-hosted git repository.
pnoltes pushed a commit to branch feature/pubsub-interceptor-fix
in repository https://gitbox.apache.org/repos/asf/celix.git
commit fc7174298cd4b3448e3a4883d93ad9e552a78147
Author: Pepijn Noltes <pe...@gmail.com>
AuthorDate: Fri Jun 25 19:07:54 2021 +0200
Removes unused pubsub mock stuff
---
bundles/pubsub/CMakeLists.txt | 1 -
bundles/pubsub/mock/CMakeLists.txt | 40 -------------
bundles/pubsub/mock/api/pubsub/publisher_mock.h | 44 --------------
bundles/pubsub/mock/src/publisher_mock.cc | 57 -------------------
bundles/pubsub/mock/tst/pubsubmock_test.cc | 76 -------------------------
bundles/pubsub/mock/tst/run_tests.cc | 25 --------
6 files changed, 243 deletions(-)
diff --git a/bundles/pubsub/CMakeLists.txt b/bundles/pubsub/CMakeLists.txt
index d04b80b..9285195 100644
--- a/bundles/pubsub/CMakeLists.txt
+++ b/bundles/pubsub/CMakeLists.txt
@@ -51,7 +51,6 @@ if (PUBSUB)
add_subdirectory(pubsub_serializer_avrobin)
add_subdirectory(pubsub_protocol)
add_subdirectory(keygen)
- add_subdirectory(mock)
add_subdirectory(examples)
diff --git a/bundles/pubsub/mock/CMakeLists.txt b/bundles/pubsub/mock/CMakeLists.txt
deleted file mode 100644
index 59831f9..0000000
--- a/bundles/pubsub/mock/CMakeLists.txt
+++ /dev/null
@@ -1,40 +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.
-
-#only install if CppuTest is available
-find_package(CppUTest QUIET)
-if (CPPUTEST_FOUND)
- include_directories(SYSTEM PRIVATE ${CppUTest_INCLUDE_DIR})
-
- add_library(pubsub_mock STATIC
- src/publisher_mock.cc
- )
- target_link_libraries(pubsub_mock PRIVATE Celix::pubsub_spi ${CppUTest_LIBRARY})
- target_include_directories(pubsub_mock PUBLIC api)
- target_include_directories(pubsub_mock SYSTEM PRIVATE ${CppUTest_INCLUDE_DIR})
-
- if (ENABLE_TESTING)
- add_executable(pubsubmock_test
- tst/pubsubmock_test.cc
- tst/run_tests.cc
- )
- target_include_directories(pubsubmock_test PRIVATE ${CMAKE_CURRENT_LIST_DIR}/api)
- target_link_libraries(pubsubmock_test PRIVATE Celix::pubsub_api pubsub_mock ${CppUTest_LIBRARY} ${CppUTest_EXT_LIBRARIES} Celix::framework)
- add_test(NAME pubsubmock_test COMMAND pubsubmock_test)
- endif()
-endif()
-
diff --git a/bundles/pubsub/mock/api/pubsub/publisher_mock.h b/bundles/pubsub/mock/api/pubsub/publisher_mock.h
deleted file mode 100644
index 72c8285..0000000
--- a/bundles/pubsub/mock/api/pubsub/publisher_mock.h
+++ /dev/null
@@ -1,44 +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.
- */
-
-#ifndef PUBSUB_PUBLISHER_MOCK_H_
-#define PUBSUB_PUBLISHER_MOCK_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include "pubsub/publisher.h"
-
-#define PUBSUB_PUBLISHERMOCK_SCOPE "pubsub_publisher"
-#define PUBSUB_PUBLISHERMOCK_LOCAL_MSG_TYPE_ID_FOR_MSG_TYPE_METHOD "pubsub__publisherMock_localMsgTypeIdForMsgType"
-#define PUBSUB_PUBLISHERMOCK_SEND_METHOD "pubsub__publisherMock_send"
-#define PUBSUB_PUBLISHERMOCK_SEND_MULTIPART_METHOD "pubsub__publisherMock_sendMultipart"
-
-
-/*============================================================================
- MOCK - initialize publisher mock
- ============================================================================*/
-void pubsub_publisherMock_init(pubsub_publisher_t* srv, void* handle);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif //PUBSUB_PUBLISHER_MOCK_H_
diff --git a/bundles/pubsub/mock/src/publisher_mock.cc b/bundles/pubsub/mock/src/publisher_mock.cc
deleted file mode 100644
index 8d6f7e5..0000000
--- a/bundles/pubsub/mock/src/publisher_mock.cc
+++ /dev/null
@@ -1,57 +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.
- */
-
-#include <celix_properties.h>
-#include "pubsub/publisher_mock.h"
-#include "CppUTest/TestHarness.h"
-#include "CppUTestExt/MockSupport.h"
-
-/*============================================================================
- MOCK - mock function for pubsub_publisher->localMsgTypeIdForMsgType
- ============================================================================*/
-static int pubsub__publisherMock_localMsgTypeIdForMsgType(void *handle, const char *msgType, unsigned int *msgTypeId) {
- return mock(PUBSUB_PUBLISHERMOCK_SCOPE)
- .actualCall(PUBSUB_PUBLISHERMOCK_LOCAL_MSG_TYPE_ID_FOR_MSG_TYPE_METHOD)
- .withPointerParameter("handle", handle)
- .withParameter("msgType", msgType)
- .withOutputParameter("msgTypeId", msgTypeId)
- .returnIntValue();
-}
-
-/*============================================================================
- MOCK - mock function for pubsub_publisher->send
- ============================================================================*/
-static int pubsub__publisherMock_send(void *handle, unsigned int msgTypeId, const void *msg, celix_properties_t *metadata) {
- return mock(PUBSUB_PUBLISHERMOCK_SCOPE)
- .actualCall(PUBSUB_PUBLISHERMOCK_SEND_METHOD)
- .withPointerParameter("handle", handle)
- .withParameter("msgTypeId", msgTypeId)
- .withPointerParameter("msg", (void*)msg)
- .withPointerParameter("metadata", (void*)metadata)
- .returnIntValue();
-}
-
-/*============================================================================
- MOCK - mock setup for publisher service
- ============================================================================*/
-void pubsub_publisherMock_init(pubsub_publisher_t* srv, void* handle) {
- srv->handle = handle;
- srv->localMsgTypeIdForMsgType = pubsub__publisherMock_localMsgTypeIdForMsgType;
- srv->send = pubsub__publisherMock_send;
-}
diff --git a/bundles/pubsub/mock/tst/pubsubmock_test.cc b/bundles/pubsub/mock/tst/pubsubmock_test.cc
deleted file mode 100644
index 19f8734..0000000
--- a/bundles/pubsub/mock/tst/pubsubmock_test.cc
+++ /dev/null
@@ -1,76 +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.
- */
-
-#include <CppUTestExt/MockSupport.h>
-#include <CppUTest/TestHarness.h>
-
-#include <stdio.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "pubsub/publisher_mock.h"
-
-static pubsub_publisher_t mockSrv;
-static void* mockHandle = (void*)0x42;
-
-
-TEST_GROUP(pubsubmock) {
- void setup(void) {
- //setup mock
- pubsub_publisherMock_init(&mockSrv, mockHandle);
- }
-
- void teardown() {
- mock().checkExpectations();
- mock().clear();
- }
-};
-
-TEST(pubsubmock, publishermock) {
- const char* mockFqn = "example.Msg";
- unsigned int mockOutputTypeId = 11;
-
- mock(PUBSUB_PUBLISHERMOCK_SCOPE).expectOneCall(PUBSUB_PUBLISHERMOCK_LOCAL_MSG_TYPE_ID_FOR_MSG_TYPE_METHOD)
- .withParameter("handle", mockHandle)
- .withParameter("msgType", mockFqn)
- .withOutputParameterReturning("msgTypeId", &mockOutputTypeId, sizeof(mockOutputTypeId));
-
- mock(PUBSUB_PUBLISHERMOCK_SCOPE).expectOneCall(PUBSUB_PUBLISHERMOCK_SEND_METHOD)
- .withParameter("handle", mockHandle)
- .withParameter("msgTypeId", mockOutputTypeId)
- .ignoreOtherParameters();
-
- //This should normally be code which should be tested, for now it code to verify the mock
- pubsub_publisher_t* srv = &mockSrv;
- const char* msgFqn = "example.Msg";
- unsigned int msgId = 0;
-
- //get type id (normally only if type id is not yet set (e.g. 0))
- srv->localMsgTypeIdForMsgType(srv->handle, msgFqn, &msgId);
- CHECK(msgId != 0);
-
- //set msg
- void *dummyMsg = (void*)0x43;
- srv->send(srv->handle, msgId, dummyMsg, NULL); //should satisfy the expectOneCalls
- //srv->send(srv->handle, msgId, dummyMsg); //enabling this should fail the test
-
-}
-
diff --git a/bundles/pubsub/mock/tst/run_tests.cc b/bundles/pubsub/mock/tst/run_tests.cc
deleted file mode 100644
index 1da4975..0000000
--- a/bundles/pubsub/mock/tst/run_tests.cc
+++ /dev/null
@@ -1,25 +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.
- */
-
-#include <CppUTest/TestHarness.h>
-#include "CppUTest/CommandLineTestRunner.h"
-
-int main(int argc, char** argv) {
- return RUN_ALL_TESTS(argc, argv);
-}