How to create test variable from bean property value in XML test - citrus-framework

I need to create a test variable in my XML Citrus test. The variable should be set from a bean property, like this:
<variable name="zzzz" value="#{beanID.property}"/>
The variable gets created, but the #{beanID.property} does not get evaluated to bean's property value and the variable is set to the string '#{beanID.property}' instead.
The bean property is already available in the test, for example
<echo>
<message>My best idea: #{beanID.property}</message>
</echo>
works as expected.
Any other variables which are set using the standard ${...} substitution are created as expected.
No error messages from the framework are generated.

The Spring bean property expression language is not supported by the Citrus Xml test specification. Though a good enhancement idea so maybe worth a feature request and contribution to the framework.
If you want to use it right now you can also write a custom function that resolves the Spring bean property expression on the fly.
You can find good documentation about custom functions in Citrus user guide.

Related

Access to Bind Parameters in MyBatis Interceptor

How do I read the bind parameters inside a MyBatis Interceptor? I'm trying to extract those information so I can write them to a log table.
The guide (http://www.mybatis.org/mybatis-3/configuration.html) didn't mention how to get them, and the JavaDoc (http://www.mybatis.org/mybatis-3/es/apidocs/org/apache/ibatis/mapping/BoundSql.html) does not have a single line of comment. I saw an example on SO about constructing a new BoundSql but that isn't what I needed.
I tried to test what contents are stored in BoundSql.getParameterMappings() and BoundSql.getParameterObject(), but it seems to be pretty complex. There's JavaType and JdbcType, and if there's only one parameter the ParameterObject isn't a Map object.
What is the proper way to get the bind parameters from BoundSql?
After going through MyBatis source code (where comment is an endangered species), I found out how MyBatis processes the bind parameters. However, that requires access to the JDBC Statement object, which is simply not available inside an Interceptor.
Then I did some testing and settled on this:
If there is only a single parameter, BindSql.getParameterObject() will give you the parameter itself. By using BindSql.getParameterMappings() and ParameterMapping.getJavaType() I can tell which Java class the parameter is.
If there are more than one parameter, BindSql.getParameterObject() will return an instance of org.apache.ibatis.binding.MapperMethod.ParamMap, which extends HashMap, or it will be an instance of the DTO you used. Using .getProperty() from ParameterMapping as key or as getter name, you can process the bind parameters one by one.
If anyone has a better way to do this, I'm all ears.

Can SoapUI's property expansion be used to access a TestCase label?

I'm trying to write a SoapUI TestCase at the moment. I'd like to access the label of the test case in one of my test steps. Is there any way to do this using the property expansion syntax?
Something in the region of
${#TestCase#label}
Thanks
It's possible using the follow syntax:
${=context.testCase.name}
Explanation
${= } this allows to execute some Groovy code inside the request.
Like in the Groovy testSteps you've context available so you can access the testCase and then access the name property which contains the label.

How to make a request parameter optional in Spring REST Docs

I know fieldWithPath() has optional() but didn't find how to make parameterWithName() optional.
In Spring REST Docs 1.1 you can mark request and path parameters as optional. If you want that information to also appear in the generated table you can use a custom snippet that adds the optional column (once this bug has been fixed).
In Spring REST Docs 1.0 you can't mark a request parameter as optional via a first-class API. I would recommend using a combination of a custom attribute on the parameter descriptor and, if necessary, setting the ignored flag on the descriptor to allow the test to pass in the parameter's absence.

Prevent properties from generating resources

How do i prevent certain properties from generating resources when running the IDE "Generate Local Resource" tool?
I have applied the attribute to properties as well to the entire class, which is a custom server control but resources are still being generated?
I have a control that inherits WebControls.Label and I would like to prevent the Text property from generating resources...
Thx
The problem was the Text property was defined as overloads - changing the property definition from Overloads to Overrides yields the expected results (e.g. no resource generated for that property).

What does GWT.create mean and why should I use it?

I am new to GWT. i have below line of code.
SomeClientServiceAsync someService = GWT.create(SomeClientService.class);
what does above line means and why cannot i use any other alternatives to instantiate it?
Please help me!
Thanks.
GWT.create is used for deferred binding. This allows you to supply different implementations of the same service based on the user's browser. See the following question:
Why use GWT.create() instead of new?
If you do not need to have multiple implementations of your service, just create it via new!
GWT works by creating a service just like RMI does. Here you are creating the service SomeClientService which resides in the client package. It contains all the functions that can be called server-side.
GWT.create works in different ways:
It tries to see if in the gwt.xml files there is no declaration of which implementation to use depending on a GWT property. This GWT property can be the well known user agent which in this case will have the effect of selecting different implementations for each browser, but it can also be used for other things, for example to disable logging (the fact that logging is enabled or not has nothing to do with in which browser it runs)
Example:
<replace-with class="com.x.app.client.ui.base.button.CustomSlicedButtonCellAppearance">
<when-type-is class="com.x.app.client.ui.base.button.CustomButtonCellAppearance" />
<when-property-is name="gxt.css3.enabled" value="false"/>
<when-property-is name="gxt.theme" value="themeName" />
</replace-with>
In this case it will use CustomSlicedButtonCellAppearance for a call to GWT.create(CustomButtonCellAppearance.class) only if css3 is not supported and for the given theme. Notice that "when-property-is" is optional, and if not supplied it will always use that implementation for the given interface.
It also looks for generators, in which case a new class is generated during GWT compilation (or in devmode) usually based on annotation that are present in the interface passed to the create method.
Example:
<generate-with class="org.fusesource.restygwt.rebind.RestServiceGenerator">
<when-type-assignable class="org.fusesource.restygwt.client.RestService" />
</generate-with>
In this case the RestServiceGenerator will generate code to submit the request.
Another example is how UIBinder works: besides using the annotations in the interface it also generates code based on what is inside the ui.xml file.
If no declaration matches the class/interface passed to the GWT.create method, then it will try to do a new on that class (in case of an interface it will fail).
Declarations in gwt.xml files can be overwritten by other declarations that are processed afterwards, so if you are using a module which declares a rule you can change that rule by declaring a new rule after the inherits declaration of the module containing the original declaration.