@Test public void testWithFile() { final File file = Converters.create(File.class, "foo/hello.txt"); assertThat(file).hasName("hello.txt") .doesNotExist(); }
@Test public void securityFileContainsSSLPropsAndNoUseSSL() throws Exception { properties.setProperty(SSL_KEYSTORE, "keystore"); result = gfshParserRule.executeCommandWithInstance(connectCommand, "connect --security-properties-file=test"); // will try to load from this file verify(connectCommand).loadProperties(any(), fileCaptor.capture()); assertThat(fileCaptor.getValue()).hasName("test"); // it will prompt for missing properties verify(gfsh, times(6)).readText(any()); verify(gfsh, times(2)).readPassword(any()); }
@Test public void securityFileContainsNoSSLPropsAndNoUseSSL() throws Exception { result = gfshParserRule.executeCommandWithInstance(connectCommand, "connect --security-properties-file=test"); // will try to load from this file verify(connectCommand).loadProperties(any(), fileCaptor.capture()); assertThat(fileCaptor.getValue()).hasName("test"); // it will prompt for missing properties verify(gfsh, times(0)).readText(any()); verify(gfsh, times(0)).readPassword(any()); }
@Test public void getFlowDir() throws Exception { final String FLOW_NAME = "embedded"; final File flowDir = ExecutionsTestUtil.getFlowDir(FLOW_NAME); assertThat(flowDir).exists(); assertThat(flowDir).hasName(FLOW_NAME); }
@Test public void getFlowFile() throws Exception { final String FLOW_NAME = "logtest"; final String FILE_NAME = "largeLog1.log"; final File testFile = ExecutionsTestUtil.getFlowFile(FLOW_NAME, FILE_NAME); assertThat(testFile).exists(); assertThat(testFile).hasName(FILE_NAME); }
@Test public void connectUseLegacySecurityPropertiesFile() throws Exception { properties.setProperty(JMX_MANAGER_SSL_KEYSTORE, "jmx-keystore"); result = gfshParserRule.executeCommandWithInstance(connectCommand, "connect --security-properties-file=test --key-store=keystore --key-store-password=password"); // wil try to load from this file verify(connectCommand).loadProperties(fileCaptor.capture()); assertThat(fileCaptor.getValue()).hasName("test"); // it will not prompt for missing properties verify(gfsh, times(0)).readText(any()); verify(gfsh, times(0)).readPassword(any()); // the command option will be ignored assertThat(properties).hasSize(1); assertThat(properties.get(JMX_MANAGER_SSL_KEYSTORE)).isEqualTo("jmx-keystore"); }
@Test public void explode_jar_to_temp_directory() { PluginInfo info = PluginInfo.create(plugin1Jar()); ExplodedPlugin exploded = underTest.explode(info); // all the files loaded by classloaders (JAR + META-INF/libs/*.jar) are copied to a dedicated temp directory File copiedJar = exploded.getMain(); assertThat(exploded.getKey()).isEqualTo("test"); assertThat(copiedJar).isFile().exists(); assertThat(copiedJar.getParentFile()).isDirectory().hasName("test"); assertThat(copiedJar.getParentFile().getParentFile()).isDirectory().hasName("ce-exploded-plugins"); }
@Test public void plugins_do_not_overlap() { PluginInfo info1 = PluginInfo.create(plugin1Jar()); PluginInfo info2 = PluginInfo.create(plugin2Jar()); ExplodedPlugin exploded1 = underTest.explode(info1); ExplodedPlugin exploded2 = underTest.explode(info2); assertThat(exploded1.getKey()).isEqualTo("test"); assertThat(exploded1.getMain()).isFile().exists().hasName("sonar-test-plugin-0.1-SNAPSHOT.jar"); assertThat(exploded2.getKey()).isEqualTo("test2"); assertThat(exploded2.getMain()).isFile().exists().hasName("sonar-test2-plugin-0.1-SNAPSHOT.jar"); }
@Test public void copy_and_use_existing_packed_jar_if_compression_enabled() throws IOException { File jar = touch(temp.newFolder(), "sonar-foo-plugin.jar"); File packedJar = touch(jar.getParentFile(), "sonar-foo-plugin.pack.gz"); PluginInfo info = new PluginInfo("foo").setJarFile(jar); // the JAR is copied somewhere else in order to be loaded by classloaders File loadedJar = touch(temp.newFolder(), "sonar-foo-plugin.jar"); settings.setProperty(PROPERTY_PLUGIN_COMPRESSION_ENABLE, true); PluginFileSystem underTest = new PluginFileSystem(settings.asConfig()); underTest.addInstalledPlugin(info, loadedJar); assertThat(underTest.getInstalledFiles()).hasSize(1); InstalledPlugin installedPlugin = underTest.getInstalledPlugin("foo").get(); assertThat(installedPlugin.getPluginInfo()).isSameAs(info); assertThat(installedPlugin.getLoadedJar().getFile().toPath()).isEqualTo(loadedJar.toPath()); assertThat(installedPlugin.getCompressedJar().getFile()) .exists() .isFile() .hasName(packedJar.getName()) .hasParent(loadedJar.getParentFile()) .hasSameContentAs(packedJar); }
@Test public void compress_jar_if_compression_enabled() throws IOException { File jar = touch(temp.newFolder(), "sonar-foo-plugin.jar"); PluginInfo info = new PluginInfo("foo").setJarFile(jar); // the JAR is copied somewhere else in order to be loaded by classloaders File loadedJar = touch(temp.newFolder(), "sonar-foo-plugin.jar"); settings.setProperty(PROPERTY_PLUGIN_COMPRESSION_ENABLE, true); PluginFileSystem underTest = new PluginFileSystem(settings.asConfig()); underTest.addInstalledPlugin(info, loadedJar); assertThat(underTest.getInstalledFiles()).hasSize(1); InstalledPlugin installedPlugin = underTest.getInstalledPlugin("foo").get(); assertThat(installedPlugin.getPluginInfo()).isSameAs(info); assertThat(installedPlugin.getLoadedJar().getFile().toPath()).isEqualTo(loadedJar.toPath()); assertThat(installedPlugin.getCompressedJar().getFile()) .exists() .isFile() .hasName("sonar-foo-plugin.pack.gz") .hasParent(loadedJar.getParentFile()); }
@Test public void testWithFile() { final File file = Converters.create(File.class, "foo/hello.txt"); assertThat(file).hasName("hello.txt") .doesNotExist(); }
public void testNewFQN() { final Project project = getProject(); final File expectedDir = new File(project.getBaseDir().getPath(), "src/org/intellivim/test"); assertThat(expectedDir).doesNotExist(); final SimpleResult result = (SimpleResult) new JavaNewCommand(project, "class", "org.intellivim.test.NewlyCreated").execute(); assertSuccess(result); LocationResult location = result.getResult(); System.out.println("Created: " + location); assertThat(location).isNotNull(); assertThat(expectedDir).exists(); final File createdFile = new File(location.file); assertThat(createdFile) .exists() .hasParent(expectedDir) .hasName("NewlyCreated.java"); // cleanup createdFile.delete(); expectedDir.delete(); }