From b92b1f86492d1fb0e546ef5124116abdf2d07dc9 Mon Sep 17 00:00:00 2001 From: "Smokowski, Steve (ss835w)" Date: Thu, 30 Aug 2018 19:06:46 -0400 Subject: Update Logging Add CXF interceptor for SOAP based logging Clean up extra logging statements Add UT to ensure MDC properly populated Change package name on Jax-RS Filter to be more accurate Issue-ID: SO-947 Change-Id: I3a2afc58de3bf370675658ce3d19cf899b90def7 Change-Id: I3a2afc58de3bf370675658ce3d19cf899b90def7 Signed-off-by: Smokowski, Steve (ss835w) --- .../src/test/java/org/onap/so/BaseTest.java | 15 ------ .../java/org/onap/so/EmbeddedMariaDbConfig.java | 60 ---------------------- .../src/test/java/org/onap/so/TestApplication.java | 48 ----------------- .../test/java/org/onap/so/db/catalog/BaseTest.java | 15 ++++++ .../so/db/catalog/BuildingBlockDetailTest.java | 1 - .../catalog/ControllerSelectionReferenceTest.java | 1 - .../onap/so/db/catalog/EmbeddedMariaDbConfig.java | 60 ++++++++++++++++++++++ .../java/org/onap/so/db/catalog/NetworkTest.java | 1 - ...strationStatusStateTransitionDirectiveTest.java | 1 - .../java/org/onap/so/db/catalog/ServiceTest.java | 1 - .../org/onap/so/db/catalog/TestApplication.java | 48 +++++++++++++++++ .../java/org/onap/so/db/catalog/VFModuleTest.java | 1 - .../data/repository/CloudSiteRepositoryTest.java | 2 +- .../repository/CloudifyManagerRepositoryTest.java | 2 +- 14 files changed, 125 insertions(+), 131 deletions(-) delete mode 100644 mso-catalog-db/src/test/java/org/onap/so/BaseTest.java delete mode 100644 mso-catalog-db/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java delete mode 100644 mso-catalog-db/src/test/java/org/onap/so/TestApplication.java create mode 100644 mso-catalog-db/src/test/java/org/onap/so/db/catalog/BaseTest.java create mode 100644 mso-catalog-db/src/test/java/org/onap/so/db/catalog/EmbeddedMariaDbConfig.java create mode 100644 mso-catalog-db/src/test/java/org/onap/so/db/catalog/TestApplication.java (limited to 'mso-catalog-db/src/test/java') diff --git a/mso-catalog-db/src/test/java/org/onap/so/BaseTest.java b/mso-catalog-db/src/test/java/org/onap/so/BaseTest.java deleted file mode 100644 index 6e6db11c45..0000000000 --- a/mso-catalog-db/src/test/java/org/onap/so/BaseTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.onap.so; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@ActiveProfiles("test") -public class BaseTest { - @Test - public void testNothing(){} -} diff --git a/mso-catalog-db/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java b/mso-catalog-db/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java deleted file mode 100644 index 60f8de6c2e..0000000000 --- a/mso-catalog-db/src/test/java/org/onap/so/EmbeddedMariaDbConfig.java +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.so; -import ch.vorburger.exec.ManagedProcessException; -import ch.vorburger.mariadb4j.DBConfigurationBuilder; -import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import javax.sql.DataSource; - -@Configuration -@Profile({"test","local"}) -public class EmbeddedMariaDbConfig { - - @Bean - MariaDB4jSpringService mariaDB4jSpringService() { - return new MariaDB4jSpringService(); - } - - @Bean - DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService, - @Value("${mariaDB4j.databaseName}") String databaseName, - @Value("${spring.datasource.username}") String datasourceUsername, - @Value("${spring.datasource.password}") String datasourcePassword, - @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException { - //Create our database with default root user and no password - mariaDB4jSpringService.getDB().createDB(databaseName); - - DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration(); - - return DataSourceBuilder - .create() - .username(datasourceUsername) - .password(datasourcePassword) - .url(config.getURL(databaseName)) - .driverClassName(datasourceDriver) - .build(); - } -} diff --git a/mso-catalog-db/src/test/java/org/onap/so/TestApplication.java b/mso-catalog-db/src/test/java/org/onap/so/TestApplication.java deleted file mode 100644 index 6ee88e407d..0000000000 --- a/mso-catalog-db/src/test/java/org/onap/so/TestApplication.java +++ /dev/null @@ -1,48 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed 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. - * ============LICENSE_END========================================================= - */ - -package org.onap.so; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.domain.EntityScan; -import org.springframework.context.annotation.Profile; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; - -@SpringBootApplication(scanBasePackages = { "org.onap"}) -@EnableJpaRepositories("org.onap.so.db.catalog.data.repository") -@EntityScan("org.onap.so.db.catalog.beans") -@Profile("test") -public class TestApplication { - private static final String LOGS_DIR = "logs_dir"; - - private static void setLogsDir() { - if (System.getProperty(LOGS_DIR) == null) { - System.getProperties().setProperty(LOGS_DIR, "./logs/catdb/"); - } - } - - public static void main(String... args) { - SpringApplication.run(TestApplication.class, args); - System.getProperties().setProperty("mso.db", "MARIADB"); - System.getProperties().setProperty("server.name", "Springboot"); - setLogsDir(); - } -} diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BaseTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BaseTest.java new file mode 100644 index 0000000000..5a5dc70029 --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BaseTest.java @@ -0,0 +1,15 @@ +package org.onap.so.db.catalog; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@ActiveProfiles("test") +public class BaseTest { + @Test + public void testNothing(){} +} diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BuildingBlockDetailTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BuildingBlockDetailTest.java index 7a9fc19fcb..73f1ef49fa 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BuildingBlockDetailTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/BuildingBlockDetailTest.java @@ -24,7 +24,6 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.so.TestApplication; import org.onap.so.db.catalog.beans.BuildingBlockDetail; import org.onap.so.db.catalog.beans.OrchestrationAction; import org.onap.so.db.catalog.beans.ResourceType; diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ControllerSelectionReferenceTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ControllerSelectionReferenceTest.java index f793fd79e3..bc34883ad3 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ControllerSelectionReferenceTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ControllerSelectionReferenceTest.java @@ -26,7 +26,6 @@ import static org.junit.Assert.assertTrue; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.so.TestApplication; import org.onap.so.db.catalog.beans.ControllerSelectionReference; import org.onap.so.db.catalog.data.repository.ControllerSelectionReferenceRepository; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/EmbeddedMariaDbConfig.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/EmbeddedMariaDbConfig.java new file mode 100644 index 0000000000..147de51c67 --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/EmbeddedMariaDbConfig.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.db.catalog; +import ch.vorburger.exec.ManagedProcessException; +import ch.vorburger.mariadb4j.DBConfigurationBuilder; +import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import javax.sql.DataSource; + +@Configuration +@Profile({"test","local"}) +public class EmbeddedMariaDbConfig { + + @Bean + MariaDB4jSpringService mariaDB4jSpringService() { + return new MariaDB4jSpringService(); + } + + @Bean + DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService, + @Value("${mariaDB4j.databaseName}") String databaseName, + @Value("${spring.datasource.username}") String datasourceUsername, + @Value("${spring.datasource.password}") String datasourcePassword, + @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException { + //Create our database with default root user and no password + mariaDB4jSpringService.getDB().createDB(databaseName); + + DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration(); + + return DataSourceBuilder + .create() + .username(datasourceUsername) + .password(datasourcePassword) + .url(config.getURL(databaseName)) + .driverClassName(datasourceDriver) + .build(); + } +} diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/NetworkTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/NetworkTest.java index 55c5c8351b..456c826d19 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/NetworkTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/NetworkTest.java @@ -24,7 +24,6 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.so.TestApplication; import org.onap.so.db.catalog.beans.NetworkResource; import org.onap.so.db.catalog.data.repository.NetworkResourceRepository; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/OrchestrationStatusStateTransitionDirectiveTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/OrchestrationStatusStateTransitionDirectiveTest.java index 52cac88402..b6aa408185 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/OrchestrationStatusStateTransitionDirectiveTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/OrchestrationStatusStateTransitionDirectiveTest.java @@ -24,7 +24,6 @@ import static org.junit.Assert.assertEquals; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.so.TestApplication; import org.onap.so.db.catalog.beans.OrchestrationAction; import org.onap.so.db.catalog.beans.OrchestrationStatus; import org.onap.so.db.catalog.beans.OrchestrationStatusStateTransitionDirective; diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ServiceTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ServiceTest.java index 0ecaa5fbba..ffa56a9ce3 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ServiceTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/ServiceTest.java @@ -26,7 +26,6 @@ import java.util.List; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.so.TestApplication; import org.onap.so.db.catalog.beans.Service; import org.onap.so.db.catalog.data.repository.ServiceRepository; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/TestApplication.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/TestApplication.java new file mode 100644 index 0000000000..0226b86739 --- /dev/null +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/TestApplication.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.db.catalog; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.context.annotation.Profile; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; + +@SpringBootApplication(scanBasePackages = { "org.onap.so.db.catalog"}) +@EnableJpaRepositories("org.onap.so.db.catalog.data.repository") +@EntityScan("org.onap.so.db.catalog") +@Profile("test") +public class TestApplication { + private static final String LOGS_DIR = "logs_dir"; + + private static void setLogsDir() { + if (System.getProperty(LOGS_DIR) == null) { + System.getProperties().setProperty(LOGS_DIR, "./logs/catdb/"); + } + } + + public static void main(String... args) { + SpringApplication.run(TestApplication.class, args); + System.getProperties().setProperty("mso.db", "MARIADB"); + System.getProperties().setProperty("server.name", "Springboot"); + setLogsDir(); + } +} diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/VFModuleTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/VFModuleTest.java index 44e7a03855..1f13bd946a 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/VFModuleTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/VFModuleTest.java @@ -26,7 +26,6 @@ import java.util.List; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.so.TestApplication; import org.onap.so.db.catalog.beans.VfModule; import org.onap.so.db.catalog.data.repository.VFModuleRepository; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudSiteRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudSiteRepositoryTest.java index 5a0770ead6..37a43aa529 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudSiteRepositoryTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudSiteRepositoryTest.java @@ -2,7 +2,7 @@ package org.onap.so.db.catalog.data.repository; import org.junit.Assert; import org.junit.Test; -import org.onap.so.BaseTest; +import org.onap.so.db.catalog.BaseTest; import org.onap.so.db.catalog.beans.CloudSite; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; diff --git a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudifyManagerRepositoryTest.java b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudifyManagerRepositoryTest.java index 21f95a7727..db62759406 100644 --- a/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudifyManagerRepositoryTest.java +++ b/mso-catalog-db/src/test/java/org/onap/so/db/catalog/data/repository/CloudifyManagerRepositoryTest.java @@ -2,7 +2,7 @@ package org.onap.so.db.catalog.data.repository; import org.junit.Assert; import org.junit.Test; -import org.onap.so.BaseTest; +import org.onap.so.db.catalog.BaseTest; import org.onap.so.db.catalog.beans.CloudifyManager; import org.springframework.beans.factory.annotation.Autowired; -- cgit 1.2.3-korg