[ 
https://issues.apache.org/jira/browse/GEODE-9178?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kirk Lund updated GEODE-9178:
-----------------------------
    Component/s: tests

> ClassPathLoaderTest > testZeroLengthFile intermittently fails and touches 
> filesystem
> ------------------------------------------------------------------------------------
>
>                 Key: GEODE-9178
>                 URL: https://issues.apache.org/jira/browse/GEODE-9178
>             Project: Geode
>          Issue Type: Bug
>          Components: tests
>            Reporter: Kirk Lund
>            Priority: Major
>
> PR failure: https://concourse.apachegeode-ci.info/builds/27301
> {noformat}
> > Task :geode-core:test
> org.apache.geode.internal.classloader.ClassPathLoaderTest > 
> testZeroLengthFile FAILED
>     java.lang.AssertionError: 
>     Expecting actual throwable to be an instance of:
>       java.lang.IllegalArgumentException
>     but was:
>       java.lang.NullPointerException
>       at java.io.File.<init>(File.java:365)
>       at 
> org.apache.geode.deployment.internal.JarDeployer.getNextVersionedJarFile(JarDeployer.java:101)
>       at 
> org.apache.geode.deployment.internal.JarDeployer.deployWithoutRegistering(JarDeployer.java:84)
>       ...(59 remaining lines not displayed - this can be changed with 
> Assertions.setMaxStackTraceElementsDisplayed)
>         at 
> org.apache.geode.internal.classloader.ClassPathLoaderTest.testZeroLengthFile(ClassPathLoaderTest.java:109)
> {noformat}
> ClassPathLoaderTest also uses TemporaryFolder and uses the filesystem which 
> does not belong in a "Unit Test":
> {noformat}
>   @Test
>   public void testZeroLengthFile() throws IOException {
>     File zeroFile = tempFolder.newFile("JarDeployerDUnitZLF.jar");
>     zeroFile.createNewFile();
>     JarDeploymentService jarDeploymentService =
>         JarDeploymentServiceFactory.getJarDeploymentServiceInstance();
>     assertThatThrownBy(() -> {
>       Deployment deployment =
>           new Deployment("JarDeployerDUnitZLF.jar", "test", 
> Instant.now().toString());
>       deployment.setFile(zeroFile);
>       jarDeploymentService.deploy(
>           deployment);
>     }).isInstanceOf(IllegalArgumentException.class);
>     byte[] validBytes = new 
> ClassBuilder().createJarFromName("JarDeployerDUnitZLF1");
>     File validFile = tempFolder.newFile("JarDeployerDUnitZLF1.jar");
>     IOUtils.copy(new ByteArrayInputStream(validBytes), new 
> FileOutputStream(validFile));
>     Set<File> files = new HashSet<>();
>     files.add(validFile);
>     files.add(zeroFile);
>     assertThatThrownBy(() -> {
>       for (File file : files) {
>         Deployment deployment = new Deployment(file.getName(), "test", 
> Instant.now().toString());
>         deployment.setFile(file);
>         jarDeploymentService.deploy(deployment);
>       }
>     }).isInstanceOf(IllegalArgumentException.class);
>     // clean up the deployed files
>     jarDeploymentService.listDeployed()
>         .forEach(deployment -> jarDeploymentService
>             .undeployByDeploymentName(deployment.getDeploymentName()));
>   }
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to