Does Citrus Framework for Integration testing(Java) supports Object to Object Asserts as in Junit? - citrus-framework

I am working on Citrus Integration Testing for a Web-service. I need to use the same DB used by the application. I am wondering if I can get response in Citrus in form of Objects, so that I can use the Object in Assert.

Citrus is able to automatically map message payloads into domain objects. You need to setup a marshaller (Xml) or object mapper (Json) in Citrus. Then you will be able to use domain object instances in send and receive operations.
See these samples for details:
https://github.com/christophd/citrus-samples/tree/master/sample-databind
https://github.com/christophd/citrus-samples/tree/master/sample-oxm
Hope this helps

Related

I am triying to do junit testing of a producer template

I am trying to do junit testing of a processor.
The issue I'm facing happens around producer template which has been used in the method.
The processor uses the producer template which is sending the return of a method call to an endpoint(this is where my junit is failing...
Does anyone know how to get trough the producer template?
If you want to test a processor in a junit test, then you need to supply a mocked exchange. You can use any mocking framework for it. You'll then be able to catch the processors calls to the exchange object.
You can also consider using a POJO instead of a processor and have Camel inject the required data. That might ease the unit testing part because you won't have a dependency on any Camel API. See: http://camel.apache.org/bean.html

In SOAPUI service mocking, is there a way to generate representative values for response fields?

I am trying to develop a SOAP client for a service to which I don't yet have access. I have therefore loaded the wsdl into soapui and am using the soapui service mocking functionality.
When I generate a mock response, the values are always set to '?'. Is there any way to ask soapui to generate representative test values given the type of each field? (The response in question has about 500 fields, so this would be really nice..). Alternatively, is there another tool I could use to generate such a response from a wsdl?
Many thanks!
Ah - answered my own question. Go to preferences -> WSDL and check the box that say sample data for requests. Even though it says for requests, it also generates sample data for responses :-)

GWT with Apache CXF

I am working with gwt code which involves call to web-service. We generated stub for web-service using Apache CXF. It generates all the request and response types. (I am not gwt expert) What I understand is, you need to have Common Data Models( Serilizable ) for accessing model classes on client side. Can we access model classes generated by Apache CXF on client side also ? Or Do we need to replicate all these classes for accessing them in client side ?
You need to first reference this before deciding which approach suits you best.
Depending on your performance requirements and screen type ( form vs chart vs tabular data ) you would have to choose the server communication type.
I am guessing RPC Or Json with Requestbuilder will serve you best. In both cases you might choose to have your own model classes layer on client side ( to be lightweight ).
If you intend to use CXF generated models then you would need to put them in shared folder of GWT and avoid pushing in data that is not serializable by GWT.

Grails integration testing of internationalized REST calls

I am trying to test internationalization from integration tests for a grails controller.
The controller is REST enabled and returns JSON responses.
In order to test internationalization, one can simply give ?lang=es in the URL and the respective message bundle is used internally by grails.
I am in a support project where the internationalization already works as it is supposed to. When I give a curl request, I receive the responses in the correct languages.
The integration test is just intended to validate the different language specific responses.
I am not sure how I can request for any language from the integration test.
I tried :
response.locale = new Locale("es", "es") //did not work
controller.params.lang = "es" // did not work
I have not found much help on this from http://grails.org/doc/latest/guide/i18n.html#changingLocales. And neither from other questions but A related article could be How to unit or integration test use of injected messageSource for i18n in Grails 2.0 service
Integration tests use the GrailsMockHttpServletRequest class that have the method addPreferredLocale(Locale) to change the locale of the current test request.
Normally we get the request through RequestContextHolder:
def request = RequestContextHolder.currentRequestAttributes().request
request.addPreferredLocale(new Locale("pt","BR"))

What's causing this SoapMapper error in VBA Soap Service call?

I'm trying to consume a Java based SOAP web service from VBA code in an Excel 2003 workbook. There are two methods available. One retrieves data, the other uploads data. The service for retrieving data works fine. However, when we try to upload data, we're running into a strange error that I just cannot find good information about on Google. The error message is:
Run-time error '-2147221504 (800040000)';
SoapMapper: Putting data into SoapMapper element failed
If we try to consume the same web service from a .NET application, it looks like the generated classes and methods are slightly different. For example, the fetch data service call takes a DataContainer object which has some identifying properties to determine what data to get. Then it returns the same type of object with the data filled in.
In the VBA classes generated by the Web Reference Toolkit, both fetch and save take the same type of object. But in .NET, the save takes a SaveDataContainerDetails object.
So a couple questions really:
Has anyone seen the SoapMapper error before in their VBA work?
Has anyone seen .NET and VBA generate different method signatures from the same WSDL? What could cause that and how could I work around it?
Is there a better way to call SOAP services from VBA rather than using the Web Reference Toolkit and the SOAP Toolkit?
I've figured out the issue here. The VBA Soap Toolkit and Web References Toolkit just can't handle array's of complex types. The error message above was somewhat misleading because "element" was actually the name of the XML element in the Soap envelope. So it was failing to put data into an element called "element". That was masking the issue a bit.
So I've determined it all boiled down to arrays of complex types. I've also determined that it's MUCH easier to just craft the soap envelopes my self in the VBA. The XML required is generally pretty well structured and not too difficult to create and or parse. So, if you're having trouble with the Soap Toolkit or the Web References Toolkit in VBA... just don't use it! :)
The best way to consume web services from VBA, VBSCRIPT, Classic ASP, etc. is to create your client using .NET. Then turn your client into a COM object. These are easily consumed by these older technologies.