captaindebug | Samples from Captain Debug 's Blog | Application Framework library
kandi X-RAY | captaindebug Summary
kandi X-RAY | captaindebug Summary
This repository contains sample code linked to Captain Debug’s Blog (www.captaindebug.com). The sample projects are:.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Initializes the database .
- Returns a runnable that will be executed .
- Read a byte array from the input buffer .
- Process the tag buffer and write it to the output stream .
- Creates a single thread executor .
- Finds the users with the given connection .
- Overwrites the given byte .
- To list list .
- Adds the bean .
- Send report by email
captaindebug Key Features
captaindebug Examples and Code Snippets
Community Discussions
Trending Discussions on captaindebug
QUESTION
The issue I am facing is that two objects returned from spring cacheable method with a same key fail assertSame test. Why are these objects not sharing one same storage area?
Details: I am using redis cache mechanism to implement caching in a spring boot REST api. The caching works correctly in the way that it first retrieve the data from externally provided source (JPS repository accessing a database) and then subsequent calls for the same cache key returns data from cache. However, I am not able to mimic this behavior completely in the JUnit test cases. My assertEquals or assertSame fail on 2 objects returned from the cache.
my code base looks as below: mvn dependencies:
...ANSWER
Answered 2017-Jun-30 at 18:23I had got this issue resolved and was able to design the test case as it should be for verifying spring cacheable mechanism.
Just providing my analysis and resolution below to help someone out there facing this same issue.
I mentioned in my comments and original questions above that assertSame would not work due to how serialization works and assertEquals though was working but it was kind of not satisfying my test requirement.
The conclusion I made (based on comments) that I should actually test number of method calls and not the result. I tried to mock the CIDomainDAO repository dao as in my question but I faced with couple issues. Creating mocked object of CIDomainDAO and passing it in the CIDomainService constructor was not triggering spring cache and my test was failing. If I do not mock CIDomainDAO and tried spying on CIDomainService to check no of method calls and ran my test then I was ending up getting
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install captaindebug
You can use captaindebug like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the captaindebug component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page