use of com.emc.storageos.coordinator.exceptions.DecodingException in project coprhd-controller by CoprHD.
the class PropertyInfoTest method testEncodeDecode.
@Test
public void testEncodeDecode() {
Map<String, String> map = new HashMap<String, String>();
map.put("node_id", "node2");
map.put("system_connectemc_username", "username");
map.put("version", "");
map.put("twoEquals", "abc==abc==abc");
PropertyInfoExt propertyInfo = new PropertyInfoExt(map);
String encodeStr2 = propertyInfo.encodeAsString();
Assert.assertTrue(encodeStr2.indexOf("node_id") != -1);
Assert.assertTrue(encodeStr2.indexOf("system_connectemc_username") != -1);
Assert.assertTrue(encodeStr2.indexOf("version") != -1);
Assert.assertTrue(encodeStr2.indexOf("twoEquals") != -1);
try {
PropertyInfoExt props = PropertyInfoExt.class.newInstance().decodeFromString(encodeStr2);
Assert.assertTrue(props.getAllProperties().get("system_connectemc_username").equals("username"));
Assert.assertTrue(props.getAllProperties().get("version").equals(""));
Assert.assertTrue(props.getAllProperties().get("twoEquals").equals("abc==abc==abc"));
} catch (DecodingException e) {
Assert.assertTrue(false);
} catch (Exception e) {
Assert.assertTrue(false);
}
PropertyInfoExt propertyInfo1 = new PropertyInfoExt(new String[] { "", "node_id=node2", "system_connectemc_username=username", "multiEquals=a=b=c" });
String encodeStr1 = propertyInfo1.encodeAsString();
char[] chars = encodeStr1.toCharArray();
int len = chars.length;
int count = 0;
for (int i = 0; i < len; i++) {
if (chars[i] == '=') {
count++;
}
}
Assert.assertTrue(count == 5);
}
Aggregations