Skip to content

Commit

Permalink
Java 5 compatibilty updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
dghgit committed Jun 19, 2023
1 parent a9da560 commit 54cac17
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;

Expand All @@ -16,6 +14,8 @@
import junit.framework.TestCase;
import org.bouncycastle.est.ESTResponse;
import org.bouncycastle.est.Source;
import org.bouncycastle.util.Strings;
import org.bouncycastle.util.encoders.Base64;
import org.bouncycastle.util.io.Streams;

public class ESTResponseTest
Expand Down Expand Up @@ -98,7 +98,7 @@ public void assertESTResponseMessageEquals(String expected, ESTResponse response
try
{
byte[] data = Streams.readAll(response.getInputStream());
String dataString = new String(data, StandardCharsets.UTF_8);
String dataString = Strings.fromUTF8ByteArray(data);
assertEquals(expected, dataString);
}
catch (IOException e)
Expand Down Expand Up @@ -145,7 +145,7 @@ public void testESTResponseShouldSupportContentTransferEncodingBase64()
throws IOException
{
String data = "Test message body";
String dataBase64 = Base64.getEncoder().encodeToString(data.getBytes(StandardCharsets.UTF_8));
String dataBase64 = Base64.toBase64String(Strings.toUTF8ByteArray(data));

Map<String, String> httpHeader = new HashMap<String, String>();
httpHeader.put("content-transfer-encoding", "base64");
Expand Down Expand Up @@ -207,7 +207,7 @@ public void testESTResponseMustNotThrowOnChunkedTransferEncodingWithContentTrans
throws IOException
{
String data = "Test message body";
String dataBase64 = Base64.getEncoder().encodeToString(data.getBytes(StandardCharsets.UTF_8));
String dataBase64 = Base64.toBase64String(Strings.toUTF8ByteArray(data));

Map<String, String> httpHeader = new HashMap<String, String>();
httpHeader.put("content-transfer-encoding", "base64");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2108,6 +2108,11 @@ public String getName()
private void testJKS()
throws Exception
{
if (System.getProperty("java.version").indexOf("1.5.") == 0)
{
return;
}

KeyStore ks = KeyStore.getInstance("PKCS12", BC);

ks.load(new ByteArrayInputStream(JKS_Store), JKS_TEST_PWD);
Expand Down

0 comments on commit 54cac17

Please sign in to comment.