From 1d94fb7de14b42ccd01d2bdcdd7adf935dbc5b84 Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 18 Jul 2023 09:16:25 +0530 Subject: [PATCH 1/3] Fix test case failing --- .../pom.xml | 15 +++++++++++---- .../mgt/core/mgt/impl/PolicyManagerImpl.java | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index f93f462924..0e518faf96 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -70,6 +70,8 @@ io.entgra.device.mgt.core.device.mgt.core.operation.mgt;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.core.task.impl;version="[5.0,6)", + io.entgra.device.mgt.core.notification.logger;version="[5.0,6)", + io.entgra.device.mgt.core.notification.logger.impl;version="[5.0,6)", io.entgra.device.mgt.core.policy.mgt.common;version="[5.0,6)", io.entgra.device.mgt.core.policy.mgt.common.monitor;version="[5.0,6)", io.entgra.device.mgt.core.policy.mgt.core.cache, @@ -126,9 +128,9 @@ src/test/resources/testng.xml - - org.ops4j.pax.logging - + + + @@ -169,7 +171,7 @@ org.ops4j.pax.logging pax-logging-api - provided + org.wso2.carbon @@ -283,9 +285,14 @@ org.wso2.orbit.javax.xml.bind jaxb-api + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.device.mgt.extensions.logger + io.entgra.device.mgt.core io.entgra.device.mgt.core.notification.logger + provided diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java index 6b710b259b..63eb01b200 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/main/java/io/entgra/device/mgt/core/policy/mgt/core/mgt/impl/PolicyManagerImpl.java @@ -642,8 +642,8 @@ public class PolicyManagerImpl implements PolicyManager { @Override public void activatePolicy(int policyId) throws PolicyManagementException { + Policy policy = this.getPolicy(policyId); try { - Policy policy = this.getPolicy(policyId); PolicyManagementDAOFactory.beginTransaction(); policyDAO.activatePolicy(policyId); policyDAO.recordUpdatedPolicy(policy); From 349bb0a3dc0c4a8ff2feff9a113c5013945655da Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Tue, 18 Jul 2023 09:33:33 +0530 Subject: [PATCH 2/3] Fix test case failure --- .../pom.xml | 5 + .../user-test/user-mgt-registry-test.xml | 2 +- .../resources/carbon-home/dbscripts/h2.sql | 19 --- .../conf/datasources/data-source-config.xml | 2 +- .../pom.xml | 41 +++++- .../impl/ConfigurationServiceImplTest.java | 3 +- .../service/impl/DeviceAgentServiceTest.java | 2 +- .../impl/DeviceManagementServiceImplTest.java | 2 +- .../DeviceTypeManagementAdminServiceTest.java | 2 +- .../impl/DeviceTypeManagementServiceTest.java | 7 +- .../impl/GroupManagementServiceImplTest.java | 6 +- ...NotificationManagementServiceImplTest.java | 2 +- .../impl/UserManagementServiceImplTest.java | 2 +- .../pom.xml | 11 +- .../mgt/PermissionManagerServiceTest.java | 4 + .../mgt/core/search/ProcessorImplTest.java | 5 +- .../core/search/util/ChangeEnumValues.java | 122 ------------------ .../datasource/data-source-config-mock.xml | 2 +- .../data-source-config-no-table.xml | 2 +- .../config/datasource/data-source-config.xml | 2 +- .../src/test/resources/sql/h2.sql | 70 ++++------ .../user-test/user-mgt-registry-test.xml | 2 +- .../pom.xml | 21 ++- .../resources/carbon-home/dbscripts/h2.sql | 18 --- .../conf/datasource/data-source-config.xml | 2 +- .../src/test/resources/sql-files/h2.sql | 93 +++++++------ .../user-test/user-mgt-registry-test.xml | 2 +- .../pom.xml | 1 - .../pom.xml | 11 +- .../user-test/user-mgt-registry-test.xml | 2 +- pom.xml | 12 +- 31 files changed, 172 insertions(+), 305 deletions(-) delete mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/util/ChangeEnumValues.java diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index 7e3ef60c38..3307c0bd73 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -44,6 +44,11 @@ powermock-api-mockito2 test + + org.mockito + mockito-core + test + org.testng testng diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/resources/user-test/user-mgt-registry-test.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/resources/user-test/user-mgt-registry-test.xml index 1ced8bb1f1..4d53df601c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:target/databasetest/CARBON_TEST + jdbc:h2:./target/databasetest/CARBON_TEST org.h2.Driver 50 60000 diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/test/resources/carbon-home/dbscripts/h2.sql b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/test/resources/carbon-home/dbscripts/h2.sql index 2f96eeba79..7f20466a6f 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/test/resources/carbon-home/dbscripts/h2.sql +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/test/resources/carbon-home/dbscripts/h2.sql @@ -16,24 +16,6 @@ * under the License. */ -/* - * Copyright (c) 2021, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. 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. - */ - CREATE TABLE IF NOT EXISTS REG_CLUSTER_LOCK ( REG_LOCK_NAME VARCHAR (20), REG_LOCK_STATUS VARCHAR (20), @@ -104,7 +86,6 @@ CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_PATH_ID_NAME ON REG_RESOURCE(REG_ CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_UUID ON REG_RESOURCE(REG_UUID); CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_TENANT ON REG_RESOURCE(REG_TENANT_ID, REG_UUID); CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_TYPE ON REG_RESOURCE(REG_TENANT_ID, REG_MEDIA_TYPE); - CREATE TABLE IF NOT EXISTS REG_RESOURCE_HISTORY ( REG_PATH_ID INTEGER NOT NULL, REG_NAME VARCHAR(256), diff --git a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml index ad8165fc67..2e591b07c9 100644 --- a/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml +++ b/components/device-mgt-extensions/io.entgra.device.mgt.core.device.mgt.extensions.defaultrole.manager/src/test/resources/carbon-home/repository/conf/datasources/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:smart-meter-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 0c2e5663fe..72c30b6d93 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -38,6 +38,10 @@ org.apache.maven.plugins maven-compiler-plugin + + 1.8 + 1.8 + org.apache.maven.plugins @@ -151,16 +155,25 @@ spring-web provided - - org.apache.cxf - cxf-bundle-jaxrs - provided - commons-httpclient.wso2 commons-httpclient provided + + org.apache.cxf + cxf-rt-frontend-jaxrs + + + javax.ws.rs + jsr311-api + + + org.apache.cxf + cxf-rt-core + + + org.wso2.carbon org.wso2.carbon.utils @@ -213,6 +226,14 @@ javassist javassist + + javax.ws.rs + jsr311-api + + + javax.ws.rs + javax.ws.rs-api + @@ -295,6 +316,10 @@ org.slf4j slf4j-api + + javax.ws.rs + jsr311-api + @@ -329,6 +354,12 @@ org.wso2.carbon.registry org.wso2.carbon.registry.resource + + + javax.ws.rs + javax.ws.rs-api + + provided diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ConfigurationServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ConfigurationServiceImplTest.java index 8bc2f8c0c7..5fa7eecb6b 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ConfigurationServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/ConfigurationServiceImplTest.java @@ -43,10 +43,11 @@ import java.util.List; /** * This is a test class for {@link ConfigurationServiceImpl}. */ -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) +@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"}) @SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils", "org.wso2.carbon.context.CarbonContext"}) @PrepareForTest({DeviceMgtAPIUtils.class, PolicyManagerUtil.class}) +//@PowerMockIgnore("org.mockito.*") public class ConfigurationServiceImplTest { private ConfigurationManagementService configurationManagementService; private PlatformConfigurationManagementService platformConfigurationManagementService; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceTest.java index b61f4254b2..4a5a370d0f 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceAgentServiceTest.java @@ -69,7 +69,7 @@ import static org.mockito.MockitoAnnotations.initMocks; /** * This class holds the unit tests for the class {@link DeviceAgentServiceImpl} */ -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) +@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"}) @SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils", "org.wso2.carbon.context.CarbonContext", "org.wso2.carbon.context.internal.CarbonContextDataHolder"}) @PrepareForTest({DeviceMgtAPIUtils.class, DeviceManagementProviderService.class, diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java index dd98043164..25cdd5168c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImplTest.java @@ -72,7 +72,7 @@ import static org.mockito.MockitoAnnotations.initMocks; /** * This class includes unit tests for testing the functionality of {@link DeviceManagementServiceImpl} */ -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) +@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"}) @SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils", "org.wso2.carbon.context.CarbonContext", "org.wso2.carbon.user.core.service.RealmService"}) @PrepareForTest({DeviceMgtAPIUtils.class, MultitenantUtils.class, CarbonContext.class, RealmService.class}) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementAdminServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementAdminServiceTest.java index f18426501c..4fe4473930 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementAdminServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementAdminServiceTest.java @@ -51,7 +51,7 @@ import static org.mockito.MockitoAnnotations.initMocks; /** * This class holds the unit tests for the class {@link DeviceTypeManagementAdminService} */ -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) +@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"}) @SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils", "org.wso2.carbon.context.PrivilegedCarbonContext"}) @PrepareForTest({DeviceMgtAPIUtils.class, DeviceManagementProviderService.class, CarbonContext.class}) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementServiceTest.java index c6ff5a3b95..24f8841ca8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceTypeManagementServiceTest.java @@ -48,7 +48,7 @@ import static org.mockito.MockitoAnnotations.initMocks; /** * This class holds the unit tests for the class {@link DeviceTypeManagementService} */ -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) +@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"}) @SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils"}) @PrepareForTest({DeviceMgtAPIUtils.class, DeviceManagementProviderService.class}) public class DeviceTypeManagementServiceTest { @@ -129,8 +129,9 @@ public class DeviceTypeManagementServiceTest { FeatureManager featureManager = Mockito.mock(FeatureManager.class); Mockito.when(this.deviceManagementProviderService.getFeatureManager(Mockito.anyString())).thenReturn (featureManager); - Mockito.when((featureManager).getFeatures(Mockito.anyString())).thenThrow(new DeviceManagementException()); - Mockito.when((featureManager).getFeatures(Mockito.anyString(), Mockito.anyBoolean())).thenThrow(new DeviceManagementException()); + Mockito.when(featureManager.getFeatures(Mockito.anyString())).thenThrow(new DeviceManagementException()); + Mockito.when(featureManager.getFeatures(Mockito.anyString(), Mockito.anyBoolean())).thenThrow(new DeviceManagementException()); + Mockito.when(featureManager.getFeatures(Mockito.any(), Mockito.anyBoolean())).thenThrow(new DeviceManagementException()); Response response = this.deviceTypeManagementService.getFeatures(TEST_DEVICE_TYPE, null, "false", MODIFIED_SINCE); Assert.assertNotNull(response, "The response object is null."); Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImplTest.java index dc94b03ab8..42f6c80383 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/GroupManagementServiceImplTest.java @@ -51,7 +51,7 @@ import java.util.List; /** * This is a test case for {@link GroupManagementServiceImpl}. */ -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "javax.xml.parsers"}) +@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "javax.xml.parsers", "org.mockito.*"}) @SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils", "org.wso2.carbon.context.PrivilegedCarbonContext"}) @PrepareForTest({DeviceMgtAPIUtils.class, CarbonContext.class}) @@ -125,13 +125,13 @@ public class GroupManagementServiceImplTest { PowerMockito.stub(PowerMockito.method(PrivilegedCarbonContext.class, "getThreadLocalCarbonContext")) .toReturn(context); Mockito.doReturn(2).when(groupManagementProviderService) - .getGroupCount(Mockito.anyString(), Mockito.anyString()); + .getGroupCount(Mockito.anyString(), Mockito.any()); Response response = groupManagementService.getGroupCount(); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), "GetGroupCount request failed with valid parameters"); Mockito.reset(groupManagementProviderService); Mockito.doThrow(new GroupManagementException()).when(groupManagementProviderService) - .getGroupCount(Mockito.anyString(), Mockito.anyString()); + .getGroupCount(Mockito.anyString(), Mockito.any()); response = groupManagementService.getGroupCount(); Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), "GetGroupCount request succeeded with in-valid parameters"); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/NotificationManagementServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/NotificationManagementServiceImplTest.java index e15c12e677..d40b8bd406 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/NotificationManagementServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/NotificationManagementServiceImplTest.java @@ -46,7 +46,7 @@ import static org.mockito.MockitoAnnotations.initMocks; /** * This is a test class for {@link NotificationManagementServiceImpl}. */ -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) +@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"}) @SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils", "org.wso2.carbon.context.CarbonContext"}) @PrepareForTest({DeviceMgtAPIUtils.class, MultitenantUtils.class, CarbonContext.class}) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImplTest.java index f584bb31ec..5b2417c4db 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/UserManagementServiceImplTest.java @@ -61,7 +61,7 @@ import static org.mockito.MockitoAnnotations.initMocks; /** * This is a test case for {@link UserManagementService}. */ -@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*"}) +@PowerMockIgnore({"javax.ws.rs.*", "org.apache.log4j.*", "org.mockito.*"}) @SuppressStaticInitializationFor({"io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils", "org.wso2.carbon.context.CarbonContext"}) @PrepareForTest({DeviceMgtAPIUtils.class, MultitenantUtils.class, CarbonContext.class}) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml index 26f6603912..6846df32e0 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/pom.xml @@ -514,7 +514,16 @@ jaxb-api compile + + com.sun.xml.bind + jaxb-core + compile + + + com.sun.xml.bind + jaxb-impl + compile + - diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionManagerServiceTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionManagerServiceTest.java index 9af3c4a94b..5b99437470 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionManagerServiceTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/permission/mgt/PermissionManagerServiceTest.java @@ -23,6 +23,7 @@ import io.entgra.device.mgt.core.device.mgt.common.permission.mgt.PermissionMana import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.testng.Assert; import org.testng.IObjectFactory; @@ -40,6 +41,9 @@ import static org.mockito.MockitoAnnotations.initMocks; * This contains unit tests for PermissionManagerService class. */ @PrepareForTest(PermissionUtils.class) +@PowerMockIgnore("org.mockito.*") + +//@PowerMockIgnore({"javax.management.*", "javax.script.*", "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "org.w3c.*"}) public class PermissionManagerServiceTest { private static final Log log = LogFactory.getLog(PermissionManagerServiceTest.class);; diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/ProcessorImplTest.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/ProcessorImplTest.java index 089b945f95..1818bd1277 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/ProcessorImplTest.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/ProcessorImplTest.java @@ -29,7 +29,6 @@ import io.entgra.device.mgt.core.device.mgt.core.internal.DeviceManagementServic import io.entgra.device.mgt.core.device.mgt.core.search.mgt.InvalidOperatorException; import io.entgra.device.mgt.core.device.mgt.core.search.mgt.SearchMgtException; import io.entgra.device.mgt.core.device.mgt.core.search.mgt.impl.ProcessorImpl; -import io.entgra.device.mgt.core.device.mgt.core.search.util.ChangeEnumValues; import io.entgra.device.mgt.core.device.mgt.core.search.util.Utils; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderService; import io.entgra.device.mgt.core.device.mgt.core.service.DeviceManagementProviderServiceImpl; @@ -131,8 +130,6 @@ public class ProcessorImplTest extends BaseDeviceManagementTest { public void testInvalidState() throws SearchMgtException { SearchContext context = new SearchContext(); List conditions = new ArrayList<>(); - ChangeEnumValues.addEnum(Condition.State.class, "BLA"); - Condition.State state = Condition.State.valueOf("BLA"); Condition cond = new Condition(); cond.setKey("batteryLevel"); @@ -152,7 +149,7 @@ public class ProcessorImplTest extends BaseDeviceManagementTest { cond3.setKey("batteryLevel"); cond3.setOperator("="); cond3.setValue("23.0"); - cond3.setState(state); + cond3.setState(Condition.State.AND); conditions.add(cond3); context.setConditions(conditions); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/util/ChangeEnumValues.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/util/ChangeEnumValues.java deleted file mode 100644 index e5a9d3399e..0000000000 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/search/util/ChangeEnumValues.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. 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. - */ -package io.entgra.device.mgt.core.device.mgt.core.search.util; - -import io.entgra.device.mgt.core.device.mgt.common.search.Condition; -import sun.reflect.ConstructorAccessor; -import sun.reflect.FieldAccessor; -import sun.reflect.ReflectionFactory; - -import java.lang.reflect.AccessibleObject; -import java.lang.reflect.Array; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * Changes the Enum values of a given class. - */ -public class ChangeEnumValues { - - private static ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory(); - - public ChangeEnumValues() {} - - private static void setFailSafeFieldValue(Field field, Object target, Object value) throws NoSuchFieldException, - IllegalAccessException { - field.setAccessible(true); - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - int modifiers = modifiersField.getInt(field); - modifiers &= ~Modifier.FINAL; - modifiersField.setInt(field, modifiers); - FieldAccessor fa = reflectionFactory.newFieldAccessor(field, false); - fa.set(target, value); - } - - private static void blankField(Class enumClass, String fieldName) throws NoSuchFieldException, - IllegalAccessException { - for (Field field : Class.class.getDeclaredFields()) { - if (field.getName().contains(fieldName)) { - AccessibleObject.setAccessible(new Field[]{field}, true); - setFailSafeFieldValue(field, enumClass, null); - break; - } - } - } - - private static void cleanEnumCache(Class enumClass) throws NoSuchFieldException, IllegalAccessException { - blankField(enumClass, "enumConstantDirectory"); - blankField(enumClass, "enumConstants"); - } - - private static ConstructorAccessor getConstructorAccessor(Class enumClass, Class[] additionalParameterTypes) - throws NoSuchMethodException { - Class[] parameterTypes = new Class[additionalParameterTypes.length + 2]; - parameterTypes[0] = String.class; - parameterTypes[1] = int.class; - System.arraycopy(additionalParameterTypes, 0, parameterTypes, 2, additionalParameterTypes.length); - return reflectionFactory.newConstructorAccessor(enumClass.getDeclaredConstructor(parameterTypes)); - } - - private static Object makeEnum(Class enumClass, String value, int ordinal, Class[] additionalTypes, - Object[] additionalValues) throws Exception { - Object[] parms = new Object[additionalValues.length + 2]; - parms[0] = value; - parms[1] = ordinal; - System.arraycopy(additionalValues, 0, parms, 2, additionalValues.length); - return enumClass.cast(getConstructorAccessor(enumClass, additionalTypes).newInstance(parms)); - } - - /** - * Add an enum instance to the enum class given as argument - * - * @param the type of the enum - * @param enumType the class of the enum to be modified - * @param enumName the name of the new enum instance to be added to the class. - */ - public static > void addEnum(Class enumType, String enumName) { - - if (!Enum.class.isAssignableFrom(enumType)) { - throw new RuntimeException("class " + enumType + " is not an instance of Enum"); - } - - Field valuesField = null; - Field[] fields = Condition.State.class.getDeclaredFields(); - for (Field field : fields) { - if (field.getName().contains("$VALUES")) { - valuesField = field; - break; - } - } - AccessibleObject.setAccessible(new Field[]{valuesField}, true); - - try { - T[] previousValues = (T[]) valuesField.get(enumType); - List values = new ArrayList(Arrays.asList(previousValues)); - T newValue = (T) makeEnum(enumType, enumName, values.size(), new Class[]{}, new Object[]{}); - values.add(newValue); - setFailSafeFieldValue(valuesField, null, values.toArray((T[]) Array.newInstance(enumType, 0))); - cleanEnumCache(enumType); - } catch (Exception e) { - throw new RuntimeException(e.getMessage(), e); - } - } -} diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config-mock.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config-mock.xml index f6031ebc08..35a3fcf16c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config-mock.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config-mock.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE io.entgra.device.mgt.core.device.mgt.core.mock.MockJDBCDriver wso2carbon wso2carbon diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config-no-table.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config-no-table.xml index b28626efe7..71e35416f3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config-no-table.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config-no-table.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:nodb-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:nodb-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config.xml index 27b6dfeaeb..533fd82959 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/config/datasource/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql index 4f83fa5b5e..ace89fc192 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/sql/h2.sql @@ -34,7 +34,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE ( ID INTEGER auto_increment NOT NULL, DESCRIPTION TEXT DEFAULT NULL, NAME VARCHAR(100) DEFAULT NULL, - DEVICE_TYPE_ID INT(11) DEFAULT NULL, + DEVICE_TYPE_ID INT DEFAULT NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, @@ -180,16 +180,18 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ); CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , NAME VARCHAR(45) DEFAULT NULL , DESCRIPTION VARCHAR(1000) NULL, - TENANT_ID INT(11) NOT NULL , - PROFILE_ID INT(11) NOT NULL , + PAYLOAD_VERSION VARCHAR (45) NULL, + TENANT_ID INT NOT NULL , + PROFILE_ID INT NOT NULL , OWNERSHIP_TYPE VARCHAR(45) NULL, COMPLIANCE VARCHAR(100) NULL, PRIORITY INT NOT NULL, - ACTIVE INT(2) NOT NULL, - UPDATED INT(1) NULL, + ACTIVE INT NOT NULL, + UPDATED INT NULL, + POLICY_TYPE VARCHAR(45) NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY FOREIGN KEY (PROFILE_ID ) @@ -199,11 +201,11 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , - DEVICE_ID INT(11) NOT NULL , - ENROLMENT_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT , + DEVICE_ID INT NOT NULL , + ENROLMENT_ID INT NOT NULL, DEVICE BLOB NOT NULL, - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -218,9 +220,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT(11) NOT NULL , + ID INT NOT NULL , DEVICE_TYPE VARCHAR(300) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) @@ -230,11 +232,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT(11) NOT NULL AUTO_INCREMENT, - PROFILE_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT, + PROFILE_ID INT NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL, - TENANT_ID INT(11) NOT NULL , + TENANT_ID INT NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -245,9 +247,9 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ); CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -271,11 +273,11 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( ID INT NOT NULL AUTO_INCREMENT , DEVICE_ID INT NOT NULL , - ENROLMENT_ID INT(11) NOT NULL, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL , POLICY_CONTENT BLOB NULL , TENANT_ID INT NOT NULL, - APPLIED TINYINT(1) NULL , + APPLIED TINYINT NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -328,7 +330,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( ID INT NOT NULL AUTO_INCREMENT, DEVICE_ID INT NOT NULL, - ENROLMENT_ID INT(11) NOT NULL, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -343,7 +345,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( ID INT NOT NULL AUTO_INCREMENT, POLICY_ID INT NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL , - TENANT_ID INT(11) NOT NULL, + TENANT_ID INT NOT NULL, PRIMARY KEY (ID) ); @@ -372,7 +374,7 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER(10) NULL, + MEMORY_USAGE INTEGER NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, DEVICE_ID INTEGER NOT NULL, ENROLMENT_ID INTEGER NOT NULL, @@ -439,7 +441,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), CONSTRAINT DM_DEVICE_LOCATION_DEVICE FOREIGN KEY (DEVICE_ID) @@ -472,8 +474,8 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( CPU_USAGE DECIMAL(5) NULL, TOTAL_RAM_MEMORY DECIMAL(30,3) NULL, AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL, - PLUGGED_IN INT(1) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + PLUGGED_IN INT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE FOREIGN KEY (DEVICE_ID) @@ -487,24 +489,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( ON UPDATE NO ACTION ); -/* - * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. 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. - */ - -- POLICY AND DEVICE GROUP MAPPING -- CREATE TABLE IF NOT EXISTS DM_DEVICE_GROUP_POLICY ( ID INT NOT NULL AUTO_INCREMENT, diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml index fc32a2698d..96fd6acfff 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:target/databasetest/CARBON_TEST + jdbc:h2:./target/databasetest/CARBON_TEST org.h2.Driver 50 60000 diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml index c12f494f37..3af053e025 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/pom.xml @@ -66,6 +66,12 @@ org.wso2.carbon org.wso2.carbon.utils + + + org.eclipse.platform + org.eclipse.osgi + + org.wso2.carbon @@ -111,10 +117,10 @@ org.wso2.carbon.governance.registry.extensions test - - jaxen - jaxen - + + jaxen + jaxen + @@ -145,6 +151,11 @@ org.wso2.orbit.javax.xml.bind jaxb-api + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.notification.logger + provided + @@ -263,8 +274,6 @@ - - diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/carbon-home/dbscripts/h2.sql b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/carbon-home/dbscripts/h2.sql index 2f96eeba79..620b98e321 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/carbon-home/dbscripts/h2.sql +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/carbon-home/dbscripts/h2.sql @@ -16,24 +16,6 @@ * under the License. */ -/* - * Copyright (c) 2021, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. 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. - */ - CREATE TABLE IF NOT EXISTS REG_CLUSTER_LOCK ( REG_LOCK_NAME VARCHAR (20), REG_LOCK_STATUS VARCHAR (20), diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/carbon-home/repository/conf/datasource/data-source-config.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/carbon-home/repository/conf/datasource/data-source-config.xml index 27b6dfeaeb..533fd82959 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/carbon-home/repository/conf/datasource/data-source-config.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/carbon-home/repository/conf/datasource/data-source-config.xml @@ -18,7 +18,7 @@ --> - jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE;MVCC=true + jdbc:h2:mem:cdm-test-db;DB_CLOSE_ON_EXIT=FALSE org.h2.Driver wso2carbon wso2carbon diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql index 2b2200bb2b..a1cf506655 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/sql-files/h2.sql @@ -31,7 +31,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE ( ID INTEGER auto_increment NOT NULL, DESCRIPTION TEXT DEFAULT NULL, NAME VARCHAR(100) DEFAULT NULL, - DEVICE_TYPE_ID INT(11) DEFAULT NULL, + DEVICE_TYPE_ID INT DEFAULT NULL, DEVICE_IDENTIFICATION VARCHAR(300) DEFAULT NULL, LAST_UPDATED_TIMESTAMP TIMESTAMP NOT NULL, TENANT_ID INTEGER DEFAULT 0, @@ -177,16 +177,16 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE ( ); CREATE TABLE IF NOT EXISTS DM_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , NAME VARCHAR(45) DEFAULT NULL , DESCRIPTION VARCHAR(1000) NULL, - TENANT_ID INT(11) NOT NULL , - PROFILE_ID INT(11) NOT NULL , + TENANT_ID INT NOT NULL , + PROFILE_ID INT NOT NULL , OWNERSHIP_TYPE VARCHAR(45) NULL, COMPLIANCE VARCHAR(100) NULL, PRIORITY INT NOT NULL, - ACTIVE INT(2) NOT NULL, - UPDATED INT(1) NULL, + ACTIVE INT NOT NULL, + UPDATED INT NULL, PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY FOREIGN KEY (PROFILE_ID ) @@ -196,11 +196,11 @@ CREATE TABLE IF NOT EXISTS DM_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , - DEVICE_ID INT(11) NOT NULL , - ENROLMENT_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT , + DEVICE_ID INT NOT NULL , + ENROLMENT_ID INT NOT NULL, DEVICE BLOB NOT NULL, - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY FOREIGN KEY (POLICY_ID ) @@ -215,9 +215,9 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( - ID INT(11) NOT NULL , + ID INT NOT NULL , DEVICE_TYPE VARCHAR(300) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_DEVICE_TYPE_POLICY FOREIGN KEY (POLICY_ID ) @@ -227,11 +227,11 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY ( ); CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( - ID INT(11) NOT NULL AUTO_INCREMENT, - PROFILE_ID INT(11) NOT NULL, + ID INT NOT NULL AUTO_INCREMENT, + PROFILE_ID INT NOT NULL, FEATURE_CODE VARCHAR(100) NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL, - TENANT_ID INT(11) NOT NULL , + TENANT_ID INT NOT NULL , CONTENT BLOB NULL DEFAULT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES @@ -242,9 +242,9 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_FEATURES ( ); CREATE TABLE IF NOT EXISTS DM_ROLE_POLICY ( - ID INT(11) NOT NULL AUTO_INCREMENT , + ID INT NOT NULL AUTO_INCREMENT , ROLE_NAME VARCHAR(45) NOT NULL , - POLICY_ID INT(11) NOT NULL , + POLICY_ID INT NOT NULL , PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY FOREIGN KEY (POLICY_ID ) @@ -268,11 +268,11 @@ CREATE TABLE IF NOT EXISTS DM_USER_POLICY ( CREATE TABLE IF NOT EXISTS DM_DEVICE_POLICY_APPLIED ( ID INT NOT NULL AUTO_INCREMENT , DEVICE_ID INT NOT NULL , - ENROLMENT_ID INT(11) NOT NULL, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL , POLICY_CONTENT BLOB NULL , TENANT_ID INT NOT NULL, - APPLIED TINYINT(1) NULL , + APPLIED TINYINT NULL , CREATED_TIME TIMESTAMP NULL , UPDATED_TIME TIMESTAMP NULL , APPLIED_TIME TIMESTAMP NULL , @@ -325,7 +325,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CRITERIA_PROPERTIES ( CREATE TABLE IF NOT EXISTS DM_POLICY_COMPLIANCE_STATUS ( ID INT NOT NULL AUTO_INCREMENT, DEVICE_ID INT NOT NULL, - ENROLMENT_ID INT(11) NOT NULL, + ENROLMENT_ID INT NOT NULL, POLICY_ID INT NOT NULL, TENANT_ID INT NOT NULL, STATUS INT NULL, @@ -340,7 +340,7 @@ CREATE TABLE IF NOT EXISTS DM_POLICY_CHANGE_MGT ( ID INT NOT NULL AUTO_INCREMENT, POLICY_ID INT NOT NULL, DEVICE_TYPE VARCHAR(300) NOT NULL , - TENANT_ID INT(11) NOT NULL, + TENANT_ID INT NOT NULL, PRIMARY KEY (ID) ); @@ -369,10 +369,22 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( LOCATION_URL VARCHAR(100) DEFAULT NULL, IMAGE_URL VARCHAR(100) DEFAULT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER(10) NULL, + MEMORY_USAGE INTEGER NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, + DEVICE_ID INTEGER NOT NULL, + ENROLMENT_ID INTEGER NOT NULL, TENANT_ID INTEGER NOT NULL, - PRIMARY KEY (ID) + PRIMARY KEY (ID), + CONSTRAINT fk_dm_device + FOREIGN KEY (DEVICE_ID) + REFERENCES DM_DEVICE (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT fk_dm_enrolement + FOREIGN KEY (ENROLMENT_ID) + REFERENCES DM_ENROLMENT (ID) + ON DELETE NO ACTION + ON UPDATE NO ACTION ); CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING ( @@ -380,34 +392,15 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_APPLICATION_MAPPING ( DEVICE_ID INTEGER NOT NULL, APPLICATION_ID INTEGER NOT NULL, APP_PROPERTIES BLOB NULL, - MEMORY_USAGE INTEGER(10) NULL, + MEMORY_USAGE INTEGER NULL, IS_ACTIVE BOOLEAN NOT NULL DEFAULT FALSE, TENANT_ID INTEGER NOT NULL, PRIMARY KEY (ID), - CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES + CONSTRAINT fk_dm_device_tb FOREIGN KEY (DEVICE_ID) REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT fk_dm_application FOREIGN KEY (APPLICATION_ID) REFERENCES DM_APPLICATION (ID) ON DELETE NO ACTION ON UPDATE NO ACTION ); - -/* - * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. 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. - */ - -- POLICY RELATED TABLES FINISHED -- -- NOTIFICATION TABLE -- @@ -451,7 +444,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( STATE VARCHAR(45) NULL, COUNTRY VARCHAR(45) NULL, GEO_HASH VARCHAR(45) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), CONSTRAINT DM_DEVICE_LOCATION_DEVICE FOREIGN KEY (DEVICE_ID) @@ -463,6 +456,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_LOCATION ( CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( ID INT NOT NULL AUTO_INCREMENT, DEVICE_ID INT NOT NULL, + ENROLMENT_ID INT NOT NULL, DEVICE_MODEL VARCHAR(45) NULL, VENDOR VARCHAR(45) NULL, OS_VERSION VARCHAR(45) NULL, @@ -477,13 +471,18 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_DETAIL ( CPU_USAGE DECIMAL(5) NULL, TOTAL_RAM_MEMORY DECIMAL(30,3) NULL, AVAILABLE_RAM_MEMORY DECIMAL(30,3) NULL, - PLUGGED_IN INT(1) NULL, - UPDATE_TIMESTAMP BIGINT(15) NOT NULL, + PLUGGED_IN INT NULL, + UPDATE_TIMESTAMP BIGINT NOT NULL, PRIMARY KEY (ID), CONSTRAINT FK_DM_DEVICE_DETAILS_DEVICE FOREIGN KEY (DEVICE_ID) REFERENCES DM_DEVICE (ID) ON DELETE NO ACTION + ON UPDATE NO ACTION, + CONSTRAINT FK_DM_ENROLMENT_DEVICE_DETAILS + FOREIGN KEY (ENROLMENT_ID) + REFERENCES DM_ENROLMENT (ID) + ON DELETE NO ACTION ON UPDATE NO ACTION ); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/user-test/user-mgt-registry-test.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/user-test/user-mgt-registry-test.xml index 1ced8bb1f1..4d53df601c 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:target/databasetest/CARBON_TEST + jdbc:h2:./target/databasetest/CARBON_TEST org.h2.Driver 50 60000 diff --git a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml index 70ca947ed2..72e84ab493 100644 --- a/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml +++ b/components/logger/io.entgra.device.mgt.core.notification.logger/pom.xml @@ -36,7 +36,6 @@ org.ops4j.pax.logging pax-logging-api provided - org.testng diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml index 0e518faf96..0d3faea08b 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/pom.xml @@ -70,8 +70,6 @@ io.entgra.device.mgt.core.device.mgt.core.operation.mgt;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.core.service;version="[5.0,6)", io.entgra.device.mgt.core.device.mgt.core.task.impl;version="[5.0,6)", - io.entgra.device.mgt.core.notification.logger;version="[5.0,6)", - io.entgra.device.mgt.core.notification.logger.impl;version="[5.0,6)", io.entgra.device.mgt.core.policy.mgt.common;version="[5.0,6)", io.entgra.device.mgt.core.policy.mgt.common.monitor;version="[5.0,6)", io.entgra.device.mgt.core.policy.mgt.core.cache, @@ -128,9 +126,6 @@ src/test/resources/testng.xml - - - @@ -171,7 +166,7 @@ org.ops4j.pax.logging pax-logging-api - + provided org.wso2.carbon @@ -285,10 +280,6 @@ org.wso2.orbit.javax.xml.bind jaxb-api - - io.entgra.device.mgt.core - io.entgra.device.mgt.core.device.mgt.extensions.logger - io.entgra.device.mgt.core io.entgra.device.mgt.core.notification.logger diff --git a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/resources/user-test/user-mgt-registry-test.xml b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/resources/user-test/user-mgt-registry-test.xml index 1ced8bb1f1..4d53df601c 100644 --- a/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/resources/user-test/user-mgt-registry-test.xml +++ b/components/webapp-authenticator-framework/io.entgra.device.mgt.core.webapp.authenticator.framework/src/test/resources/user-test/user-mgt-registry-test.xml @@ -27,7 +27,7 @@ everyone false 500 - jdbc:h2:target/databasetest/CARBON_TEST + jdbc:h2:./target/databasetest/CARBON_TEST org.h2.Driver 50 60000 diff --git a/pom.xml b/pom.xml index 1a0eab8a0f..3c62c474e2 100644 --- a/pom.xml +++ b/pom.xml @@ -843,7 +843,6 @@ jaxb-impl 2.3.1 - org.apache.axis2.transport axis2-transport-mail @@ -1903,7 +1902,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.2 + 3.1.2 ${basedir}/target/coverage-reports/jacoco-ut.exec @@ -2084,7 +2083,7 @@ [7.3, 8) - 2.0.1 + 2.1.1 1.6.9 1.6.9 4.0.1 @@ -2096,7 +2095,7 @@ 2.8.2.wso2v1 1.2.0.wso2v1 - 5.0.2.Final + 5.1.2.Final [0.0.0,1.0.0) [0.0.0,1.0.0) @@ -2125,8 +2124,7 @@ true - 0.7.8 - 0.7.5.201505241946 + 0.8.10 1.0b3 2.0.2 1.4.0.wso2v1 @@ -2135,8 +2133,6 @@ 1.21 2.6.5 - 1.7.6 - v12.18.1 3.1.0 From 74041070f9cc22ba103c27c19dbc21b399e0c8fc Mon Sep 17 00:00:00 2001 From: Dharmakeerthi Lasantha Date: Mon, 24 Jul 2023 20:22:54 +0530 Subject: [PATCH 3/3] Fix class def not found issue --- .../io.entgra.device.mgt.core.device.mgt.api/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml index 72c30b6d93..abbc0e9875 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml @@ -192,6 +192,10 @@ org.slf4j jcl-over-slf4j + + org.ops4j.pax.logging + pax-logging-log4j2 +