|
|
|
@ -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;
|
|
|
|
|
|
|
|
|
|
import org.apache.axis2.deployment.DeploymentException;
|
|
|
|
@ -16,32 +34,31 @@ import java.lang.reflect.Field;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Unit tests for DeviceTypePluginDeployer
|
|
|
|
|
*/
|
|
|
|
|
public class DeviceTypePluginDeployerTest {
|
|
|
|
|
|
|
|
|
|
private DeviceTypePluginDeployer deviceTypePluginDeployer;
|
|
|
|
|
private DeploymentFileData deploymentFileData;
|
|
|
|
|
|
|
|
|
|
private Field deviceTypeServiceRegistrations = null;
|
|
|
|
|
private Field deviceTypeConfigurationDataMap = null;
|
|
|
|
|
private ServiceRegistration serviceRegistration = null;
|
|
|
|
|
|
|
|
|
|
@BeforeClass
|
|
|
|
|
public void init() throws Exception {
|
|
|
|
|
public void init() throws NoSuchFieldException, IllegalAccessException, IOException, RegistryException {
|
|
|
|
|
deviceTypePluginDeployer = Mockito.mock(DeviceTypePluginDeployer.class, Mockito.CALLS_REAL_METHODS);
|
|
|
|
|
serviceRegistration = Mockito.mock(ServiceRegistration.class, Mockito.CALLS_REAL_METHODS);
|
|
|
|
|
Mockito.doReturn(serviceRegistration).when(deviceTypePluginDeployer).registerDeviceType(Mockito.any(),
|
|
|
|
|
Mockito.any());
|
|
|
|
|
|
|
|
|
|
deviceTypeServiceRegistrations = DeviceTypePluginDeployer.class.getDeclaredField
|
|
|
|
|
("deviceTypeServiceRegistrations");
|
|
|
|
|
deviceTypeServiceRegistrations.setAccessible(true);
|
|
|
|
|
deviceTypeServiceRegistrations.set(deviceTypePluginDeployer, new ConcurrentHashMap());
|
|
|
|
|
|
|
|
|
|
deviceTypeConfigurationDataMap = DeviceTypePluginDeployer.class.getDeclaredField
|
|
|
|
|
("deviceTypeConfigurationDataMap");
|
|
|
|
|
deviceTypeConfigurationDataMap.setAccessible(true);
|
|
|
|
|
deviceTypeConfigurationDataMap.set(deviceTypePluginDeployer, new ConcurrentHashMap());
|
|
|
|
|
|
|
|
|
|
this.initializeCarbonContext();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|