Skip to content

Commit

Permalink
testing work
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenp committed Aug 26, 2015
1 parent b7822cc commit 7a7ad7b
Showing 1 changed file with 20 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -35,9 +36,10 @@ public void whenStringIsEncoded_thenStringCanBeDecoded() throws UnsupportedEncod
}

@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);
}
Expand All @@ -55,25 +57,27 @@ public void whenStringIsEncodedWithoutPadding_thenStringCanBeDecoded() throws Un
}

@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();
Expand All @@ -83,7 +87,7 @@ public void whenMIMEIsEncoded() throws UnsupportedEncodingException {
}

@Test
public void whenMIMEIsEncoded_thenMIMECanBeDecoded() throws UnsupportedEncodingException {
public void whenMimeIsEncoded_thenItCanBeDecoded() throws UnsupportedEncodingException {
final StringBuilder buffer = getMimeBuffer();

final byte[] forEncode = buffer.toString().getBytes();
Expand Down

0 comments on commit 7a7ad7b

Please sign in to comment.