test/java/fr/jayasoft/ivy/repository/vfs/VfsRepositoryTest.java
/**
	 * Test the retrieval of an artifact from the repository overwriting an existing artifact
	 * 
	 * @throws Exception
	 */
Test the retrieval of an artifact from the repository overwriting an existing artifact

@throws Exception
Test the retrieval of an artifact from the repository overwriting an existing artifact @throws Exception
public void testGetOverwriteExisting() throws Exception {
		String testResource = VfsTestHelper.TEST_IVY_XML;
		File testFile = new File( FileUtil.concat(scratchDir.getAbsolutePath(), 
				                                           testResource));
		Iterator vfsURIs = helper.createVFSUriSet(testResource).iterator();
		while (vfsURIs.hasNext()) {
			VfsURI vfsURI = (VfsURI) vfsURIs.next();
			if (scratchDir.exists()) {
				FileUtil.forceDelete(scratchDir);
			}
            testFile.getParentFile().mkdirs();
			testFile.createNewFile();
			try {
				repo.get(vfsURI.toString(), testFile);
				if (! testFile.exists()) {
					fail("Expected file: " + testFile + "not found. Failed vfsURI: " + vfsURI.toString());
				}
				if (testFile.length() == 0) {
					fail("Zero file size indicates file not overwritten");
				}
			} catch (IOException e) {
				fail("Caught unexpected IOException on Vfs URI: " + vfsURI.toString() + "\n" + e.getLocalizedMessage());
			}
		}
	}
public void testGetOverwriteExisting ( ) throws Exception { String testResource = VfsTestHelper . TEST_IVY_XML ; File testFile = new File ( FileUtil . concat ( scratchDir . getAbsolutePath ( ) , testResource ) ) ; Iterator vfsURIs = helper . createVFSUriSet ( testResource ) . iterator ( ) ; while ( vfsURIs . hasNext ( ) ) { VfsURI vfsURI = ( VfsURI ) vfsURIs . next ( ) ; if ( scratchDir . exists ( ) ) { FileUtil . forceDelete ( scratchDir ) ; } testFile . getParentFile ( ) . mkdirs ( ) ; testFile . createNewFile ( ) ; try { repo . get ( vfsURI . toString ( ) , testFile ) ; if ( ! testFile . exists ( ) ) { fail ( "Expected file: " + testFile + "not found. Failed vfsURI: " + vfsURI . toString ( ) ) ; } if ( testFile . length ( ) == 0 ) { fail ( "Zero file size indicates file not overwritten" ) ; } } catch ( IOException e ) { fail ( "Caught unexpected IOException on Vfs URI: " + vfsURI . toString ( ) + "\n" + e . getLocalizedMessage ( ) ) ; } } }
Test the retrieval of an artifact from the repository overwriting an existing artifact
Test the retrieval of an artifact from the repository overwriting an existing artifact
// setup - remove existing scratch area and populate with a file to override