Skip to content

Commit 302ac3a

Browse files
authored
Merge pull request eugenp#694 from anton-k11/master
BAEL-27 Java 9 New Features
2 parents b576a4d + 9965605 commit 302ac3a

4 files changed

Lines changed: 49 additions & 12 deletions

File tree

‎core-java-9/pom.xml‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,8 @@
6060
<configuration>
6161
<source>1.9</source>
6262
<target>1.9</target>
63-
6463
<verbose>true</verbose>
65-
<!-- <executable>C:\develop\jdks\jdk-9_ea122\bin\javac</executable>
66-
<compilerVersion>1.9</compilerVersion> -->
6764
</configuration>
68-
6965
</plugin>
7066

7167
<plugin>
@@ -85,12 +81,7 @@
8581

8682

8783
<!-- maven plugins -->
88-
<!--
89-
<maven-war-plugin.version>2.6</maven-war-plugin.version>
90-
maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version> -->
91-
<maven-compiler-plugin.version>3.6-jigsaw-SNAPSHOT</maven-compiler-plugin.version>
92-
93-
84+
<maven-compiler-plugin.version>3.6-jigsaw-SNAPSHOT</maven-compiler-plugin.version>
9485
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
9586

9687
<!-- testing -->

‎core-java-9/src/test/java/com/baeldung/java9/MultiResultionImageTest.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.baeldung.java9;
2-
3-
import static org.junit.Assert.assertTrue;
2+
43
import static org.junit.Assert.assertEquals;
54
import static org.junit.Assert.assertSame;
65

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.baeldung.java9;
2+
3+
import java.util.Optional;
4+
import java.util.stream.Stream;
5+
6+
import org.junit.Test;
7+
import static org.junit.Assert.assertEquals;
8+
9+
public class OptionalToStreamTest {
10+
11+
@Test
12+
public void testOptionalToStream() {
13+
Optional<String> op = Optional.ofNullable("String value");
14+
Stream<String> strOptionalStream = op.stream();
15+
Stream<String> filteredStream = strOptionalStream.filter((str) -> {
16+
return str != null && str.startsWith("String");
17+
});
18+
assertEquals(1, filteredStream.count());
19+
20+
}
21+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.baeldung.java9;
2+
3+
import java.util.Set;
4+
import org.junit.Test;
5+
6+
import static org.junit.Assert.assertEquals;
7+
8+
public class SetExamplesTest {
9+
10+
@Test
11+
public void testUnmutableSet() {
12+
Set<String> strKeySet = Set.of("key1", "key2", "key3");
13+
try {
14+
strKeySet.add("newKey");
15+
} catch (UnsupportedOperationException uoe) {
16+
}
17+
assertEquals(strKeySet.size(), 3);
18+
}
19+
20+
@Test
21+
public void testArrayToSet() {
22+
Integer[] intArray = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
23+
Set<Integer> intSet = Set.of(intArray);
24+
assertEquals(intSet.size(), intArray.length);
25+
}
26+
}

0 commit comments

Comments
 (0)