use of org.apache.geode.internal.ByteArrayData in project geode by apache.
the class StartupMessageDataJUnitTest method testToDataWithNullHostedLocators.
@Test
public void testToDataWithNullHostedLocators() throws Exception {
Collection<String> hostedLocators = null;
StartupMessageData data = new StartupMessageData();
data.writeHostedLocators(hostedLocators);
ByteArrayData testStream = new ByteArrayData();
assertTrue(testStream.isEmpty());
DataOutputStream out = testStream.getDataOutput();
data.writeTo(out);
assertTrue(testStream.size() > 0);
DataInput in = testStream.getDataInput();
Properties props = (Properties) DataSerializer.readObject(in);
assertNull(props);
}
use of org.apache.geode.internal.ByteArrayData in project geode by apache.
the class StartupMessageDataJUnitTest method testToDataWithThreeHostedLocators.
@Test
public void testToDataWithThreeHostedLocators() throws Exception {
String[] locatorStrings = createManyLocatorStrings(3);
List<String> hostedLocators = new ArrayList<String>();
for (int i = 0; i < 3; i++) {
hostedLocators.add(locatorStrings[i]);
}
StartupMessageData data = new StartupMessageData();
data.writeHostedLocators(hostedLocators);
ByteArrayData testStream = new ByteArrayData();
assertTrue(testStream.isEmpty());
DataOutputStream out = testStream.getDataOutput();
data.writeTo(out);
assertTrue(testStream.size() > 0);
DataInput in = testStream.getDataInput();
Properties props = (Properties) DataSerializer.readObject(in);
assertNotNull(props);
String hostedLocatorsString = props.getProperty(StartupMessageData.HOSTED_LOCATORS);
assertNotNull(hostedLocatorsString);
Collection<String> actualLocatorStrings = new ArrayList<String>(1);
StringTokenizer st = new StringTokenizer(hostedLocatorsString, StartupMessageData.COMMA_DELIMITER);
while (st.hasMoreTokens()) {
actualLocatorStrings.add(st.nextToken());
}
assertEquals(3, actualLocatorStrings.size());
int i = 0;
for (String actualLocatorString : actualLocatorStrings) {
assertEquals(locatorStrings[i], actualLocatorString);
i++;
}
}
use of org.apache.geode.internal.ByteArrayData in project geode by apache.
the class StartupMessageDataJUnitTest method testToDataWithEmptyHostedLocators.
@Test
public void testToDataWithEmptyHostedLocators() throws Exception {
Collection<String> hostedLocators = new ArrayList<String>();
StartupMessageData data = new StartupMessageData();
data.writeHostedLocators(hostedLocators);
ByteArrayData testStream = new ByteArrayData();
assertTrue(testStream.isEmpty());
DataOutputStream out = testStream.getDataOutput();
data.writeTo(out);
assertTrue(testStream.size() > 0);
DataInput in = testStream.getDataInput();
Properties props = (Properties) DataSerializer.readObject(in);
assertNull(props);
}
use of org.apache.geode.internal.ByteArrayData in project geode by apache.
the class StartupMessageDataJUnitTest method testToDataWithOneHostedLocator.
@Test
public void testToDataWithOneHostedLocator() throws Exception {
String locatorString = createOneLocatorString();
List<String> hostedLocators = new ArrayList<String>();
hostedLocators.add(locatorString);
StartupMessageData data = new StartupMessageData();
data.writeHostedLocators(hostedLocators);
ByteArrayData testStream = new ByteArrayData();
assertTrue(testStream.isEmpty());
DataOutputStream out = testStream.getDataOutput();
data.writeTo(out);
assertTrue(testStream.size() > 0);
DataInput in = testStream.getDataInput();
Properties props = (Properties) DataSerializer.readObject(in);
assertNotNull(props);
String hostedLocatorsString = props.getProperty(StartupMessageData.HOSTED_LOCATORS);
assertNotNull(hostedLocatorsString);
assertEquals(locatorString, hostedLocatorsString);
}
use of org.apache.geode.internal.ByteArrayData in project geode by apache.
the class StartupMessageDataJUnitTest method getDataInputWithOneHostedLocator.
private DataInput getDataInputWithOneHostedLocator(String locatorString) throws Exception {
List<String> hostedLocators = new ArrayList<String>();
if (locatorString != null) {
hostedLocators.add(locatorString);
}
StartupMessageData dataToWrite = new StartupMessageData();
dataToWrite.writeHostedLocators(hostedLocators);
ByteArrayData testStream = new ByteArrayData();
assertTrue(testStream.isEmpty());
DataOutputStream out = testStream.getDataOutput();
dataToWrite.writeTo(out);
assertTrue(testStream.size() > 0);
DataInput in = testStream.getDataInput();
assertNotNull(in);
return in;
}
Aggregations