• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DOMReader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



DOMReader类属于com.helger.xml.serialize.read包,在下文中一共展示了DOMReader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testUserMessageSOAPBodyPayloadSignedMimeSuccess

import com.helger.xml.serialize.read.DOMReader; //导入依赖的package包/类
@Test
public void testUserMessageSOAPBodyPayloadSignedMimeSuccess () throws Exception
{
  final Node aPayload = DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
  final MimeMessage aMsg = MimeMessageCreator.generateMimeMessage (m_eSOAPVersion,
                                                                   MockMessages.testSignedUserMessage (m_eSOAPVersion,
                                                                                                       aPayload,
                                                                                                       null,
                                                                                                       s_aResMgr),
                                                                   null);
  final String sResponse = sendMimeMessage (new HttpMimeMessageEntity (aMsg), 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,代码行数:18,代码来源:UserMessageSoapBodyPayloadTest.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: testPayloadChangedAfterSigningShouldFail

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


示例5: 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


示例6: testUserMessageWithBodyPayloadOnlyNoInfo

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


示例7: 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


示例8: sendPullRequestSuccessTwoWayPullPush

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


示例9: sendDuplicateMessageTestDisposalFeature

import com.helger.xml.serialize.read.DOMReader; //导入依赖的package包/类
@Ignore
@Test
public void sendDuplicateMessageTestDisposalFeature () throws Exception
{
  final Node aPayload = DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_SOAP_BODY_PAYLOAD_XML));
  final Document aDoc = MockMessages.testUserMessageSoapNotSigned (m_eSOAPVersion, aPayload, null);

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

  sendPlainMessage (aEntity, true, null);

  // Making sure the message gets disposed off
  // 60 000 = 1 minute, *2 and + 10000 are a buffer
  // test file is configured for 1 minute can take LONGER if configured
  // differently
  Thread.sleep (AS4ServerConfiguration.getIncomingDuplicateDisposalMinutes () * 60000 * 2 + 10000);

  sendPlainMessage (aEntity, true, null);
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:20,代码来源:UserMessageDuplicateTest.java


示例10: sendBodyPayloadSignedMessageSuccessful

import com.helger.xml.serialize.read.DOMReader; //导入依赖的package包/类
@Test
public void sendBodyPayloadSignedMessageSuccessful () throws Exception
{
  final AS4ClientUserMessage aClient = _getMandatoryAttributesSuccessMessage ();
  aClient.setPayload (DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_PAYLOAD_XML)));

  // Keystore
  _setKeyStoreTestData (aClient);

  // Sign specific
  aClient.setCryptoAlgorithmSign (ECryptoAlgorithmSign.RSA_SHA_256);
  aClient.setCryptoAlgorithmSignDigest (ECryptoAlgorithmSignDigest.DIGEST_SHA_256);

  final IMicroDocument aDoc = aClient.sendMessageAndGetMicroDocument (SERVER_URL);
  assertTrue (MicroWriter.getNodeAsString (aDoc).contains (AS4TestConstants.RECEIPT_ASSERTCHECK));
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:17,代码来源:AS4ClientUserMessageTest.java


示例11: sendBodyPayloadSignedEncryptedMessageSuccessful

import com.helger.xml.serialize.read.DOMReader; //导入依赖的package包/类
@Test
public void sendBodyPayloadSignedEncryptedMessageSuccessful () throws Exception
{
  final AS4ClientUserMessage aClient = _getMandatoryAttributesSuccessMessage ();
  aClient.setPayload (DOMReader.readXMLDOM (new ClassPathResource (AS4TestConstants.TEST_PAYLOAD_XML)));

  // Keystore
  _setKeyStoreTestData (aClient);

  // Sign specific
  aClient.setCryptoAlgorithmSign (ECryptoAlgorithmSign.RSA_SHA_256);
  aClient.setCryptoAlgorithmSignDigest (ECryptoAlgorithmSignDigest.DIGEST_SHA_256);

  // Encrypt specific
  aClient.setCryptoAlgorithmCrypt (ECryptoAlgorithmCrypt.AES_128_GCM);

  final IMicroDocument aDoc = aClient.sendMessageAndGetMicroDocument (SERVER_URL);
  assertTrue (MicroWriter.getNodeAsString (aDoc).contains (AS4TestConstants.RECEIPT_ASSERTCHECK));
}
 
开发者ID:phax,项目名称:ph-as4,代码行数:20,代码来源:AS4ClientUserMessageTest.java


示例12: 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


示例13: setUpCEF

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

  m_eSOAPVersion = m_aESENSTwoWayPMode.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,代码来源:AbstractCEFTwoWayTestSetUp.java


示例14: 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


示例15: 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


示例16: 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


示例17: 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


示例18: 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


示例19: 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


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LanguageNamesValidation类代码示例发布时间:2022-05-22
下一篇:
Java ApprovalStatus类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap