本文整理汇总了Java中com.helger.xml.microdom.serialize.MicroWriter类的典型用法代码示例。如果您正苦于以下问题:Java MicroWriter类的具体用法?Java MicroWriter怎么用?Java MicroWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MicroWriter类属于com.helger.xml.microdom.serialize包,在下文中一共展示了MicroWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendBodyPayloadSignedMessageSuccessful
import com.helger.xml.microdom.serialize.MicroWriter; //导入依赖的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));
}
示例2: sendBodyPayloadSignedEncryptedMessageSuccessful
import com.helger.xml.microdom.serialize.MicroWriter; //导入依赖的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));
}
示例3: sendOneAttachmentSignedMessageSuccessful
import com.helger.xml.microdom.serialize.MicroWriter; //导入依赖的package包/类
@Test
public void sendOneAttachmentSignedMessageSuccessful () throws Exception
{
final AS4ClientUserMessage aClient = _getMandatoryAttributesSuccessMessage ();
aClient.addAttachment (new ClassPathResource (AS4TestConstants.ATTACHMENT_SHORTXML_XML).getAsFile (),
CMimeType.APPLICATION_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));
}
示例4: sendOneAttachmentEncryptedMessageSuccessful
import com.helger.xml.microdom.serialize.MicroWriter; //导入依赖的package包/类
@Test
public void sendOneAttachmentEncryptedMessageSuccessful () throws Exception
{
final AS4ClientUserMessage aClient = _getMandatoryAttributesSuccessMessage ();
aClient.addAttachment (new ClassPathResource (AS4TestConstants.ATTACHMENT_SHORTXML_XML).getAsFile (),
CMimeType.APPLICATION_XML);
// Keystore
_setKeyStoreTestData (aClient);
// Encrypt specific
aClient.setCryptoAlgorithmCrypt (ECryptoAlgorithmCrypt.AES_128_GCM);
final IMicroDocument aDoc = aClient.sendMessageAndGetMicroDocument (SERVER_URL);
s_aLogger.info (MicroWriter.getNodeAsString (aDoc));
}
示例5: sendOneAttachmentSignedEncryptedMessageSuccessful
import com.helger.xml.microdom.serialize.MicroWriter; //导入依赖的package包/类
@Test
public void sendOneAttachmentSignedEncryptedMessageSuccessful () throws Exception
{
final AS4ClientUserMessage aClient = _getMandatoryAttributesSuccessMessage ();
aClient.addAttachment (new ClassPathResource (AS4TestConstants.ATTACHMENT_SHORTXML_XML).getAsFile (),
CMimeType.APPLICATION_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));
}
示例6: sendManyAttachmentSignedMessageSuccessful
import com.helger.xml.microdom.serialize.MicroWriter; //导入依赖的package包/类
@Test
public void sendManyAttachmentSignedMessageSuccessful () throws Exception
{
final AS4ClientUserMessage aClient = _getMandatoryAttributesSuccessMessage ();
aClient.addAttachment (new ClassPathResource (AS4TestConstants.ATTACHMENT_SHORTXML_XML).getAsFile (),
CMimeType.APPLICATION_XML);
aClient.addAttachment (new ClassPathResource (AS4TestConstants.ATTACHMENT_SHORTXML2_XML).getAsFile (),
CMimeType.APPLICATION_XML);
aClient.addAttachment (new ClassPathResource (AS4TestConstants.ATTACHMENT_TEST_IMG_JPG).getAsFile (),
CMimeType.IMAGE_JPG);
// 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));
}
示例7: sendManyAttachmentEncryptedMessageSuccessful
import com.helger.xml.microdom.serialize.MicroWriter; //导入依赖的package包/类
@Test
public void sendManyAttachmentEncryptedMessageSuccessful () throws Exception
{
final AS4ClientUserMessage aClient = _getMandatoryAttributesSuccessMessage ();
aClient.addAttachment (new ClassPathResource (AS4TestConstants.ATTACHMENT_SHORTXML_XML).getAsFile (),
CMimeType.APPLICATION_XML);
aClient.addAttachment (new ClassPathResource (AS4TestConstants.ATTACHMENT_SHORTXML2_XML).getAsFile (),
CMimeType.APPLICATION_XML);
aClient.addAttachment (new ClassPathResource (AS4TestConstants.ATTACHMENT_TEST_IMG_JPG).getAsFile (),
CMimeType.IMAGE_JPG);
// Keystore
_setKeyStoreTestData (aClient);
// Encrypt specific
aClient.setCryptoAlgorithmCrypt (ECryptoAlgorithmCrypt.AES_128_GCM);
final IMicroDocument aDoc = aClient.sendMessageAndGetMicroDocument (SERVER_URL);
assertTrue (MicroWriter.getNodeAsString (aDoc).contains (AS4TestConstants.RECEIPT_ASSERTCHECK));
}
示例8: sendManyAttachmentSignedEncryptedMessageSuccessful
import com.helger.xml.microdom.serialize.MicroWriter; //导入依赖的package包/类
@Test
public void sendManyAttachmentSignedEncryptedMessageSuccessful () throws Exception
{
final AS4ClientUserMessage aClient = _getMandatoryAttributesSuccessMessage ();
aClient.addAttachment (new ClassPathResource (AS4TestConstants.ATTACHMENT_SHORTXML_XML).getAsFile (),
CMimeType.APPLICATION_XML);
aClient.addAttachment (new ClassPathResource (AS4TestConstants.ATTACHMENT_SHORTXML2_XML).getAsFile (),
CMimeType.APPLICATION_XML);
aClient.addAttachment (new ClassPathResource (AS4TestConstants.ATTACHMENT_TEST_IMG_JPG).getAsFile (),
CMimeType.IMAGE_JPG);
// 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));
}
示例9: close
import com.helger.xml.microdom.serialize.MicroWriter; //导入依赖的package包/类
public void close () throws IOException
{
// Get all remaining objects and save them for late reuse
final ICommonsList <IIndexerWorkItem> aRemainingWorkItems = m_aIndexerWorkQueue.stop ();
if (aRemainingWorkItems.isNotEmpty ())
{
s_aLogger.info ("Persisting " + aRemainingWorkItems.size () + " indexer work items");
final IMicroDocument aDoc = new MicroDocument ();
final IMicroElement eRoot = aDoc.appendElement (ELEMENT_ROOT);
for (final IIndexerWorkItem aItem : aRemainingWorkItems)
eRoot.appendChild (MicroTypeConverter.convertToMicroElement (aItem, ELEMENT_ITEM));
if (MicroWriter.writeToFile (aDoc, m_aIndexerWorkItemFile).isFailure ())
throw new IllegalStateException ("Failed to write IndexerWorkItems to " + m_aIndexerWorkItemFile);
}
// Unschedule the job to avoid problems on shutdown. Use the saved instance
// because GlobalQuartzScheduler.getInstance() would fail because the global
// scope is already in destruction.
m_aScheduler.unscheduleJob (m_aTriggerKey);
// Close Lucene index etc.
m_aStorageMgr.close ();
}
示例10: writeSettings
import com.helger.xml.microdom.serialize.MicroWriter; //导入依赖的package包/类
@Nonnull
public ESuccess writeSettings (@Nonnull final ISettings aSettings, @Nonnull @WillClose final OutputStream aOS)
{
ValueEnforcer.notNull (aSettings, "Settings");
ValueEnforcer.notNull (aOS, "OutputStream");
try
{
// Inside try so that OS is closed
ValueEnforcer.notNull (aSettings, "Settings");
// No event manager invocation on writing
final SettingsMicroDocumentConverter <T> aConverter = new SettingsMicroDocumentConverter <> (m_aSettingsFactory);
final IMicroDocument aDoc = new MicroDocument ();
aDoc.appendChild (aConverter.convertToMicroElement (GenericReflection.uncheckedCast (aSettings),
getWriteNamespaceURI (),
getWriteElementName ()));
// auto-closes the stream
return MicroWriter.writeToStream (aDoc, aOS, m_aXWS);
}
finally
{
StreamHelper.close (aOS);
}
}
示例11: writeMap
import com.helger.xml.microdom.serialize.MicroWriter; //导入依赖的package包/类
/**
* Write the passed map to the passed output stream using the predefined XML
* layout.
*
* @param aMap
* The map to be written. May not be <code>null</code>.
* @param aOS
* The output stream to write to. The stream is closed independent of
* success or failure. May not be <code>null</code>.
* @return {@link ESuccess#SUCCESS} when everything went well,
* {@link ESuccess#FAILURE} otherwise.
*/
@Nonnull
public static ESuccess writeMap (@Nonnull final Map <String, String> aMap, @Nonnull @WillClose final OutputStream aOS)
{
ValueEnforcer.notNull (aMap, "Map");
ValueEnforcer.notNull (aOS, "OutputStream");
try
{
final IMicroDocument aDoc = createMapDocument (aMap);
return MicroWriter.writeToStream (aDoc, aOS, XMLWriterSettings.DEFAULT_XML_SETTINGS);
}
finally
{
StreamHelper.close (aOS);
}
}
示例12: writeList
import com.helger.xml.microdom.serialize.MicroWriter; //导入依赖的package包/类
/**
* Write the passed collection to the passed output stream using the
* predefined XML layout.
*
* @param aCollection
* The map to be written. May not be <code>null</code>.
* @param aOS
* The output stream to write to. The stream is closed independent of
* success or failure. May not be <code>null</code>.
* @return {@link ESuccess#SUCCESS} when everything went well,
* {@link ESuccess#FAILURE} otherwise.
*/
@Nonnull
public static ESuccess writeList (@Nonnull final Collection <String> aCollection,
@Nonnull @WillClose final OutputStream aOS)
{
ValueEnforcer.notNull (aCollection, "Collection");
ValueEnforcer.notNull (aOS, "OutputStream");
try
{
final IMicroDocument aDoc = createListDocument (aCollection);
return MicroWriter.writeToStream (aDoc, aOS, XMLWriterSettings.DEFAULT_XML_SETTINGS);
}
finally
{
StreamHelper.close (aOS);
}
}
示例13: testConvertToXML
import com.helger.xml.microdom.serialize.MicroWriter; //导入依赖的package包/类
@Test
public void testConvertToXML ()
{
final IMicroDocument aDoc = new MicroDocument ();
final IMicroElement eRoot = aDoc.appendElement ("vatins");
for (final VATINStructure aStructure : VATINStructureManager.getAllStructures ())
{
final IMicroElement eVatin = eRoot.appendElement ("vatin");
eVatin.setAttribute ("country", aStructure.getCountry ().getCountry ());
eVatin.setAttribute ("pattern", aStructure.getPattern ());
for (final String sExample : aStructure.getExamples ())
eVatin.appendElement ("example").appendText (sExample);
}
final String sXML = MicroWriter.getNodeAsString (aDoc);
assertNotNull (sXML);
}
示例14: testMarshal
import com.helger.xml.microdom.serialize.MicroWriter; //导入依赖的package包/类
@Test
public void testMarshal ()
{
final Locale aLocale = Locale.GERMAN;
final PostalAddress aAddress = new PostalAddress ();
aAddress.setStreet ("Cumberlandstraße", aLocale);
aAddress.setPostalCode ("1140");
aAddress.setCity ("Vienna", aLocale);
aAddress.setState ("W", aLocale);
aAddress.setCountry ("AT", aLocale);
final IMicroElement aElement = MicroTypeConverter.convertToMicroElement (aAddress, "addr");
assertNotNull (aElement);
s_aLogger.info (MicroWriter.getNodeAsString (aElement));
final PostalAddress aAddress2 = MicroTypeConverter.convertToNative (aElement, PostalAddress.class);
assertEquals (aAddress, aAddress2);
}
示例15: readSchema
import com.helger.xml.microdom.serialize.MicroWriter; //导入依赖的package包/类
/**
* Read the schema from the resource supplied in the constructor. First all
* includes are resolved and than {@link #readSchemaFromXML(IMicroElement)} is
* called.
*
* @return The read {@link PSSchema}.
* @throws SchematronReadException
* If reading fails
*/
@Nonnull
public PSSchema readSchema () throws SchematronReadException
{
// Resolve all includes as the first action
final SAXReaderSettings aSettings = new SAXReaderSettings ().setEntityResolver (m_aEntityResolver);
final IMicroDocument aDoc = SchematronHelper.getWithResolvedSchematronIncludes (m_aResource,
aSettings,
m_aErrorHandler);
if (aDoc == null || aDoc.getDocumentElement () == null)
throw new SchematronReadException (m_aResource,
"Failed to resolve includes in Schematron resource " + m_aResource);
if (SchematronDebug.isShowResolvedSourceSchematron ())
s_aLogger.info ("Resolved source Schematron:\n" + MicroWriter.getNodeAsString (aDoc));
return readSchemaFromXML (aDoc.getDocumentElement ());
}