From 0df340f847429bac5e557da74078ac72a999179d Mon Sep 17 00:00:00 2001 From: Sorin Zamfir Date: Mon, 17 Aug 2020 23:55:43 +0300 Subject: [PATCH] BAEL-4516: Refine examples --- gradle-5/source-sets/.gitignore | 1 + gradle-5/source-sets/build.gradle | 37 ++++++++++++++----- .../com/baeldung/itest/SourceSetsItest.java | 22 ++++++++--- .../com/baeldung/main/SourceSetsObject.java | 21 +++++++++++ gradle-5/source-sets/src/random/Random.java | 0 .../com/baeldung/test/SourceSetsTest.java | 11 +++--- 6 files changed, 71 insertions(+), 21 deletions(-) create mode 100644 gradle-5/source-sets/.gitignore create mode 100644 gradle-5/source-sets/src/main/java/com/baeldung/main/SourceSetsObject.java create mode 100644 gradle-5/source-sets/src/random/Random.java diff --git a/gradle-5/source-sets/.gitignore b/gradle-5/source-sets/.gitignore new file mode 100644 index 0000000000..84c048a73c --- /dev/null +++ b/gradle-5/source-sets/.gitignore @@ -0,0 +1 @@ +/build/ diff --git a/gradle-5/source-sets/build.gradle b/gradle-5/source-sets/build.gradle index 47f64aca04..435c54c7a9 100644 --- a/gradle-5/source-sets/build.gradle +++ b/gradle-5/source-sets/build.gradle @@ -27,23 +27,40 @@ task printConfigurationInformation(){ } } -// sourceSets{ +sourceSets{ + itest { + compileClasspath += sourceSets.main.output + runtimeClasspath += sourceSets.main.output + java { + } + } +} -// itest { -// java { -// } -// } -// } +test { + testLogging { + events "passed","skipped", "failed" + } +} + // main { + // java { + // srcDir('src/random') + // } + // } dependencies { implementation('org.apache.httpcomponents:httpclient:4.5.12') testImplementation('junit:junit:4.12') - // itestImplementation('com.google.guava:guava:29.0-jre') + itestImplementation('com.google.guava:guava:29.0-jre') } -// configurations { -// itestImplementation.extendsFrom(testImplementation) -// } +configurations { + itestImplementation.extendsFrom(testImplementation) + itestRuntimeOnly.extendsFrom(t) +} + +task itest(Type: test) { + +} // eclipse { // classpath { diff --git a/gradle-5/source-sets/src/itest/java/com/baeldung/itest/SourceSetsItest.java b/gradle-5/source-sets/src/itest/java/com/baeldung/itest/SourceSetsItest.java index 7f5d0699a2..6a528a9b9b 100644 --- a/gradle-5/source-sets/src/itest/java/com/baeldung/itest/SourceSetsItest.java +++ b/gradle-5/source-sets/src/itest/java/com/baeldung/itest/SourceSetsItest.java @@ -3,17 +3,27 @@ package com.baeldung.itest; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; -import java.util.List; +//import java.util.List; import org.junit.Test; -import com.google.common.collect.ImmutableList; +import com.baeldung.main.SourceSetsObject; +//import com.google.common.collect.ImmutableList; public class SourceSetsItest { - + @Test - public void whenRunThenFail() { - List someStrings = ImmutableList.of("Baeldung", "is", "cool"); - assertThat(false, is(true)); + public void whenRunThenSuccess() { + + SourceSetsObject underTest = new SourceSetsObject("lorem","ipsum"); + + assertThat(underTest.getUser(), is("lorem")); + assertThat(underTest.getPassword(), is("ipsum")); } + +// @Test +// public void whenRunThenFail() { +// List someStrings = ImmutableList.of("Baeldung", "is", "cool"); +// assertThat(false, is(true)); +// } } diff --git a/gradle-5/source-sets/src/main/java/com/baeldung/main/SourceSetsObject.java b/gradle-5/source-sets/src/main/java/com/baeldung/main/SourceSetsObject.java new file mode 100644 index 0000000000..130121789c --- /dev/null +++ b/gradle-5/source-sets/src/main/java/com/baeldung/main/SourceSetsObject.java @@ -0,0 +1,21 @@ +package com.baeldung.main; + +public class SourceSetsObject { + + private final String user; + private final String password; + + public SourceSetsObject(String user, String password) { + this.user = user; + this.password = password; + } + + public String getPassword() { + return password; + } + + public String getUser() { + return user; + } + +} diff --git a/gradle-5/source-sets/src/random/Random.java b/gradle-5/source-sets/src/random/Random.java new file mode 100644 index 0000000000..e69de29bb2 diff --git a/gradle-5/source-sets/src/test/java/com/baeldung/test/SourceSetsTest.java b/gradle-5/source-sets/src/test/java/com/baeldung/test/SourceSetsTest.java index 829b6ee36b..4891ffd694 100644 --- a/gradle-5/source-sets/src/test/java/com/baeldung/test/SourceSetsTest.java +++ b/gradle-5/source-sets/src/test/java/com/baeldung/test/SourceSetsTest.java @@ -3,17 +3,18 @@ package com.baeldung.test; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; -import java.util.List; - import org.junit.Test; -import com.google.common.collect.ImmutableList; +import com.baeldung.main.SourceSetsObject; public class SourceSetsTest { @Test public void whenRunThenSuccess() { - List someStrings = ImmutableList.of("Baeldung", "is", "cool"); - assertThat(true, is(true)); + + SourceSetsObject underTest = new SourceSetsObject("lorem","ipsum"); + + assertThat(underTest.getUser(), is("lorem")); + assertThat(underTest.getPassword(), is("ipsum")); } }