use of org.eclipse.kura.test.annotation.TestTarget in project kura by eclipse.
the class SystemServiceTest method testGetPrimaryMacAddress.
@TestTarget(targetPlatforms = { TestTarget.PLATFORM_ALL })
@Test
public void testGetPrimaryMacAddress() {
String actual = systemService.getPrimaryMacAddress();
System.out.println("MAC: " + actual);
Pattern regex = Pattern.compile("[0-9a-fA-F:]{12}");
Matcher match = regex.matcher(actual);
assertEquals("getPrimaryMacAddress() length", 17, actual.length());
assertTrue("getPrimaryMacAddress() is string with colons", match.find());
}
use of org.eclipse.kura.test.annotation.TestTarget in project kura by eclipse.
the class XmlUtilTest method testXmlComponentConfigurationsUnmarshalling.
@TestTarget(targetPlatforms = { TestTarget.PLATFORM_ALL })
@Test
public void testXmlComponentConfigurationsUnmarshalling() {
try {
XmlComponentConfigurations xmlComponentConfigurations = getSampleXmlComponentConfigurationsObject();
// test String unmarshalling
String marshalledString = org.eclipse.kura.core.configuration.util.XmlUtil.marshal(xmlComponentConfigurations);
Object unmarshalledObjectFromString = org.eclipse.kura.core.configuration.util.XmlUtil.unmarshal(marshalledString, XmlComponentConfigurations.class);
Assert.assertTrue(String.format(differentInstanceMessage, XmlComponentConfigurations.class, unmarshalledObjectFromString.getClass()), unmarshalledObjectFromString instanceof XmlComponentConfigurations);
XmlComponentConfigurations outputXmlComponentConfigurations = (XmlComponentConfigurations) unmarshalledObjectFromString;
assertValuesForEquality(pid, xmlComponentConfigurations.getConfigurations().get(0).getPid(), outputXmlComponentConfigurations.getConfigurations().get(0).getPid(), false);
assertValuesForEquality(hashmapValues, xmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("int"), outputXmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("int"), false);
assertValuesForEquality(hashmapValues, xmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("long"), outputXmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("long"), false);
assertValuesForEquality(hashmapValues, xmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("string"), outputXmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("string"), false);
assertValuesForEquality(hashmapValues, xmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("boolean"), outputXmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("boolean"), false);
assertValuesForEquality(hashmapValues, xmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("double"), outputXmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("double"), false);
assertValuesForEquality(hashmapValues, xmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("float"), outputXmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("float"), false);
assertValuesForEquality(hashmapValues, xmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("char"), outputXmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("char"), false);
assertValuesForEquality(hashmapValues, xmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("short"), outputXmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("short"), false);
assertValuesForEquality(hashmapValues, xmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("byte"), outputXmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("byte"), false);
// test Reader unmarshalling
Reader marshalledStringReader = new StringReader(marshalledString);
Object unmarshalledObjectFromStringReader = org.eclipse.kura.core.configuration.util.XmlUtil.unmarshal(marshalledStringReader, XmlComponentConfigurations.class);
Assert.assertTrue(String.format(differentInstanceMessage, XmlComponentConfigurations.class, unmarshalledObjectFromStringReader.getClass()), unmarshalledObjectFromStringReader instanceof XmlComponentConfigurations);
outputXmlComponentConfigurations = (XmlComponentConfigurations) unmarshalledObjectFromStringReader;
assertValuesForEquality(pid, xmlComponentConfigurations.getConfigurations().get(0).getPid(), outputXmlComponentConfigurations.getConfigurations().get(0).getPid(), true);
assertValuesForEquality(hashmapValues, xmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("int"), outputXmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("int"), true);
assertValuesForEquality(hashmapValues, xmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("long"), outputXmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("long"), true);
assertValuesForEquality(hashmapValues, xmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("string"), outputXmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("string"), true);
assertValuesForEquality(hashmapValues, xmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("boolean"), outputXmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("boolean"), true);
assertValuesForEquality(hashmapValues, xmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("double"), outputXmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("double"), true);
assertValuesForEquality(hashmapValues, xmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("float"), outputXmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("float"), true);
assertValuesForEquality(hashmapValues, xmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("char"), outputXmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("char"), true);
assertValuesForEquality(hashmapValues, xmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("short"), outputXmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("short"), true);
assertValuesForEquality(hashmapValues, xmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("byte"), outputXmlComponentConfigurations.getConfigurations().get(0).getConfigurationProperties().get("byte"), true);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.eclipse.kura.test.annotation.TestTarget in project kura by eclipse.
the class XmlUtilTest method testXmlDeploymentPackagesMarshalling.
@TestTarget(targetPlatforms = { TestTarget.PLATFORM_ALL })
@Test
public void testXmlDeploymentPackagesMarshalling() {
try {
XmlDeploymentPackages xmlDeploymentPackages = getSampleXmlDeploymentPackagesObject();
String marshalledString = XmlUtil.marshal(xmlDeploymentPackages);
Assert.assertTrue(String.format(missingItemsMessage, xmlDeploymentPackages.getDeploymentPackages()[0].getName()), marshalledString.contains(xmlDeploymentPackages.getDeploymentPackages()[0].getName()));
Assert.assertTrue(String.format(missingItemsMessage, xmlDeploymentPackages.getDeploymentPackages()[0].getVersion()), marshalledString.contains(xmlDeploymentPackages.getDeploymentPackages()[0].getVersion()));
Assert.assertTrue(String.format(missingItemsMessage, xmlDeploymentPackages.getDeploymentPackages()[0].getBundleInfos()[0].getName()), marshalledString.contains(xmlDeploymentPackages.getDeploymentPackages()[0].getBundleInfos()[0].getName()));
Assert.assertTrue(String.format(missingItemsMessage, xmlDeploymentPackages.getDeploymentPackages()[0].getBundleInfos()[0].getVersion()), marshalledString.contains(xmlDeploymentPackages.getDeploymentPackages()[0].getBundleInfos()[0].getVersion()));
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.eclipse.kura.test.annotation.TestTarget in project kura by eclipse.
the class XmlUtilTest method testXmlSnapshotIdResultMarshalling.
@TestTarget(targetPlatforms = { TestTarget.PLATFORM_ALL })
@Test
public void testXmlSnapshotIdResultMarshalling() {
try {
XmlSnapshotIdResult xmlSnapshotIdResult = getSampleXmlSnapshotIdResultObject();
String marshalledString = org.eclipse.kura.core.configuration.util.XmlUtil.marshal(xmlSnapshotIdResult);
for (Long value : xmlSnapshotIdResult.getSnapshotIds()) {
Assert.assertTrue(String.format(missingItemsMessage, value), marshalledString.contains(Long.toString(value)));
}
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.eclipse.kura.test.annotation.TestTarget in project kura by eclipse.
the class CloudDeploymentHandlerTest method testGetPackages.
@TestTarget(targetPlatforms = { TestTarget.PLATFORM_ALL })
@Test
@Ignore
public void testGetPackages() throws Exception {
assertTrue(s_cloudCallService.isConnected());
DeploymentPackage dp = s_deploymentAdmin.getDeploymentPackage(LOCAL_DP_NAME);
if (dp == null) {
s_logger.warn("Getting dp");
InputStream is = getTestDpUrl().openStream();
dp = s_deploymentAdmin.installDeploymentPackage(is);
}
StringBuilder sb = new StringBuilder(CloudletTopic.Method.GET.toString()).append("/").append(CloudDeploymentHandlerV2.RESOURCE_PACKAGES);
KuraResponsePayload resp = s_cloudCallService.call(CloudDeploymentHandlerV2.APP_ID, sb.toString(), null, 5000);
assertEquals(KuraResponsePayload.RESPONSE_CODE_OK, resp.getResponseCode());
String s = new String(resp.getBody());
// XmlDeploymentPackages xmlPackages = XmlUtil.unmarshal(s, XmlDeploymentPackages.class);
XmlDeploymentPackages xmlPackages = CoreTestXmlUtil.unmarshal(s, XmlDeploymentPackages.class);
XmlDeploymentPackage[] packages = xmlPackages.getDeploymentPackages();
XmlDeploymentPackage xmlDp = null;
if (packages != null) {
for (int i = 0; i < packages.length; i++) {
if (packages[i].getName().equals(LOCAL_DP_NAME)) {
xmlDp = packages[i];
break;
}
}
}
assertNotNull(xmlDp);
assertEquals(LOCAL_DP_VERSION, xmlDp.getVersion());
XmlBundleInfo[] bundleInfos = xmlDp.getBundleInfos();
assertEquals(1, bundleInfos.length);
assertEquals(LOCAL_BUNDLE_NAME, bundleInfos[0].getName());
assertEquals(LOCAL_BUNDLE_VERSION, bundleInfos[0].getVersion());
}
Aggregations