}
public void testGetReaderWhileWriting() throws Exception
{
DataCacheWriter writer = mResource.getWriter();
String s1 = "1";
String s2 = "2";
String s3 = "3";
String s4 = "4";
writer.write(s1);
writer.write(s2);
DataCacheReader reader1 = mResource.getReader();
Object obj = reader1.read();
assertTrue(obj instanceof String);
assertEquals(s1, (String)obj);
writer.write(s3);
obj = reader1.read();
assertTrue(obj instanceof String);
assertEquals(s2, (String)obj);
obj = reader1.read();
assertTrue(obj instanceof String);
assertEquals(s3, (String)obj);
try
{
reader1.read();
}
catch (NoSuchElementException e)
{
// expected
}
reader1.close();
writer.write(s4);
mResource.releaseWriter();
}