Testing secured EJBs with Arquillian - testing

I made some first steps with Arquillian and get it starting and some simple tests like testing DI etc are working. However, I need to test EJBs that are secured (RolesAllowed) adn I didn't find any solution till now. Further, I have a book regarding Testing with Arquillian and WildFly - the topic about security etc is not mentioned at all - not with a single word. I have also another two books regarding Java EE development where testing is also mentioned, however, always without involving security... I don't need any code just few tips what is required in order to get it working...
Thanks in advance for any suggestions/support.
BR,
Erno

You need to test entire request and issue login before request (If you are doing so called client tests. If you are doing this, your IT class would probably have #RunAsClient annotation).
If you don't have #RunAsClient, you can try to mock the session with the desired roles.

Related

Mock a client to a dependency when doing integration tests

I have a service composed of several micro services working in workflow. Some of these MS are calling dependencies.
Now I'd like to mock these calls, so when I send a message at the entrance of the workflow the dependencies answers get mocked, but my system works as normal.
The challenge is that I would want to configure the mock from the outside: Configure on the fly the answer I want to get from the mock, run my test, verify that my system behaves properly.
I worked for a company that shall remain unnamed that has an internal tool doing just that, but I'm wondering if there is a public tool doing this? I can't believe it doesn't exist, I bet more on my lack of knowledge about this, at that point ;)
Cheers
So far best I've found is https://wiremock.org/docs/
I don't want to do any ad here, it's just the only one I see that gets its mocks configured from a distance

Reuse Geb Pages for multiple domains

I'd like to test the search functionality of 30 websites that are generated by the same CMS under different domains with different Lucene-indexes. For this purpose I'd like to write a single Page Object which I'd like to be fed by the configuration with those 30 different baseUrls.
I'd be running those tests in the same environment so I'm not sure how to approach this issue. Is there anything I've been missing so far? Looking forward to a push in the right direction and thanks in advance.
You can always override the base url in your test using using browser.config.baseUrl = 'http://example.com'. It will be reverted to the value configured in GebConfig.groovy for the next test.
The question is how many tests do you wish to run this way? If it's just one test then you can get away by using Spock's support for parametrised tests with where: block and this approach. If it's more than one test then you will probably be looking at custom test runners or running your tests multiple times using your build system with different geb environment settings.

AngularJS Protractor E2E Mocking

I have an Angular SPA retrieving its data from a node backend.
Since the node project is fully covered with tests I want to mock the Angular HTTP calls.
(I do not want to start a discussion about functional-/smoke-tests in general, thanks).
What I'd like to have is s.th. like this
Api = $injector.get('Api');
sinon.mock(Api, 'getSomethingFromServer').andRespondWith({foo: 'bar'})
assert(Api.getSomethingFromServer.wasCalledOnce);
But no matter how I can't find a nice solution.
I found several posts regarding the same issue.
For example this one.
Since protractor is changing a lot and frequently, I just like to ask here on SO if anyone found a proper solution for mocking the HTTP requests.
we are currently doing that using http://apiary.io
Besides being able to "mock" your responses, you get a nice API description as a bonus!
What we do is we run the Angular app against a proxy, which depending on whether we are in dev or in production can forward either to real backend or the one provided by apiary.
I agree with previous answer. An answer to frequent change of Protractor is to completly decorrelate the backend from the system under test, no matter if it is mock, stub, or fake.
The difficulty is to maintain a strong coherence with the real backend, but it is not said that it is more overhead than trying to maintain an always changing way of mocking with angular.

Benchmarking/Performance testing of the API - REST/SOAP

I'm trying to benchmark/ do performance testing of API's at my work. So the client facing is REST format while the backend data is retrieved by SOAP messages. So my question is can some of you share your thoughts on how you implement it (if you have done so in the past/doing it now), am basically interested in avg response time it takes for API to return results for the client
Please let me know if you need any additional information to answer the question
Could not say it any better than Mark, really: http://www.mnot.net/blog/2011/05/18/http_benchmark_rules
Maybe you should give JMeter a try.
You can try using Apache Benchmark.This is simple and quick
Jmeter gives you additional flexibility like adding functional cases along with performance details. Results will be almost similar to Apache Benchmark tool.
The detailed one which gives Functional Test Result, performance counters settings, Call response time details, CPU and Memory changes along with Load/Stress results, with different bandwidth and browser settings - Visual Studio Team system
I used VSTS2010 for performance testing. Also GET and POST are straight forward. PUT and DELETE need coded version of webtest.
Thanks,
Madhusudanan
Tesco
If you are trying to test the REST -> SOAP calls. One more thing you can consider is to have some stubs created (for backend). This way you can perf test REST -> Stub performance followed by Stub -> SOAP perfomance. This will help in analyzing the individual components.

FlexUnit 4 and Cairngorm commands

Does anyone know if it is possible to test remote procedure calls in Cairngorm Commands with FlexUnit 4. I have an old app full of them and before I introduce FlexUnit into the mix would like to hear if anyone has been successful with this.
Many thanks,
It's pretty easy using asynchronous tests (as you've found the relevant doc) - as long as you can exchange the remote service with a mock service, e.g. by injecting a different service locator that returns mock services, or better by using a DI framework like Spring ActionScript or Parsley. In that case you will have a real unit test that is not depending on a running server.