本文整理汇总了Java中com.helger.commons.io.resource.ClassPathResource类的典型用法代码示例。如果您正苦于以下问题:Java ClassPathResource类的具体用法?Java ClassPathResource怎么用?Java ClassPathResource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClassPathResource类属于com.helger.commons.io.resource包,在下文中一共展示了ClassPathResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testUserMessageSOAPBodyPayloadEncryptSuccess
import com.helger.commons.io.resource.ClassPathResource; //导入依赖的package包/类
@Test
public void testUserMessageSOAPBodyPayloadEncryptSuccess () throws Exception
{
final Node aPayload = DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
final ICommonsList <WSS4JAttachment> aAttachments = new CommonsArrayList <> ();
Document aDoc = MockMessages.testUserMessageSoapNotSigned (m_eSOAPVersion, aPayload, aAttachments);
aDoc = new EncryptionCreator (AS4CryptoFactory.DEFAULT_INSTANCE).encryptSoapBodyPayload (m_eSOAPVersion,
aDoc,
false,
ECryptoAlgorithmCrypt.ENCRPYTION_ALGORITHM_DEFAULT);
final String sResponse = sendPlainMessage (new HttpXMLEntity (aDoc, m_eSOAPVersion), true, null);
assertTrue (sResponse.contains (AS4TestConstants.RECEIPT_ASSERTCHECK));
}
示例2: testUserMessageSOAPBodyPayloadSignedEncryptedSuccess
import com.helger.commons.io.resource.ClassPathResource; //导入依赖的package包/类
@Test
public void testUserMessageSOAPBodyPayloadSignedEncryptedSuccess () throws Exception
{
final Node aPayload = DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
final ICommonsList <WSS4JAttachment> aAttachments = new CommonsArrayList <> ();
Document aDoc = MockMessages.testSignedUserMessage (m_eSOAPVersion, aPayload, aAttachments, s_aResMgr);
aDoc = new EncryptionCreator (AS4CryptoFactory.DEFAULT_INSTANCE).encryptSoapBodyPayload (m_eSOAPVersion,
aDoc,
false,
ECryptoAlgorithmCrypt.ENCRPYTION_ALGORITHM_DEFAULT);
final String sResponse = sendPlainMessage (new HttpXMLEntity (aDoc, m_eSOAPVersion), true, null);
assertTrue (sResponse.contains (AS4TestConstants.RECEIPT_ASSERTCHECK));
assertTrue (sResponse.contains (AS4TestConstants.NON_REPUDIATION_INFORMATION));
assertTrue (sResponse.contains (ECryptoAlgorithmSign.SIGN_ALGORITHM_DEFAULT.getAlgorithmURI ()));
assertTrue (sResponse.contains (ECryptoAlgorithmSignDigest.SIGN_DIGEST_ALGORITHM_DEFAULT.getAlgorithmURI ()));
}
示例3: testUserMessageOneAttachmentMimeSuccess
import com.helger.commons.io.resource.ClassPathResource; //导入依赖的package包/类
@Test
public void testUserMessageOneAttachmentMimeSuccess () throws Exception
{
final ICommonsList <WSS4JAttachment> aAttachments = new CommonsArrayList <> ();
final AS4ResourceManager aResMgr = s_aResMgr;
aAttachments.add (WSS4JAttachment.createOutgoingFileAttachment (ClassPathResource.getAsFile (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML),
CMimeType.APPLICATION_XML,
null,
aResMgr));
final MimeMessage aMsg = MimeMessageCreator.generateMimeMessage (m_eSOAPVersion,
MockMessages.testUserMessageSoapNotSigned (m_eSOAPVersion,
null,
aAttachments),
aAttachments);
final String sResponse = sendMimeMessage (new HttpMimeMessageEntity (aMsg), true, null);
assertTrue (sResponse.contains (AS4TestConstants.RECEIPT_ASSERTCHECK));
}
示例4: testUserMessageOneAttachmentEncryptedMimeSuccess
import com.helger.commons.io.resource.ClassPathResource; //导入依赖的package包/类
@Test
public void testUserMessageOneAttachmentEncryptedMimeSuccess () throws Exception
{
final ICommonsList <WSS4JAttachment> aAttachments = new CommonsArrayList <> ();
final AS4ResourceManager aResMgr = s_aResMgr;
aAttachments.add (WSS4JAttachment.createOutgoingFileAttachment (ClassPathResource.getAsFile (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML),
CMimeType.APPLICATION_XML,
null,
aResMgr));
final MimeMessage aMsg = new EncryptionCreator (AS4CryptoFactory.DEFAULT_INSTANCE).encryptMimeMessage (m_eSOAPVersion,
MockMessages.testUserMessageSoapNotSigned (m_eSOAPVersion,
null,
aAttachments),
false,
aAttachments,
s_aResMgr,
ECryptoAlgorithmCrypt.ENCRPYTION_ALGORITHM_DEFAULT);
final String sResponse = sendMimeMessage (new HttpMimeMessageEntity (aMsg), true, null);
assertTrue (sResponse.contains (AS4TestConstants.RECEIPT_ASSERTCHECK));
}
示例5: testPayloadChangedAfterSigningShouldFail
import com.helger.commons.io.resource.ClassPathResource; //导入依赖的package包/类
@Test
public void testPayloadChangedAfterSigningShouldFail () throws Exception
{
final Node aPayload = DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
final ICommonsList <WSS4JAttachment> aAttachments = new CommonsArrayList <> ();
final Document aDoc = MockMessages.testSignedUserMessage (m_eSOAPVersion, aPayload, aAttachments, s_aResMgr);
final NodeList nList = aDoc.getElementsByTagName (m_eSOAPVersion.getNamespacePrefix () + ":Body");
for (int i = 0; i < nList.getLength (); i++)
{
final Node nNode = nList.item (i);
final Element eElement = (Element) nNode;
eElement.setAttribute ("INVALID", "INVALID");
}
sendPlainMessage (new HttpXMLEntity (aDoc, m_eSOAPVersion),
false,
EEbmsError.EBMS_FAILED_DECRYPTION.getErrorCode ());
}
示例6: testCompressionStandalone
import com.helger.commons.io.resource.ClassPathResource; //导入依赖的package包/类
@Test
public void testCompressionStandalone () throws IOException
{
final byte [] aSrc = StreamHelper.getAllBytes (ClassPathResource.getInputStream ("SOAPBodyPayload.xml"));
assertNotNull (aSrc);
// Compression
final NonBlockingByteArrayOutputStream aCompressedOS = new NonBlockingByteArrayOutputStream ();
_compressPayload (new NonBlockingByteArrayInputStream (aSrc), aCompressedOS);
final byte [] aCompressed = aCompressedOS.toByteArray ();
// DECOMPRESSION
final NonBlockingByteArrayOutputStream aDecompressedOS = new NonBlockingByteArrayOutputStream ();
_decompressPayload (new NonBlockingByteArrayInputStream (aCompressed), aDecompressedOS);
final byte [] aDecompressed = aDecompressedOS.toByteArray ();
assertArrayEquals (aSrc, aDecompressed);
}
示例7: testUserMessageMessageInfoIDMissing
import com.helger.commons.io.resource.ClassPathResource; //导入依赖的package包/类
@Test
public void testUserMessageMessageInfoIDMissing ()
{
final CollectingValidationEventHandler aCVEH = new CollectingValidationEventHandler ();
final Soap11Envelope aEnv = Ebms3ReaderBuilder.soap11 ()
.setValidationEventHandler (aCVEH)
.read (new ClassPathResource ("/soap11test/MessageInfoIDMissing.xml"));
assertNotNull (aEnv);
assertTrue (aCVEH.getErrorList ().isEmpty ());
assertNotNull (aEnv.getHeader ());
assertEquals (1, aEnv.getHeader ().getAnyCount ());
assertTrue (aEnv.getHeader ().getAnyAtIndex (0) instanceof Element);
final Ebms3Messaging aMessage = Ebms3ReaderBuilder.ebms3Messaging ()
.setValidationEventHandler (aCVEH)
.read ((Element) aEnv.getHeader ().getAnyAtIndex (0));
assertTrue (aCVEH.getErrorList ().containsAtLeastOneError ());
assertNull (aMessage);
}
示例8: testUserMessageWithBodyPayloadOnlyNoInfo
import com.helger.commons.io.resource.ClassPathResource; //导入依赖的package包/类
@Test
public void testUserMessageWithBodyPayloadOnlyNoInfo () throws Exception
{
final Node aPayload = DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
final Document aDoc = MockMessages.testUserMessageSoapNotSigned (m_eSOAPVersion, aPayload, null);
// Delete the added Payload in the soap body to confirm right behaviour when
// the payload is missing
Node aNext = XMLHelper.getFirstChildElementOfName (aDoc, "Envelope");
aNext = XMLHelper.getFirstChildElementOfName (aNext, "Header");
aNext = XMLHelper.getFirstChildElementOfName (aNext, CAS4.EBMS_NS, "Messaging");
aNext = XMLHelper.getFirstChildElementOfName (aNext, CAS4.EBMS_NS, AS4TestConstants.USERMESSAGE_ASSERTCHECK);
aNext = XMLHelper.getFirstChildElementOfName (aNext, CAS4.EBMS_NS, "PayloadInfo");
aNext.getParentNode ().removeChild (aNext);
sendPlainMessage (new HttpXMLEntity (aDoc, m_eSOAPVersion),
false,
EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode ());
}
示例9: testUserMessageWithAttachmentPartInfoOnly
import com.helger.commons.io.resource.ClassPathResource; //导入依赖的package包/类
@Test
public void testUserMessageWithAttachmentPartInfoOnly () throws Exception
{
final ICommonsList <WSS4JAttachment> aAttachments = new CommonsArrayList <> ();
final AS4ResourceManager aResMgr = s_aResMgr;
aAttachments.add (WSS4JAttachment.createOutgoingFileAttachment (ClassPathResource.getAsFile (AS4TestConstants.ATTACHMENT_TEST_XML_GZ),
CMimeType.APPLICATION_GZIP,
null,
aResMgr));
final MimeMessage aMsg = MimeMessageCreator.generateMimeMessage (m_eSOAPVersion,
MockMessages.testUserMessageSoapNotSigned (m_eSOAPVersion,
null,
aAttachments),
aAttachments);
final SoapMimeMultipart aMultipart = (SoapMimeMultipart) aMsg.getContent ();
// Since we want to remove the attachment
aMultipart.removeBodyPart (1);
aMsg.saveChanges ();
sendMimeMessage (new HttpMimeMessageEntity (aMsg), false, EEbmsError.EBMS_EXTERNAL_PAYLOAD_ERROR.getErrorCode ());
}
示例10: testUserMessageWithOnlyAttachmentsNoPartInfo
import com.helger.commons.io.resource.ClassPathResource; //导入依赖的package包/类
@Test
public void testUserMessageWithOnlyAttachmentsNoPartInfo () throws Exception
{
final ICommonsList <WSS4JAttachment> aAttachments = new CommonsArrayList <> ();
final Document aSoapDoc = MockMessages.testUserMessageSoapNotSigned (m_eSOAPVersion, null, aAttachments);
final AS4ResourceManager aResMgr = s_aResMgr;
aAttachments.add (WSS4JAttachment.createOutgoingFileAttachment (ClassPathResource.getAsFile (AS4TestConstants.ATTACHMENT_TEST_XML_GZ),
CMimeType.APPLICATION_GZIP,
null,
aResMgr));
final MimeMessage aMsg = MimeMessageCreator.generateMimeMessage (m_eSOAPVersion,
aSoapDoc,
aAttachments);
aMsg.saveChanges ();
sendMimeMessage (new HttpMimeMessageEntity (aMsg), false, EEbmsError.EBMS_EXTERNAL_PAYLOAD_ERROR.getErrorCode ());
}
示例11: testUserMessageWithCompressedAttachmentSuccessful
import com.helger.commons.io.resource.ClassPathResource; //导入依赖的package包/类
@Category (IHolodeckTests.class)
@Test
public void testUserMessageWithCompressedAttachmentSuccessful () throws Exception
{
final ICommonsList <WSS4JAttachment> aAttachments = new CommonsArrayList <> ();
aAttachments.add (WSS4JAttachment.createOutgoingFileAttachment (ClassPathResource.getAsFile (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML),
CMimeType.APPLICATION_XML,
EAS4CompressionMode.GZIP,
s_aResMgr));
final MimeMessage aMsg = MimeMessageCreator.generateMimeMessage (m_eSOAPVersion,
MockMessages.testUserMessageSoapNotSigned (m_eSOAPVersion,
null,
aAttachments),
aAttachments);
sendMimeMessage (new HttpMimeMessageEntity (aMsg), true, null);
}
示例12: testUserMessageWithCompressedSignedSuccessful
import com.helger.commons.io.resource.ClassPathResource; //导入依赖的package包/类
@Test
public void testUserMessageWithCompressedSignedSuccessful () throws Exception
{
final ICommonsList <WSS4JAttachment> aAttachments = new CommonsArrayList <> ();
aAttachments.add (WSS4JAttachment.createOutgoingFileAttachment (ClassPathResource.getAsFile (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML),
CMimeType.APPLICATION_XML,
EAS4CompressionMode.GZIP,
s_aResMgr));
final Document aDoc = SignedMessageCreator.createSignedMessage (AS4CryptoFactory.DEFAULT_INSTANCE,
MockMessages.testUserMessageSoapNotSigned (m_eSOAPVersion,
null,
aAttachments),
m_eSOAPVersion,
aAttachments,
s_aResMgr,
false,
ECryptoAlgorithmSign.SIGN_ALGORITHM_DEFAULT,
ECryptoAlgorithmSignDigest.SIGN_DIGEST_ALGORITHM_DEFAULT);
final MimeMessage aMsg = MimeMessageCreator.generateMimeMessage (m_eSOAPVersion, aDoc, aAttachments);
sendMimeMessage (new HttpMimeMessageEntity (aMsg), true, null);
}
示例13: testUserMessageCompressedEncrpytedSuccessful
import com.helger.commons.io.resource.ClassPathResource; //导入依赖的package包/类
@Test
public void testUserMessageCompressedEncrpytedSuccessful () throws Exception
{
final ICommonsList <WSS4JAttachment> aAttachments = new CommonsArrayList <> ();
aAttachments.add (WSS4JAttachment.createOutgoingFileAttachment (ClassPathResource.getAsFile (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML),
CMimeType.APPLICATION_XML,
EAS4CompressionMode.GZIP,
s_aResMgr));
final Document aDoc = MockMessages.testUserMessageSoapNotSigned (m_eSOAPVersion, null, aAttachments);
final MimeMessage aMsg = new EncryptionCreator (AS4CryptoFactory.DEFAULT_INSTANCE).encryptMimeMessage (m_eSOAPVersion,
aDoc,
false,
aAttachments,
s_aResMgr,
ECryptoAlgorithmCrypt.ENCRPYTION_ALGORITHM_DEFAULT);
sendMimeMessage (new HttpMimeMessageEntity (aMsg), true, null);
}
示例14: sendPullRequestSuccessTwoWayPullPush
import com.helger.commons.io.resource.ClassPathResource; //导入依赖的package包/类
@Test
public void sendPullRequestSuccessTwoWayPullPush () throws Exception
{
// Depending on the payload a different EMEPBinding get chosen by
// @MockPullRequestProcessorSPI
// To Test the pull request part of the EMEPBinding
final Document aPayload = DOMReader.readXMLDOM (new ClassPathResource ("testfiles/PullPush.xml"));
final ICommonsList <Object> aAny = new CommonsArrayList <> ();
aAny.add (aPayload.getDocumentElement ());
final Document aDoc = PullRequestMessageCreator.createPullRequestMessage (m_eSOAPVersion,
MessageHelperMethods.createEbms3MessageInfo (),
AS4TestConstants.DEFAULT_MPC,
aAny)
.getAsSOAPDocument ();
final HttpEntity aEntity = new HttpXMLEntity (aDoc, m_eSOAPVersion);
final String sResponse = sendPlainMessage (aEntity, true, null);
assertTrue (sResponse.contains (AS4TestConstants.USERMESSAGE_ASSERTCHECK));
}
示例15: receiveUserMessageWithMimeAsResponseSuccessWithoutEncryption
import com.helger.commons.io.resource.ClassPathResource; //导入依赖的package包/类
@Test
public void receiveUserMessageWithMimeAsResponseSuccessWithoutEncryption () throws Exception
{
m_aPMode.getLeg2 ().getSecurity ().setX509EncryptionAlgorithm (null);
MetaAS4Manager.getPModeMgr ().createOrUpdatePMode (m_aPMode);
final ICommonsList <WSS4JAttachment> aAttachments = new CommonsArrayList <> ();
aAttachments.add (WSS4JAttachment.createOutgoingFileAttachment (ClassPathResource.getAsFile (AS4TestConstants.ATTACHMENT_SHORTXML_XML),
CMimeType.APPLICATION_XML,
null,
s_aResMgr));
final Document aDoc = _modifyUserMessage (m_aPMode.getID (), null, null, _defaultProperties (), aAttachments);
final MimeMessage aMimeMsg = MimeMessageCreator.generateMimeMessage (m_eSOAPVersion, aDoc, aAttachments);
final String sResponse = sendMimeMessage (new HttpMimeMessageEntity (aMimeMsg), true, null);
assertTrue (sResponse.contains (AS4TestConstants.USERMESSAGE_ASSERTCHECK));
assertFalse (sResponse.contains (AS4TestConstants.RECEIPT_ASSERTCHECK));
assertTrue (sResponse.contains (m_aPMode.getLeg2 ()
.getSecurity ()
.getX509SignatureAlgorithm ()
.getAlgorithmURI ()));
// Checking if he adds the attachment to the response message, the mock spi
// just adds the xml that gets sent in the original message and adds it to
// the response
assertTrue (sResponse.contains ("<dummy>This is a test XML</dummy>"));
}