本文整理汇总了Java中org.apache.axiom.om.OMElement类的典型用法代码示例。如果您正苦于以下问题:Java OMElement类的具体用法?Java OMElement怎么用?Java OMElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OMElement类属于org.apache.axiom.om包,在下文中一共展示了OMElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: messageProcessorMediaTypeTest
import org.apache.axiom.om.OMElement; //导入依赖的package包/类
@Test(groups = {"wso2.esb"}, description = "Test message Processor media type - text/xml", enabled = false)
public void messageProcessorMediaTypeTest() throws Exception {
String messageStoreName = "xyz";
OMElement messageStore = AXIOMUtil.stringToOM("<messageStore xmlns=\"http://ws.apache.org/ns/synapse\" name=\"" + messageStoreName + "\">" +
"<parameter name=\"abc\">10</parameter>" +
"</messageStore>");
messageStoreAdminClient.addMessageStore(messageStore);
isMessageStoreExist = true;
Thread.sleep(1000);
OMElement messageProcessor = AXIOMUtil.stringToOM("<messageProcessor xmlns=\"http://ws.apache.org/ns/synapse\" " +
"class=\"org.apache.synapse.message.processors.forward.ScheduledMessageForwardingProcessor\" " +
"name=\"" + MESSAGE_PROCESSOR_NAME + "\" messageStore=\"" + messageStoreName + "\">" +
"<parameter name=\"abc\">100</parameter>" +
"</messageProcessor>");
messageProcessorClient.addMessageProcessor(messageProcessor);
isMessageProcessorExist = true;
//addEndpoint is a a asynchronous call, it will take some time to write to a registry
Thread.sleep(10000);
MetadataBean metadata = resourceAdmin.getMetadata("/_system/config/repository/synapse/default/synapse-message-processors/" + MESSAGE_PROCESSOR_NAME);
Assert.assertEquals(metadata.getMediaType(), "text/xml", "Media Type mismatched for Message Processor");
}
示例2: secureRequestScenario6
import org.apache.axiom.om.OMElement; //导入依赖的package包/类
@Test(groups = "wso2.esb", description = "secure Request to a pass through proxy refer secure backend service")
public void secureRequestScenario6() throws Exception {
OMElement response = new SecureStockQuoteClient().sendSecuredSimpleStockQuoteRequest(null, null
, getProxyServiceURLHttp(proxyName + "6")
, policyPath + "scenario6-policy.xml", "Secured");
String lastPrice = response.getFirstElement().getFirstChildWithName(new QName("http://services.samples/xsd", "last"))
.getText();
assertNotNull(lastPrice, "Fault: response message 'last' price null");
String symbol = response.getFirstElement().getFirstChildWithName(new QName("http://services.samples/xsd", "symbol"))
.getText();
assertEquals(symbol, "Secured", "Fault: value 'symbol' mismatched");
}
示例3: definedEndpointMediaTypeTest
import org.apache.axiom.om.OMElement; //导入依赖的package包/类
@Test(groups = {"wso2.esb"}, description = "Test defined Endpoint media type - text/xml", enabled = false)
public void definedEndpointMediaTypeTest() throws Exception {
OMElement endpoint = AXIOMUtil.stringToOM("<endpoint xmlns=\"http://ws.apache.org/ns/synapse\" " +
"name=\"" + DEFINED_ENDPOINT_NAME + "\">" +
"<address uri=\"http://localhost:9000/services/SimpleStockQuoteService\" />" +
"</endpoint>");
isDefinedEndpointExist = endpointAdminClient.addEndPoint(endpoint);
Assert.assertTrue(isDefinedEndpointExist, "Endpoint addition failed");
boolean isEndpointExist = false;
for (String endpointName : endpointAdminClient.getEndpointNames()) {
if (DEFINED_ENDPOINT_NAME.equalsIgnoreCase(endpointName)) {
isEndpointExist = true;
break;
}
}
Assert.assertTrue(isEndpointExist, "Endpoint not found in Defined Endpoint list");
//addEndpoint is a a asynchronous call, it will take some time to write to a registry
Thread.sleep(10000);
MetadataBean metadata = resourceAdmin.getMetadata("/_system/config/repository/synapse/default/endpoints/" + DEFINED_ENDPOINT_NAME);
Assert.assertEquals(metadata.getMediaType(), "text/xml", "Media Type mismatched for Defined Endpoint");
}
示例4: init
import org.apache.axiom.om.OMElement; //导入依赖的package包/类
@BeforeClass(alwaysRun = true)
public void init() throws Exception {
activeMQServer.startJMSBroker();
OMElement synapse;
super.init(TENANT1, "user1");
inboundAdminClient1 = new InboundAdminClient(context.getContextUrls().getBackEndUrl(), sessionCookie);
synapse = esbUtils.loadResource("/artifacts/ESB/jms/inbound/transport/jms_http_tenant_transport.xml");
updateESBConfiguration(JMSEndpointManager.setConfigurations(synapse));
logViewerClient = new LogViewerClient(contextUrls.getBackEndUrl(), sessionCookie);
super.init(TENANT2, "user1");
inboundAdminClient2 = new InboundAdminClient(context.getContextUrls().getBackEndUrl(), sessionCookie);
synapse = esbUtils.loadResource("/artifacts/ESB/jms/inbound/transport/jms_http_tenant_transport.xml");
updateESBConfiguration(JMSEndpointManager.setConfigurations(synapse));
}
示例5: testMoreNumberThanMaximum
import org.apache.axiom.om.OMElement; //导入依赖的package包/类
@Test(groups = {"wso2.esb"}, description = "more number of messages than maximum count")
public void testMoreNumberThanMaximum() throws IOException, XMLStreamException {
int responseCount = 0;
no_of_requests = 15;
aggregatedRequestClient.setNoOfIterations(no_of_requests);
String Response = aggregatedRequestClient.getResponse();
Assert.assertNotNull(Response);
OMElement Response2 = AXIOMUtil.stringToOM(Response);
OMElement soapBody = Response2.getFirstElement();
Iterator iterator = soapBody.getChildrenWithName(new QName("http://services.samples",
"getQuoteResponse"));
while (iterator.hasNext()) {
responseCount++;
OMElement getQuote = (OMElement) iterator.next();
Assert.assertTrue(getQuote.toString().contains("IBM"));
}
Assert.assertTrue(minMessageCount <= responseCount && responseCount <= maxMessageCount);
}
示例6: addEndpoint1
import org.apache.axiom.om.OMElement; //导入依赖的package包/类
private OMElement addEndpoint1() throws Exception {
OMElement synapseConfig = null;
synapseConfig = AXIOMUtil
.stringToOM("<inboundEndpoint xmlns=\"http://ws.apache.org/ns/synapse\"\n" +
" name=\"Test1\"\n" +
" sequence=\"requestHandlerSeq\"\n" +
" onError=\"inFault\"\n" +
" class=\"org.wso2.carbon.inbound.endpoint.test.GenericConsumer\"\n" +
" suspend=\"false\">\n" +
" <parameters>\n" +
" <parameter name=\"interval\">1000</parameter>\n" +
" </parameters>\n" +
"</inboundEndpoint>");
return synapseConfig;
}
示例7: addEmployee
import org.apache.axiom.om.OMElement; //导入依赖的package包/类
private void addEmployee(String serviceEndPoint, String employeeNumber) throws AxisFault {
OMElement payload = fac.createOMElement("addEmployee", omNs);
OMElement empNo = fac.createOMElement("employeeNumber", omNs);
empNo.setText(employeeNumber);
payload.addChild(empNo);
OMElement lastName = fac.createOMElement("lastName", omNs);
lastName.setText("BBB");
payload.addChild(lastName);
OMElement fName = fac.createOMElement("firstName", omNs);
fName.setText("AAA");
payload.addChild(fName);
OMElement email = fac.createOMElement("email", omNs);
email.setText("[email protected]");
payload.addChild(email);
OMElement salary = fac.createOMElement("salary", omNs);
salary.setText("50000");
payload.addChild(salary);
new AxisServiceClient().sendRobust(payload, serviceEndPoint, "addEmployee");
}
示例8: loadEmailConfig
import org.apache.axiom.om.OMElement; //导入依赖的package包/类
private String loadEmailConfig(OMElement configElement) {
StringBuilder emailTemplate = new StringBuilder();
Iterator it = configElement.getChildElements();
while (it.hasNext()) {
OMElement element = (OMElement) it.next();
if ("subject".equals(element.getLocalName())) {
emailTemplate.append(element.getText());
} else if ("body".equals(element.getLocalName())) {
emailTemplate.append("|");
emailTemplate.append(element.getText());
} else if ("footer".equals(element.getLocalName())) {
emailTemplate.append("|");
emailTemplate.append(element.getText());
}
}
return emailTemplate.toString();
}
示例9: testMoreNumberThanMinimum
import org.apache.axiom.om.OMElement; //导入依赖的package包/类
@Test(groups = {"wso2.esb"}, description = "higher number of messages than minimum count")
public void testMoreNumberThanMinimum() throws IOException, XMLStreamException {
int responseCount=0;
no_of_requests=8;
aggregatedRequestClient.setNoOfIterations(no_of_requests);
String Response= aggregatedRequestClient.getResponse();
Assert.assertNotNull(Response);
OMElement Response2= AXIOMUtil.stringToOM(Response);
OMElement soapBody = Response2.getFirstElement();
Iterator iterator =soapBody.getChildrenWithName(new QName("http://services.samples",
"getQuoteResponse"));
while (iterator.hasNext()) {
responseCount++;
OMElement getQuote = (OMElement) iterator.next();
Assert.assertTrue(getQuote.toString().contains("IBM"));
}
Assert.assertTrue(minMessageCount<=responseCount&&responseCount<=no_of_requests);
}
示例10: addEndpoint2
import org.apache.axiom.om.OMElement; //导入依赖的package包/类
private OMElement addEndpoint2() throws Exception {
OMElement synapseConfig = null;
synapseConfig = AXIOMUtil
.stringToOM("<inboundEndpoint name=\"testFtpFile2\" onError=\"inFault\" protocol=\"file\"\n"
+ " sequence=\"requestHandlerSeq\" suspend=\"false\" xmlns=\"http://ws.apache.org/ns/synapse\">\"\n"
+ " <parameters>\n"
+ " <parameter name=\"interval\">1000</parameter>\n"
+ " <parameter name=\"transport.vfs.ActionAfterErrors\">NONE</parameter>\n"
+ " <parameter name=\"transport.vfs.Locking\">enable</parameter>\n"
+ " <parameter name=\"transport.vfs.ContentType\">application/xml</parameter>\n"
+ " <parameter name=\"transport.vfs.ActionAfterFailure\">NONE</parameter>\n"
+ " <parameter name=\"transport.vfs.ActionAfterProcess\">MOVE</parameter>\n"
+ "<parameter name=\"transport.vfs.MoveAfterProcess\">ftp://admin:[email protected]:9653/ftpout"
+ "</parameter>"
+ " <parameter name=\"transport.vfs.FileURI\">ftp://admin:[email protected]:9653/ftpin"
+ "</parameter>\n"
+ " </parameters>\n"
+ "</inboundEndpoint>\n");
return synapseConfig;
}
示例11: testMoreNumberThanMinimum
import org.apache.axiom.om.OMElement; //导入依赖的package包/类
@Test(groups = {"wso2.esb"}, description = "higher number of messages than minimum count")
public void testMoreNumberThanMinimum() throws IOException, XMLStreamException {
int responseCount=0;
no_of_requests=10;
aggregatedRequestClient.setNoOfIterations(no_of_requests);
String Response= aggregatedRequestClient.getResponse();
Assert.assertNotNull(Response);
OMElement Response2= AXIOMUtil.stringToOM(Response);
OMElement soapBody = Response2.getFirstElement();
Iterator iterator =soapBody.getChildrenWithName(new QName("http://services.samples",
"getQuoteResponse"));
while (iterator.hasNext()) {
responseCount++;
OMElement getQuote = (OMElement) iterator.next();
Assert.assertTrue(getQuote.toString().contains("IBM"));
}
Assert.assertTrue(2<=responseCount&&responseCount<=no_of_requests);
}
示例12: searchXACML3Designator
import org.apache.axiom.om.OMElement; //导入依赖的package包/类
/**
* This searches through designator and selector values in the attribute elements to extract
* the policy meta data
*
* @param omElement apply element as an OMElement
* @param attributeDTO AttributeDTO object which holds the policy meta data in String format
* @return AttributeValueDTO object which holds the policy meta data in String format
*/
public AttributeDTO searchXACML3Designator(OMElement omElement,
AttributeDTO attributeDTO) {
Iterator iterator1 = omElement.
getChildrenWithLocalName(PDPConstants.ATTRIBUTE_DESIGNATOR);
while (iterator1.hasNext()) {
OMElement attributeDesignator = (OMElement) iterator1.next();
if (attributeDesignator != null) {
String attributeId = attributeDesignator.
getAttributeValue(new QName(PDPConstants.ATTRIBUTE_ID));
String category = attributeDesignator.
getAttributeValue(new QName(PDPConstants.CATEGORY));
String dataType = attributeDesignator.
getAttributeValue(new QName(PDPConstants.DATA_TYPE));
attributeDTO.setCategory(category);
attributeDTO.setAttributeId(attributeId);
attributeDTO.setAttributeDataType(dataType);
}
}
return attributeDTO;
}
示例13: generateSampleStockQuoteRequest
import org.apache.axiom.om.OMElement; //导入依赖的package包/类
/**
* Generate a request payload similar to what is sent by the test-axis2-client for SimpleStockQuoteService.
* @param symbol parameter used for payload
* @return sample request payload
*/
private String generateSampleStockQuoteRequest(String symbol) {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace soapNs = fac.createOMNamespace("http://schemas.xmlsoap.org/soap/envelope/", "soapenv");
OMNamespace omNs = fac.createOMNamespace("http://services.samples", "ns");
OMElement soapEnvelope = fac.createOMElement("Envelope", soapNs);
OMElement soapBody = fac.createOMElement("Body", soapNs);
OMElement method = fac.createOMElement("getSimpleQuote", omNs);
OMElement value1 = fac.createOMElement("symbol", omNs);
value1.addChild(fac.createOMText(method, symbol));
method.addChild(value1);
soapBody.addChild(method);
soapEnvelope.addChild(soapBody);
return "<?xml version='1.0' encoding='utf-8'?>" + soapEnvelope.toString();
}
示例14: injectToProxyTest
import org.apache.axiom.om.OMElement; //导入依赖的package包/类
@Test(groups = {"wso2.esb"})
public void injectToProxyTest() throws Exception {
OMElement task = AXIOMUtil.stringToOM("<task:task xmlns:task=\"http://www.wso2.org/products/wso2commons/tasks\"\n" +
" name=\"SampleInjectToProxyTask\" class=\"org.apache.synapse.startup.tasks.MessageInjector\"\n" +
" group=\"synapse.simple.quartz\">\n" +
" <task:trigger count=\"1\" interval=\"1\"/>\n" +
" <task:property name=\"message\">\n" +
" <m0:placeOrder xmlns:m0=\"http://services.samples\">\n" +
" <m0:order>\n" +
" <m0:price>100</m0:price>\n" +
" <m0:quantity>200</m0:quantity>\n" +
" <m0:symbol>IBM</m0:symbol>\n" +
" </m0:order>\n" +
" </m0:placeOrder>\n" +
" </task:property>\n" +
" <task:property name=\"proxyName\" value=\"SampleProxy\"/>\n" +
" <task:property name=\"injectTo\" value=\"proxy\"/>\n" +
"</task:task>");
addScheduledTask(task);
boolean invokedLogFound = Utils.checkForLog(logViewer, "PROXY INVOKED", 4);
assertTrue(invokedLogFound);
}
示例15: getMultipleResponse
import org.apache.axiom.om.OMElement; //导入依赖的package包/类
/**
* This is used to send a multiple stockquote request
*
* @param address service address
* @param symbol stock quote symbol
* @return
* @throws java.io.IOException
*/
public String getMultipleResponse(String address, String symbol, int iterations)
throws IOException {
AxisOperationClient operationClient = new AxisOperationClient();
OMElement response = null;
try {
response = operationClient.send(address, null, createMultipleQuoteRequestBody(symbol, iterations), "urn:getQuote");
} finally {
operationClient.destroy();
}
Assert.assertNotNull(response, "Response null");
return response.toString();
}