SignatureService { public void validatePes(byte[] pesFile) throws SignatureException { validatePes(new ByteArrayInputStream(pesFile)); }  void validatePes(byte[] pesFile); void validatePes(InputStream pesStream);  }
@Test public void testAlteredSignature() throws Exception { boolean valid = true; InputStream pesFile = new ClassPathResource("data/test-alteree.xml").getInputStream(); try { signatureService.validatePes(pesFile); } catch (SignatureException e) { valid = false; } Assert.assertFalse(valid); }
@Test public void testValidSignature() throws Exception { boolean valid = true; InputStream pesFile = new ClassPathResource("data/PESALR2_25060187900027_190328_001.xml").getInputStream(); try { signatureService.validatePes(pesFile); } catch (SignatureException e) { valid = false; } Assert.assertTrue(valid); }
@Test public void testExpiredSignature() throws Exception { boolean valid = true; InputStream pesFile = new ClassPathResource("data/test-perime-04-04-2016.xml").getInputStream(); try { signatureService.validatePes(pesFile); } catch (SignatureException e) { valid = false; } Assert.assertFalse(valid); }