Java Code Examples for org.gradle.internal.impldep.org.testng.Assert#assertNotNull()
The following examples show how to use
org.gradle.internal.impldep.org.testng.Assert#assertNotNull() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HelmPackageTest.java From gradle-plugins with Apache License 2.0 | 5 votes |
@Before public void setup() throws IOException { File tempDir = new File("build/tmp/helm"); tempDir.mkdirs(); workingDir = new File(tempDir, "demo"); workingDir.mkdirs(); File chartFolder = new File(workingDir, "src/main/helm/helmapp"); File remplateFolder = new File(chartFolder, "templates"); remplateFolder.mkdirs(); System.setProperty("org.gradle.daemon", "false"); File gradleFile = new File(workingDir, "build.gradle"); File chartFile = new File(chartFolder, "Chart.yaml"); File valuesFile = new File(chartFolder, "values.yaml"); File serviceFile = new File(remplateFolder, "service.yaml"); ClassLoader cl = getClass().getClassLoader(); Assert.assertNotNull(cl.getResource("plugin-under-test-metadata.properties")); File settingsFile = new File(workingDir, "settings.gradle"); FileUtils.write(settingsFile, "", StandardCharsets.UTF_8); IOUtils.copy(cl.getResourceAsStream("build.gradle"), new FileOutputStream(gradleFile)); IOUtils.copy(cl.getResourceAsStream("Chart.yaml"), new FileOutputStream(chartFile)); IOUtils.copy(cl.getResourceAsStream("values.yaml"), new FileOutputStream(valuesFile)); IOUtils.copy(cl.getResourceAsStream("service.yaml"), new FileOutputStream(serviceFile)); }
Example 2
Source File: HelmSysTest.java From gradle-plugins with Apache License 2.0 | 4 votes |
@Test public void testPackaging() throws IOException, InterruptedException { File tempDir = new File("build/tmp/systest"); tempDir.mkdirs(); workingDir = new File(tempDir, "demo"); workingDir.mkdirs(); File chartFolder = new File(workingDir, "src/main/helm/helmapp"); File remplateFolder = new File(chartFolder, "templates"); remplateFolder.mkdirs(); System.setProperty("org.gradle.daemon", "false"); File gradleFile = new File(workingDir, "build.gradle"); File tillerFile = new File(workingDir, "src/main/kubectl/tiller-template.yaml"); tillerFile.getParentFile().mkdirs(); File chartFile = new File(chartFolder, "Chart.yaml"); File valuesFile = new File(chartFolder, "values.yaml"); File serviceFile = new File(remplateFolder, "service.yaml"); File tplFile = new File(remplateFolder, "_helpers.tpl"); Assert.assertNotNull(getClass().getClassLoader().getResource("plugin-under-test-metadata.properties")); IOUtils.copy(getClass().getClassLoader().getResourceAsStream("build.gradle"), new FileOutputStream(gradleFile)); IOUtils.copy(getClass().getClassLoader().getResourceAsStream("Chart.yaml"), new FileOutputStream(chartFile)); IOUtils.copy(getClass().getClassLoader().getResourceAsStream("values.yaml"), new FileOutputStream(valuesFile)); IOUtils.copy(getClass().getClassLoader().getResourceAsStream("service.yaml"), new FileOutputStream(serviceFile)); IOUtils.copy(getClass().getClassLoader().getResourceAsStream("_helpers.tpl"), new FileOutputStream(tplFile)); IOUtils.copy(getClass().getClassLoader().getResourceAsStream("tiller-template.yaml"), new FileOutputStream(tillerFile)); try { GradleRunner runner = GradleRunner.create(); runner = runner.forwardOutput(); runner = runner.withPluginClasspath(); runner = runner.withProjectDir(workingDir).withArguments("ocSetup", "--stacktrace").forwardOutput(); runner.build(); // wait with oc client runner = GradleRunner.create(); runner = runner.forwardOutput(); runner = runner.withPluginClasspath(); runner = runner.withProjectDir(workingDir).withArguments("ocWaitForTiller", "--stacktrace").forwardOutput(); runner.build(); // install software runner = GradleRunner.create(); runner = runner.forwardOutput(); runner = runner.withPluginClasspath(); runner = runner.withProjectDir(workingDir).withArguments("helmInstall", "--stacktrace").forwardOutput(); runner.build(); // wait for tiller again (with kubectl client for testing purposes) // TODO replacce with something meaningful => setup proper app runner = GradleRunner.create(); runner = runner.forwardOutput(); runner = runner.withPluginClasspath(); runner = runner.withProjectDir(workingDir).withArguments("kubectlWaitForTiller", "--stacktrace").forwardOutput(); runner.build(); File helmPackageFile = new File(workingDir, "build/distributions/helmapp-0.1.0.tgz"); Assert.assertTrue(helmPackageFile.exists()); } finally { /* GradleRunner runner = GradleRunner.create(); runner = runner.forwardOutput(); runner = runner.withPluginClasspath(); runner = runner.withProjectDir(workingDir).withArguments("ocDeleteProject", "--stacktrace").forwardOutput(); runner.build(); */ } }
Example 3
Source File: HelmBootstrapSysTest.java From gradle-plugins with Apache License 2.0 | 4 votes |
@Test public void testPackaging() throws IOException, InterruptedException { File tempDir = new File("build/tmp/systest"); tempDir.mkdirs(); workingDir = new File(tempDir, "demoBootstrap"); workingDir.mkdirs(); File chartFolder = new File(workingDir, "src/main/helm/helmapp"); File remplateFolder = new File(chartFolder, "templates"); remplateFolder.mkdirs(); System.setProperty("org.gradle.daemon", "false"); File gradleFile = new File(workingDir, "build.gradle"); File tillerFile = new File(workingDir, "tiller-template.yaml"); File chartFile = new File(chartFolder, "Chart.yaml"); File valuesFile = new File(chartFolder, "values.yaml"); File serviceFile = new File(remplateFolder, "service.yaml"); File tplFile = new File(remplateFolder, "_helpers.tpl"); Assert.assertNotNull(getClass().getClassLoader().getResource("plugin-under-test-metadata.properties")); IOUtils.copy(getClass().getClassLoader().getResourceAsStream("build.gradle"), new FileOutputStream(gradleFile)); IOUtils.copy(getClass().getClassLoader().getResourceAsStream("Chart.yaml"), new FileOutputStream(chartFile)); IOUtils.copy(getClass().getClassLoader().getResourceAsStream("values.yaml"), new FileOutputStream(valuesFile)); IOUtils.copy(getClass().getClassLoader().getResourceAsStream("service.yaml"), new FileOutputStream(serviceFile)); IOUtils.copy(getClass().getClassLoader().getResourceAsStream("_helpers.tpl"), new FileOutputStream(tplFile)); IOUtils.copy(getClass().getClassLoader().getResourceAsStream("tiller-template.yaml"), new FileOutputStream(tillerFile)); try { // install software GradleRunner runner = GradleRunner.create(); runner = runner.forwardOutput(); runner = runner.withPluginClasspath(); runner = runner.withProjectDir(workingDir).withArguments("helmClientVersion", "--stacktrace").forwardOutput(); runner.build(); } finally { /* GradleRunner runner = GradleRunner.create(); runner = runner.forwardOutput(); runner = runner.withPluginClasspath(); runner = runner.withProjectDir(workingDir).withArguments("ocDeleteProject", "--stacktrace").forwardOutput(); runner.build(); */ } }
Example 4
Source File: SchemaGenerationPluginTest.java From gradle-plugins with Apache License 2.0 | 4 votes |
private void check(boolean liquibase, String example) throws IOException { testFolder.create(); workingDir = testFolder.getRoot(); File javaFolder = testFolder.newFolder("src", "main", "java", "example"); File secondJavaPackage = testFolder.newFolder("src", "main", "java", "excluded"); File resourceFolder = testFolder.newFolder("src", "main", "resources"); File metaInfFolder = testFolder.newFolder("src", "main", "resources", "META-INF"); System.setProperty("org.gradle.daemon", "false"); File gradleFile = testFolder.newFile("build.gradle"); File entityFile = new File(javaFolder, "ExampleEntity.java"); File excludedFile = new File(secondJavaPackage, "ExcludedEntity.java"); File persistenceFile = new File(metaInfFolder, "persistence.xml"); File exampleResource = new File(resourceFolder, "example_config.properties"); File settingsFile = testFolder.newFile("settings.gradle"); FileUtils.write(settingsFile, "", StandardCharsets.UTF_8); // make sure to run gradle first Assert.assertNotNull(getClass().getClassLoader().getResource("plugin-under-test-metadata.properties")); IOUtils.copy(getClass().getClassLoader().getResourceAsStream( example + (liquibase ? "/input_liquibase.gradle" : "/input_flyway.gradle")), new FileOutputStream(gradleFile)); IOUtils.copy(getClass().getClassLoader().getResourceAsStream(example + "/input_persistence.xml"), new FileOutputStream(persistenceFile)); IOUtils.copy(getClass().getClassLoader().getResourceAsStream(example + "/input_entity.java"), new FileOutputStream(entityFile)); InputStream excludedFileContents = getClass().getClassLoader().getResourceAsStream(example + "/input_excluded_entity.java"); if (excludedFileContents != null) { IOUtils.copy(excludedFileContents, new FileOutputStream(excludedFile)); } IOUtils.copy(getClass().getClassLoader().getResourceAsStream(example + "/input_example_config.properties"), new FileOutputStream(exampleResource)); GradleRunner runner = GradleRunner.create(); runner = runner.withPluginClasspath().withDebug(true); List<String> args = new ArrayList<>(); args.add("build"); args.add("--stacktrace"); httpProxyArguments(args); runner = runner.withProjectDir(workingDir).withArguments(args).forwardOutput(); runner.build(); File exampleResourceOutputFile = new File(workingDir, "build/classes/java/main/example_config.properties"); Assert.assertTrue(exampleResourceOutputFile.exists()); }
Example 5
Source File: SystemdApplicationTest.java From gradle-plugins with Apache License 2.0 | 4 votes |
@Test public void check() throws IOException { File tempDir = new File("build/tmp"); tempDir.mkdirs(); testFolder = new TemporaryFolder(tempDir); testFolder.create(); workingDir = new File(testFolder.getRoot(), "demo"); workingDir.mkdirs(); File javaFolder = new File(workingDir, "src/main/java/example"); javaFolder.mkdirs(); File rpmFolder = new File(workingDir, "src/main/rpm"); rpmFolder.mkdirs(); System.setProperty("org.gradle.daemon", "false"); File gradleFile = new File(workingDir, "build.gradle"); File settingsFile = new File(workingDir, "settings.gradle"); File entityFile = new File(javaFolder, "Main.java"); File propertiesFile = new File(rpmFolder, "application.properties"); Assert.assertNotNull(getClass().getClassLoader().getResource("plugin-under-test-metadata.properties")); IOUtils.copy(getClass().getClassLoader().getResourceAsStream("helm-app/input.gradle"), new FileOutputStream(gradleFile)); IOUtils.copy(getClass().getClassLoader().getResourceAsStream("helm-app/input_settings.gradle"), new FileOutputStream(settingsFile)); IOUtils.copy(getClass().getClassLoader().getResourceAsStream("helm-app/input_main.java"), new FileOutputStream(entityFile)); IOUtils.copy(getClass().getClassLoader().getResourceAsStream("helm-app/input_application.properties"), new FileOutputStream(propertiesFile)); GradleRunner runner = GradleRunner.create(); runner = runner.forwardOutput(); runner = runner.withPluginClasspath(); runner = runner.withProjectDir(workingDir).withArguments("buildRpm", "--stacktrace").forwardOutput(); runner.build(); File rpmFile = new File(workingDir, "build/distributions/demo.rpm"); Assert.assertTrue(rpmFile.exists()); File serviceFile = new File(workingDir, "build/systemd/services/demo-app.service"); Assert.assertTrue(serviceFile.exists()); String serviceDesc = IOUtils.toString(new FileInputStream(serviceFile)); Assert.assertTrue(serviceDesc.contains("ExecStart=/var/demo-app/bin/demo run")); }