TemporaryJDBC { public String getTemporaryDerbyJDBC() throws IOException { File tmpDir = createTempFile("t2platform-", ".db"); tmpDir.delete(); if (!tmpDir.mkdir()) throw new IOException("Could not create temporary directory " + tmpDir); return "jdbc:derby:" + tmpDir.getPath() + "/database;create=true"; }  String getTemporaryDerbyJDBC();  }
@Test public void getDerby() throws Exception { TemporaryJDBC temporaryJDBC = new TemporaryJDBC(); String jdbcURL = temporaryJDBC.getTemporaryDerbyJDBC(); assertTrue("Not a Derby URL", jdbcURL.startsWith(JDBC_DERBY)); String url = jdbcURL.split(JDBC_DERBY)[1]; assertTrue("Did not end with " + CREATE_TRUE, url.endsWith(CREATE_TRUE)); String location = url.split(CREATE_TRUE)[0]; assertFalse("Location was an empty string", location.equals("")); File locationFile = new File(location); assertFalse("File already exists: " + locationFile, locationFile.exists()); File parentFile = locationFile.getParentFile(); assertTrue("Parent directory did not exist", parentFile.isDirectory()); assertTrue("Did not end with " + T2PLATFORM, parentFile.getName().startsWith(T2PLATFORM)); assertTrue("Did not start with " + DB , parentFile.getName().endsWith(DB)); }