forked from community/device-mgt-core
parent
a0f1d13964
commit
13f6bc602d
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* 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.template;
|
||||
|
||||
import org.testng.annotations.BeforeSuite;
|
||||
import org.wso2.carbon.CarbonConstants;
|
||||
import org.wso2.carbon.base.MultitenantConstants;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.context.RegistryType;
|
||||
import org.wso2.carbon.context.internal.OSGiDataHolder;
|
||||
import org.wso2.carbon.device.mgt.extensions.internal.DeviceTypeExtensionDataHolder;
|
||||
import org.wso2.carbon.device.mgt.extensions.utils.Utils;
|
||||
import org.wso2.carbon.governance.api.util.GovernanceArtifactConfiguration;
|
||||
import org.wso2.carbon.governance.api.util.GovernanceUtils;
|
||||
import org.wso2.carbon.registry.core.Registry;
|
||||
import org.wso2.carbon.registry.core.exceptions.RegistryException;
|
||||
import org.wso2.carbon.registry.core.service.RegistryService;
|
||||
import org.wso2.carbon.registry.core.session.UserRegistry;
|
||||
import org.wso2.carbon.utils.FileUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.wso2.carbon.governance.api.util.GovernanceUtils.getGovernanceArtifactConfiguration;
|
||||
|
||||
/**
|
||||
* This class handles all the setup that need to be done before starting to run the test cases.
|
||||
*/
|
||||
public class BaseExtensionsTest {
|
||||
|
||||
@BeforeSuite
|
||||
public void init() throws RegistryException, IOException {
|
||||
ClassLoader classLoader = getClass().getClassLoader();
|
||||
URL resourceUrl = classLoader.getResource("license.rxt");
|
||||
String rxt = null;
|
||||
File carbonHome;
|
||||
if (resourceUrl != null) {
|
||||
rxt = FileUtil.readFileToString(resourceUrl.getFile());
|
||||
}
|
||||
resourceUrl = classLoader.getResource("carbon-home");
|
||||
|
||||
if (resourceUrl != null) {
|
||||
carbonHome = new File(resourceUrl.getFile());
|
||||
System.setProperty("carbon.home", carbonHome.getAbsolutePath());
|
||||
}
|
||||
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext()
|
||||
.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID);
|
||||
RegistryService registryService = Utils.getRegistryService();
|
||||
OSGiDataHolder.getInstance().setRegistryService(registryService);
|
||||
UserRegistry systemRegistry =
|
||||
registryService.getRegistry(CarbonConstants.REGISTRY_SYSTEM_USERNAME);
|
||||
|
||||
GovernanceArtifactConfiguration configuration = getGovernanceArtifactConfiguration(rxt);
|
||||
List<GovernanceArtifactConfiguration> configurations = new ArrayList<>();
|
||||
configurations.add(configuration);
|
||||
GovernanceUtils.loadGovernanceArtifacts(systemRegistry, configurations);
|
||||
Registry governanceSystemRegistry = registryService.getConfigSystemRegistry();
|
||||
DeviceTypeExtensionDataHolder.getInstance().setRegistryService(registryService);
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext()
|
||||
.setRegistry(RegistryType.SYSTEM_CONFIGURATION, governanceSystemRegistry);
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
<DeviceTypeConfiguration name="android_sense">
|
||||
<Features>
|
||||
<Feature code="keywords">
|
||||
<Name>Add Keywords</Name>
|
||||
<Description>Send keywords to the device</Description>
|
||||
<!--<Operation context="/android_sense/device/{deviceId}/words" method="POST">-->
|
||||
<!--<QueryParameters>-->
|
||||
<!--<Parameter>keywords</Parameter>-->
|
||||
<!--</QueryParameters>-->
|
||||
<!--</Operation>-->
|
||||
</Feature>
|
||||
<Feature code="threshold">
|
||||
<Name>Add Threshold</Name>
|
||||
<Description>Send Threshold to the device</Description>
|
||||
<!--<Operation context="/android_sense/device/{deviceId}/words/threshold" method="POST">-->
|
||||
<!--<QueryParameters>-->
|
||||
<!--<Parameter>threshold</Parameter>-->
|
||||
<!--</QueryParameters>-->
|
||||
<!--</Operation>-->
|
||||
</Feature>
|
||||
<Feature code="remove_words">
|
||||
<Name>Remove words</Name>
|
||||
<Description>Remove Threshold from the device</Description>
|
||||
<!--<Operation context="/android_sense/device/{deviceId}/words" method="DELETE">-->
|
||||
<!--<QueryParameters>-->
|
||||
<!--<Parameter>words</Parameter>-->
|
||||
<!--</QueryParameters>-->
|
||||
<!--</Operation>-->
|
||||
</Feature>
|
||||
</Features>
|
||||
|
||||
<ProvisioningConfig>
|
||||
<SharedWithAllTenants>true</SharedWithAllTenants>
|
||||
</ProvisioningConfig>
|
||||
|
||||
<PushNotificationProviderConfig type="MQTT">
|
||||
<FileBasedProperties>true</FileBasedProperties>
|
||||
</PushNotificationProviderConfig>
|
||||
|
||||
<License>
|
||||
<Language>en_US</Language>
|
||||
<Version>1.0.0</Version>
|
||||
<Text>This is license text</Text>
|
||||
</License>
|
||||
|
||||
</DeviceTypeConfiguration>
|
Loading…
Reference in new issue