use of com.android.internal.util.FileRotator.Writer in project platform_frameworks_base by android.
the class FileRotatorTest method testThrowRestoresBackup.
public void testThrowRestoresBackup() throws Exception {
final FileRotator rotate = new FileRotator(mBasePath, PREFIX, MINUTE_IN_MILLIS, DAY_IN_MILLIS);
final RecordingReader reader = new RecordingReader();
long currentTime = TEST_TIME;
// first, write some valid data
rotate.combineActive(reader, writer("foo"), currentTime);
reader.assertRead();
assertReadAll(rotate, "foo");
try {
// now, try writing which will throw
reader.reset();
rotate.combineActive(reader, new Writer() {
public void write(OutputStream out) throws IOException {
new DataOutputStream(out).writeUTF("bar");
throw new NullPointerException("yikes");
}
}, currentTime);
fail("woah, somehow able to write exception");
} catch (IOException e) {
// expected from above
}
// assert that we read original data, and that it's still intact after
// the failed write above.
reader.assertRead("foo");
assertReadAll(rotate, "foo");
}
use of com.android.internal.util.FileRotator.Writer in project android_frameworks_base by ParanoidAndroid.
the class FileRotatorTest method testThrowRestoresBackup.
public void testThrowRestoresBackup() throws Exception {
final FileRotator rotate = new FileRotator(mBasePath, PREFIX, MINUTE_IN_MILLIS, DAY_IN_MILLIS);
final RecordingReader reader = new RecordingReader();
long currentTime = TEST_TIME;
// first, write some valid data
rotate.combineActive(reader, writer("foo"), currentTime);
reader.assertRead();
assertReadAll(rotate, "foo");
try {
// now, try writing which will throw
reader.reset();
rotate.combineActive(reader, new Writer() {
public void write(OutputStream out) throws IOException {
new DataOutputStream(out).writeUTF("bar");
throw new NullPointerException("yikes");
}
}, currentTime);
fail("woah, somehow able to write exception");
} catch (IOException e) {
// expected from above
}
// assert that we read original data, and that it's still intact after
// the failed write above.
reader.assertRead("foo");
assertReadAll(rotate, "foo");
}
use of com.android.internal.util.FileRotator.Writer in project android_frameworks_base by DirtyUnicorns.
the class FileRotatorTest method testThrowRestoresBackup.
public void testThrowRestoresBackup() throws Exception {
final FileRotator rotate = new FileRotator(mBasePath, PREFIX, MINUTE_IN_MILLIS, DAY_IN_MILLIS);
final RecordingReader reader = new RecordingReader();
long currentTime = TEST_TIME;
// first, write some valid data
rotate.combineActive(reader, writer("foo"), currentTime);
reader.assertRead();
assertReadAll(rotate, "foo");
try {
// now, try writing which will throw
reader.reset();
rotate.combineActive(reader, new Writer() {
public void write(OutputStream out) throws IOException {
new DataOutputStream(out).writeUTF("bar");
throw new NullPointerException("yikes");
}
}, currentTime);
fail("woah, somehow able to write exception");
} catch (IOException e) {
// expected from above
}
// assert that we read original data, and that it's still intact after
// the failed write above.
reader.assertRead("foo");
assertReadAll(rotate, "foo");
}
use of com.android.internal.util.FileRotator.Writer in project android_frameworks_base by AOSPA.
the class FileRotatorTest method testThrowRestoresBackup.
public void testThrowRestoresBackup() throws Exception {
final FileRotator rotate = new FileRotator(mBasePath, PREFIX, MINUTE_IN_MILLIS, DAY_IN_MILLIS);
final RecordingReader reader = new RecordingReader();
long currentTime = TEST_TIME;
// first, write some valid data
rotate.combineActive(reader, writer("foo"), currentTime);
reader.assertRead();
assertReadAll(rotate, "foo");
try {
// now, try writing which will throw
reader.reset();
rotate.combineActive(reader, new Writer() {
public void write(OutputStream out) throws IOException {
new DataOutputStream(out).writeUTF("bar");
throw new NullPointerException("yikes");
}
}, currentTime);
fail("woah, somehow able to write exception");
} catch (IOException e) {
// expected from above
}
// assert that we read original data, and that it's still intact after
// the failed write above.
reader.assertRead("foo");
assertReadAll(rotate, "foo");
}
use of com.android.internal.util.FileRotator.Writer in project android_frameworks_base by ResurrectionRemix.
the class FileRotatorTest method testThrowRestoresBackup.
public void testThrowRestoresBackup() throws Exception {
final FileRotator rotate = new FileRotator(mBasePath, PREFIX, MINUTE_IN_MILLIS, DAY_IN_MILLIS);
final RecordingReader reader = new RecordingReader();
long currentTime = TEST_TIME;
// first, write some valid data
rotate.combineActive(reader, writer("foo"), currentTime);
reader.assertRead();
assertReadAll(rotate, "foo");
try {
// now, try writing which will throw
reader.reset();
rotate.combineActive(reader, new Writer() {
public void write(OutputStream out) throws IOException {
new DataOutputStream(out).writeUTF("bar");
throw new NullPointerException("yikes");
}
}, currentTime);
fail("woah, somehow able to write exception");
} catch (IOException e) {
// expected from above
}
// assert that we read original data, and that it's still intact after
// the failed write above.
reader.assertRead("foo");
assertReadAll(rotate, "foo");
}
Aggregations