forked from eugenp/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/eugenp/tutorials into tas…
…k/BAEL-20665 # Conflicts: # core-java-modules/core-java-jndi/pom.xml
- Loading branch information
Showing
97 changed files
with
1,158 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...re-java-13/src/test/java/com/baeldung/newfeatures/SwitchExpressionsWithYieldUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.baeldung.newfeatures; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Test; | ||
|
||
public class SwitchExpressionsWithYieldUnitTest { | ||
|
||
@Test | ||
@SuppressWarnings("preview") | ||
public void whenSwitchingOnOperationSquareMe_thenWillReturnSquare() { | ||
var me = 4; | ||
var operation = "squareMe"; | ||
var result = switch (operation) { | ||
case "doubleMe" -> { | ||
yield me * 2; | ||
} | ||
case "squareMe" -> { | ||
yield me * me; | ||
} | ||
default -> me; | ||
}; | ||
|
||
assertEquals(16, result); | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
...-java-modules/core-java-13/src/test/java/com/baeldung/newfeatures/TextBlocksUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.baeldung.newfeatures; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import org.junit.Test; | ||
|
||
public class TextBlocksUnitTest { | ||
|
||
private static final String JSON_STRING = "{\r\n" + "\"name\" : \"Baeldung\",\r\n" + "\"website\" : \"https://www.%s.com/\"\r\n" + "}"; | ||
|
||
@SuppressWarnings("preview") | ||
private static final String TEXT_BLOCK_JSON = """ | ||
{ | ||
"name" : "Baeldung", | ||
"website" : "https://www.%s.com/" | ||
} | ||
"""; | ||
|
||
@Test | ||
public void whenTextBlocks_thenStringOperationsWork() { | ||
|
||
assertThat(TEXT_BLOCK_JSON.contains("Baeldung")).isTrue(); | ||
assertThat(TEXT_BLOCK_JSON.indexOf("www")).isGreaterThan(0); | ||
assertThat(TEXT_BLOCK_JSON.length()).isGreaterThan(0); | ||
|
||
} | ||
|
||
@SuppressWarnings("removal") | ||
@Test | ||
public void whenTextBlocks_thenFormattedWorksAsFormat() { | ||
assertThat(TEXT_BLOCK_JSON.formatted("baeldung") | ||
.contains("www.baeldung.com")).isTrue(); | ||
|
||
assertThat(String.format(JSON_STRING, "baeldung") | ||
.contains("www.baeldung.com")).isTrue(); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.