Added code examples for BAEL-4300 article.

This commit is contained in:
Jordan Simpson 2020-06-25 15:16:48 -05:00
parent 7b53c3cb55
commit 85acab7915
5 changed files with 98 additions and 0 deletions

View File

@ -0,0 +1,25 @@
*.class
0.*
#folders#
/target
/neoDb*
/data
/src/main/webapp/WEB-INF/classes
*/META-INF/*
.resourceCache
# Packaged files #
*.jar
*.war
*.ear
# Files generated by integration tests
backup-pom.xml
/bin/
/temp
#IntelliJ specific
.idea/
*.iml

View File

@ -0,0 +1,6 @@
## Core Java Lang (Part 3)
This module contains articles about core features in the Java language
### Relevant Articles:
- [[<-- Prev]](/core-java-modules/core-java-lang-2)

View File

@ -0,0 +1,37 @@
<?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">
<parent>
<groupId>com.baeldung.core-java-modules</groupId>
<artifactId>core-java-modules</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-lang-3</artifactId>
<dependencies>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>core-java-lang-3</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<properties>
<assertj.version>3.12.2</assertj.version>
</properties>
</project>

View File

@ -0,0 +1,29 @@
package com.baeldung.stringtoboolean;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
public class StringToBooleanUnitTest
{
@Test
public void givenStringTrue_whenUsingParseBoolean_thenTrue() {
assertThat(Boolean.parseBoolean("true")).isTrue();
}
@Test
public void givenStringTrue_whenUsingValueOf_thenTrue() {
assertThat(Boolean.valueOf("true")).isTrue();
}
@Test
public void givenStringTrue_whenUsingGetBoolean_thenFalse() {
assertThat(Boolean.getBoolean("true")).isFalse();
}
@Test
public void givenSystemProperty_whenUsingGetBoolean_thenTrue() {
System.setProperty("CODING_IS_FUN", "true");
assertThat(Boolean.getBoolean("CODING_IS_FUN")).isTrue();
}
}

View File

@ -131,6 +131,7 @@
<!-- <module>multimodulemavenproject</module> --> <!-- We haven't upgraded to java 9. Fixing in BAEL-10841 -->
<module>pre-jpms</module>
<module>core-java-lang-3</module>
</modules>
<build>