- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.finra.herd.dao.helper.XmlHelper
类的一些代码示例,展示了XmlHelper
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlHelper
类的具体详情如下:
包路径:org.finra.herd.dao.helper.XmlHelper
类名称:XmlHelper
[英]A helper class for XML functionality.
[中]XML功能的助手类。
代码示例来源:origin: org.finra.herd/herd-dao
/**
* Returns XML representation of the object.
*
* @param obj the Java object to be serialized
*
* @return the XML representation of this object
* @throws javax.xml.bind.JAXBException if a JAXB error occurred.
*/
public String objectToXml(Object obj) throws JAXBException
{
// By default, we do not ask the marshalled XML data to be formatted with line feeds and indentation.
return objectToXml(obj, false);
}
代码示例来源:origin: FINRAOS/herd
/**
* This method tests the error cases for AmazonExceptions for Illegal Argument
*/
@Test(expected = ObjectNotFoundException.class)
public void testCreateEmrClusterAmazonObjectNotFound() throws Exception
{
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
String configXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_MINIMAL_CLASSPATH).getInputStream());
EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml);
emrClusterDefinition.setAmiVersion(MockAwsOperationsHelper.AMAZON_NOT_FOUND);
configXml = xmlHelper.objectToXml(emrClusterDefinition);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, configXml);
// Create a new EMR cluster create request.
EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
emrService.createCluster(request);
}
代码示例来源:origin: FINRAOS/herd
@Bean
public XmlHelper xmlHelper()
{
return new XmlHelper();
}
代码示例来源:origin: FINRAOS/herd
return xmlHelper.unmarshallXmlToObject(classType, xml);
代码示例来源:origin: org.finra.herd/herd-service
return xmlHelper.unmarshallXmlToObject(classType, xml);
代码示例来源:origin: FINRAOS/herd
/**
* Returns XML representation of the object.
*
* @param obj the Java object to be serialized
*
* @return the XML representation of this object
* @throws javax.xml.bind.JAXBException if a JAXB error occurred.
*/
public String objectToXml(Object obj) throws JAXBException
{
// By default, we do not ask the marshalled XML data to be formatted with line feeds and indentation.
return objectToXml(obj, false);
}
代码示例来源:origin: FINRAOS/herd
/**
* This method tests the error cases for AmazonExceptions for Illegal Argument
*/
@Test(expected = IllegalArgumentException.class)
public void testCreateEmrClusterAmazonBadRequest() throws Exception
{
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
String configXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_MINIMAL_CLASSPATH).getInputStream());
EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml);
emrClusterDefinition.setAmiVersion(MockAwsOperationsHelper.AMAZON_BAD_REQUEST);
configXml = xmlHelper.objectToXml(emrClusterDefinition);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, configXml);
// Create a new EMR cluster create request.
EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
emrService.createCluster(request);
}
代码示例来源:origin: FINRAOS/herd
/**
* A test case to validate that the XSD restrictions are loose enough to allow empty elements for nested elements.
*/
@Test
public void testUnmarshallXmlWithNestedElements() throws JAXBException
{
String xml = "<emrClusterCreateRequest>" + "<namespace>" + NAMESPACE + "</namespace>" + "<emrClusterDefinitionName>" + EMR_CLUSTER_DEFINITION_NAME +
"</emrClusterDefinitionName>" + "<emrClusterName>cluster1</emrClusterName>" + "<dryRun>true</dryRun>" + "<emrClusterDefinitionOverride>" +
"<customBootstrapActionMaster/>" + "<customBootstrapActionAll/>" + "<instanceDefinitions/>" + "<nodeTags/>" + "<daemonConfigurations/>" +
"<hadoopConfigurations/>" + "</emrClusterDefinitionOverride>" + "</emrClusterCreateRequest>";
xmlHelper.unmarshallXmlToObject(EmrClusterCreateRequest.class, xml);
}
代码示例来源:origin: FINRAOS/herd
private HttpEntity getHttpEntity(Object content) throws UnsupportedCharsetException, JAXBException
{
String xml = xmlHelper.objectToXml(content);
LOGGER.debug("xml = " + xml);
ContentType contentType = ContentType.APPLICATION_XML.withCharset(StandardCharsets.UTF_8);
return new StringEntity(xml, contentType);
}
代码示例来源:origin: FINRAOS/herd
/**
* This method tests the error cases for AmazonExceptions for AmazonServiceException
*/
@Test(expected = AmazonServiceException.class)
public void testCreateEmrClusterAmazonOtherException() throws Exception
{
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
String configXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_MINIMAL_CLASSPATH).getInputStream());
EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml);
emrClusterDefinition.setAmiVersion(MockAwsOperationsHelper.AMAZON_SERVICE_EXCEPTION);
configXml = xmlHelper.objectToXml(emrClusterDefinition);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, configXml);
// Create a new EMR cluster create request.
EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
emrService.createCluster(request);
}
代码示例来源:origin: FINRAOS/herd
/**
* Loads from the specified XML file and returns a test EMR cluster definition configuration.
*
* @param xmlFileClasspath the XML file classpath to be loaded
*
* @return the newly created EMR cluster definition configuration instance
*/
private EmrClusterDefinition getTestEmrClusterDefinitionConfiguration(String xmlFileClasspath) throws Exception
{
String xmlString = getTestEmrClusterDefinitionConfigurationXml(xmlFileClasspath);
return xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, xmlString);
}
代码示例来源:origin: org.finra.herd/herd-service
@NamespacePermission(fields = "#emrClusterDefinitionKey?.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
public EmrClusterDefinitionInformation deleteEmrClusterDefinition(EmrClusterDefinitionKey emrClusterDefinitionKey) throws Exception
{
// Perform validate and trim of the EMR cluster definition key.
emrClusterDefinitionHelper.validateEmrClusterDefinitionKey(emrClusterDefinitionKey);
// Retrieve and ensure that a EMR cluster definition already exists with the specified key.
EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoHelper.getEmrClusterDefinitionEntity(emrClusterDefinitionKey);
// Log the existing EMR cluster definition.
LOGGER.info("Logging EMR cluster definition being deleted. emrClusterDefinition={}",
xmlHelper.objectToXml(createEmrClusterDefinitionFromEntity(emrClusterDefinitionEntity), true));
// Delete the EMR cluster definition.
emrClusterDefinitionDao.delete(emrClusterDefinitionEntity);
// Create and return the EMR cluster definition object from the deleted entity.
return createEmrClusterDefinitionFromEntity(emrClusterDefinitionEntity);
}
代码示例来源:origin: FINRAOS/herd
/**
* This method tests supported product
*/
@Test
public void testCreateEmrClusterSupportedProduct() throws Exception
{
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
String configXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_MINIMAL_CLASSPATH).getInputStream());
EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml);
// Set the supported product
emrClusterDefinition.setSupportedProduct("mapr-m3");
configXml = xmlHelper.objectToXml(emrClusterDefinition);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, configXml);
// Create a new EMR cluster create request.
EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
emrService.createCluster(request);
}
代码示例来源:origin: FINRAOS/herd
@Test
public void testGetXmlClobPropertyAndUnmarshallToObject() throws JAXBException
{
// Create a mock configuration entity.
ConfigurationEntity configurationEntity = mock(ConfigurationEntity.class);
when(configurationEntity.getValueClob()).thenReturn(CONFIGURATION_VALUE);
// Mock the external calls.
when(configurationDao.getConfigurationByKey(CONFIGURATION_KEY)).thenReturn(configurationEntity);
when(xmlHelper.unmarshallXmlToObject(String.class, CONFIGURATION_VALUE)).thenReturn(STRING_VALUE);
// Call the method under test.
String result = configurationDaoHelper.getXmlClobPropertyAndUnmarshallToObject(String.class, CONFIGURATION_KEY);
// Verify the external calls.
verify(configurationDao).getConfigurationByKey(CONFIGURATION_KEY);
verify(xmlHelper).unmarshallXmlToObject(String.class, CONFIGURATION_VALUE);
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(STRING_VALUE, result);
}
代码示例来源:origin: FINRAOS/herd
@NamespacePermission(fields = "#emrClusterDefinitionKey?.namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
public EmrClusterDefinitionInformation deleteEmrClusterDefinition(EmrClusterDefinitionKey emrClusterDefinitionKey) throws Exception
{
// Perform validate and trim of the EMR cluster definition key.
emrClusterDefinitionHelper.validateEmrClusterDefinitionKey(emrClusterDefinitionKey);
// Retrieve and ensure that a EMR cluster definition already exists with the specified key.
EmrClusterDefinitionEntity emrClusterDefinitionEntity = emrClusterDefinitionDaoHelper.getEmrClusterDefinitionEntity(emrClusterDefinitionKey);
// Log the existing EMR cluster definition.
LOGGER.info("Logging EMR cluster definition being deleted. emrClusterDefinition={}",
xmlHelper.objectToXml(createEmrClusterDefinitionFromEntity(emrClusterDefinitionEntity), true));
// Delete the EMR cluster definition.
emrClusterDefinitionDao.delete(emrClusterDefinitionEntity);
// Create and return the EMR cluster definition object from the deleted entity.
return createEmrClusterDefinitionFromEntity(emrClusterDefinitionEntity);
}
代码示例来源:origin: FINRAOS/herd
/**
* This method tests additionalInfo
*/
@Test
public void testCreateEmrClusterAdditionalInfo() throws Exception
{
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
String configXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_MINIMAL_CLASSPATH).getInputStream());
EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml);
// Set the additional Info
emrClusterDefinition
.setAdditionalInfo("{ami64: \"ami-e82af080\", amiHvm64: \"ami-e82af080\", hadoopVersion: \"2.4.0\", hadoopConfigurationVersion: \"3.1\"}");
configXml = xmlHelper.objectToXml(emrClusterDefinition);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, configXml);
// Create a new EMR cluster create request.
EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
emrService.createCluster(request);
}
代码示例来源:origin: FINRAOS/herd
@Test
public void testGetXmlClobPropertyAndUnmarshallToObjectJAXBException() throws JAXBException
{
// Create a mock configuration entity.
ConfigurationEntity configurationEntity = mock(ConfigurationEntity.class);
when(configurationEntity.getValueClob()).thenReturn(CONFIGURATION_VALUE);
// Mock the external calls.
when(configurationDao.getConfigurationByKey(CONFIGURATION_KEY)).thenReturn(configurationEntity);
when(xmlHelper.unmarshallXmlToObject(String.class, CONFIGURATION_VALUE)).thenThrow(new JAXBException(ERROR_MESSAGE));
// Try to call the method under test.
try
{
configurationDaoHelper.getXmlClobPropertyAndUnmarshallToObject(String.class, CONFIGURATION_KEY);
}
catch (IllegalStateException e)
{
assertEquals(String.format("Failed to unmarshall \"%s\" configuration value to %s.", CONFIGURATION_KEY, String.class.getName()), e.getMessage());
}
// Verify the external calls.
verify(configurationDao).getConfigurationByKey(CONFIGURATION_KEY);
verify(xmlHelper).unmarshallXmlToObject(String.class, CONFIGURATION_VALUE);
verifyNoMoreInteractionsHelper();
}
代码示例来源:origin: FINRAOS/herd
private void populateParameters(JdbcExecutionRequest jdbcExecutionRequest, List<FieldExtension> fieldExtensionList, List<Parameter> parameters)
{
try
{
String jdbcExecutionRequestString = xmlHelper.objectToXml(jdbcExecutionRequest);
fieldExtensionList.add(buildFieldExtension("contentType", "${contentType}"));
fieldExtensionList.add(buildFieldExtension("jdbcExecutionRequest", "${jdbcExecutionRequest}"));
parameters.add(buildParameter("contentType", "xml"));
parameters.add(buildParameter("jdbcExecutionRequest", jdbcExecutionRequestString));
}
catch (JAXBException e)
{
throw new IllegalArgumentException(e);
}
}
}
代码示例来源:origin: FINRAOS/herd
@Test
public void testCreateEmrClusterSecurityConfigurationReleaseLabelWithPrefix() throws Exception
{
// Create the namespace entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
String configXml = IOUtils.toString(resourceLoader.getResource(EMR_CLUSTER_DEFINITION_XML_FILE_MINIMAL_CLASSPATH).getInputStream());
EmrClusterDefinition emrClusterDefinition = xmlHelper.unmarshallXmlToObject(EmrClusterDefinition.class, configXml);
// Set the security configuration along with the EMR release label starting with an "emr-" prefix.
// This is needed since security configuration is not supported prior to EMR version 4.8.0.
emrClusterDefinition.setSecurityConfiguration("securityConfiguration");
emrClusterDefinition.setReleaseLabel("emr-4.8.0");
configXml = xmlHelper.objectToXml(emrClusterDefinition);
emrClusterDefinitionDaoTestHelper.createEmrClusterDefinitionEntity(namespaceEntity, EMR_CLUSTER_DEFINITION_NAME, configXml);
// Create a new EMR cluster create request.
EmrClusterCreateRequest request = getNewEmrClusterCreateRequest();
emrService.createCluster(request);
}
代码示例来源:origin: FINRAOS/herd
@Test
public void testUnmarshallXmlToObject() throws Exception
{
assertEquals(getTestBuildInformation(), xmlHelper.unmarshallXmlToObject(BuildInformation.class, getTestXml()));
}
本文整理了Java中org.finra.herd.dao.helper.XmlHelper类的一些代码示例,展示了XmlHelper类的具体用法。这些代码示例主要来源于Github/Stackover
本文整理了Java中org.finra.herd.dao.helper.XmlHelper.objectToXml()方法的一些代码示例,展示了XmlHelper.objectToXml()的具体用法
本文整理了Java中org.finra.herd.dao.helper.XmlHelper.unmarshallXmlToObject()方法的一些代码示例,展示了XmlHelper.unmarsha
我是一名优秀的程序员,十分优秀!