Base64 decode returns null in test environment
<p>I am trying to run Unit Tests on my code, and one test fails, when I got deeper I notice that <code>Base64.decode()</code> always return <strong>null</strong> in test environment. My specific case is:</p>

<p>The method to test</p>

<pre><code>public String decode(String jwt){
    System.out.println(jwt); //eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9
    byte[] data = Base64.decode(jwt, Base64.DEFAULT);
    return new String(data, "UTF-8"); //null pointer exception - data = null
}
</code></pre>

<p>Test itself:</p>

<pre><code>@Test
public void validateBase64Decode() {
    String stringToTest = "eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9";
    String expectedResult = "{\"sub\": \"1234567890\", \"name\": \"John Doe\", \"admin\": true}";
    Assert.assertEquals(Util.decode(stringToTest), expectedResult);
}
</code></pre>

<p>The test always fails due to null pointer exception:</p>

<pre><code>java.lang.NullPointerException
    at java.lang.String.&lt;init&gt;(String.java:481)
</code></pre>

<p>Thus I went further and found that any String in test environment cannot be decoded:</p>

<pre><code>  @Test
  public void validateBase64Decode() {
         Assert.assertNotNull(Base64.decode("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9", 0));     
} //Test NEVER passes - assertion error
</code></pre>

<p>Please, any guru here? What is wrong ? Thanks in advance</p>