testing work

This commit is contained in:
eugenp 2015-08-26 12:10:06 +03:00
parent b7822cc678
commit 7a7ad7b368
1 changed files with 20 additions and 16 deletions

View File

@ -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();