merged PR locally
This commit is contained in:
commit
b8fe12f709
@ -113,4 +113,21 @@
|
|||||||
- [Difference Between Wait and Sleep in Java](http://www.baeldung.com/java-wait-and-sleep)
|
- [Difference Between Wait and Sleep in Java](http://www.baeldung.com/java-wait-and-sleep)
|
||||||
- [LongAdder and LongAccumulator in Java](http://www.baeldung.com/java-longadder-and-longaccumulator)
|
- [LongAdder and LongAccumulator in Java](http://www.baeldung.com/java-longadder-and-longaccumulator)
|
||||||
- [Using Java MappedByteBuffer](http://www.baeldung.com/java-mapped-byte-buffer)
|
- [Using Java MappedByteBuffer](http://www.baeldung.com/java-mapped-byte-buffer)
|
||||||
|
- [Dynamic Proxies in Java](http://www.baeldung.com/java-dynamic-proxies)
|
||||||
|
- [How to Copy an Array in Java](http://www.baeldung.com/java-array-copy)
|
||||||
|
- [Introduction to JDBC](http://www.baeldung.com/java-jdbc)
|
||||||
|
- [Guide to CopyOnWriteArrayList](http://www.baeldung.com/java-copy-on-write-arraylist)
|
||||||
|
- [Period and Duration in Java](http://www.baeldung.com/java-period-duration)
|
||||||
|
- [Converting a Stack Trace to a String in Java](http://www.baeldung.com/java-stacktrace-to-string)
|
||||||
|
- [Guide to the Java Phaser](http://www.baeldung.com/java-phaser)
|
||||||
|
- [Count Occurrences of a Char in a String](http://www.baeldung.com/java-count-chars)
|
||||||
|
- [Java Double Brace Initialization](http://www.baeldung.com/java-double-brace-initialization)
|
||||||
|
- [The StackOverflowError in Java](http://www.baeldung.com/java-stack-overflow-error)
|
||||||
|
- [Split a String in Java](http://www.baeldung.com/java-split-string)
|
||||||
|
- [Introduction to Java Serialization](http://www.baeldung.com/java-serialization)
|
||||||
|
- [How to Remove the Last Character of a String?](http://www.baeldung.com/java-remove-last-character-of-string)
|
||||||
|
- [Guide to Synchronized Keyword in Java](http://www.baeldung.com/java-synchronized)
|
||||||
|
- [ClassNotFoundException vs NoClassDefFoundError](http://www.baeldung.com/java-classnotfoundexception-and-noclassdeffounderror)
|
||||||
|
- [Guide to UUID in Java](http://www.baeldung.com/java-uuid)
|
||||||
|
- [How to Get the Last Element of a Stream in Java?](http://www.baeldung.com/java-stream-last-element)
|
||||||
|
- [Guide to Escaping Characters in Java RegExps](http://www.baeldung.com/java-regexp-escape-char)
|
||||||
|
@ -0,0 +1,51 @@
|
|||||||
|
package com.baeldung.maths;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
public class FloatingPointArithmetic {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
double a = 13.22;
|
||||||
|
double b = 4.88;
|
||||||
|
double c = 21.45;
|
||||||
|
|
||||||
|
System.out.println("a = " + a);
|
||||||
|
System.out.println("b = " + b);
|
||||||
|
System.out.println("c = " + c);
|
||||||
|
|
||||||
|
double sum_ab = a + b;
|
||||||
|
System.out.println("a + b = " + sum_ab);
|
||||||
|
|
||||||
|
double abc = a + b + c;
|
||||||
|
System.out.println("a + b + c = " + abc);
|
||||||
|
|
||||||
|
double ab_c = sum_ab + c;
|
||||||
|
System.out.println("ab + c = " + ab_c);
|
||||||
|
|
||||||
|
double sum_ac = a + c;
|
||||||
|
System.out.println("a + c = " + sum_ac);
|
||||||
|
|
||||||
|
double acb = a + c + b;
|
||||||
|
System.out.println("a + c + b = " + acb);
|
||||||
|
|
||||||
|
double ac_b = sum_ac + b;
|
||||||
|
System.out.println("ac + b = " + ac_b);
|
||||||
|
|
||||||
|
double ab = 18.1;
|
||||||
|
double ac = 34.67;
|
||||||
|
double sum_ab_c = ab + c;
|
||||||
|
double sum_ac_b = ac + b;
|
||||||
|
System.out.println("ab + c = " + sum_ab_c);
|
||||||
|
System.out.println("ac + b = " + sum_ac_b);
|
||||||
|
|
||||||
|
BigDecimal d = new BigDecimal(String.valueOf(a));
|
||||||
|
BigDecimal e = new BigDecimal(String.valueOf(b));
|
||||||
|
BigDecimal f = new BigDecimal(String.valueOf(c));
|
||||||
|
|
||||||
|
BigDecimal def = d.add(e).add(f);
|
||||||
|
BigDecimal dfe = d.add(f).add(e);
|
||||||
|
|
||||||
|
System.out.println("d + e + f = " + def);
|
||||||
|
System.out.println("d + f + e = " + dfe);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package com.baeldung.java.currentmethod;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The class presents various ways of finding the name of currently executed method.
|
||||||
|
*/
|
||||||
|
public class CurrentlyExecutedMethodFinderTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenCurrentThread_whenGetStackTrace_thenFindMethod() {
|
||||||
|
final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
|
||||||
|
assertEquals("givenCurrentThread_whenGetStackTrace_thenFindMethod", stackTrace[1].getMethodName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenException_whenGetStackTrace_thenFindMethod() {
|
||||||
|
String methodName = new Exception().getStackTrace()[0].getMethodName();
|
||||||
|
assertEquals("givenException_whenGetStackTrace_thenFindMethod", methodName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenThrowable_whenGetStacktrace_thenFindMethod() {
|
||||||
|
StackTraceElement[] stackTrace = new Throwable().getStackTrace();
|
||||||
|
assertEquals("givenThrowable_whenGetStacktrace_thenFindMethod", stackTrace[0].getMethodName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenObject_whenGetEnclosingMethod_thenFindMethod() {
|
||||||
|
String methodName = new Object() {}.getClass().getEnclosingMethod().getName();
|
||||||
|
assertEquals("givenObject_whenGetEnclosingMethod_thenFindMethod", methodName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenLocal_whenGetEnclosingMethod_thenFindMethod() {
|
||||||
|
class Local {};
|
||||||
|
String methodName = Local.class.getEnclosingMethod().getName();
|
||||||
|
assertEquals("givenLocal_whenGetEnclosingMethod_thenFindMethod", methodName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package com.baeldung.maths;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class FloatingPointArithmeticTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenDecimalNumbers_whenAddedTogether_thenGetExpectedResult() {
|
||||||
|
double a = 13.22;
|
||||||
|
double b = 4.88;
|
||||||
|
double c = 21.45;
|
||||||
|
double result = 39.55;
|
||||||
|
|
||||||
|
double abc = a + b + c;
|
||||||
|
double acb = a + c + b;
|
||||||
|
|
||||||
|
Assert.assertEquals(result, abc, 0);
|
||||||
|
Assert.assertNotEquals(result, acb, 0);
|
||||||
|
|
||||||
|
double ab = 18.1;
|
||||||
|
double ac = 34.67;
|
||||||
|
|
||||||
|
double ab_c = ab + c;
|
||||||
|
double ac_b = ac + b;
|
||||||
|
|
||||||
|
Assert.assertEquals(result, ab_c, 0);
|
||||||
|
Assert.assertNotEquals(result, ac_b, 0);
|
||||||
|
|
||||||
|
BigDecimal d = new BigDecimal(String.valueOf(a));
|
||||||
|
BigDecimal e = new BigDecimal(String.valueOf(b));
|
||||||
|
BigDecimal f = new BigDecimal(String.valueOf(c));
|
||||||
|
BigDecimal sum = new BigDecimal("39.55");
|
||||||
|
|
||||||
|
BigDecimal def = d.add(e).add(f);
|
||||||
|
BigDecimal dfe = d.add(f).add(e);
|
||||||
|
|
||||||
|
Assert.assertEquals(0, def.compareTo(sum));
|
||||||
|
Assert.assertEquals(0, dfe.compareTo(sum));
|
||||||
|
|
||||||
|
Assert.assertNotEquals(0, sum.compareTo(new BigDecimal(String.valueOf(acb))));
|
||||||
|
}
|
||||||
|
}
|
@ -2,41 +2,58 @@ package com.baeldung.string;
|
|||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
|
||||||
public class StringToCharStreamUnitTest {
|
public class StringToCharStreamUnitTest {
|
||||||
|
|
||||||
|
private String testString = "Tests";
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenTestString_whenChars_thenReturnIntStream() {
|
public void givenTestString_whenChars_thenReturnIntStream() {
|
||||||
assertThat(StringToCharStream.getIntStreamFromChars("test"), instanceOf(IntStream.class));
|
assertThat(testString.chars(), instanceOf(IntStream.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenTestString_whenCodePoints_thenReturnIntStream() {
|
public void givenTestString_whenCodePoints_thenReturnIntStream() {
|
||||||
assertThat(StringToCharStream.getIntStreamFromCodePoints("test"), instanceOf(IntStream.class));
|
assertThat(testString.codePoints(), instanceOf(IntStream.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenTestString_whenCodePoints_thenShowOccurences() throws Exception {
|
||||||
|
Map<Character, Integer> map = testString.codePoints()
|
||||||
|
.mapToObj(c -> (char) c)
|
||||||
|
.filter(Character::isLetter)
|
||||||
|
.collect(Collectors.toMap(c -> c, c -> 1, Integer::sum));
|
||||||
|
|
||||||
|
System.out.println(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenIntStream_whenMapToObj_thenReturnCharacterStream() {
|
public void givenIntStream_whenMapToObj_thenReturnCharacterStream() {
|
||||||
Stream<Character> characterStream
|
Stream<Character> characterStream = testString.chars()
|
||||||
= StringToCharStream.mapIntStreamToCharStream(StringToCharStream.getIntStreamFromChars("test"));
|
.mapToObj(c -> (char) c);
|
||||||
Stream<Character> characterStream1
|
Stream<Character> characterStream1 = testString.codePoints()
|
||||||
= StringToCharStream.mapIntStreamToCharStream(StringToCharStream.getIntStreamFromCodePoints("test"));
|
.mapToObj(c -> (char) c);
|
||||||
assertNotNull("IntStream returned by chars() did not map to Stream<Character>", characterStream);
|
assertNotNull("IntStream returned by chars() did not map to Stream<Character>", characterStream);
|
||||||
assertNotNull("IntStream returned by codePoints() did not map to Stream<Character>", characterStream1);
|
assertNotNull("IntStream returned by codePoints() did not map to Stream<Character>", characterStream1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenIntStream_whenMapToObj_thenReturnStringStream() {
|
public void givenIntStream_whenMapToObj_thenReturnStringStream() {
|
||||||
Stream<String> stringStream
|
List<String> strings = testString.codePoints()
|
||||||
= StringToCharStream.mapIntStreamToStringStream(StringToCharStream.getIntStreamFromCodePoints("test"));
|
.mapToObj(c -> String.valueOf((char) c))
|
||||||
assertNotNull(stringStream);
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
assertEquals(strings.size(), 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,3 +25,6 @@
|
|||||||
- [Guide to Guava RangeMap](http://www.baeldung.com/guava-rangemap)
|
- [Guide to Guava RangeMap](http://www.baeldung.com/guava-rangemap)
|
||||||
- [Guide to Guava Table](http://www.baeldung.com/guava-table)
|
- [Guide to Guava Table](http://www.baeldung.com/guava-table)
|
||||||
- [Guide to Guava’s Reflection Utilities](http://www.baeldung.com/guava-reflection)
|
- [Guide to Guava’s Reflection Utilities](http://www.baeldung.com/guava-reflection)
|
||||||
|
- [Guide to Guava ClassToInstanceMap](http://www.baeldung.com/guava-class-to-instance-map)
|
||||||
|
- [Guide to Guava MinMaxPriorityQueue and EvictingQueue](http://www.baeldung.com/guava-minmax-priority-queue-and-evicting-queue)
|
||||||
|
- [Guide to Mathematical Utilities in Guava](http://www.baeldung.com/guava-math)
|
||||||
|
@ -4,3 +4,4 @@
|
|||||||
- [Converters, Listeners and Validators in Java EE 7](http://www.baeldung.com/java-ee7-converter-listener-validator)
|
- [Converters, Listeners and Validators in Java EE 7](http://www.baeldung.com/java-ee7-converter-listener-validator)
|
||||||
- [Introduction to JAX-WS](http://www.baeldung.com/jax-ws)
|
- [Introduction to JAX-WS](http://www.baeldung.com/jax-ws)
|
||||||
- [A Guide to Java EE Web-Related Annotations](http://www.baeldung.com/javaee-web-annotations)
|
- [A Guide to Java EE Web-Related Annotations](http://www.baeldung.com/javaee-web-annotations)
|
||||||
|
- [Introduction to Testing with Arquillian](http://www.baeldung.com/arquillian)
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
### Relevant Articles:
|
### Relevant Articles:
|
||||||
- [The Basics of JUnit 5 – A Preview](http://www.baeldung.com/junit-5-preview)
|
- [The Basics of JUnit 5 – A Preview](http://www.baeldung.com/junit-5-preview)
|
||||||
- [A Guide to JUnit 5](http://www.baeldung.com/junit-5)
|
- [A Guide to JUnit 5](http://www.baeldung.com/junit-5)
|
||||||
|
- [Guide to Dynamic Tests in Junit 5](http://www.baeldung.com/junit5-dynamic-tests)
|
||||||
|
- [A Guide to @RepeatedTest in Junit 5](http://www.baeldung.com/junit-5-repeated-test)
|
||||||
|
- [Guide to Dynamic Tests in Junit 5](http://www.baeldung.com/junit5-dynamic-tests)
|
||||||
|
@ -4,5 +4,5 @@
|
|||||||
- [A guide to the “when{}” block in Kotlin](http://www.baeldung.com/kotlin-when)
|
- [A guide to the “when{}” block in Kotlin](http://www.baeldung.com/kotlin-when)
|
||||||
- [Comprehensive Guide to Null Safety in Kotlin](http://www.baeldung.com/kotlin-null-safety)
|
- [Comprehensive Guide to Null Safety in Kotlin](http://www.baeldung.com/kotlin-null-safety)
|
||||||
- [Kotlin Java Interoperability](http://www.baeldung.com/kotlin-java-interoperability)
|
- [Kotlin Java Interoperability](http://www.baeldung.com/kotlin-java-interoperability)
|
||||||
- [Difference Between “==” and “===” in Kotlin]()
|
- [Difference Between “==” and “===” in Kotlin](http://www.baeldung.com/kotlin-equality-operators)
|
||||||
- [Generics in Kotlin](http://www.baeldung.com/kotlin-generics)
|
- [Generics in Kotlin](http://www.baeldung.com/kotlin-generics)
|
||||||
|
@ -12,6 +12,11 @@
|
|||||||
- [Introduction to Apache Commons Math](http://www.baeldung.com/apache-commons-math)
|
- [Introduction to Apache Commons Math](http://www.baeldung.com/apache-commons-math)
|
||||||
- [Intro to JaVer](http://www.baeldung.com/serenity-bdd)
|
- [Intro to JaVer](http://www.baeldung.com/serenity-bdd)
|
||||||
- [Introduction to Netty](http://www.baeldung.com/netty)
|
- [Introduction to Netty](http://www.baeldung.com/netty)
|
||||||
|
- [Guide to Java Data Objects](http://www.baeldung.com/jdo)
|
||||||
|
- [Software Transactional Memory in Java Using Multiverse](http://www.baeldung.com/java-multiverse-stm)
|
||||||
|
- [Introduction to HikariCP](http://www.baeldung.com/hikaricp)
|
||||||
|
- [Serenity BDD with Spring and JBehave](http://www.baeldung.com/serenity-spring-jbehave)
|
||||||
|
|
||||||
|
|
||||||
The libraries module contains examples related to small libraries that are relatively easy to use and does not require any separate module of its own.
|
The libraries module contains examples related to small libraries that are relatively easy to use and does not require any separate module of its own.
|
||||||
|
|
||||||
|
@ -180,6 +180,12 @@
|
|||||||
<artifactId>serenity-core</artifactId>
|
<artifactId>serenity-core</artifactId>
|
||||||
<version>${serenity.version}</version>
|
<version>${serenity.version}</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.asciidoctor</groupId>
|
||||||
|
<artifactId>asciidoctor-java-integration</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.serenity-bdd</groupId>
|
<groupId>net.serenity-bdd</groupId>
|
||||||
@ -323,6 +329,16 @@
|
|||||||
<artifactId>netty-all</artifactId>
|
<artifactId>netty-all</artifactId>
|
||||||
<version>${netty.version}</version>
|
<version>${netty.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.asciidoctor</groupId>
|
||||||
|
<artifactId>asciidoctorj</artifactId>
|
||||||
|
<version>1.5.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.asciidoctor</groupId>
|
||||||
|
<artifactId>asciidoctorj-pdf</artifactId>
|
||||||
|
<version>1.5.0-alpha.11</version>
|
||||||
|
</dependency>
|
||||||
<!-- OpenNLP -->
|
<!-- OpenNLP -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.opennlp</groupId>
|
<groupId>org.apache.opennlp</groupId>
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
package com.baeldung.asciidoctor;
|
||||||
|
|
||||||
|
import static org.asciidoctor.Asciidoctor.Factory.create;
|
||||||
|
import static org.asciidoctor.OptionsBuilder.options;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.asciidoctor.Asciidoctor;
|
||||||
|
|
||||||
|
public class AsciidoctorDemo {
|
||||||
|
|
||||||
|
private final Asciidoctor asciidoctor;
|
||||||
|
|
||||||
|
public AsciidoctorDemo() {
|
||||||
|
asciidoctor = create();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void generatePDFFromString(final String input) {
|
||||||
|
|
||||||
|
final Map<String, Object> options = options().inPlace(true)
|
||||||
|
.backend("pdf")
|
||||||
|
.asMap();
|
||||||
|
|
||||||
|
final String outfile = asciidoctor.convertFile(new File("sample.adoc"), options);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String generateHTMLFromString(final String input) {
|
||||||
|
final String output = asciidoctor.convert("Hello _Baeldung_!", new HashMap<String, Object>());
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.baeldung.asciidoctor;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class AsciidoctorDemoTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenString_whenConverting_thenResultingHTMLCode() {
|
||||||
|
final AsciidoctorDemo asciidoctorDemo = new AsciidoctorDemo();
|
||||||
|
Assert.assertEquals(asciidoctorDemo.generateHTMLFromString("Hello _Baeldung_!"), "<div class=\"paragraph\">\n<p>Hello <em>Baeldung</em>!</p>\n</div>");
|
||||||
|
}
|
||||||
|
}
|
2
mustache/README.md
Normal file
2
mustache/README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
### Relevant Articles:
|
||||||
|
[Introduction to Mustache](http://www.baeldung.com/mustache)
|
2
pom.xml
2
pom.xml
@ -25,7 +25,6 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>spring-vertx</module>
|
|
||||||
<module>aws</module>
|
<module>aws</module>
|
||||||
<module>akka-streams</module>
|
<module>akka-streams</module>
|
||||||
<module>algorithms</module>
|
<module>algorithms</module>
|
||||||
@ -208,6 +207,7 @@
|
|||||||
<module>spring-userservice</module>
|
<module>spring-userservice</module>
|
||||||
<module>spring-zuul</module>
|
<module>spring-zuul</module>
|
||||||
<module>spring-reactor</module>
|
<module>spring-reactor</module>
|
||||||
|
<module>spring-vertx</module>
|
||||||
|
|
||||||
<module>testing</module>
|
<module>testing</module>
|
||||||
<module>testng</module>
|
<module>testng</module>
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
selenium-junit-testng/geckodriver.mac
Executable file
BIN
selenium-junit-testng/geckodriver.mac
Executable file
Binary file not shown.
@ -66,6 +66,6 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<testng.version>6.10</testng.version>
|
<testng.version>6.10</testng.version>
|
||||||
<selenium-java.version>3.0.1</selenium-java.version>
|
<selenium-java.version>3.4.0</selenium-java.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
@ -1,32 +1,31 @@
|
|||||||
package main.java.com.baeldung.selenium;
|
package main.java.com.baeldung.selenium;
|
||||||
|
|
||||||
|
import main.java.com.baeldung.selenium.config.SeleniumConfig;
|
||||||
import org.openqa.selenium.By;
|
import org.openqa.selenium.By;
|
||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.firefox.FirefoxDriver;
|
import org.openqa.selenium.firefox.FirefoxDriver;
|
||||||
|
import org.openqa.selenium.interactions.Actions;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
public class SeleniumExample {
|
public class SeleniumExample {
|
||||||
|
|
||||||
private WebDriver webDriver;
|
private SeleniumConfig config;
|
||||||
private String url = "http://www.baeldung.com/";
|
private String url = "http://www.baeldung.com/";
|
||||||
|
|
||||||
public SeleniumExample() {
|
public SeleniumExample() {
|
||||||
System.setProperty("webdriver.firefox.marionette", "C:\\selenium\\geckodriver.exe");
|
config = new SeleniumConfig();
|
||||||
webDriver = new FirefoxDriver();
|
config.getDriver().get(url);
|
||||||
webDriver.manage().window().maximize();
|
|
||||||
webDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
|
|
||||||
webDriver.get(url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeWindow() {
|
public void closeWindow() {
|
||||||
webDriver.close();
|
this.config.getDriver().close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle() {
|
public String getTitle() {
|
||||||
return webDriver.getTitle();
|
return this.config.getDriver().getTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getAboutBaeldungPage() {
|
public void getAboutBaeldungPage() {
|
||||||
@ -36,7 +35,7 @@ public class SeleniumExample {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void closeOverlay() {
|
private void closeOverlay() {
|
||||||
List<WebElement> webElementList = webDriver.findElements(By.tagName("a"));
|
List<WebElement> webElementList = this.config.getDriver().findElements(By.tagName("a"));
|
||||||
if (webElementList != null) {
|
if (webElementList != null) {
|
||||||
webElementList.stream()
|
webElementList.stream()
|
||||||
.filter(webElement -> "Close".equalsIgnoreCase(webElement.getAttribute("title")))
|
.filter(webElement -> "Close".equalsIgnoreCase(webElement.getAttribute("title")))
|
||||||
@ -47,14 +46,18 @@ public class SeleniumExample {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void clickAboutLink() {
|
private void clickAboutLink() {
|
||||||
webDriver.findElement(By.partialLinkText("About")).click();
|
this.config.getDriver().findElement(By.partialLinkText("About")).click();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clickAboutUsLink() {
|
private void clickAboutUsLink() {
|
||||||
webDriver.findElement(By.partialLinkText("About Baeldung.")).click();
|
Actions builder = new Actions(config.getDriver());
|
||||||
|
WebElement element = this.config.getDriver().findElement(By.partialLinkText("About Baeldung."));
|
||||||
|
builder.moveToElement(element).build().perform();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAuthorInformationAvailable() {
|
public boolean isAuthorInformationAvailable() {
|
||||||
return webDriver.findElement(By.xpath("//*[contains(text(), 'an engineer with a passion for teaching and building stuff on the web')]")).isDisplayed();
|
return this.config.getDriver()
|
||||||
|
.findElement(By.cssSelector("article > .row > div"))
|
||||||
|
.isDisplayed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,11 @@ import org.openqa.selenium.Capabilities;
|
|||||||
import org.openqa.selenium.WebDriver;
|
import org.openqa.selenium.WebDriver;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.chrome.ChromeDriver;
|
import org.openqa.selenium.chrome.ChromeDriver;
|
||||||
|
import org.openqa.selenium.firefox.FirefoxDriver;
|
||||||
import org.openqa.selenium.remote.DesiredCapabilities;
|
import org.openqa.selenium.remote.DesiredCapabilities;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -15,30 +17,13 @@ public class SeleniumConfig {
|
|||||||
private WebDriver driver;
|
private WebDriver driver;
|
||||||
|
|
||||||
public SeleniumConfig() {
|
public SeleniumConfig() {
|
||||||
Capabilities capabilities = DesiredCapabilities.chrome();
|
Capabilities capabilities = DesiredCapabilities.firefox();
|
||||||
driver = new ChromeDriver(capabilities);
|
driver = new FirefoxDriver(capabilities);
|
||||||
|
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
String osName = getOsName("os.name").toLowerCase();
|
System.setProperty("webdriver.gecko.driver", findFile("geckodriver.mac"));
|
||||||
final Matcher matcher = Pattern.compile("(mac|nux|win)").matcher(osName);
|
|
||||||
if (matcher.find()) {
|
|
||||||
switch (matcher.group()) {
|
|
||||||
case "mac":
|
|
||||||
System.setProperty("webdriver.chrome.driver", findFile("chromedriver.mac"));
|
|
||||||
break;
|
|
||||||
case "nux":
|
|
||||||
System.setProperty("webdriver.chrome.driver", findFile("chromedriver.linux"));
|
|
||||||
break;
|
|
||||||
case "win":
|
|
||||||
System.setProperty("webdriver.chrome.driver", findFile("chromedriver.exe"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getOsName(String prop) {
|
|
||||||
return (System.getProperty(prop));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static private String findFile(String filename) {
|
static private String findFile(String filename) {
|
||||||
@ -51,7 +36,7 @@ public class SeleniumConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
driver.quit();
|
driver.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void navigateTo(String url) {
|
public void navigateTo(String url) {
|
||||||
|
@ -10,7 +10,7 @@ import static org.testng.Assert.*;
|
|||||||
public class SeleniumWithJUnitLiveTest {
|
public class SeleniumWithJUnitLiveTest {
|
||||||
|
|
||||||
private static SeleniumExample seleniumExample;
|
private static SeleniumExample seleniumExample;
|
||||||
private String expectedTitle = "About Baeldung | Baeldung";
|
private String expectedTitle = "Baeldung | Java, Spring and Web Development tutorials";
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setUp() {
|
public static void setUp() {
|
||||||
|
@ -10,7 +10,7 @@ import static org.testng.Assert.*;
|
|||||||
public class SeleniumWithTestNGLiveTest {
|
public class SeleniumWithTestNGLiveTest {
|
||||||
|
|
||||||
private SeleniumExample seleniumExample;
|
private SeleniumExample seleniumExample;
|
||||||
private String expectedTitle = "About Baeldung | Baeldung";
|
private String expectedTitle = "Baeldung | Java, Spring and Web Development tutorials";
|
||||||
|
|
||||||
@BeforeSuite
|
@BeforeSuite
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
@ -23,3 +23,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
|
|||||||
- [Create a Custom Auto-Configuration with Spring Boot](http://www.baeldung.com/spring-boot-custom-auto-configuration)
|
- [Create a Custom Auto-Configuration with Spring Boot](http://www.baeldung.com/spring-boot-custom-auto-configuration)
|
||||||
- [Testing in Spring Boot](http://www.baeldung.com/spring-boot-testing)
|
- [Testing in Spring Boot](http://www.baeldung.com/spring-boot-testing)
|
||||||
- [Guide to @ConfigurationProperties in Spring Boot](http://www.baeldung.com/configuration-properties-in-spring-boot)
|
- [Guide to @ConfigurationProperties in Spring Boot](http://www.baeldung.com/configuration-properties-in-spring-boot)
|
||||||
|
- [Spring Boot and Togglz Aspect](http://www.baeldung.com/spring-togglz)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
- [Spring Cloud – Bootstrapping](http://www.baeldung.com/spring-cloud-bootstrapping)
|
- [Spring Cloud – Bootstrapping](http://www.baeldung.com/spring-cloud-bootstrapping)
|
||||||
- [Spring Cloud – Securing Services](http://www.baeldung.com/spring-cloud-securing-services)
|
- [Spring Cloud – Securing Services](http://www.baeldung.com/spring-cloud-securing-services)
|
||||||
- [Spring Cloud – Tracing Services with Zipkin](http://www.baeldung.com/tracing-services-with-zipkin)
|
- [Spring Cloud – Tracing Services with Zipkin](http://www.baeldung.com/tracing-services-with-zipkin)
|
||||||
|
- [Spring Cloud – Adding Angular 4](http://www.baeldung.com/spring-cloud-angular)
|
||||||
|
|
||||||
|
|
||||||
- To run the project:
|
- To run the project:
|
||||||
|
@ -6,3 +6,4 @@
|
|||||||
|
|
||||||
### Relevant Articles:
|
### Relevant Articles:
|
||||||
-
|
-
|
||||||
|
- [Guide to Spring Web Flow](http://www.baeldung.com/spring-web-flow)
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
- [Intro to Spring Remoting with HTTP Invokers](http://www.baeldung.com/spring-remoting-http-invoker)
|
- [Intro to Spring Remoting with HTTP Invokers](http://www.baeldung.com/spring-remoting-http-invoker)
|
||||||
- [Spring Remoting with Hessian and Burlap](http://www.baeldung.com/spring-remoting-hessian-burlap)
|
- [Spring Remoting with Hessian and Burlap](http://www.baeldung.com/spring-remoting-hessian-burlap)
|
||||||
- [Spring Remoting with AMQP](http://www.baeldung.com/spring-remoting-amqp)
|
- [Spring Remoting with AMQP](http://www.baeldung.com/spring-remoting-amqp)
|
||||||
|
- [Spring Remoting with JMS](http://www.baeldung.com/spring-remoting-jms)
|
||||||
|
|
||||||
### Overview
|
### Overview
|
||||||
This Maven project contains the Java source code for various modules used in the Spring Remoting series of articles.
|
This Maven project contains the Java source code for various modules used in the Spring Remoting series of articles.
|
||||||
|
2
spring-roo/README.md
Normal file
2
spring-roo/README.md
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
### Relevant Articles:
|
||||||
|
[Quick Guide to Spring Roo](http://www.baeldung.com/spring-roo)
|
@ -8,7 +8,7 @@
|
|||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>vertx-spring</name>
|
<name>spring-vertx</name>
|
||||||
<description>A demo project with vertx spring integration</description>
|
<description>A demo project with vertx spring integration</description>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
@ -41,6 +41,7 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.vertx</groupId>
|
<groupId>io.vertx</groupId>
|
||||||
<artifactId>vertx-web</artifactId>
|
<artifactId>vertx-web</artifactId>
|
||||||
|
@ -11,7 +11,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||||
|
|
||||||
import com.baeldung.vertxspring.verticles.ServerVerticle;
|
import com.baeldung.vertxspring.verticles.ServerVerticle;
|
||||||
import com.baeldung.vertxspring.verticles.ServiceVerticle;
|
import com.baeldung.vertxspring.verticles.ArticleRecipientVerticle;
|
||||||
|
|
||||||
import io.vertx.core.Vertx;
|
import io.vertx.core.Vertx;
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ public class VertxSpringApplication {
|
|||||||
private ServerVerticle serverVerticle;
|
private ServerVerticle serverVerticle;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ServiceVerticle serviceVerticle;
|
private ArticleRecipientVerticle serviceVerticle;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(VertxSpringApplication.class, args);
|
SpringApplication.run(VertxSpringApplication.class, args);
|
||||||
|
@ -13,7 +13,7 @@ import io.vertx.core.eventbus.Message;
|
|||||||
import io.vertx.core.json.Json;
|
import io.vertx.core.json.Json;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class ServiceVerticle extends AbstractVerticle {
|
public class ArticleRecipientVerticle extends AbstractVerticle {
|
||||||
|
|
||||||
public static final String GET_ALL_ARTICLES = "get.articles.all";
|
public static final String GET_ALL_ARTICLES = "get.articles.all";
|
||||||
|
|
@ -11,7 +11,7 @@ public class ServerVerticle extends AbstractVerticle {
|
|||||||
|
|
||||||
private void getAllArticlesHandler(RoutingContext routingContext) {
|
private void getAllArticlesHandler(RoutingContext routingContext) {
|
||||||
vertx.eventBus()
|
vertx.eventBus()
|
||||||
.<String>send(ServiceVerticle.GET_ALL_ARTICLES, "", result -> {
|
.<String>send(ArticleRecipientVerticle.GET_ALL_ARTICLES, "", result -> {
|
||||||
if (result.succeeded()) {
|
if (result.succeeded()) {
|
||||||
routingContext.response()
|
routingContext.response()
|
||||||
.putHeader("content-type", "application/json")
|
.putHeader("content-type", "application/json")
|
||||||
|
@ -11,3 +11,4 @@
|
|||||||
- [Cucumber and Scenario Outline](http://www.baeldung.com/cucumber-scenario-outline)
|
- [Cucumber and Scenario Outline](http://www.baeldung.com/cucumber-scenario-outline)
|
||||||
- [Testing with Google Truth](http://www.baeldung.com/google-truth)
|
- [Testing with Google Truth](http://www.baeldung.com/google-truth)
|
||||||
- [Testing with JGoTesting](http://www.baeldung.com/jgotesting)
|
- [Testing with JGoTesting](http://www.baeldung.com/jgotesting)
|
||||||
|
- [Introduction to JUnitParams](http://www.baeldung.com/junit-params)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
### Relevant articles
|
### Relevant articles
|
||||||
|
|
||||||
- [Introduction to TestNG](http://www.baeldung.com/testng)
|
- [Introduction to TestNG](http://www.baeldung.com/testng)
|
||||||
|
- [Custom Reporting with TestNG](http://www.baeldung.com/testng-custom-reporting)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user