Unit test a single processor implementation (java) in Kafka Streams? [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
The specific problem encountered is mocking context, state stores, and window objects pass into the function process.
Looks like all the examples, e.g., here and here are unit tests at the stream level (e.g., mockStreams, or using EmbeddedKafkaCluster).

If you're looking to test a single processor implementation, and need to mock context, state stores, etc, I would just use whatever testing tools you ordinarily use to mock things (Mockito, CGLIB, etc).
Beyond the scope of your question, there is also the ProcessorTopologyTestDriver. Posting in case you missed it. Kafka Streams is getting new/improved testing functionality in an upcoming version.

Related

Simulate external webservice for integration test [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I have to simulate external webservice, specially SOAP webservice, to run integration test in java.
Any suggestion?
There are two approaches to this:
Run your integrations tests against the real external webservice, or a test version of it.
Write your own test webservice that simulates the subset of the external service's behavior required for your integration tests.
Note that depending on the nature of the service you are trying to simulate, your test service could be pretty dumb; e.g. providing pre-computed / hard-wired responses to expected requests.
There is no magic here. Just common sense and hard work.

how to hook into java static method? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I want to hook some system api in Android, but some of them are static method. So can I hook a java static method by reflection or any other method without tool like xposed?
Java does not support monkey-patching (like you could do in javascript for instance). The only way of achieving this would be by working with your own classloader and instrumenting the class before you return it -- which would obviously not work for an Android system api.
If you want to intercept your own calls to the api and replace them in some specific cases, create a facade for the api (with non-static methods) and access it through your facade. Then you can use a decorator on that facade to modify its behavior on the fly.

How to test a QuickFIXJ application [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have implemented a QuickFIX/J application (the J stands for Java). Now I consider how to set up fixed test cases.
I am a little bit familiar with JUnit but I don't know if it's the right one for that issue, because QuickFIX/J has callbacks (fromApp-method of the Application class for example).
Maybe there is someone out there who has had the same problem and found a nice solution for that issue. ;)
I have used JUnit with QuickFIX/J tests. For call backs you can use a BlockingQueue<Message> so you can check in your main thread that you get the messages you expect. Or you can use a BlockingQueue of a data type of your choice.
If you're testing the responses of a QuickFix application, then you're really into integration testing rather than unit testing.
So as you've already written one QuickfixJ application, you could write a testing application that connects to it. So if your application is a Fix acceptor, write one that is an initiator.
Now you can send messages from your test application to your real application. Any responses from your real application will call onMessage() in your test application.
You can capture these callbacks and then you can verify that they match certain patterns (e.g., the application returns the same Client order id that the test sent). You can certainly use JUnit for this.

Switching Persistence Framework after implementation? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
When design a system that uses a persistence framework (PF) to store and retrieve information from a database, say for example Hibernate, how important is it in the planning phase to choose a suitable framework?
Say for example that you find a more suitable PF later in development, would a switch require mayor rewrites in the entire system or would it be possible to contain the changes to the service-layer?
Changing the persistence framework is always a big effort, but you can use the DAO pattern to insulate the UI and business model of your system from those changes, and reduce the amount of code required for a rewrite.
In future if you need to switch to another PF it will require major change in the application.So you can use JPA right now so later you need to do small change in the application code.

How to Ignore logging [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Currently, my code uses an implementation of slf4j. The logger is fetched using a url (wsdl). Due to this, I am unable to test my code in a stand alone dev env, unless I bring up the giant server which hosts the service. Other than commenting the relevant code, does anyone know of a way I could make my eclipse ignore the usage of org.slf4j,impl.LoggingService in a class? I think an annotation like #Ignore which takes class params would have been fantastic. This could help someone pass those classes as params which being called in code need to be ignored. I am open to writing my own annotation implementations for it. Thank you
SLF4J seperates out the logging API from the underlying implementation, you should be able to switch out the implementation at runtime by selecting a different logging implementation. So for example slf4j-noop.jar that ignores all logging requests.

Categories