use of org.talend.sdk.component.junit.base.junit5.TemporaryFolder in project component-runtime by Talend.
the class StudioInstallerTest method run.
@Test
void run(final TemporaryFolder temporaryFolder, final TestInfo info) throws IOException {
final String testName = info.getTestMethod().get().getName();
final File studioHome = new File(temporaryFolder.getRoot(), testName);
final File configuration = org.apache.ziplock.Files.mkdir(new File(studioHome, "configuration"));
try (final Writer configIni = new FileWriter(new File(configuration, "config.ini"))) {
// no-op
}
final File artifact = new File(temporaryFolder.getRoot(), testName + ".jar");
try (final JarOutputStream out = new JarOutputStream(new FileOutputStream(artifact))) {
out.putNextEntry(new JarEntry("META-INF/MANIFEST.MF"));
out.closeEntry();
}
final StudioInstaller installer = new StudioInstaller("gtest:atest:1.0-SNAPSHOT", studioHome, singletonMap("gtest:atest:1.0-SNAPSHOT", artifact), new Log() {
@Override
public void debug(final String s) {
log.info(s);
}
@Override
public void error(final String s) {
log.error(s);
}
@Override
public void info(final String s) {
log.info(s);
}
});
installer.run();
final File backup = new File(studioHome, "configuration/backup");
{
assertTrue(backup.exists());
assertEquals(1, backup.listFiles((dir, name) -> name.startsWith("config.ini")).length);
assertSetup(studioHome);
}
installer.run();
{
assertSetup(studioHome);
// 1 again cause already here so no other backup
assertEquals(1, backup.listFiles((dir, name) -> name.startsWith("config.ini")).length);
}
}
Aggregations