Unit tests for the reader portion of RemovableDrivePlugin.

This commit is contained in:
akwizgran
2011-10-05 16:39:20 +01:00
parent f6df333796
commit 9464e29d75
3 changed files with 161 additions and 2 deletions

View File

@@ -28,7 +28,8 @@ abstract class FilePlugin implements BatchTransportPlugin {
protected Map<ContactId, Map<String, String>> remoteProperties = null;
protected Map<String, String> config = null;
protected BatchTransportCallback callback = null;
private boolean started = false;
private volatile boolean started = false;
protected abstract File chooseOutputDirectory();
protected abstract void writerFinished(File f);
@@ -117,6 +118,7 @@ abstract class FilePlugin implements BatchTransportPlugin {
}
protected void createReaderFromFile(File f) {
if(!started) throw new IllegalStateException();
if(!isPossibleConnectionFilename(f.getName())) return;
if(f.length() < TransportConstants.MIN_CONNECTION_LENGTH) return;
try {
@@ -128,6 +130,11 @@ abstract class FilePlugin implements BatchTransportPlugin {
if(read == -1) break;
offset += read;
}
if(offset < iv.length) {
// The file was truncated
in.close();
return;
}
ContactId c = recogniser.acceptConnection(iv);
if(c == null) {
// Nobody there

View File

@@ -11,6 +11,6 @@ interface RemovableDriveMonitor {
interface Callback {
void driveInserted(File f);
void driveInserted(File root);
}
}