Skip to content
Advertisement

Is Spring Framework used in a unit test?

I am getting ready to take my Spring Certification v5.0 and there appears to be a question: Do you use Spring in a unit test? Link to Exam Guide questions. From Spring reference guide I know this: The POJOs that make up your application should be testable in JUnit or TestNG tests, with objects simply instantiated using the new operator,

Java JDB: ERROR: transport error 202: gethostbyname: unknown host

I have a very similar error message to this post; however, the solution on that same post did not work for me. Editing the host file my adding in 127.0.0.1 my-host-name to my hosts file (per solution in linked thread) did nothing for me unfortunately. After “run” in JDB, I get the following error message: Initializing jdb … run run

Converting string to ‘Instant’

I am trying to convert datetime in a string to an Instant instance using Java 8 or a utilities package. For example, to reqString is in the America/Toronto time zone. This is what I tried The above code results in “2018-05-12T23:30:00Z”. How can I do it? Answer tl;dr Fix your formatting pattern for unpadded month and day. Use only java.time

Incompatible library version selenium / guava

My app has a hard dependency on com.google.guava:guava:23.3 or superior But I am also using org.seleniumhq.selenium:selenium-java:3.0.1 which is incompatible with guava versions > 22.0 as discussed here: https://github.com/SeleniumHQ/selenium/issues/4381 I am pretty new to Java, what is the best course of action here ? I have looked into class loaders but that looks like a pretty deep rabbit hole. Answer As

How do I replace multiple characters in a String?

How do I replace multiple characters in a String? Like Java’s replaceAll(regex:replacement:) function. This answer is very close but I want to change more than one character at the same time. Answer [$,.] is regex, which is the expected input for Java’s replaceAll() method. Kotlin, however, has a class called Regex, and string.replace() is overloaded to take either a String

Can Java’s Stream.collect() return null?

The JavaDoc for Stream.collect() says that it returns “the result of the reduction”. That doesn’t tell me if code like this can return null for filteredList: I would expect that if it could return null then it would return an Optional, but it doesn’t say that either. Is it documented anywhere whether Stream.collect() can return null? Answer Collector.toList() will return

Java quiz with multi choices in answers

I’m trying to develop a java quiz, here’s the basic idea: A quiz contains n questions, and a question has 0 to n true answers, I have to link that to a database, so my tables are: Table Quiz: Table Question: Table answer: So my java classes are: My Question class: and the same for Answer: The main JFrame contains

Advertisement