assertTrue(file1.exists() && file2.exists() && !file3.exists());
assertTrue(file1.exists()); assertTrue(file2.exists()); assertTrue(!file3.exists());
	public void testReliableFile() {		String fileName = "testReliableFile.txt";		File file1 = new File(base, fileName+".1");		File file2 = new File(base, fileName+".2");		File file3 = new File(base, fileName+".3");		String contents1 = "test reliable file cOntents #1";		String contents2 = "test reliable file cOntents #2";		try {			manager1 = new FileManager(base, null);			StreamManager stream1 = new StreamManager(manager1);			stream1.setUseReliableFiles(true); // force reliable files			manager1.open(true);			StreamManagerOutputStream fmos = stream1.getOutputStream(fileName);			assertNotNull(fmos);			fmos.write(contents1.getBytes());			fmos.close();						// Write verion2 of the file			fmos = stream1.getOutputStream(fileName);			assertNotNull(fmos);			fmos.write(contents2.getBytes());			fmos.close();			assertTrue(file1.exists() && file2.exists() && !file3.exists());			manager1.close();			manager1 = null;			stream1 = null;						//now, open new manager, verify file contents are #2			manager2 = new FileManager(base, null);			StreamManager stream2 = new StreamManager(manager2);			stream2.setUseReliableFiles(true);			manager2.open(true);			InputStream is = stream2.getInputStream(fileName);			assertNotNull(is);			assertEquals(contents2, getInputStreamContents(is));			manager2.close();			manager2 = null;			stream2 = null;						// need to sleep, FAT32 doesn't have too fine granularity in timestamps			try {				Thread.sleep(5000);			} catch(InterruptedException e) {/*ignore*/}			//now, corrupt version 2 of the file			RandomAccessFile raf = new RandomAccessFile(file2, "rw");			raf.seek(20);			raf.write('0'); // change 'O' to '0'			raf.close();						manager1 = new FileManager(base, null);			stream1 = new StreamManager(manager1);			stream1.setUseReliableFiles(true);			manager1.open(true);						//request any valid stream available			is = stream1.getInputStream(fileName);			assertNotNull(is);			assertEquals(contents1, getInputStreamContents(is));						//now request only the primary file			try {				is = stream1.getInputStream(fileName, StreamManager.OPEN_FAIL_ON_PRIMARY);				is.close();				fail("getInputStream was successful");			} catch(IOException e) {				//good			}						//now, corrupt version 1 of the file			raf = new RandomAccessFile(file1, "rw");			raf.seek(20);			raf.write('0'); // change 'O' to '0'			raf.close();						// get input stream should fail			try {				is = stream1.getInputStream(fileName);				fail("get input stream succedded");			} catch(IOException e) {				//good			}			manager1.close();			manager1 = null;			stream1 = null;		} catch(IOException e) {			e.printStackTrace();			fail(e.getMessage());		}	}