BAEL-4516: Refine examples

This commit is contained in:
Sorin Zamfir 2020-08-17 23:55:43 +03:00
parent 6b75e0cbed
commit 0df340f847
6 changed files with 71 additions and 21 deletions

1
gradle-5/source-sets/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/build/

View File

@ -27,23 +27,40 @@ task printConfigurationInformation(){
} }
} }
// sourceSets{ sourceSets{
itest {
compileClasspath += sourceSets.main.output
runtimeClasspath += sourceSets.main.output
java {
}
}
}
// itest { test {
testLogging {
events "passed","skipped", "failed"
}
}
// main {
// java { // java {
// srcDir('src/random')
// } // }
// } // }
// }
dependencies { dependencies {
implementation('org.apache.httpcomponents:httpclient:4.5.12') implementation('org.apache.httpcomponents:httpclient:4.5.12')
testImplementation('junit:junit:4.12') testImplementation('junit:junit:4.12')
// itestImplementation('com.google.guava:guava:29.0-jre') itestImplementation('com.google.guava:guava:29.0-jre')
} }
// configurations { configurations {
// itestImplementation.extendsFrom(testImplementation) itestImplementation.extendsFrom(testImplementation)
// } itestRuntimeOnly.extendsFrom(t)
}
task itest(Type: test) {
}
// eclipse { // eclipse {
// classpath { // classpath {

View File

@ -3,17 +3,27 @@ package com.baeldung.itest;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import java.util.List; //import java.util.List;
import org.junit.Test; import org.junit.Test;
import com.google.common.collect.ImmutableList; import com.baeldung.main.SourceSetsObject;
//import com.google.common.collect.ImmutableList;
public class SourceSetsItest { public class SourceSetsItest {
@Test @Test
public void whenRunThenFail() { public void whenRunThenSuccess() {
List<String> someStrings = ImmutableList.of("Baeldung", "is", "cool");
assertThat(false, is(true)); SourceSetsObject underTest = new SourceSetsObject("lorem","ipsum");
assertThat(underTest.getUser(), is("lorem"));
assertThat(underTest.getPassword(), is("ipsum"));
} }
// @Test
// public void whenRunThenFail() {
// List<String> someStrings = ImmutableList.of("Baeldung", "is", "cool");
// assertThat(false, is(true));
// }
} }

View File

@ -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;
}
}

View File

@ -3,17 +3,18 @@ package com.baeldung.test;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import java.util.List;
import org.junit.Test; import org.junit.Test;
import com.google.common.collect.ImmutableList; import com.baeldung.main.SourceSetsObject;
public class SourceSetsTest { public class SourceSetsTest {
@Test @Test
public void whenRunThenSuccess() { public void whenRunThenSuccess() {
List<String> 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"));
} }
} }