Monday, July 16, 2018

PowerMockito: java.security.NoSuchAlgorithmException: class configured for SSLContext: sun.security.ssl.SSLContextImpl$TLSContext not a SSLContext

Problem

Following exception is encountered while running a JUnit test written using PowerMockito.
org.apache.http.ssl.SSLInitializationException: class configured for SSLContext: sun.security.ssl.SSLContextImpl$\$$TLSContext not a SSLContext
at org.apache.http.ssl.SSLContexts.createDefault(SSLContexts.java:55)
at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:964)
.................
.................

Caused by: java.security.NoSuchAlgorithmException: class configured for SSLContext: sun.security.ssl.SSLContextImpl$\$$TLSContext not a SSLContext
.................
.................

Solution

This can be fixed by adding following annotation to the test class.

@PowerMockIgnore({"javax.net.ssl.*"})








PowerMockito: java.lang.AssertionError: Illegal subclass: class com.sun.net.ssl.internal.ssl.Provider

Problem

Following exception is encountered while running a JUnit test written using PowerMockito.
java.lang.AssertionError: Illegal subclass: class com.sun.net.ssl.internal.ssl.Provider

at sun.security.ssl.SunJSSE.subclassCheck(SunJSSE.java:235)
at sun.security.ssl.SunJSSE.(SunJSSE.java:108)
at com.sun.net.ssl.internal.ssl.Provider.(Provider.java:41)
.................
.................

Solution

This can be fixed by adding following annotation to the test class.

@PowerMockIgnore({"com.sun.net.ssl.internal.ssl.Provider"})








Tuesday, July 10, 2018

Replacing With Spaces for Tabs in VI/VIM

$\mathtt{REFERENCE}$ @ Stackover

Requirement

Recently I have been doing my programming in VIM. My IDE is customized to use 2 Space Characters for a Tab. This was not the case in the VIM. I wanted the same behavior in VIM as well.

Solution

Luckily there is a very simple solution.
:set tabstop=2 shiftwidth=2 expandtab
should do the trick.

If you already have tabs, then follow it up with a nice global RE to replace them with double spaces.

If you want to persist the behavior for all the files you work with VIM, you can place the command in the file~/.vimrc (:scriptnames to see all files loaded by VIM). Otherwise you can enter the command every time you need it.