From 7a7ad7b368bcd7dcec6543c3467d1dfd69d7fb14 Mon Sep 17 00:00:00 2001 From: eugenp Date: Wed, 26 Aug 2015 12:10:06 +0300 Subject: [PATCH] testing work --- .../java8/base64/Java8EncodeDecodeTest.java | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/core-java-8/src/test/java/org/baeldung/java8/base64/Java8EncodeDecodeTest.java b/core-java-8/src/test/java/org/baeldung/java8/base64/Java8EncodeDecodeTest.java index c8d57d40b3..7b7a0be26a 100644 --- a/core-java-8/src/test/java/org/baeldung/java8/base64/Java8EncodeDecodeTest.java +++ b/core-java-8/src/test/java/org/baeldung/java8/base64/Java8EncodeDecodeTest.java @@ -15,9 +15,10 @@ public class Java8EncodeDecodeTest { // tests @Test - public void whenStringIsEncoded() throws UnsupportedEncodingException { + public void whenStringIsEncoded_thenOk() throws UnsupportedEncodingException { final String originalInput = "test input"; final String encodedString = Base64.getEncoder().encodeToString(originalInput.getBytes()); + assertNotNull(encodedString); assertNotEquals(originalInput, encodedString); } @@ -35,9 +36,10 @@ public class Java8EncodeDecodeTest { } @Test - public void whenStringIsEncodedWithoutPadding() throws UnsupportedEncodingException { + public void whenStringIsEncodedWithoutPadding_thenOk() throws UnsupportedEncodingException { final String originalInput = "test input"; final String encodedString = Base64.getEncoder().withoutPadding().encodeToString(originalInput.getBytes()); + assertNotNull(encodedString); assertNotEquals(originalInput, encodedString); } @@ -55,25 +57,27 @@ public class Java8EncodeDecodeTest { } @Test - public void whenURLIsEncoded() throws UnsupportedEncodingException { - final String originalURL = "https://www.google.co.nz/?gfe_rd=cr&ei=dzbFVf&gws_rd=ssl#q=java"; - final String encodedURL = Base64.getUrlEncoder().encodeToString(originalURL.getBytes()); - assertNotNull(encodedURL); - assertNotEquals(originalURL, encodedURL); + public void whenUrlIsEncoded_thenOk() throws UnsupportedEncodingException { + final String originalUrl = "https://www.google.co.nz/?gfe_rd=cr&ei=dzbFVf&gws_rd=ssl#q=java"; + final String encodedUrl = Base64.getUrlEncoder().encodeToString(originalUrl.getBytes()); + assertNotNull(encodedUrl); + assertNotEquals(originalUrl, encodedUrl); } @Test - public void whenURLIsEncoded_thenURLCanBeDecoded() throws UnsupportedEncodingException { - final String originalURL = "https://www.google.co.nz/?gfe_rd=cr&ei=dzbFVf&gws_rd=ssl#q=java"; - final String encodedURL = Base64.getUrlEncoder().encodeToString(originalURL.getBytes()); - final byte[] decodedBytes = Base64.getUrlDecoder().decode(encodedURL.getBytes()); - final String decodedURL = new String(decodedBytes); - assertNotNull(decodedURL); - assertEquals(originalURL, decodedURL); + public void whenUrlIsEncoded_thenURLCanBeDecoded() throws UnsupportedEncodingException { + final String originalUrl = "https://www.google.co.nz/?gfe_rd=cr&ei=dzbFVf&gws_rd=ssl#q=java"; + final String encodedUrl = Base64.getUrlEncoder().encodeToString(originalUrl.getBytes()); + + final byte[] decodedBytes = Base64.getUrlDecoder().decode(encodedUrl.getBytes()); + final String decodedUrl = new String(decodedBytes); + + assertNotNull(decodedUrl); + assertEquals(originalUrl, decodedUrl); } @Test - public void whenMIMEIsEncoded() throws UnsupportedEncodingException { + public void whenMimeIsEncoded_thenOk() throws UnsupportedEncodingException { final StringBuilder buffer = getMimeBuffer(); final byte[] forEncode = buffer.toString().getBytes(); @@ -83,7 +87,7 @@ public class Java8EncodeDecodeTest { } @Test - public void whenMIMEIsEncoded_thenMIMECanBeDecoded() throws UnsupportedEncodingException { + public void whenMimeIsEncoded_thenItCanBeDecoded() throws UnsupportedEncodingException { final StringBuilder buffer = getMimeBuffer(); final byte[] forEncode = buffer.toString().getBytes();