use of org.junit.rules.TemporaryFolder in project flow by vaadin.
the class DevModeInitializerTest method onStartup_fallbackBaseDirIsNotProjectDirectory_throws.
@Test(expected = IllegalStateException.class)
public void onStartup_fallbackBaseDirIsNotProjectDirectory_throws() throws Exception {
Mockito.when(appConfig.getStringProperty(FrontendUtils.PROJECT_BASEDIR, null)).thenReturn(null);
TemporaryFolder tmp = new TemporaryFolder();
tmp.create();
baseDir = tmp.getRoot().getPath();
String originalUserDirValue = null;
try {
originalUserDirValue = System.getProperty("user.dir");
System.setProperty("user.dir", baseDir);
devModeStartupListener.onStartup(classes, servletContext);
} finally {
if (originalUserDirValue != null) {
System.setProperty("user.dir", originalUserDirValue);
}
}
}
use of org.junit.rules.TemporaryFolder in project flow by vaadin.
the class DevModeInitializerTest method onStartup_fallbackBaseDirIsMavenProjectDirectory_isAccepted.
@Test
public void onStartup_fallbackBaseDirIsMavenProjectDirectory_isAccepted() throws Exception {
Mockito.when(appConfig.getStringProperty(FrontendUtils.PROJECT_BASEDIR, null)).thenReturn(null);
TemporaryFolder tmp = new TemporaryFolder();
tmp.create();
tmp.newFile("pom.xml");
baseDir = tmp.getRoot().getPath();
String originalUserDirValue = null;
try {
originalUserDirValue = System.getProperty("user.dir");
System.setProperty("user.dir", baseDir);
devModeStartupListener.onStartup(classes, servletContext);
} finally {
if (originalUserDirValue != null) {
System.setProperty("user.dir", originalUserDirValue);
}
}
}
use of org.junit.rules.TemporaryFolder in project flow by vaadin.
the class BuildFrontendUtilTest method testWebpackRequiredFlagsPassedToNodeEnvironment.
@Test
public void testWebpackRequiredFlagsPassedToNodeEnvironment() throws IOException, URISyntaxException, TimeoutException {
Assume.assumeFalse("Test not runnable on Windows", FrontendUtils.isWindows());
Assume.assumeTrue("Test requires /bin/bash", new File("/bin/bash").exists());
TemporaryFolder tmpDir = new TemporaryFolder();
tmpDir.create();
File baseDir = tmpDir.newFolder();
// setup: mock a webpack executable
File webpackBin = new File(baseDir, "node_modules/webpack/bin");
Assert.assertTrue(webpackBin.mkdirs());
File webPackExecutableMock = new File(webpackBin, "webpack.js");
Assert.assertTrue(webPackExecutableMock.createNewFile());
PluginAdapterBase adapter = Mockito.mock(PluginAdapterBase.class);
Mockito.when(adapter.npmFolder()).thenReturn(baseDir);
Mockito.when(adapter.projectBaseDirectory()).thenReturn(tmpDir.getRoot().toPath());
FrontendTools tools = Mockito.mock(FrontendTools.class);
// given: "node" stub that exits normally only if expected environment
// set
File fakeNode = new File(baseDir, "node");
try (PrintWriter out = new PrintWriter(fakeNode)) {
out.println("#!/bin/bash");
out.println("[ x$NODE_OPTIONS == xexpected ]");
out.println("exit $?");
}
Assert.assertTrue(fakeNode.setExecutable(true));
Mockito.when(tools.getNodeExecutable()).thenReturn(fakeNode.getAbsolutePath());
Map<String, String> environment = new HashMap<>();
environment.put("NODE_OPTIONS", "expected");
Mockito.when(tools.getWebpackNodeEnvironment()).thenReturn(environment);
// then
BuildFrontendUtil.runWebpack(adapter, tools);
// terminates successfully
}
use of org.junit.rules.TemporaryFolder in project pentaho-kettle by pentaho.
the class ResultFileTest method testGetRow.
@Test
public void testGetRow() throws KettleFileException, FileSystemException {
File tempDir = new File(new TemporaryFolder().toString());
FileObject tempFile = KettleVFS.createTempFile("prefix", "suffix", tempDir.toString());
Date timeBeforeFile = Calendar.getInstance().getTime();
ResultFile resultFile = new ResultFile(ResultFile.FILE_TYPE_GENERAL, tempFile, "myOriginParent", "myOrigin");
Date timeAfterFile = Calendar.getInstance().getTime();
assertNotNull(resultFile);
RowMetaInterface rm = resultFile.getRow().getRowMeta();
assertEquals(7, rm.getValueMetaList().size());
assertEquals(ValueMetaInterface.TYPE_STRING, rm.getValueMeta(0).getType());
assertEquals(ValueMetaInterface.TYPE_STRING, rm.getValueMeta(1).getType());
assertEquals(ValueMetaInterface.TYPE_STRING, rm.getValueMeta(2).getType());
assertEquals(ValueMetaInterface.TYPE_STRING, rm.getValueMeta(3).getType());
assertEquals(ValueMetaInterface.TYPE_STRING, rm.getValueMeta(4).getType());
assertEquals(ValueMetaInterface.TYPE_STRING, rm.getValueMeta(5).getType());
assertEquals(ValueMetaInterface.TYPE_DATE, rm.getValueMeta(6).getType());
assertEquals(ResultFile.FILE_TYPE_GENERAL, resultFile.getType());
assertEquals("myOrigin", resultFile.getOrigin());
assertEquals("myOriginParent", resultFile.getOriginParent());
assertTrue("ResultFile timestamp is created in the expected window", timeBeforeFile.compareTo(resultFile.getTimestamp()) <= 0 && timeAfterFile.compareTo(resultFile.getTimestamp()) >= 0);
tempFile.delete();
tempDir.delete();
}
use of org.junit.rules.TemporaryFolder in project pentaho-kettle by pentaho.
the class SFTPPutIntegrationIT method startServer.
@BeforeClass
public static void startServer() throws Exception {
KettleEnvironment.init();
folder = new TemporaryFolder();
folder.create();
server = SftpServer.createDefaultServer(folder);
server.start();
}
Aggregations