aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBogumil Zebek <bogumil.zebek@nokia.com>2020-06-25 09:06:11 +0200
committerZebek Bogumil <bogumil.zebek@nokia.com>2020-07-02 08:40:33 +0200
commitdfc831bbb63ca3f42dc78135bfcca66b07cd5db2 (patch)
tree025d49791fad181265da02b4cc392879e9a48a02 /src
parente23d317a7c5ab6f0ce61054750c95748c1f26fef (diff)
Upgrade java from 8 to 113.5.0
Issue-ID: DCAEGEN2-2287 Signed-off-by: Zebek Bogumil <bogumil.zebek@nokia.com> Change-Id: I1a80ac133798ec6fbd96696aaa292244b1feec05
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/onap/dcae/inventory/InventoryApplication.java52
-rw-r--r--src/test/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImplTests.java8
-rw-r--r--src/test/java/io/swagger/api/impl/DcaeServicesApiServiceImplH2Tests.java3
-rw-r--r--src/test/java/io/swagger/api/impl/DcaeServicesApiServiceImplTests.java7
-rw-r--r--src/test/java/org/onap/dcae/inventory/InventoryApplicationTest.java7
-rw-r--r--src/test/java/org/onap/dcae/inventory/exceptions/mappers/DBIExceptionMapperTests.java7
6 files changed, 50 insertions, 34 deletions
diff --git a/src/main/java/org/onap/dcae/inventory/InventoryApplication.java b/src/main/java/org/onap/dcae/inventory/InventoryApplication.java
index 5f0104f..0964f83 100644
--- a/src/main/java/org/onap/dcae/inventory/InventoryApplication.java
+++ b/src/main/java/org/onap/dcae/inventory/InventoryApplication.java
@@ -3,13 +3,14 @@
* dcae-inventory
* ================================================================================
* Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020 Nokia. 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.
@@ -104,8 +105,8 @@ public class InventoryApplication extends Application<InventoryConfiguration> {
// You are here because you want to use the default way of configuring inventory - YAML file.
// The config file yaml file however has the path to the file that has the cert jks password in the keyStorePassword filed
// Update config file's keyStorePassword to have actual password instead of path to the password file
- // for junit purposes, it's not possible to do the above with keyStorePassword so return userArgs as we used to do before
- if ( "some-junit-yaml.yaml".equals(userArgs[1]) ) {
+ // for junit purposes, it's not possible to do the above with keyStorePassword so return userArgs as we used to do before
+ if ( "some-junit-yaml.yaml".equals(userArgs[1]) ) {
return userArgs;
}
debugLogger.debug(String.format("Default configuration file received: %s", userArgs[1]));
@@ -131,10 +132,10 @@ public class InventoryApplication extends Application<InventoryConfiguration> {
context.reset();
ContextInitializer initializer = new ContextInitializer(context);
initializer.autoConfig();
-
+
metricsLogger.info("Starting DCAE inventory application...");
debugLogger.debug(String.format("Starting DCAE inventory application... args[0]: %s", args[0]));
-
+
}
@Override
@@ -222,37 +223,42 @@ public class InventoryApplication extends Application<InventoryConfiguration> {
environment.jersey().register(new ApiListingResource());
environment.jersey().register(new SwaggerSerializers());
}
-
-
+
+
private static void createConfigFileFromDefault (String defaultConfigFile) {
-
+
try {
- JSONObject dzConfig = new JSONObject ( new JSONTokener ( new FileInputStream ( new File ( defaultConfigFile ) ) ) );
+ JSONObject dzConfig = new JSONObject ( new JSONTokener ( new FileInputStream ( new File ( defaultConfigFile ) ) ) );
JSONObject server = dzConfig.getJSONObject("server");
JSONArray applicationConnectors = server.getJSONArray("applicationConnectors");
- String jksPasswdFile = applicationConnectors.getJSONObject(0).getString("keyStorePassword");
- if ( jksPasswdFile != null ) {
- applicationConnectors.getJSONObject(0).put("keyStorePassword", getFileContents(jksPasswdFile));
- }
- else {
- errorLogger.error(String.format("Exiting due to null value for JKS password file: %s", jksPasswdFile));
- System.exit(1);
- }
+ if(isProductionModeActivated()) {
+ String jksPasswdFile = applicationConnectors.getJSONObject(0).getString("keyStorePassword");
+ if (jksPasswdFile != null) {
+ applicationConnectors.getJSONObject(0).put("keyStorePassword", getFileContents(jksPasswdFile));
+ } else {
+ errorLogger.error(String.format("Exiting due to null value for JKS password file: %s", jksPasswdFile));
+ System.exit(1);
+ }
+ }
FileWriter fileWriter = new FileWriter(configFile);
fileWriter.write(dzConfig.toString());
fileWriter.flush();
- fileWriter.close();
+ fileWriter.close();
} catch (JSONException | FileNotFoundException e) {
- errorLogger.error(String.format("JSONException | FileNotFoundException while processing default config file: %s; execption: %s",
+ errorLogger.error(String.format("JSONException | FileNotFoundException while processing default config file: %s; execption: %s",
defaultConfigFile, e));
System.exit(1);
} catch ( Exception e ) {
- errorLogger.error(String.format("Exception while processing default config file: %s; execption: %s",
+ errorLogger.error(String.format("Exception while processing default config file: %s; execption: %s",
defaultConfigFile, e));
System.exit(1);
}
}
-
+
+ private static boolean isProductionModeActivated() {
+ return System.getProperty("devMode","false").equals("false");
+ }
+
public static String getFileContents (String filename) {
File f = new File(filename);
try {
@@ -262,7 +268,7 @@ public class InventoryApplication extends Application<InventoryConfiguration> {
errorLogger.error(String.format("FileNotFoundException for filename: %s; execption: %s", filename, e));
System.exit(1);
} catch (IOException e) {
- errorLogger.error(String.format("IOException for filename: %s; execption: %s", filename, e));
+ errorLogger.error(String.format("IOException for filename: %s; execption: %s", filename, e));
System.exit(1);
}
return null;
diff --git a/src/test/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImplTests.java b/src/test/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImplTests.java
index bd13abe..5630c40 100644
--- a/src/test/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImplTests.java
+++ b/src/test/java/io/swagger/api/impl/DcaeServiceTypesApiServiceImplTests.java
@@ -3,14 +3,14 @@ package io.swagger.api.impl;/*-
* dcae-inventory
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2020 Nokia Intellectual Property. All rights reserved.
+ * Copyright (C) 2020 Nokia. 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.
@@ -42,6 +42,7 @@ import org.onap.dcae.inventory.daos.InventoryDAOManager;
import org.onap.dcae.inventory.dbthings.models.DCAEServiceObject;
import org.onap.dcae.inventory.dbthings.models.DCAEServiceTypeObject;
import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.slf4j.Logger;
@@ -55,6 +56,7 @@ import io.swagger.model.DCAEServiceTypeRequest;
* Created by mhwang on 10/27/16.
*/
@PrepareForTest({InventoryDAOManager.class})
+@PowerMockIgnore("jdk.internal.reflect.*")
@RunWith(PowerMockRunner.class)
public class DcaeServiceTypesApiServiceImplTests {
diff --git a/src/test/java/io/swagger/api/impl/DcaeServicesApiServiceImplH2Tests.java b/src/test/java/io/swagger/api/impl/DcaeServicesApiServiceImplH2Tests.java
index 32cc664..a431687 100644
--- a/src/test/java/io/swagger/api/impl/DcaeServicesApiServiceImplH2Tests.java
+++ b/src/test/java/io/swagger/api/impl/DcaeServicesApiServiceImplH2Tests.java
@@ -3,6 +3,7 @@
* dcae-inventory
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2020 Nokia. 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.
@@ -40,6 +41,7 @@ import org.onap.dcae.inventory.daos.DCAEServicesDAO;
import org.onap.dcae.inventory.daos.InventoryDAOManager;
import org.onap.dcae.inventory.dbthings.models.DCAEServiceObject;
import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.skife.jdbi.v2.DBI;
@@ -64,6 +66,7 @@ import io.swagger.model.DCAEServiceRequest;
* test here was not included in the original class because of conflicting setup operations.
*/
@PrepareForTest({InventoryDAOManager.class})
+@PowerMockIgnore("jdk.internal.reflect.*")
@RunWith(PowerMockRunner.class)
public class DcaeServicesApiServiceImplH2Tests {
diff --git a/src/test/java/io/swagger/api/impl/DcaeServicesApiServiceImplTests.java b/src/test/java/io/swagger/api/impl/DcaeServicesApiServiceImplTests.java
index 9599ca5..9c8d688 100644
--- a/src/test/java/io/swagger/api/impl/DcaeServicesApiServiceImplTests.java
+++ b/src/test/java/io/swagger/api/impl/DcaeServicesApiServiceImplTests.java
@@ -3,6 +3,7 @@ package io.swagger.api.impl;/*-
* dcae-inventory
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2020 Nokia. 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.
@@ -43,6 +44,7 @@ import org.onap.dcae.inventory.daos.InventoryDAOManager;
import org.onap.dcae.inventory.dbthings.models.DCAEServiceComponentObject;
import org.onap.dcae.inventory.dbthings.models.DCAEServiceObject;
import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.slf4j.Logger;
@@ -57,6 +59,7 @@ import io.swagger.model.DCAEServiceRequest;
* Created by mhwang on 9/25/17.
*/
@PrepareForTest({InventoryDAOManager.class})
+@PowerMockIgnore("jdk.internal.reflect.*")
@RunWith(PowerMockRunner.class)
public class DcaeServicesApiServiceImplTests {
@@ -88,7 +91,7 @@ public class DcaeServicesApiServiceImplTests {
// This block is a trick to make a private method accessible for testing
try {
- createDCAEService = DcaeServicesApiServiceImpl.class.getDeclaredMethod("createDCAEService",
+ createDCAEService = DcaeServicesApiServiceImpl.class.getDeclaredMethod("createDCAEService",
DCAEServiceObject.class, Collection.class, UriInfo.class);
createDCAEService.setAccessible(true);
} catch (NoSuchMethodException e) {
@@ -137,7 +140,7 @@ public class DcaeServicesApiServiceImplTests {
}
/*
- Commented this unit test because could not get past Nullpointer in the line trying to mock the explicit "bind"
+ Commented this unit test because could not get past Nullpointer in the line trying to mock the explicit "bind"
function call. Mockito does not handle mocking overloaded functions well so it goes into the actual method where
an member variable called foreman is null.
@Test
diff --git a/src/test/java/org/onap/dcae/inventory/InventoryApplicationTest.java b/src/test/java/org/onap/dcae/inventory/InventoryApplicationTest.java
index aacbd25..0e5562b 100644
--- a/src/test/java/org/onap/dcae/inventory/InventoryApplicationTest.java
+++ b/src/test/java/org/onap/dcae/inventory/InventoryApplicationTest.java
@@ -3,6 +3,7 @@
* dcae-inventory
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020 Nokia. 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.
@@ -27,12 +28,11 @@ import io.dropwizard.jetty.setup.ServletEnvironment;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import org.eclipse.jetty.servlets.CrossOriginFilter;
-import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.junit.runner.manipulation.Filter;
import org.onap.dcae.inventory.daos.InventoryDAOManager;
import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -41,8 +41,6 @@ import java.util.HashMap;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -51,6 +49,7 @@ import static org.mockito.Mockito.when;
* Created by mhwang on 3/14/19.
*/
@PrepareForTest({InventoryDAOManager.class})
+@PowerMockIgnore("jdk.internal.reflect.*")
@RunWith(PowerMockRunner.class)
public class InventoryApplicationTest {
diff --git a/src/test/java/org/onap/dcae/inventory/exceptions/mappers/DBIExceptionMapperTests.java b/src/test/java/org/onap/dcae/inventory/exceptions/mappers/DBIExceptionMapperTests.java
index 21feaba..0597036 100644
--- a/src/test/java/org/onap/dcae/inventory/exceptions/mappers/DBIExceptionMapperTests.java
+++ b/src/test/java/org/onap/dcae/inventory/exceptions/mappers/DBIExceptionMapperTests.java
@@ -3,13 +3,14 @@
* dcae-inventory
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020 Nokia. 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.
@@ -30,6 +31,7 @@ import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.onap.dcae.inventory.daos.InventoryDAOManager;
import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.skife.jdbi.v2.exceptions.UnableToCreateStatementException;
@@ -42,6 +44,7 @@ import io.swagger.api.ApiResponseMessage;
* Created by mhwang on 3/8/17.
*/
@PrepareForTest({InventoryDAOManager.class})
+@PowerMockIgnore("jdk.internal.reflect.*")
@RunWith(PowerMockRunner.class)
public class DBIExceptionMapperTests {