diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2018-05-10 21:47:15 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2018-05-11 20:20:47 +0200 |
commit | 01e1c69fe35fac0678130f5784ee0b70422c8536 (patch) | |
tree | 5c39a4b19872e6cbe75a229f43bc52ddb14912b9 /sonar-core | |
parent | 54a47fb03ec189410fa6d53a5355b2116624fe33 (diff) | |
download | sonarqube-01e1c69fe35fac0678130f5784ee0b70422c8536.tar.gz sonarqube-01e1c69fe35fac0678130f5784ee0b70422c8536.zip |
SONAR-10591 scanner uses WS api/plugins/download
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/platform/RemotePlugin.java | 118 | ||||
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/platform/RemotePluginTest.java | 59 |
2 files changed, 0 insertions, 177 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/platform/RemotePlugin.java b/sonar-core/src/main/java/org/sonar/core/platform/RemotePlugin.java deleted file mode 100644 index 54201e21861..00000000000 --- a/sonar-core/src/main/java/org/sonar/core/platform/RemotePlugin.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.core.platform; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import org.apache.commons.codec.digest.DigestUtils; -import org.apache.commons.lang.StringUtils; - -/** - * @deprecated since 6.6 Used for deprecated deploy/plugin/index.txt - * - */ -@Deprecated -public class RemotePlugin { - private String pluginKey; - private boolean sonarLintSupported; - private RemotePluginFile file = null; - - public RemotePlugin(String pluginKey) { - this.pluginKey = pluginKey; - } - - public static RemotePlugin create(PluginInfo pluginInfo) { - RemotePlugin result = new RemotePlugin(pluginInfo.getKey()); - result.setFile(pluginInfo.getNonNullJarFile()); - result.setSonarLintSupported(pluginInfo.isSonarLintSupported()); - return result; - } - - public static RemotePlugin unmarshal(String row) { - String[] fields = StringUtils.split(row, ","); - RemotePlugin result = new RemotePlugin(fields[0]); - if (fields.length >= 3) { - result.setSonarLintSupported(StringUtils.equals("true", fields[1])); - String[] nameAndHash = StringUtils.split(fields[2], "|"); - result.setFile(nameAndHash[0], nameAndHash[1]); - } - return result; - } - - public String marshal() { - StringBuilder sb = new StringBuilder(); - sb.append(pluginKey) - .append(",") - .append(sonarLintSupported) - .append(",") - .append(file.getFilename()) - .append("|") - .append(file.getHash()); - return sb.toString(); - } - - public String getKey() { - return pluginKey; - } - - public RemotePlugin setFile(String filename, String hash) { - file = new RemotePluginFile(filename, hash); - return this; - } - - public RemotePlugin setSonarLintSupported(boolean sonarLintPlugin) { - this.sonarLintSupported = sonarLintPlugin; - return this; - } - - public RemotePlugin setFile(File f) { - try (FileInputStream fis = new FileInputStream(f)) { - return this.setFile(f.getName(), DigestUtils.md5Hex(fis)); - } catch (IOException e) { - throw new IllegalStateException("Fail to compute hash", e); - } - } - - public RemotePluginFile file() { - return file; - } - - public boolean isSonarLintSupported() { - return sonarLintSupported; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - RemotePlugin that = (RemotePlugin) o; - return pluginKey.equals(that.pluginKey); - } - - @Override - public int hashCode() { - return pluginKey.hashCode(); - } -} diff --git a/sonar-core/src/test/java/org/sonar/core/platform/RemotePluginTest.java b/sonar-core/src/test/java/org/sonar/core/platform/RemotePluginTest.java deleted file mode 100644 index f67161eca13..00000000000 --- a/sonar-core/src/test/java/org/sonar/core/platform/RemotePluginTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2018 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.core.platform; - -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -public class RemotePluginTest { - @Test - public void shouldEqual() { - RemotePlugin clirr1 = new RemotePlugin("clirr"); - RemotePlugin clirr2 = new RemotePlugin("clirr"); - RemotePlugin checkstyle = new RemotePlugin("checkstyle"); - assertThat(clirr1).isEqualTo(clirr2); - assertThat(clirr1).isEqualTo(clirr1); - assertThat(clirr1).isNotEqualTo(checkstyle); - } - - @Test - public void shouldMarshalNotSonarLintByDefault() { - RemotePlugin clirr = new RemotePlugin("clirr").setFile("clirr-1.1.jar", "fakemd5"); - String text = clirr.marshal(); - assertThat(text).isEqualTo("clirr,false,clirr-1.1.jar|fakemd5"); - } - - @Test - public void shouldMarshalSonarLint() { - RemotePlugin clirr = new RemotePlugin("clirr").setFile("clirr-1.1.jar", "fakemd5").setSonarLintSupported(true); - String text = clirr.marshal(); - assertThat(text).isEqualTo("clirr,true,clirr-1.1.jar|fakemd5"); - } - - @Test - public void shouldUnmarshal() { - RemotePlugin clirr = RemotePlugin.unmarshal("clirr,true,clirr-1.1.jar|fakemd5"); - assertThat(clirr.getKey()).isEqualTo("clirr"); - assertThat(clirr.isSonarLintSupported()).isTrue(); - assertThat(clirr.file().getFilename()).isEqualTo("clirr-1.1.jar"); - assertThat(clirr.file().getHash()).isEqualTo("fakemd5"); - } -} |