StatisticsKeyTool { public PublicKey loadPublicKeyFromClassPath() { InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(OXALIS_STATISTICS_PUBLIC_KEY); if (inputStream == null) { throw new IllegalStateException("Unable to locate file " + OXALIS_STATISTICS_PUBLIC_KEY); } try { byte[] bytes = loadBytesFrom(inputStream); log.info("Loaded public key with " + bytes.length + " bytes"); return publicKeyFromBytes(bytes); } catch (InvalidKeySpecException e) { throw new IllegalStateException("Invalid public key encoded in " + OXALIS_STATISTICS_PUBLIC_KEY, e); } finally { try { inputStream.close(); } catch (IOException e) { throw new IllegalStateException("Unable to close input stream for " + OXALIS_STATISTICS_PUBLIC_KEY, e); } } }  PublicKey loadPublicKeyFromClassPath(); PublicKey loadPublicKey(File file); static final String ASYMMETRIC_KEY_ALGORITHM; static final String OXALIS_STATISTICS_PUBLIC_KEY; static final int MAX_LENGTH_OF_ENCODED_KEY; }
@Test public void loadPublicKeyFromClassPath() { StatisticsKeyTool statisticsKeyTool = new StatisticsKeyTool(); PublicKey publicKey = statisticsKeyTool.loadPublicKeyFromClassPath(); assertNotNull(publicKey); }