Skip to content

Commit

Permalink
Merge pull request eugenp#694 from anton-k11/master
Browse files Browse the repository at this point in the history
BAEL-27 Java 9 New Features
  • Loading branch information
mklew authored Sep 26, 2016
2 parents b576a4d + 9965605 commit 302ac3a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 12 deletions.
11 changes: 1 addition & 10 deletions core-java-9/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,8 @@
<configuration>
<source>1.9</source>
<target>1.9</target>

<verbose>true</verbose>
<!-- <executable>C:\develop\jdks\jdk-9_ea122\bin\javac</executable>
<compilerVersion>1.9</compilerVersion> -->
</configuration>

</plugin>

<plugin>
Expand All @@ -85,12 +81,7 @@


<!-- maven plugins -->
<!--
<maven-war-plugin.version>2.6</maven-war-plugin.version>
maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version> -->
<maven-compiler-plugin.version>3.6-jigsaw-SNAPSHOT</maven-compiler-plugin.version>


<maven-compiler-plugin.version>3.6-jigsaw-SNAPSHOT</maven-compiler-plugin.version>
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>

<!-- testing -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.baeldung.java9;

import static org.junit.Assert.assertTrue;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.baeldung.java9;

import java.util.Optional;
import java.util.stream.Stream;

import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class OptionalToStreamTest {

@Test
public void testOptionalToStream() {
Optional<String> op = Optional.ofNullable("String value");
Stream<String> strOptionalStream = op.stream();
Stream<String> filteredStream = strOptionalStream.filter((str) -> {
return str != null && str.startsWith("String");
});
assertEquals(1, filteredStream.count());

}
}
26 changes: 26 additions & 0 deletions core-java-9/src/test/java/com/baeldung/java9/SetExamplesTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.baeldung.java9;

import java.util.Set;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class SetExamplesTest {

@Test
public void testUnmutableSet() {
Set<String> strKeySet = Set.of("key1", "key2", "key3");
try {
strKeySet.add("newKey");
} catch (UnsupportedOperationException uoe) {
}
assertEquals(strKeySet.size(), 3);
}

@Test
public void testArrayToSet() {
Integer[] intArray = new Integer[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
Set<Integer> intSet = Set.of(intArray);
assertEquals(intSet.size(), intArray.length);
}
}

0 comments on commit 302ac3a

Please sign in to comment.