public void JarBuilder_Build() { // Arrange IJdkWrapper jdkWrapper = new JdkWrapper(); TestLogger logger = new TestLogger(); string inputsDir = TestUtils.CreateTestDirectory(this.TestContext, "in"); string outputsDir = TestUtils.CreateTestDirectory(this.TestContext, "out"); string file1 = TestUtils.CreateTextFile("file1.txt", inputsDir, "file1 content"); string file2 = TestUtils.CreateTextFile("file2.txt", inputsDir, "file2 content"); // Act JarBuilder builder = new JarBuilder(logger, jdkWrapper); builder.SetManifestPropety("prop1", "prop1 value"); builder.AddFile(file1, null); builder.AddFile(file2, "myorg\\myapp\\f2.txt"); string finalJarPath = Path.Combine(outputsDir, "newJar.jar"); bool success = builder.Build(finalJarPath); // Assert Assert.IsTrue(success, "Failed to build the jar file"); new JarChecker(this.TestContext, finalJarPath) .JarContainsFiles( "META-INF\\MANIFEST.MF", "file1.txt", "myorg\\myapp\\f2.txt"); }
public void RulePluginGen_Simple() { string inputDir = TestUtils.CreateTestDirectory(this.TestContext, "input"); string outputDir = TestUtils.CreateTestDirectory(this.TestContext, "output"); string fullJarFilePath = Path.Combine(outputDir, "myPlugin.jar"); string language = "xx"; string rulesXmlFilePath = TestUtils.CreateTextFile("rules.xml", inputDir, "<xml Rules />"); IJdkWrapper jdkWrapper = new JdkWrapper(); RulesPluginBuilder generator = new RulesPluginBuilder(jdkWrapper, new TestLogger()); PluginManifest defn = new PluginManifest() { Key = "MyPlugin", Name = "My Plugin", Description = "Generated plugin", Version = "0.1-SNAPSHOT", Organization = "ACME Software Ltd", License = "Commercial", Developers = typeof(RulesPluginBuilder).FullName }; generator.GeneratePlugin(defn, language, rulesXmlFilePath, fullJarFilePath); if (File.Exists(fullJarFilePath)) { this.TestContext.AddResultFile(fullJarFilePath); } new JarChecker(this.TestContext, fullJarFilePath) .JarContainsFiles( "resources\\rules.xml", "org\\sonarqube\\plugin\\sdk\\MyPlugin\\Plugin.class", "org\\sonarqube\\plugin\\sdk\\MyPlugin\\PluginRulesDefinition.class"); }
public void RulePluginGen_Simple() { string inputDir = TestUtils.CreateTestDirectory(this.TestContext, "input"); string outputDir = TestUtils.CreateTestDirectory(this.TestContext, "output"); string fullJarFilePath = Path.Combine(outputDir, "myPlugin.jar"); string language = "xx"; string rulesXmlFilePath = TestUtils.CreateTextFile("rules.xml", inputDir, "<xml Rules />"); IJdkWrapper jdkWrapper = new JdkWrapper(); RulesPluginBuilder generator = new RulesPluginBuilder(jdkWrapper, new TestLogger()); PluginManifest defn = new PluginManifest() { Key = "MyPlugin", Name = "My Plugin", Description = "Generated plugin", Version = "0.1-SNAPSHOT", Organization = "ACME Software Ltd", License = "Commercial", Developers = typeof(RulesPluginBuilder).FullName }; generator.GeneratePlugin(defn, language, rulesXmlFilePath, fullJarFilePath); if (File.Exists(fullJarFilePath)) { this.TestContext.AddResultFile(fullJarFilePath); } new JarChecker(this.TestContext, fullJarFilePath) .JarContainsFiles( "resources\\*rules.xml", "org\\sonarqube\\plugin\\sdk\\MyPlugin\\Plugin.class", "org\\sonarqube\\plugin\\sdk\\MyPlugin\\PluginRulesDefinition.class"); }