Extract guava-2
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
*.class
|
||||
|
||||
#folders#
|
||||
/target
|
||||
/neoDb*
|
||||
/data
|
||||
/src/main/webapp/WEB-INF/classes
|
||||
*/META-INF/*
|
||||
|
||||
# Packaged files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
@@ -0,0 +1,6 @@
|
||||
## Guava
|
||||
|
||||
This module contains articles a Google Guava
|
||||
|
||||
### Relevant Articles:
|
||||
- [Introduction to Guava Throwables](https://www.baeldung.com/guava-throwables)
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>guava</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-java</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
<!-- test scoped -->
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<version>${assertj.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>guava</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<!-- testing -->
|
||||
<assertj.version>3.6.1</assertj.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.baeldung.guava.throwables;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ThrowablesUnitTest {
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void whenThrowable_shouldWrapItInRuntimeException() throws Exception {
|
||||
try {
|
||||
throwThrowable(Throwable::new);
|
||||
} catch (Throwable t) {
|
||||
Throwables.propagateIfPossible(t, Exception.class);
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = Error.class)
|
||||
public void whenError_shouldPropagateAsIs() throws Exception {
|
||||
try {
|
||||
throwThrowable(Error::new);
|
||||
} catch (Throwable t) {
|
||||
Throwables.propagateIfPossible(t, Exception.class);
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(expected = Exception.class)
|
||||
public void whenException_shouldPropagateAsIs() throws Exception {
|
||||
try {
|
||||
throwThrowable(Exception::new);
|
||||
} catch (Throwable t) {
|
||||
Throwables.propagateIfPossible(t, Exception.class);
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
}
|
||||
|
||||
private <T extends Throwable> void throwThrowable(Supplier<T> exceptionSupplier) throws Throwable {
|
||||
throw exceptionSupplier.get();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
*.class
|
||||
|
||||
#folders#
|
||||
/target
|
||||
/neoDb*
|
||||
/data
|
||||
/src/main/webapp/WEB-INF/classes
|
||||
*/META-INF/*
|
||||
|
||||
# Packaged files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
@@ -0,0 +1 @@
|
||||
John Jane Adam Tom
|
||||
@@ -0,0 +1 @@
|
||||
Hello world
|
||||
@@ -0,0 +1 @@
|
||||
Test
|
||||
@@ -0,0 +1,4 @@
|
||||
John
|
||||
Jane
|
||||
Adam
|
||||
Tom
|
||||
@@ -0,0 +1 @@
|
||||
Hello world
|
||||
Binary file not shown.
Reference in New Issue
Block a user