1212import java .nio .channels .SocketChannel ;
1313import java .nio .file .Files ;
1414import java .nio .file .Path ;
15- import java .nio .file .Paths ;
1615import java .util .concurrent .CountDownLatch ;
1716import java .util .concurrent .Executors ;
1817import java .util .logging .Logger ;
@@ -35,7 +34,7 @@ public void testAssertionKeyWord() {
3534
3635 @ Test
3736 public void testNewInputOutputAkaNIO () throws IOException {
38- Path path = Paths . get ("src" , "test" , "resources" , "nio.txt" );
37+ Path path = Path . of ("src" , "test" , "resources" , "nio.txt" );
3938 byte [] fileBytes = Files .readAllBytes (path );
4039 String content = new String (fileBytes );
4140 Assertions .assertEquals ("Hello NIO!" , content );
@@ -44,12 +43,12 @@ public void testNewInputOutputAkaNIO() throws IOException {
4443 @ Test
4544 public void testRegex () {
4645 Pattern pattern = Pattern .compile ("<title>(.*)</title>" , Pattern .DOTALL );
47- Matcher matcher = pattern .matcher (getTestHtml ());
46+ Matcher matcher = pattern .matcher (createTestHtml ());
4847 Assertions .assertTrue (matcher .find ());
4948 Assertions .assertEquals ("Title" , matcher .group (1 ));
5049 }
5150
52- private String getTestHtml () {
51+ private String createTestHtml () {
5352 return """
5453 <!DOCTYPE html>
5554 <html lang="en">
@@ -89,6 +88,7 @@ public void testImageIO() throws IOException {
8988 BufferedImage image = ImageIO .read (new File ("src/test/resources/imageio.png" ));
9089 Assertions .assertTrue (ImageIO .write (image , "jpg" , File .createTempFile ("imageio" , ".jpg" )));
9190 }
91+
9292 @ Test
9393 public void testServerClientSocketChannel () throws IOException , InterruptedException {
9494 int port = 8004 ;
@@ -124,5 +124,4 @@ private void handleConnectedClient(ServerSocket serverSocket) throws IOException
124124 }
125125 }
126126
127-
128127}
0 commit comments