List of usage examples for org.apache.commons.jxpath JXPathContext getValue
public abstract Object getValue(String xpath);
From source file:org.fireflow.pdl.fpdl.test.service.callback.WebserviceStartProcessTest.java
@Test public void testCallbackService() { final WorkflowSession session = WorkflowSessionFactory.createWorkflowSession(fireflowRuntimeContext, FireWorkflowSystem.getInstance()); final WorkflowStatement stmt = session.createWorkflowStatement(FpdlConstants.PROCESS_TYPE_FPDL20); //0??/* www.j a v a2s .c o m*/ final WorkflowProcess process = getWorkflowProcess(); //1??? transactionTemplate.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus arg0) { //? try { ProcessDescriptor descriptor = stmt.uploadProcessObject(process, 0); ((ProcessDescriptorImpl) descriptor).setPublishState(true); stmt.updateProcessDescriptor(descriptor); } catch (InvalidModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }); //2?CallbackManagerinit?Webservice //TODO WorkflowServer?webservice // WebServiceManager callbackManager = this.runtimeContext.getEngineModule(WebServiceManager.class, FpdlConstants.PROCESS_TYPE_FPDL20); // try { // callbackManager.publishAllCallbackServices(); // } catch (WebservicePublishException e1) { // // TODO Auto-generated catch block // e1.printStackTrace(); // } //JaxwsWebservice Environment env = fireflowRuntimeContext.getEngineModule(Environment.class, FpdlConstants.PROCESS_TYPE_FPDL20); URL url = null; try { String contextPath = env.getWebserviceContextPath(); if (!contextPath.startsWith("/")) { contextPath = "/" + contextPath; } if (!contextPath.endsWith("/")) { contextPath = contextPath + "/"; } String address = "http://" + env.getWebserviceIP() + ":" + Integer.toString(env.getWebservicePort()) + contextPath; url = new URL(address + serviceQName.getLocalPart() + "?wsdl"); } catch (Exception e) { e.printStackTrace(); } javax.xml.ws.Service jawsService = javax.xml.ws.Service.create(url, serviceQName); Dispatch<Source> dispatch = jawsService.createDispatch(portQName, Source.class, javax.xml.ws.Service.Mode.PAYLOAD); String messageStr = "<cal:acceptRequest xmlns:cal=\"" + targetNsUri + "\">" + "<cal:id>" + bizId + "</cal:id>" + "<cal:approveResult>" + approveResult + "</cal:approveResult>" + "</cal:acceptRequest>"; java.io.ByteArrayInputStream byteInStream = new java.io.ByteArrayInputStream(messageStr.getBytes()); StreamSource source = new StreamSource(byteInStream); Source response = dispatch.invoke(source); DOMResult result = new DOMResult(); // StreamResult result = new StreamResult(System.out); Transformer transformer = null; try { TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformer = transformerFactory.newTransformer(); transformer.transform(response, result); } catch (TransformerConfigurationException e) { throw new RuntimeException("Couldn't parse response stream.", e); } catch (TransformerException e) { throw new RuntimeException("Couldn't parse response stream.", e); } Document theResponsePayload = (Document) result.getNode(); Assert.assertNotNull(theResponsePayload); JXPathContext jxpathContext = JXPathContext.newContext(theResponsePayload); jxpathContext.registerNamespace("ns0", targetNsUri); String response2 = (String) jxpathContext.getValue("ns0:acceptResponse/ns0:response2"); String response1 = (String) jxpathContext.getValue("ns0:acceptResponse/ns0:response1"); Assert.assertEquals(responseResult, response2); Assert.assertNotNull(response1); this.processInstanceId = response1; this.assertResult(session); }
From source file:org.fireflow.pdl.fpdl20.test.service.callback.TheCallbackServiceProcessTest1.java
@Test public void testCallbackService() { final WorkflowSession session = WorkflowSessionFactory.createWorkflowSession(runtimeContext, FireWorkflowSystem.getInstance()); final WorkflowStatement stmt = session.createWorkflowStatement(FpdlConstants.PROCESS_TYPE_FPDL20); //0??/*from ww w .ja va2 s.co m*/ final WorkflowProcess process = getWorkflowProcess(); //1??? transactionTemplate.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus arg0) { //? try { stmt.uploadProcessObject(process, true, null, null); } catch (InvalidModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }); //2?CallbackManagerinit?Webservice WebServiceManager callbackManager = this.runtimeContext.getEngineModule(WebServiceManager.class, FpdlConstants.PROCESS_TYPE_FPDL20); try { callbackManager.publishAllCallbackServices(); } catch (WebservicePublishException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //3??? transactionTemplate.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus arg0) { //?? try { ProcessInstance processInstance = stmt.startProcess(process.getId(), bizId, null); if (processInstance != null) { processInstanceId = processInstance.getId(); } } catch (InvalidModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (WorkflowProcessNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvalidOperationException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }); //JaxwsWebservice Environment env = runtimeContext.getEngineModule(Environment.class, FpdlConstants.PROCESS_TYPE_FPDL20); URL url = null; try { String contextPath = env.getWebserviceContextPath(); if (!contextPath.startsWith("/")) { contextPath = "/" + contextPath; } if (!contextPath.endsWith("/")) { contextPath = contextPath + "/"; } String address = "http://" + env.getWebserviceIP() + ":" + Integer.toString(env.getWebservicePort()) + contextPath; url = new URL(address + serviceQName.getLocalPart() + "?wsdl"); } catch (Exception e) { e.printStackTrace(); } javax.xml.ws.Service jawsService = javax.xml.ws.Service.create(url, serviceQName); Dispatch<Source> dispatch = jawsService.createDispatch(portQName, Source.class, javax.xml.ws.Service.Mode.PAYLOAD); String messageStr = "<cal:acceptRequest xmlns:cal=\"http://www.fireflow.org/junit/callbackservice\">" + "<cal:id>" + bizId + "</cal:id>" + "<cal:approveResult>" + approveResult + "</cal:approveResult>" + "</cal:acceptRequest>"; java.io.ByteArrayInputStream byteInStream = new java.io.ByteArrayInputStream(messageStr.getBytes()); StreamSource source = new StreamSource(byteInStream); Source response = dispatch.invoke(source); DOMResult result = new DOMResult(); // StreamResult result = new StreamResult(System.out); Transformer transformer = null; try { TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformer = transformerFactory.newTransformer(); transformer.transform(response, result); } catch (TransformerConfigurationException e) { throw new RuntimeException("Couldn't parse response stream.", e); } catch (TransformerException e) { throw new RuntimeException("Couldn't parse response stream.", e); } Document theResponsePayload = (Document) result.getNode(); Assert.assertNotNull(theResponsePayload); JXPathContext jxpathContext = JXPathContext.newContext(theResponsePayload); jxpathContext.registerNamespace("ns0", targetNsUri); String response2 = (String) jxpathContext.getValue("ns0:acceptResponse/ns0:response2"); Assert.assertEquals(responseResult, response2); this.assertResult(session); }
From source file:org.fireflow.pdl.fpdl20.test.service.callback.WebserviceStartProcessTest.java
@Test public void testCallbackService() { final WorkflowSession session = WorkflowSessionFactory.createWorkflowSession(runtimeContext, FireWorkflowSystem.getInstance()); final WorkflowStatement stmt = session.createWorkflowStatement(FpdlConstants.PROCESS_TYPE_FPDL20); //0??/*from w w w . ja v a 2s . co m*/ final WorkflowProcess process = getWorkflowProcess(); //1??? transactionTemplate.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus arg0) { //? try { stmt.uploadProcessObject(process, true, null, null); } catch (InvalidModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }); //2?CallbackManagerinit?Webservice WebServiceManager callbackManager = this.runtimeContext.getEngineModule(WebServiceManager.class, FpdlConstants.PROCESS_TYPE_FPDL20); try { callbackManager.publishAllCallbackServices(); } catch (WebservicePublishException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //JaxwsWebservice Environment env = runtimeContext.getEngineModule(Environment.class, FpdlConstants.PROCESS_TYPE_FPDL20); URL url = null; try { String contextPath = env.getWebserviceContextPath(); if (!contextPath.startsWith("/")) { contextPath = "/" + contextPath; } if (!contextPath.endsWith("/")) { contextPath = contextPath + "/"; } String address = "http://" + env.getWebserviceIP() + ":" + Integer.toString(env.getWebservicePort()) + contextPath; url = new URL(address + serviceQName.getLocalPart() + "?wsdl"); } catch (Exception e) { e.printStackTrace(); } javax.xml.ws.Service jawsService = javax.xml.ws.Service.create(url, serviceQName); Dispatch<Source> dispatch = jawsService.createDispatch(portQName, Source.class, javax.xml.ws.Service.Mode.PAYLOAD); String messageStr = "<cal:acceptRequest xmlns:cal=\"" + targetNsUri + "\">" + "<cal:id>" + bizId + "</cal:id>" + "<cal:approveResult>" + approveResult + "</cal:approveResult>" + "</cal:acceptRequest>"; java.io.ByteArrayInputStream byteInStream = new java.io.ByteArrayInputStream(messageStr.getBytes()); StreamSource source = new StreamSource(byteInStream); Source response = dispatch.invoke(source); DOMResult result = new DOMResult(); // StreamResult result = new StreamResult(System.out); Transformer transformer = null; try { TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformer = transformerFactory.newTransformer(); transformer.transform(response, result); } catch (TransformerConfigurationException e) { throw new RuntimeException("Couldn't parse response stream.", e); } catch (TransformerException e) { throw new RuntimeException("Couldn't parse response stream.", e); } Document theResponsePayload = (Document) result.getNode(); Assert.assertNotNull(theResponsePayload); JXPathContext jxpathContext = JXPathContext.newContext(theResponsePayload); jxpathContext.registerNamespace("ns0", targetNsUri); String response2 = (String) jxpathContext.getValue("ns0:acceptResponse/ns0:response2"); String response1 = (String) jxpathContext.getValue("ns0:acceptResponse/ns0:response1"); Assert.assertEquals(responseResult, response2); Assert.assertNotNull(response1); this.processInstanceId = response1; this.assertResult(session); }
From source file:org.firesoa.common.jxpath.JXPathTestCase.java
protected void assertXPathValue(JXPathContext ctx, String xpath, Object expected) { ctx.setLenient(false);/* ww w .j a va2 s. c o m*/ Object actual = ctx.getValue(xpath); assertEquals("Evaluating <" + xpath + ">", expected, actual); }
From source file:org.firesoa.common.jxpath.JXPathTestCase.java
protected void assertXPathValueLenient(JXPathContext ctx, String xpath, Object expected) { ctx.setLenient(true);/* ww w . j a v a 2 s .c o m*/ Object actual = ctx.getValue(xpath); ctx.setLenient(false); assertEquals("Evaluating lenient <" + xpath + ">", expected, actual); }
From source file:org.firesoa.common.jxpath.JXPathTestCase.java
protected void assertXPathSetValue(JXPathContext ctx, String xpath, Object value, Object expected) { ctx.setValue(xpath, value);/*from ww w. j a v a2 s .c o m*/ Object actual = ctx.getValue(xpath); assertEquals("Modifying <" + xpath + ">", expected, actual); }
From source file:org.firesoa.common.jxpath.JXPathTestCase.java
protected void assertXPathCreatePath(JXPathContext ctx, String xpath, Object expectedValue, String expectedPath) {//w w w . j a v a 2s. c o m Pointer pointer = ctx.createPath(xpath); assertEquals("Creating path <" + xpath + ">", expectedPath, pointer.asPath()); assertEquals("Creating path (pointer value) <" + xpath + ">", expectedValue, pointer.getValue()); assertEquals("Creating path (context value) <" + xpath + ">", expectedValue, ctx.getValue(pointer.asPath())); }
From source file:org.firesoa.common.jxpath.JXPathTestCase.java
protected void assertXPathCreatePathAndSetValue(JXPathContext ctx, String xpath, Object value, String expectedPath) {/* ww w .j a v a 2 s .c om*/ Pointer pointer = ctx.createPathAndSetValue(xpath, value); assertEquals("Creating path <" + xpath + ">", expectedPath, pointer.asPath()); assertEquals("Creating path (pointer value) <" + xpath + ">", value, pointer.getValue()); assertEquals("Creating path (context value) <" + xpath + ">", value, ctx.getValue(pointer.asPath())); }
From source file:org.firesoa.common.jxpath.JXPathTestCase.java
protected void assertXPathValueType(JXPathContext ctx, String xpath, Class clazz) { ctx.setLenient(false);//from w ww . j a v a2 s . c om Object actual = ctx.getValue(xpath); assertTrue("Evaluating <" + xpath + "> = " + actual.getClass(), clazz.isAssignableFrom(actual.getClass())); }
From source file:org.geoserver.sfs.CapabilitiesTest.java
@Test public void testBasicContents() throws Exception { MockHttpServletResponse response = getAsServletResponse(root() + "capabilities"); assertEquals(200, response.getErrorCode()); JSONArray json = (JSONArray) json(response); // print(json); // check we have the right number of layers assertEquals(getCatalog().getFeatureTypes().size(), json.size()); // extract and check one JXPathContext context = JXPathContext.newContext(json); JSONObject primitive = (JSONObject) context.getValue(".[name = 'sf:PrimitiveGeoFeature']"); assertNotNull(primitive);// w w w. ja va2s. c om assertEquals("urn:ogc:def:crs:EPSG:4326", primitive.get("crs")); assertEquals("xy", primitive.get("axisorder")); JSONArray bbox = (JSONArray) primitive.get("bbox"); assertEquals(-180.0, bbox.getDouble(0), 1E-7); assertEquals(-90.0, bbox.getDouble(1), 1E-7); assertEquals(180.0, bbox.getDouble(2), 1E-7); assertEquals(90.0, bbox.getDouble(3), 1E-7); }