@Test public void testTemporalDirectory$vmConfig$happyPath() throws Exception { final AtomicBoolean valid=new AtomicBoolean(false); final AtomicInteger tries=new AtomicInteger(0); final AtomicBoolean fallback=new AtomicBoolean(false); final AtomicReference<File> result=new AtomicReference<File>(null); new MockUp<Files>() { @Mock void createParentDirs(File file) throws IOException { tries.incrementAndGet(); File parentFile = file.getParentFile(); String path = parentFile.getPath(); valid.set(path.startsWith(dirName(System.getProperty("java.io.tmpdir"),"ldp4j","ctx","context"))); result.set(parentFile); } @Mock File createTempDir() { fallback.set(true); return null; } }; assertThat(Deployment.newInstance().withContextPath(CONTEXT).temporalDirectory(),equalTo(result.get())); assertThat(valid.get(),equalTo(true)); assertThat(tries.get(),equalTo(1)); assertThat(fallback.get(),equalTo(false)); }
File temporalDirectory() { if(this.temporalDirectory==null) { String ctx=this.contextPath.substring(1); File result=null; for(TemporalDirectoryFactory factory:FACTORIES) { result=factory.create(ctx); if(result!=null) { break; } } if(result==null) { result=Files.createTempDir(); } this.temporalDirectory=result; } return this.temporalDirectory; }
Deployment { File temporalDirectory() { if(this.temporalDirectory==null) { String ctx=this.contextPath.substring(1); File result=null; for(TemporalDirectoryFactory factory:FACTORIES) { result=factory.create(ctx); if(result!=null) { break; } } if(result==null) { result=Files.createTempDir(); } this.temporalDirectory=result; } return this.temporalDirectory; } }
Deployment { File temporalDirectory() { if(this.temporalDirectory==null) { String ctx=this.contextPath.substring(1); File result=null; for(TemporalDirectoryFactory factory:FACTORIES) { result=factory.create(ctx); if(result!=null) { break; } } if(result==null) { result=Files.createTempDir(); } this.temporalDirectory=result; } return this.temporalDirectory; } private  Deployment(String contextPath, File temporalDirectory); }
Deployment { File temporalDirectory() { if(this.temporalDirectory==null) { String ctx=this.contextPath.substring(1); File result=null; for(TemporalDirectoryFactory factory:FACTORIES) { result=factory.create(ctx); if(result!=null) { break; } } if(result==null) { result=Files.createTempDir(); } this.temporalDirectory=result; } return this.temporalDirectory; } private  Deployment(String contextPath, File temporalDirectory);  }
Deployment { File temporalDirectory() { if(this.temporalDirectory==null) { String ctx=this.contextPath.substring(1); File result=null; for(TemporalDirectoryFactory factory:FACTORIES) { result=factory.create(ctx); if(result!=null) { break; } } if(result==null) { result=Files.createTempDir(); } this.temporalDirectory=result; } return this.temporalDirectory; } private  Deployment(String contextPath, File temporalDirectory);   }