当前位置: 首页>>代码示例>>Java>>正文


Java DOMReader.readXMLDOM方法代码示例

本文整理汇总了Java中com.helger.xml.serialize.read.DOMReader.readXMLDOM方法的典型用法代码示例。如果您正苦于以下问题:Java DOMReader.readXMLDOM方法的具体用法?Java DOMReader.readXMLDOM怎么用?Java DOMReader.readXMLDOM使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.helger.xml.serialize.read.DOMReader的用法示例。


在下文中一共展示了DOMReader.readXMLDOM方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUpCEF

import com.helger.xml.serialize.read.DOMReader; //导入方法依赖的package包/类
@Before
public void setUpCEF ()
{
  m_aESENSOneWayPMode = ESENSPMode.createESENSPMode (AS4TestConstants.CEF_INITIATOR_ID,
                                                     AS4TestConstants.CEF_RESPONDER_ID,
                                                     AS4TestConstants.DEFAULT_SERVER_ADDRESS,
                                                     IPModeIDProvider.DEFAULT_DYNAMIC);

  m_eSOAPVersion = m_aESENSOneWayPMode.getLeg1 ().getProtocol ().getSOAPVersion ();
  try
  {
    m_aPayload = DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
  }
  catch (final SAXException ex)
  {
    throw new IllegalStateException ("Failed to parse example XML", ex);
  }
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:19,代码来源:AbstractCEFTestSetUp.java

示例2: testUserMessageSOAPBodyPayloadEncryptSuccess

import com.helger.xml.serialize.read.DOMReader; //导入方法依赖的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));
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:17,代码来源:UserMessageSoapBodyPayloadTest.java

示例3: testUserMessageSOAPBodyPayloadSignedEncryptedSuccess

import com.helger.xml.serialize.read.DOMReader; //导入方法依赖的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 ()));
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:20,代码来源:UserMessageSoapBodyPayloadTest.java

示例4: testUserMessageWithPayloadInfoOnly

import com.helger.xml.serialize.read.DOMReader; //导入方法依赖的package包/类
@Test
public void testUserMessageWithPayloadInfoOnly () 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
  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 aElement = (Element) nNode;
    XMLHelper.removeAllChildElements (aElement);
  }

  sendPlainMessage (new HttpXMLEntity (aDoc, m_eSOAPVersion),
                    false,
                    EEbmsError.EBMS_VALUE_INCONSISTENT.getErrorCode ());
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:21,代码来源:UserMessageFailureForgeryTest.java

示例5: buildMessageSignedChecks

import com.helger.xml.serialize.read.DOMReader; //导入方法依赖的package包/类
@Test
public void buildMessageSignedChecks () throws Exception
{
  final AS4ClientReceiptMessage aClient = new AS4ClientReceiptMessage (s_aResMgr);
  aClient.setSOAPVersion (ESOAPVersion.AS4_DEFAULT);
  // Parse EBMS3 Messaging object
  final Node aPayload = DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
  aClient.setSOAPDocument (MockMessages.testSignedUserMessage (aClient.getSOAPVersion (), aPayload, null, s_aResMgr));
  aClient.setNonRepudiation (true);
  aClient.setReceiptShouldBeSigned (true);

  aClient.setKeyStoreResource (new ClassPathResource ("keys/dummy-pw-test.jks"));
  aClient.setKeyStorePassword ("test");
  aClient.setKeyStoreType (EKeyStoreType.JKS);
  aClient.setKeyStoreAlias ("ph-as4");
  aClient.setKeyStoreKeyPassword ("test");

  aClient.setCryptoAlgorithmSign (ECryptoAlgorithmSign.SIGN_ALGORITHM_DEFAULT);
  aClient.setCryptoAlgorithmSignDigest (ECryptoAlgorithmSignDigest.SIGN_DIGEST_ALGORITHM_DEFAULT);

  _ensureValidState (aClient);
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:23,代码来源:AS4ClientReceiptMessageTest.java

示例6: sendPullRequestSuccessTwoWayPushPull

import com.helger.xml.serialize.read.DOMReader; //导入方法依赖的package包/类
@Test
public void sendPullRequestSuccessTwoWayPushPull () 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/PushPull.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));
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:21,代码来源:PullRequestTest.java

示例7: testDeliverInvoice1

import com.helger.xml.serialize.read.DOMReader; //导入方法依赖的package包/类
/**
 * Basic test case. It is ignored by default, since no test username and
 * password are present. After setting {@link #USP_WS_USERNAME} and
 * {@link #USP_WS_PASSWORD} constants in this class, this test can be
 * "un-ignored".
 *
 * @throws SAXException
 *         in case XML reading fails
 */
@Test
@Ignore
public void testDeliverInvoice1 () throws SAXException
{
  final Node aXMLDocument = DOMReader.readXMLDOM (new ClassPathResource ("test-invoices/ebi40.xml"));
  assertNotNull ("Failed to read example invoice", aXMLDocument);

  final WS120Sender aSender = new WS120Sender (USP_WS_USERNAME, USP_WS_PASSWORD);
  aSender.setDebugMode (true);
  aSender.setTestVersion (true);

  // No attachments
  final List <AttachmentType> aAttachments = null;

  final SettingsType aSettings = new SettingsType ();
  // Perform only technical validation
  aSettings.setTest (Boolean.TRUE);

  // Deliver it
  final TypeUploadStatus aResult = aSender.deliverInvoice (aXMLDocument, aAttachments, aSettings);
  assertNotNull (aResult.toString (), aResult.getSuccess ());
}
 
开发者ID:phax,项目名称:erechnung.gv.at-webservice-client,代码行数:32,代码来源:WS120SenderTest.java

示例8: testDeliverInvoice1

import com.helger.xml.serialize.read.DOMReader; //导入方法依赖的package包/类
/**
 * Basic test case. It is ignored by default, since no test username and
 * password are present. After setting {@link #USP_WS_USERNAME} and
 * {@link #USP_WS_PASSWORD} constants in this class, this test can be
 * "un-ignored".
 *
 * @throws SAXException
 *         in case XML reading fails
 */
@Test
@Ignore
public void testDeliverInvoice1 () throws SAXException
{
  final Node aXMLDocument = DOMReader.readXMLDOM (new ClassPathResource ("test-invoices/ebi40.xml"));
  assertNotNull ("Failed to read example invoice", aXMLDocument);

  final WS200Sender aSender = new WS200Sender (USP_WS_USERNAME, USP_WS_PASSWORD);
  aSender.setDebugMode (true);
  aSender.setTestVersion (true);

  // No attachments
  final List <DeliveryEmbeddedAttachmentType> aAttachments = null;

  final DeliverySettingsType aSettings = new DeliverySettingsType ();
  // Perform only technical validation
  aSettings.setTest (Boolean.TRUE);

  // Deliver it
  final DeliveryResponseType aResult = aSender.deliverInvoice (aXMLDocument, aAttachments, aSettings);
  assertNotNull (aResult.toString (), aResult.getSuccess ());
}
 
开发者ID:phax,项目名称:erechnung.gv.at-webservice-client,代码行数:32,代码来源:WS200SenderTest.java

示例9: testNumericReferencesXML10

import com.helger.xml.serialize.read.DOMReader; //导入方法依赖的package包/类
@Test
public void testNumericReferencesXML10 () throws SAXException, TransformerException
{
  for (int i = Character.MIN_VALUE; i <= Character.MAX_VALUE; ++i)
    if (!XMLCharHelper.isInvalidXMLTextChar (EXMLSerializeVersion.XML_10, (char) i))
    {
      final String sText = "abc" + (char) i + "def";
      final Document aDoc = XMLFactory.newDocument (EXMLVersion.XML_10);
      final Element eRoot = (Element) aDoc.appendChild (aDoc.createElement ("root"));
      eRoot.appendChild (aDoc.createTextNode (sText));

      // Use regular transformer
      final Transformer aTransformer = XMLTransformerFactory.newTransformer ();
      aTransformer.setOutputProperty (OutputKeys.ENCODING, StandardCharsets.UTF_8.name ());
      aTransformer.setOutputProperty (OutputKeys.INDENT, "yes");
      aTransformer.setOutputProperty (OutputKeys.VERSION, EXMLVersion.XML_10.getVersion ());
      final StringStreamResult aRes = new StringStreamResult ();
      aTransformer.transform (new DOMSource (aDoc), aRes);

      final String sXML = aRes.getAsString ();
      final Document aDoc2 = DOMReader.readXMLDOM (sXML);
      assertNotNull (aDoc2);
    }
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:25,代码来源:XMLWriterTest.java

示例10: testNumericReferencesXML11

import com.helger.xml.serialize.read.DOMReader; //导入方法依赖的package包/类
@Test
public void testNumericReferencesXML11 () throws SAXException, TransformerException
{
  for (int i = Character.MIN_VALUE; i <= Character.MAX_VALUE; ++i)
    if (!XMLCharHelper.isInvalidXMLTextChar (EXMLSerializeVersion.XML_11, (char) i))
    {
      final String sText = "abc" + (char) i + "def";
      final Document aDoc = XMLFactory.newDocument (EXMLVersion.XML_11);
      final Element eRoot = (Element) aDoc.appendChild (aDoc.createElement ("root"));
      eRoot.appendChild (aDoc.createTextNode (sText));

      final Transformer aTransformer = XMLTransformerFactory.newTransformer ();
      aTransformer.setOutputProperty (OutputKeys.ENCODING, StandardCharsets.UTF_8.name ());
      aTransformer.setOutputProperty (OutputKeys.INDENT, "no");
      aTransformer.setOutputProperty (OutputKeys.VERSION, EXMLVersion.XML_11.getVersion ());
      final StringStreamResult aRes = new StringStreamResult ();
      aTransformer.transform (new DOMSource (aDoc), aRes);

      final String sXML = aRes.getAsString ();
      final Document aDoc2 = DOMReader.readXMLDOM (sXML);
      assertNotNull (aDoc2);
    }
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:24,代码来源:XMLWriterTest.java

示例11: testConvertToMicroElementWithNS

import com.helger.xml.serialize.read.DOMReader; //导入方法依赖的package包/类
@Test
public void testConvertToMicroElementWithNS () throws SAXException
{
  final String sNS = "<root xmlns='blafoo'><ns2:element xmlns:ns2='ns2:uri' ns2:attr='value'>content</ns2:element></root>";
  final Document aDoc = DOMReader.readXMLDOM (sNS);
  assertNotNull (aDoc);
  final IMicroDocument aMicroDoc = (IMicroDocument) MicroHelper.convertToMicroNode (aDoc);
  assertNotNull (aMicroDoc);
  final IMicroElement eRoot = aMicroDoc.getDocumentElement ();
  assertNotNull (eRoot);
  assertEquals ("blafoo", eRoot.getNamespaceURI ());
  assertEquals ("root", eRoot.getLocalName ());
  assertEquals ("root", eRoot.getTagName ());
  assertEquals (0, eRoot.getAttributeCount ());
  assertEquals (1, eRoot.getChildElementCount ());
  final IMicroElement eElement = eRoot.getFirstChildElement ();
  assertEquals ("ns2:uri", eElement.getNamespaceURI ());
  assertEquals ("element", eElement.getLocalName ());
  assertEquals ("element", eElement.getTagName ());
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:21,代码来源:MicroHelperTest.java

示例12: testAll

import com.helger.xml.serialize.read.DOMReader; //导入方法依赖的package包/类
@Test
public void testAll () throws SAXException
{
  CollectingSAXErrorHandler aCEH = new CollectingSAXErrorHandler ();
  assertNotNull (DOMReader.readXMLDOM (new ClassPathResource ("xml/buildinfo.xml"),
                                       new DOMReaderSettings ().setErrorHandler (aCEH)));
  assertTrue (aCEH.getErrorList ().isEmpty ());
  assertNotNull (aCEH.toString ());

  aCEH = new CollectingSAXErrorHandler ();
  try
  {
    DOMReader.readXMLDOM (new ClassPathResource ("test1.txt"), new DOMReaderSettings ().setErrorHandler (aCEH));
    fail ();
  }
  catch (final SAXException ex)
  {}
  assertFalse (aCEH.getErrorList ().isEmpty ());
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:20,代码来源:CollectingSAXErrorHandlerTest.java

示例13: SchematronProviderXSLTPrebuild

import com.helger.xml.serialize.read.DOMReader; //导入方法依赖的package包/类
public SchematronProviderXSLTPrebuild (@Nullable final IReadableResource aXSLTResource,
                                       @Nullable final ErrorListener aCustomErrorListener,
                                       @Nullable final URIResolver aCustomURIResolver)
{
  try
  {
    // Read XSLT file as XML
    m_aSchematronXSLTDoc = DOMReader.readXMLDOM (aXSLTResource);

    // compile result of read file
    final TransformerFactory aTF = SchematronTransformerFactory.createTransformerFactorySaxonFirst ((ClassLoader) null,
                                                                                                    aCustomErrorListener,
                                                                                                    new DefaultTransformURIResolver (aCustomURIResolver));
    m_aSchematronXSLTTemplates = aTF.newTemplates (TransformSourceFactory.create (m_aSchematronXSLTDoc));
  }
  catch (final Exception ex)
  {
    s_aLogger.error ("XSLT read/compilation error for " + aXSLTResource, ex);
  }
}
 
开发者ID:phax,项目名称:ph-schematron,代码行数:21,代码来源:SchematronProviderXSLTPrebuild.java

示例14: validateXMLViaPureSchematron2

import com.helger.xml.serialize.read.DOMReader; //导入方法依赖的package包/类
public static boolean validateXMLViaPureSchematron2 (@Nonnull final File aSchematronFile,
                                                     @Nonnull final File aXMLFile) throws Exception
{
  // Read the schematron from file
  final PSSchema aSchema = new PSReader (new FileSystemResource (aSchematronFile)).readSchema ();
  if (!aSchema.isValid (new DoNothingPSErrorHandler ()))
    throw new IllegalArgumentException ("Invalid Schematron!");
  // Resolve the query binding to use
  final IPSQueryBinding aQueryBinding = PSQueryBindingRegistry.getQueryBindingOfNameOrThrow (aSchema.getQueryBinding ());
  // Pre-process schema
  final PSPreprocessor aPreprocessor = new PSPreprocessor (aQueryBinding);
  aPreprocessor.setKeepTitles (true);
  final PSSchema aPreprocessedSchema = aPreprocessor.getAsPreprocessedSchema (aSchema);
  // Bind the pre-processed schema
  final IPSBoundSchema aBoundSchema = aQueryBinding.bind (aPreprocessedSchema, null, null, null, null);
  // Read the XML file
  final Document aXMLNode = DOMReader.readXMLDOM (aXMLFile);
  if (aXMLNode == null)
    return false;
  // Perform the validation
  return aBoundSchema.validatePartially (aXMLNode, FileHelper.getAsURLString (aXMLFile)).isValid ();
}
 
开发者ID:phax,项目名称:ph-schematron,代码行数:23,代码来源:DocumentationExamples.java

示例15: duplicateSignedMessage

import com.helger.xml.serialize.read.DOMReader; //导入方法依赖的package包/类
@Test
public void duplicateSignedMessage () throws Exception
{
  final Node aPayload = DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
  final ESOAPVersion eSOAPVersion = ESOAPVersion.AS4_DEFAULT;
  final Document aDoc = MockMessages.testSignedUserMessage (eSOAPVersion, aPayload, null, new AS4ResourceManager ());

  final HttpEntity aEntity = new HttpXMLEntity (aDoc, eSOAPVersion);

  final String sResponse = sendPlainMessage (aEntity, true, null);

  assertTrue (sResponse.contains (AS4TestConstants.RECEIPT_ASSERTCHECK));

  sendPlainMessage (aEntity, false, EEbmsError.EBMS_OTHER.getErrorCode ());
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:16,代码来源:ERBTest.java


注:本文中的com.helger.xml.serialize.read.DOMReader.readXMLDOM方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。