required changes for PR

revert-70aa11f8
GDLMadushanka 7 years ago
parent 7f4158ca60
commit ca1c9b18cd

@ -1,3 +1,21 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. 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 org.wso2.carbon.device.mgt.extensions.device.type.deployer; package org.wso2.carbon.device.mgt.extensions.device.type.deployer;
import org.apache.axis2.deployment.DeploymentException; import org.apache.axis2.deployment.DeploymentException;
@ -16,32 +34,31 @@ import java.lang.reflect.Field;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
/*
Unit tests for DeviceTypePluginDeployer
*/
public class DeviceTypePluginDeployerTest { public class DeviceTypePluginDeployerTest {
private DeviceTypePluginDeployer deviceTypePluginDeployer; private DeviceTypePluginDeployer deviceTypePluginDeployer;
private DeploymentFileData deploymentFileData; private DeploymentFileData deploymentFileData;
private Field deviceTypeServiceRegistrations = null; private Field deviceTypeServiceRegistrations = null;
private Field deviceTypeConfigurationDataMap = null; private Field deviceTypeConfigurationDataMap = null;
private ServiceRegistration serviceRegistration = null; private ServiceRegistration serviceRegistration = null;
@BeforeClass @BeforeClass
public void init() throws Exception { public void init() throws NoSuchFieldException, IllegalAccessException, IOException, RegistryException {
deviceTypePluginDeployer = Mockito.mock(DeviceTypePluginDeployer.class, Mockito.CALLS_REAL_METHODS); deviceTypePluginDeployer = Mockito.mock(DeviceTypePluginDeployer.class, Mockito.CALLS_REAL_METHODS);
serviceRegistration = Mockito.mock(ServiceRegistration.class, Mockito.CALLS_REAL_METHODS); serviceRegistration = Mockito.mock(ServiceRegistration.class, Mockito.CALLS_REAL_METHODS);
Mockito.doReturn(serviceRegistration).when(deviceTypePluginDeployer).registerDeviceType(Mockito.any(), Mockito.doReturn(serviceRegistration).when(deviceTypePluginDeployer).registerDeviceType(Mockito.any(),
Mockito.any()); Mockito.any());
deviceTypeServiceRegistrations = DeviceTypePluginDeployer.class.getDeclaredField deviceTypeServiceRegistrations = DeviceTypePluginDeployer.class.getDeclaredField
("deviceTypeServiceRegistrations"); ("deviceTypeServiceRegistrations");
deviceTypeServiceRegistrations.setAccessible(true); deviceTypeServiceRegistrations.setAccessible(true);
deviceTypeServiceRegistrations.set(deviceTypePluginDeployer, new ConcurrentHashMap()); deviceTypeServiceRegistrations.set(deviceTypePluginDeployer, new ConcurrentHashMap());
deviceTypeConfigurationDataMap = DeviceTypePluginDeployer.class.getDeclaredField deviceTypeConfigurationDataMap = DeviceTypePluginDeployer.class.getDeclaredField
("deviceTypeConfigurationDataMap"); ("deviceTypeConfigurationDataMap");
deviceTypeConfigurationDataMap.setAccessible(true); deviceTypeConfigurationDataMap.setAccessible(true);
deviceTypeConfigurationDataMap.set(deviceTypePluginDeployer, new ConcurrentHashMap()); deviceTypeConfigurationDataMap.set(deviceTypePluginDeployer, new ConcurrentHashMap());
this.initializeCarbonContext(); this.initializeCarbonContext();
} }

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. ~ Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ ~
~ WSO2 Inc. licenses this file to you under the Apache License, ~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except ~ Version 2.0 (the "License"); you may not use this file except

Loading…
Cancel
Save