Answer by blacktide for How can I unit-test private members of C++ classes?
Another solution that doesn't require you to add any gtest headers or macros to your production code could be to mark the private members as protected and create a derived class used in your tests with...
View ArticleComment by blacktide on How can I unit-test private members of C++ classes?
The updated link for the previous comment is here now: Testing Private Code.
View ArticleComment by blacktide on Use the redis lock
Yes, Redis lock is a good solution to the problem. ShedLock is also commonly used.
View ArticleComment by blacktide on Why Hashtable is not deprecated in Java despite the...
The official Java YouTube channel also has a video answering this question. Summary: Deprecating something indicates it will be removed in the future, but there is no plan to remove this class in order...
View ArticleAnswer by blacktide for How to sort a string that consists of only two...
You are on the right track, but there are a couple of issues:On this line you are comparing the first character to itself:char smallerChar = text.charAt(0);if (text.charAt(0) == smallerChar) {Instead...
View ArticleComment by blacktide on Why flush a RandomAccessFile always failed?
This question is similar to: How do I flush a 'RandomAccessFile' (java)?. If you believe it’s different, please [edit] the question, make it clear how it’s different and/or how the answers on that...
View ArticleComment by blacktide on ClassPathXmlApplicationContext error in IntelliJ
It looks like you have the wrong import for ApplicationContext. Try replacing the org.apache.catalina.core.ApplicationContext import with org.springframework.context.ApplicationContext.
View ArticleAnswer by blacktide for How to subscribe redis key space event with spring
By default, the key expiry listener is disabled when initializing the application. You can enable it by adding the following to either your main application class or your RedisConfig...
View ArticleAnswer by blacktide for How to safely verify a file contains valid Python...
I believe the issue is with the Python 3.12 grammar in the grammars-v4 repository. I used your code as a base, and was able to get it working properly using the grammars in the...
View ArticleAnswer by blacktide for Adding a Java element that's a subclass of a list,...
If generic enums were possible in Java, then this would be a simple solution, but unfortunately that is not possible. Here is an option that may suit your needs.Create a generic interface that contains...
View ArticleHitachi Content Platform (HCP) S3 - How to I disable or delete previous...
I am (unfortunately) using Hitachi Content Platform for S3 object storage, and I need to sync around 400 images to a bucket every 2 minutes. The filenames are always the same, and the sync "updates"...
View ArticleAnswer by blacktide for java.lang.NoClassDefFoundError:...
It seems that the docker-java-api dependency is not included with the docker-java dependency.If you add this dependency to your pom.xml it should resolve the...
View ArticleAnswer by blacktide for How to delete a file after sending it in a web app?
Here's a simple way using StreamingResponseBody from your controller method:File file = getFile();return ResponseEntity.ok() .headers(headers) .contentLength(length)...
View ArticleAnswer by blacktide for picocli: show help if no parameter given
You can also do this with CommandSpec, as shown in the Git example in the picocli-examples repository. Just add spec.commandLine().usage(System.err) to the call()/run() method of your top-level...
View ArticleAnswer by blacktide for Unit testing c++. How to test private members?
Another solution that doesn't require you to add any gtest headers or macros to your production code could be to mark the private members as protected and create a derived class used in your tests with...
View ArticleAnswer by blacktide for Kotlin -> Java API call is not using the method I...
In Kotlin Array<Int> is a Integer[] under the hood, and IntArray is an int[] (see here).To resolve the issue, you can change c to c.toIntArray() on the last line:targetJdbcTemplate.update(sql, p,...
View ArticleAnswer by blacktide for JMH Unable to find the resource: /META-INF/BenchmarkList
If anyone is using Gradle, add the jmh-gradle-plugin to your plugins block:plugins { id 'java' id 'me.champeau.jmh' version '0.6.8'}Then add all of the following in your dependencies block (check the...
View ArticleAnswer by blacktide for Why Junit fails to perform dependency injection in test?
Your final code block is correct and is the standard practice, you don't need a constructor in this test class for the Calculator instance.For the test class you should define the fields and initialize...
View ArticleAnswer by blacktide for Convert a single-threaded calculation to...
You can use the Executors.newFixedThreadPool(int) method to get an ExecutorService to submit tasks to.Each task that you submit to the thread pool will return a Future, which you can maintain a list of...
View ArticleAnswer by blacktide for Find elements by multiple class names in Selenium Java
Only one class name can be used with the By.className(String) method. From the JavaDoc:Find elements based on the value of the "class" attribute. Only one class name should be used. If an element has...
View Article