Can I have a custom Setup method in gatling - scala

I want to have a custom setup method like for a test where i talk to a webservice and get initial values. Can i do this in gatling?I only want to run this once per simulation.

You can use the before hook to perform any custom code before running the simulation. Note that you can't use Gatling's DSL in there. But you can use whatever Java HTTP client you want, from java.net.UrlConnection to AsyncHttpClient that Gatling ships.

Related

Request Filter Attribute not executing on ServiceStack

I'm running ServiceStack version 4.x and I've created a custom Request Filter Attribute (it inherits from RequestFilterAttribute).
I have some class methods using this custom attribute with ApplyTo parameter. Whenever I use normal HTTP calls the filter gets executed perfectly, the problem comes when one of my services calls internaly a method from another service, the filter then is not executed.
According to the documentation that can be found here:
Order of operations
For non HTTP calls, Request filters with priority >= 0 will be executed right before Action filters.
I have no idea why this is not working, maybe is a bug on the implementation or I misunderstood the documentation.
Any idea how to solve this or a workaround?
Note the non-HTTP Global Request Filters is linked to the Messaging Global Request and Response Filters docs which refer to the MQ Request Filters, i.e:
appHost.GlobalMessageRequestFilters
appHost.GlobalMessageResponseFilters
Only the appHost.PreRequestFilters are executed everywhere, i.e. for every Raw HTTP Handler, HTTP or MQ Service, etc.

How to configure RAMJobStore and JDBCJobStore in single java application

I have configured the simple trigger scheduler program using RAMJobStore in my application to execute set of methods and it is working fine. Now I am trying to configure JDBCJobStore (Oracle) to execute another set of methods in the same java application. My goal is to schedule a method to get triggered based on user defined date/time which is obtained dynamically through GUI.
I am using quartz 1.6.2 and have no idea about JDBCJobStore. I need to use JDBCJobStore for my part of program without affecting the existing RAMJobStore part, someone please help me to proceed further with some suggestion/examples?
you need to have two schedulers one using RAMJobStore , another using JDBCJobStore.

Provide additional Data to Server for Pagination via RPC

I'm working on a GWT project which calls the server via RPC. A typical RPC calls the Server and passes some information and then recieves the answer as an ArrayList.Now we noticed that with a growing database we should use pagination to not overcharge the client with to many objects.
The problem is that there are at the moment many existing methods which are using RPC and each of them would must be modified to provide the necessary information for pagination (Count of Objects,Current Position ) . If i would change every method i would have to edit the Synchronous Interface,the Asynchronous Interface, and the Server and Client class which are using/implementing them.
I tried to create a generic Wrapper class, but i couldn't make it suitable for out project,because each object must be casted back in the original type. Is there a way with less effort to provide pagination without editing many methods?

Access to Akka actor outside

I take Akka 2.0 and want to use it inside my web application. For this i create Filter to run an ActorSystem on filter inits.
Filter loads, starts Akka kernel Bootable implementation.
Now i create an Actor (for user authentication) and want to send a message to it at other part of application outside of scope my akka filter. Is any way to do this (i see only making some object to hold system val)? Maybe my logic to use Akka in this way is wrong?
Thanks.
Use a ServletContextListener to create and destroy the ActorSystem and set it as an attribute on your ServletContext (make a small façade to get it and set it perhaps?) Then just obtain it from the ServletContext within your Filter.

Accessing UI Thread in nunit

I am trying to write a test case where I have to access UI Thread.
Does Nunit provide a way to access the ui thread or is there anyway I can execute some code on UI Thread in my test case.
Thanks
Update: I'm using winform. The usual way is to have the presentation layer and write the test cases against it but in this situation I have a grid that I need to work with and to populate it, its DataSource property needs to be set on UI Thread.
That very much depends on which technology you are using for your UI. Depending on that it might be possible to setup the NUnit runner thread to act as your UI thread.
Genrally though, it is recommended to make the actual UI layer as thin as possible to reduce the amount of UI-code to test.
If you really need to have a live WinForms control on your NUnit thread, consider using Application.DoEvents() which will handle all currently pending events in the message queue. Be aware that doing so might bring you other problems though.
You could try NUnit Forms, but I'd second David's recommendation to take as much logic as possible out of the UI layer.
There is a 'RequiresSTA' attribute you can specify on the test that will run it in the same thread as the NUnit UI.
I discovered this when trying to write a test for a TIBCO Rendezvous message. The listener has to be set up in the main UI thread (blame TIBCO, not me!), otherwise the call to getAutoDispatchQueueGroup returns an error "Object cannot complete the requested operation".
I tried using WindowsFormsSynchronizationContext and BeginInvoke, and neither worked.
For NUnit 3+, I got this working by declaring on a test class with [TestFixture, Apartment(ApartmentState.STA)] or on a test method with [Test, Apartment(ApartmentState.STA)].
Also see this related question.
NUnit has no builtin support AFAIK. You can execute code in your UI thread of course, but the 'how' depends on the UI technology you use (WPF or Winforms)
Look for something like BeginInvoke() and pass an anonymous delegate to it that you can define in your unit test