Buggy code:
public class TestSignatureInfo { private static final POILogger LOG = POILogFactory . getLogger ( TestSignatureInfo . class ) ; private static final POIDataSamples testdata = POIDataSamples . getXmlDSignInstance ( ) ; private static Calendar cal ; private KeyPair keyPair = null ; private X509Certificate x509 = null ; @ BeforeClass public static void initBouncy ( ) throws IOException { } @ Test public void office2007prettyPrintedRels ( ) throws Exception { } @ Test public void getSignerUnsigned ( ) throws Exception { } @ Test public void getSigner ( ) throws Exception { } @ Test public void getMultiSigners ( ) throws Exception { } @ Test public void testSignSpreadsheet ( ) throws Exception { } @ Test public void testManipulation ( ) throws Exception { } @ Test public void testSignSpreadsheetWithSignatureInfo ( ) throws Exception { } @ Test public void testSignEnvelopingDocument ( ) throws Exception { String testFile = "hello-world-unsigned.xlsx" ; OPCPackage pkg = OPCPackage . open ( TestSignatureInfo . copy ( TestSignatureInfo . testdata . getFile ( testFile ) ) , READ_WRITE ) ; initKeyPair ( "Test" , "CN=Test" ) ; final X509CRL crl = PkiTestUtils . generateCrl ( x509 , keyPair . getPrivate ( ) ) ; SignatureConfig signatureConfig = new SignatureConfig ( ) ; signatureConfig . setOpcPackage ( pkg ) ; signatureConfig . setKey ( keyPair . getPrivate ( ) ) ; List < X509Certificate > certificateChain = new ArrayList < X509Certificate > ( ) ; certificateChain . add ( x509 ) ; certificateChain . add ( x509 ) ; signatureConfig . setSigningCertificateChain ( certificateChain ) ; signatureConfig . addSignatureFacet ( new EnvelopedSignatureFacet ( ) ) ; signatureConfig . addSignatureFacet ( new KeyInfoSignatureFacet ( ) ) ; signatureConfig . addSignatureFacet ( new XAdESSignatureFacet ( ) ) ; signatureConfig . addSignatureFacet ( new XAdESXLSignatureFacet ( ) ) ; <START_BUG> boolean mockTsp = ( TestSignatureInfo . getAccessError ( "http:////timestamp.comodoca.com//rfc3161" , true , 10000 ) ) == null ; <END_BUG> signatureConfig . setTspUrl ( "http:////timestamp.comodoca.com//rfc3161" ) ; signatureConfig . setTspRequestPolicy ( null ) ; signatureConfig . setTspOldProtocol ( false ) ; String proxy = System . getProperty ( "http_proxy" ) ; if ( ( proxy != null ) && ( ( proxy . trim ( ) . length ( ) ) > 0 ) ) { signatureConfig . setProxyUrl ( proxy ) ; } if ( mockTsp ) { TimeStampService tspService = new TimeStampService ( ) { @ Override public byte [ ] timeStamp ( byte [ ] data , RevocationData revocationData ) throws Exception { revocationData . addCRL ( crl ) ; return "time-stamp-token" . getBytes ( ) ; } @ Override public void setSignatureConfig ( SignatureConfig config ) { } } ; signatureConfig . setTspService ( tspService ) ; } else { TimeStampServiceValidator tspValidator = new TimeStampServiceValidator ( ) { @ Override public void validate ( List < X509Certificate > certificateChain , RevocationData revocationData ) throws Exception { for ( X509Certificate certificate : certificateChain ) { TestSignatureInfo . LOG . log ( DEBUG , ( "certificate:<seq2seq4repair_space>" + ( certificate . getSubjectX500Principal ( ) ) ) ) ; TestSignatureInfo . LOG . log ( DEBUG , ( ( ( "validity:<seq2seq4repair_space>" + ( certificate . getNotBefore ( ) ) ) + "<seq2seq4repair_space>-<seq2seq4repair_space>" ) + ( certificate . getNotAfter ( ) ) ) ) ; } } } ; signatureConfig . setTspValidator ( tspValidator ) ; signatureConfig . setTspOldProtocol ( signatureConfig . getTspUrl ( ) . contains ( "edelweb" ) ) ; } final RevocationData revocationData = new RevocationData ( ) ; revocationData . addCRL ( crl ) ; OCSPResp ocspResp = PkiTestUtils . createOcspResp ( x509 , false , x509 , x509 , keyPair . getPrivate ( ) , "SHA1withRSA" , TestSignatureInfo . cal . getTimeInMillis ( ) ) ; revocationData . addOCSP ( ocspResp . getEncoded ( ) ) ; RevocationDataService revocationDataService = new RevocationDataService ( ) { @ Override public RevocationData getRevocationData ( List < X509Certificate > certificateChain ) { return revocationData ; } } ; signatureConfig . setRevocationDataService ( revocationDataService ) ; SignatureInfo si = new SignatureInfo ( ) ; si . setSignatureConfig ( signatureConfig ) ; try { si . confirmSignature ( ) ; } catch ( RuntimeException e ) { assertNotNull ( ( "Only<seq2seq4repair_space>allowing<seq2seq4repair_space>ConnectException<seq2seq4repair_space>here,<seq2seq4repair_space>but<seq2seq4repair_space>had:<seq2seq4repair_space>" + e ) , e . getCause ( ) ) ; if ( ! ( ( e . getCause ( ) ) instanceof ConnectException ) ) { throw e ; } assertTrue ( ( "Only<seq2seq4repair_space>allowing<seq2seq4repair_space>ConnectException<seq2seq4repair_space>here,<seq2seq4repair_space>but<seq2seq4repair_space>had:<seq2seq4repair_space>" + e ) , e . getCause ( ) . getMessage ( ) . contains ( "timed<seq2seq4repair_space>out" ) ) ; } Iterator < SignaturePart > spIter = si . getSignatureParts ( ) . iterator ( ) ; assertTrue ( spIter . hasNext ( ) ) ; SignaturePart sp = spIter . next ( ) ; boolean valid = sp . validate ( ) ; assertTrue ( valid ) ; SignatureDocument sigDoc = sp . getSignatureDocument ( ) ; String declareNS = "declare<seq2seq4repair_space>namespace<seq2seq4repair_space>xades='http:////uri.etsi.org//01903//v1.3.2#';<seq2seq4repair_space>" + "declare<seq2seq4repair_space>namespace<seq2seq4repair_space>ds='http:////www.w3.org//2000//09//xmldsig#';<seq2seq4repair_space>" ; String digestValXQuery = declareNS + "$this//ds:Signature//ds:SignedInfo//ds:Reference" ; for ( ReferenceType rt : ( ( ReferenceType [ ] ) ( sigDoc . selectPath ( digestValXQuery ) ) ) ) { assertNotNull ( rt . getDigestValue ( ) ) ; assertEquals ( signatureConfig . getDigestMethodUri ( ) , rt . getDigestMethod ( ) . getAlgorithm ( ) ) ; } String certDigestXQuery = declareNS + "$this////xades:SigningCertificate//xades:Cert//xades:CertDigest" ; XmlObject [ ] xoList = sigDoc . selectPath ( certDigestXQuery ) ; assertEquals ( xoList . length , 1 ) ; DigestAlgAndValueType certDigest = ( ( DigestAlgAndValueType ) ( xoList [ 0 ] ) ) ; assertNotNull ( certDigest . getDigestValue ( ) ) ; String qualPropXQuery = declareNS + "$this//ds:Signature//ds:Object//xades:QualifyingProperties" ; xoList = sigDoc . selectPath ( qualPropXQuery ) ; assertEquals ( xoList . length , 1 ) ; QualifyingPropertiesType qualProp = ( ( QualifyingPropertiesType ) ( xoList [ 0 ] ) ) ; boolean qualPropXsdOk = qualProp . validate ( ) ; assertTrue ( qualPropXsdOk ) ; pkg . close ( ) ; }

Fix:
boolean mockTsp = ( TestSignatureInfo . getAccessError ( "http:////timestamp.comodoca.com//rfc3161" , true , 10000 ) ) != null ;