Permalink
Browse files

fixed test issue with java 7

  • Loading branch information...
1 parent e8e1b5a commit d60cce4ddd80016410ab59f4fa811f3fb26ae73b @ddossot ddossot committed Nov 2, 2013
Showing with 11 additions and 17 deletions.
  1. +1 −1 pom.xml
  2. +10 −16 src/test/java/eu/openanalytics/rsb/component/DirectoryDepositHandlerTestCase.java
View
@@ -398,7 +398,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
+ <version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
@@ -30,11 +30,11 @@
import java.io.File;
import java.io.IOException;
import java.io.Serializable;
-import java.net.URL;
import java.net.UnknownHostException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import java.util.UUID;
import org.apache.commons.io.FileUtils;
import org.junit.Before;
@@ -94,21 +94,13 @@ public void closeChannelAdapters()
@Test
public void handleZipJob() throws Exception
{
- final URL jobSample = Thread.currentThread()
- .getContextClassLoader()
- .getResource("data/r-job-sample.zip");
-
- final File jobParentFile = mock(File.class);
- when(jobParentFile.getParentFile()).thenReturn(FileUtils.getTempDirectory());
-
- final File zipJobFile = mock(File.class);
- when(zipJobFile.getParentFile()).thenReturn(jobParentFile);
- when(zipJobFile.getName()).thenReturn("fake");
- when(zipJobFile.exists()).thenReturn(true);
- when(zipJobFile.getCanonicalPath()).thenReturn("fake_path");
- when(zipJobFile.length()).thenReturn(FileUtils.sizeOf(new File(jobSample.toURI())));
- when(zipJobFile.getPath()).thenReturn(jobSample.getPath());
- when(zipJobFile.delete()).thenReturn(true);
+ final File jobParentFile = new File(FileUtils.getTempDirectory(), UUID.randomUUID().toString());
+ FileUtils.forceMkdir(jobParentFile);
+
+ final File zipJobFile = File.createTempFile("test-", ".zip", jobParentFile);
+ FileUtils.copyInputStreamToFile(
+ Thread.currentThread().getContextClassLoader().getResourceAsStream("data/r-job-sample.zip"),
+ zipJobFile);
final DepositDirectoryConfiguration depositRootDirectoryConfig = mock(DepositDirectoryConfiguration.class);
when(depositRootDirectoryConfig.getApplicationName()).thenReturn(TEST_APPLICATION_NAME);
@@ -132,6 +124,8 @@ public void handleZipJob() throws Exception
assertThat(job.getMeta().containsKey(DirectoryDepositHandler.ORIGINAL_FILENAME_META_NAME), is(true));
assertThat(job.getSource(), is(Source.DIRECTORY));
job.destroy();
+
+ FileUtils.forceDelete(jobParentFile);
}
@Test

0 comments on commit d60cce4

Please sign in to comment.