Setting SessionProperty exception - mule

I have various mule unit tests that extend my ABCTestTransformer - this creates a new instance of ABCTransformer but also extends the AbstractTransformerTestCase
On the tests when they create a new instance of ABCTransformer and get to this line within the transformer in the public Object transformMessage(MuleMessage message, String outputEncoding) method is where all the tests fail
message.setSessionProperty(data here)
I keep getting the following exception
failed with
exception(s)[org.mule.api.transformer.TransformerException: Detected
an attempt to set a invocation or session property, but a MuleEvent
hasn't been created using this message yet.
These unit tests were working with Mule 3.2 but I am migrating to 3.6 and I am now having issues.
Anyone able to shed any light on this?
Thanks

I think the setSessionProperty is already deprecated.
You may try this as an alternative.
message.setProperty(yourkey, value, PropertyScope.SESSION);
Hope this helps :)

As I understand it, you are setting the value on a wrong sequence, you should call the testEvent first before setting the values. Below is the screenshot, with setting a session variable that works, this is created with lower version of Munit and mule 3.4.
HTH

Related

Changing Mule Flow Threading Profile at runtime

I have a requirement in hand where I need to change the Mule Flow Threading Behavior at runtime without the need of bouncing the whole Mule Container. I figured out few different ways to achieve this, but none of them are working.
I tried accessing the Mule Context Registry and from there I was trying to do a lookup of "FlowConstructLifecycleManager" Object so that I can tap in there and access the threading profile of the object and reset those values, then stop and start the flow programmatically in order to get the change applied in the flow. I am stuck in this approach as I was unable to get hold of the FlowConstructLifecycleManager Object neither from the Mule Spring Registry nor from the Transient Registry. I was able to get hold of the Flow object though which has a direct reference to that FlowConstructLifecycleManager Object. But, unfortunately, they made this object as protected and didn't expose any method for us to access this object.
Since I was unable to access this FlowConstructLifecycleManager directly from Mule implemented Flow class, I decided to extend this Flow class and just add another public method to it so that I can access FlowConstructLifecycleManager object from Flow object programmatically. But, I am stuck in this approach as well as even if I am putting my version of the same Flow class packaged and dropped in lib/user folder of the container, it is still not picking up my version of the class, and loading the original version instead.
It would be of great help if I can get any pointer on the approach of solving either my first or second problem.
Thanks in advance,
Ananya
In our company, we are building a dashboard from where we should be able to start/stop any flow or change the processing power of any flow by increasing/ decreasing the active threads for a flow or changing the pollen polling frequency. All of these should be done at runtime without any server downtime.
Anyway, I made it working finally. I had to patch up the mule-core jar and expose few objects so that I can get to the thread profile object and tweak the values at runtime and stop/ start the flow to reflect the changes to take effect. I know this is little bit messy and but it works.
Thanks,
Ananya

what should be the return value for transformMessage method in mule

In my mule flow I am reading the message form WMQ using WMQ node and then calling a Java class using Java node for required processing of the message.
For the same I have to override the public Object transformMessage(MuleMessage message, String outputEncoding) method. This method is forcing me to return value but I don't require to send any object back.
Can someone please help me to understand what I need to return and why we have to return the value.
Cheers!
First thing first, if you return something in your java code it won't automatically be sent back to WMQ like a response. The thing you return in the java node will be propagated to the next node in your flow, which in this case is nothing.
If you don't need to do anything after your java node in the flow I would suggest that you at least return the input payload. This will help you in the future if you would want to add anything after the java node.
The flow will automatically stop after it is finished with the java node.
But if you manipulate the incoming payload some how I would suggest that you return that payload instead for the same reason as above.
For returning the input payload:
return message.getPayload();

#ValidateConnection method is failing to be called when using "#Category component"

I have an issue in a new devkit Project where the following #ValidateConnection method is failing to be called (but my #processor methods are called fine when requested in the flows)
#ValidateConnection
public boolean isConnected() {
return isConnected;
}
I thought that the above should be called to check whether to call the #Connect method.
I think it is because I am using a non default category (Components) for the connector
#Category(name = "org.mule.tooling.category.core", description = "Components")
And the resulting Behavoir is different to what I am used to with DevKit in Cloud connector mode.
I guess I will need to do checks in each #processor for now to see if the initialization logic is done, as there doesn't seem to be an easy way to run a one time config.
EDIT_________________
I actually tried porting it back to a cloud connector #cat and the same behaviour, maybe its an issue with devkit -DarchetypeVersion=3.4.0, I used 3.2.x somthing before and things worked a bit better
The #ValidateConnection annotated method in the #Connector is called at the end of the makeObject() method of the generated *ConnectionFactory class. If you look for references of who is calling your isConnected() you should be able to confirm this.
So no, you should not need to perform the checks, it should be done automatically for you.
There must be something else missing... do you have a #ConnectionIdentifier annotated method?
PS. #Category annotation is purely for cosmetic purposes in Studio.

TypeNotSerializable Arguments: Exception in WCF

We have an application in Silverlight ,WCF RIA and Entity Framework.
Ever since i added a property to a class in the back end which is of type List<string>
we are getting the error below sometimes, in Production Environment
[TypeNotSerializable] Arguments: System.Linq.Enumerable+<ExceptIterator>d__99`1[System.String] Debugging resource strings are unavailable.
I tried including a [KnownType(typeof(List<string>))], but still we are getting this error occasionally. Please let me know how to get rid of this error.
Thanks !
It would appear someone is using IEnumerable.Except and not calling .ToList which is causing the iterator to still be in the structure when it is being serialized.

Create screenshot after failed selenium command

The PHPUnit Selenium base class has an option to make a screenshot on failure, which is a huge help in finding out why the test failed. The selenium server, however, returns an error instead of a failure on any error condition other than explicit assert* calls (such us trying to do something with a non-existent element). If I try to make a screenshot after the server reports the error, I get another error saying that the server already discarded the session. Is there any way to change that behavior?
Update: this is because PHPUnit breaks the connection when it receives an error. I was able to change it by some (rather ugly) manipulation of the PHPUnit code.
Make those interactions as test cases.
For example in perl,
If it is written as below and fails due to a non-existent element. the script will error out
$sel->type("email-id","trial\#trial.com");
While if the above step is made as a test case by writing it as follows
$sel->type_ok("email-id","trial\#trial.com");
If there is a non-existent element, the test case will only fail, and the script will continue.
So using TAP (test any protocol) by using the module use Test::More; , if _ok is added after a function, the function return will be used to determine the fate of the test case.
ie. - A return of 'O' means the test Failed
and A return of '1' means the test Passed
It is not the Selenium server but the SeleniumTestCase class for PHPUnit 3.4 which automatically sends a stop command when it detects an error (Driver.php line 921). PHPUnit 3.6 seems handle errors better.
I think you can overwrite method 'travelbox' and make something like this:
public function onNotSuccessfulTest(Exception $e){
file_put_content('/xxx/xxx.jpg', $this->currentScreenshot());
}