Merge branch 'eugenp:master' into PR-6865

This commit is contained in:
parthiv39731
2023-08-28 23:14:13 +05:30
committed by GitHub
163 changed files with 1453 additions and 952 deletions
-1
View File
@@ -48,7 +48,6 @@
<properties>
<maven.compiler.release>14</maven.compiler.release>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<surefire.plugin.version>3.0.0-M3</surefire.plugin.version>
</properties>
-1
View File
@@ -53,7 +53,6 @@
<properties>
<maven.compiler.release>15</maven.compiler.release>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<surefire.plugin.version>3.0.0-M3</surefire.plugin.version>
</properties>
@@ -0,0 +1,126 @@
package com.baeldung.multipleorwithif;
import static java.time.Month.DECEMBER;
import static java.time.Month.NOVEMBER;
import static java.time.Month.OCTOBER;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.in;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.time.Month;
import java.util.List;
import java.util.Random;
import java.util.Set;
import java.util.function.Predicate;
import org.junit.jupiter.api.Test;
class MultipleOrWithIfUnitTest {
private final Random rand = new Random();
final Set<Month> months = Set.of(OCTOBER, NOVEMBER, DECEMBER);
@Test
public void givenIfStatement_whenMultipleOrOperator_thenAssert() {
assertTrue(multipleOrOperatorIf(monthIn()));
assertFalse(multipleOrOperatorIf(monthNotIn()));
}
boolean multipleOrOperatorIf(Month month) {
if (month == OCTOBER || month == NOVEMBER || month == DECEMBER) {
return true;
}
return false;
}
@Test
public void givenSwitch_whenMultipleCase_thenBreakAndAssert() {
assertTrue(switchMonth(monthIn()));
assertFalse(switchMonth(monthNotIn()));
}
boolean switchMonth(Month month) {
return switch (month) {
case OCTOBER, NOVEMBER, DECEMBER -> true;
default -> false;
};
}
@Test
public void givenAllowedValuesList_whenContains_thenAssert() {
assertTrue(contains(monthIn()));
assertFalse(contains(monthNotIn()));
}
@Test
public void givenPredicates_whenTestMultipleOr_thenAssert() {
assertTrue(predicateWithIf(monthIn()));
assertFalse(predicateWithIf(monthNotIn()));
}
@Test
public void givenInputList_whenFilterWithPredicate_thenAssert() {
List<Month> list = List.of(monthIn(), monthIn(), monthNotIn());
list.stream()
.filter(this::predicateWithIf)
.forEach(m -> assertThat(m, is(in(months))));
}
Predicate<Month> orPredicate() {
Predicate<Month> predicate = x -> x == OCTOBER;
Predicate<Month> predicate1 = x -> x == NOVEMBER;
Predicate<Month> predicate2 = x -> x == DECEMBER;
return predicate.or(predicate1)
.or(predicate2);
}
boolean predicateWithIf(Month month) {
if (orPredicate().test(month)) {
return true;
}
return false;
}
@Test
public void givenContainsInSetPredicate_whenTestPredicate_thenAssert() {
Predicate<Month> collectionPredicate = this::contains;
assertTrue(collectionPredicate.test(monthIn()));
assertFalse(collectionPredicate.test(monthNotIn()));
}
@Test
public void givenInputList_whenFilterWithContains_thenAssert() {
List<Month> monthList = List.of(monthIn(), monthIn(), monthNotIn());
monthList.stream()
.filter(this::contains)
.forEach(m -> assertThat(m, is(in(months))));
}
private boolean contains(Month month) {
if (months.contains(month)) {
return true;
}
return false;
}
private Month monthIn() {
return Month.of(rand.ints(10, 13)
.findFirst()
.orElse(10));
}
private Month monthNotIn() {
return Month.of(rand.ints(1, 10)
.findFirst()
.orElse(1));
}
}
@@ -152,7 +152,6 @@
<awaitility.version>4.0.2</awaitility.version>
<maven.compiler.source>1.9</maven.compiler.source>
<maven.compiler.target>1.9</maven.compiler.target>
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
</properties>
</project>
@@ -13,3 +13,4 @@ This module contains articles about advanced operations on arrays in Java. They
- [Performance of System.arraycopy() vs. Arrays.copyOf()](https://www.baeldung.com/java-system-arraycopy-arrays-copyof-performance)
- [Slicing Arrays in Java](https://www.baeldung.com/java-slicing-arrays)
- [Combining Two or More Byte Arrays](https://www.baeldung.com/java-concatenate-byte-arrays)
- [Calculating the Sum of Two Arrays in Java](https://www.baeldung.com/java-sum-arrays-element-wise)
@@ -13,4 +13,5 @@ This module contains articles about conversions among Collection types and array
- [Combining Two Lists Into a Map in Java](https://www.baeldung.com/java-combine-two-lists-into-map)
- [Convert a List of Strings to a List of Integers](https://www.baeldung.com/java-convert-list-strings-to-integers)
- [Convert List to Long[] Array in Java](https://www.baeldung.com/java-convert-list-object-to-long-array)
- [Get the First n Elements of a List Into an Array](https://www.baeldung.com/java-take-start-elements-list-array)
- More articles: [[<-- prev]](../core-java-collections-conversions)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-collections-list-5</artifactId>
<name>core-java-collections-list-5</name>
@@ -9,4 +9,5 @@ This module contains articles about Map data structures in Java.
- [Collections.synchronizedMap vs. ConcurrentHashMap](https://www.baeldung.com/java-synchronizedmap-vs-concurrenthashmap)
- [Java HashMap Load Factor](https://www.baeldung.com/java-hashmap-load-factor)
- [Converting Java Properties to HashMap](https://www.baeldung.com/java-convert-properties-to-hashmap)
- [Get Values and Keys as ArrayList From a HashMap](https://www.baeldung.com/java-values-keys-arraylists-hashmap)
- More articles: [[<-- prev]](/core-java-modules/core-java-collections-maps-2)
@@ -58,4 +58,8 @@ public class DataQueue {
return queue.poll();
}
}
public Integer getSize() {
return queue.size();
}
}
@@ -1,12 +1,13 @@
package com.baeldung.producerconsumer;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Logger;
public class Producer implements Runnable {
private static final Logger log = Logger.getLogger(Producer.class.getCanonicalName());
private final DataQueue dataQueue;
private static int idSequence = 0;
final ReentrantLock lock = new ReentrantLock();
public Producer(DataQueue dataQueue) {
this.dataQueue = dataQueue;
@@ -19,22 +20,38 @@ public class Producer implements Runnable {
public void produce() {
while (dataQueue.runFlag) {
while (dataQueue.isFull() && dataQueue.runFlag) {
try {
dataQueue.waitOnFull();
} catch (InterruptedException e) {
e.printStackTrace();
try {
lock.lock();
while (dataQueue.isFull() && dataQueue.runFlag) {
try {
dataQueue.waitOnFull();
} catch (InterruptedException e) {
e.printStackTrace();
break;
}
}
if (!dataQueue.runFlag) {
break;
}
}
if (!dataQueue.runFlag) {
break;
}
Message message = generateMessage();
dataQueue.add(message);
dataQueue.notifyAllForEmpty();
Message message = generateMessage();
dataQueue.add(message);
dataQueue.notifyAllForEmpty();
log.info("Size of the queue is: " + dataQueue.getSize());
}
finally{
lock.unlock();
}
//Sleeping on random time to make it realistic
ThreadUtil.sleep((long) (Math.random() * 100));
}
log.info("Producer Stopped");
}
@@ -43,9 +60,6 @@ public class Producer implements Runnable {
log.info(String.format("[%s] Generated Message. Id: %d, Data: %f%n",
Thread.currentThread().getName(), message.getId(), message.getData()));
//Sleeping on random time to make it realistic
ThreadUtil.sleep((long) (message.getData() * 100));
return message;
}
@@ -36,8 +36,8 @@ public class ProducerConsumerDemonstrator {
public static void demoMultipleProducersAndMultipleConsumers() {
DataQueue dataQueue = new DataQueue(MAX_QUEUE_CAPACITY);
int producerCount = 3;
int consumerCount = 3;
int producerCount = 5;
int consumerCount = 5;
List<Thread> threads = new ArrayList<>();
Producer producer = new Producer(dataQueue);
for(int i = 0; i < producerCount; i++) {
@@ -45,6 +45,7 @@ public class ProducerConsumerDemonstrator {
producerThread.start();
threads.add(producerThread);
}
Consumer consumer = new Consumer(dataQueue);
for(int i = 0; i < consumerCount; i++) {
Thread consumerThread = new Thread(consumer);
@@ -52,8 +53,8 @@ public class ProducerConsumerDemonstrator {
threads.add(consumerThread);
}
// let threads run for two seconds
sleep(2000);
// let threads run for ten seconds
sleep(10000);
// Stop threads
producer.stop();
@@ -11,4 +11,5 @@ This module contains articles about basic Java concurrency
- [Runnable vs. Callable in Java](https://www.baeldung.com/java-runnable-callable)
- [What Is Thread-Safety and How to Achieve It?](https://www.baeldung.com/java-thread-safety)
- [How to Get Notified When a Task Completes in Java Executors](https://www.baeldung.com/java-executors-task-completed-notification)
- [Difference Between Future, CompletableFuture, and Rxjavas Observable](https://www.baeldung.com/java-future-completablefuture-rxjavas-observable)
- [[Next -->]](/core-java-modules/core-java-concurrency-basic-2)
@@ -37,20 +37,19 @@
<compilerArgs>--enable-preview</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.plugin.version}</version>
<configuration>
<argLine>--enable-preview</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.plugin.version}</version>
<configuration>
<argLine>--enable-preview</argLine>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source.version>14</maven.compiler.source.version>
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven.compiler.target.version>14</maven.compiler.target.version>
<surefire.plugin.version>3.0.0-M3</surefire.plugin.version>
</properties>
@@ -12,7 +12,7 @@
<artifactId>core-java-modules</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>joda-time</groupId>
@@ -25,7 +25,7 @@
<version>${commons-lang3.version}</version>
</dependency>
</dependencies>
<properties>
<joda-time.version>2.12.5</joda-time.version>
<commons-lang3.version>3.12.0</commons-lang3.version>
@@ -9,3 +9,4 @@ This module contains articles about converting between Java date and time object
- [Convert Between java.time.Instant and java.sql.Timestamp](https://www.baeldung.com/java-time-instant-to-java-sql-timestamp)
- [Convert Between LocalDateTime and ZonedDateTime](https://www.baeldung.com/java-localdatetime-zoneddatetime)
- [Conversion From 12-Hour Time to 24-Hour Time in Java](https://www.baeldung.com/java-convert-time-format)
- [Convert Epoch Time to LocalDate and LocalDateTime](https://www.baeldung.com/java-convert-epoch-localdate)
-1
View File
@@ -132,7 +132,6 @@
<!-- Mime Type Libraries -->
<tika.version>2.8.0</tika.version>
<jmime-magic.version>0.1.5</jmime-magic.version>
<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
<fscontext.version>4.4.2</fscontext.version>
<jakarta-activation-api.version>2.1.2</jakarta-activation-api.version>
<angus-activation.version>2.0.1</angus-activation.version>
-1
View File
@@ -275,7 +275,6 @@
<!-- maven plugins -->
<javamoney.moneta.version>1.1</javamoney.moneta.version>
<maven-javadoc-plugin.version>3.0.0-M1</maven-javadoc-plugin.version>
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
<onejar-maven-plugin.version>1.4.4</onejar-maven-plugin.version>
<maven-shade-plugin.version>3.1.1</maven-shade-plugin.version>
<maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version>
+2 -2
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.baeldung.core-java-modules</groupId>
@@ -12,3 +12,4 @@ This module contains articles about inheritance in Java
- [Guide to Inheritance in Java](https://www.baeldung.com/java-inheritance)
- [Object Type Casting in Java](https://www.baeldung.com/java-type-casting)
- [Variable and Method Hiding in Java](https://www.baeldung.com/java-variable-method-hiding)
- [Inner Classes Vs. Subclasses in Java](https://www.baeldung.com/java-inner-classes-vs-subclasses)
@@ -1,54 +1,77 @@
package com.baeldung.modulo;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import static org.assertj.core.api.Java6Assertions.*;
public class ModuloUnitTest {
@Test
public void whenIntegerDivision_thenLosesRemainder(){
assertThat(11 / 4).isEqualTo(2);
}
@Test
public void whenDoubleDivision_thenKeepsRemainder(){
assertThat(11 / 4.0).isEqualTo(2.75);
}
@Test
public void whenModulo_thenReturnsRemainder(){
assertThat(11 % 4).isEqualTo(3);
}
@Test(expected = ArithmeticException.class)
public void whenDivisionByZero_thenArithmeticException(){
double result = 1 / 0;
}
@Test(expected = ArithmeticException.class)
public void whenModuloByZero_thenArithmeticException(){
double result = 1 % 0;
}
@Test
public void whenDivisorIsOddAndModulusIs2_thenResultIs1(){
assertThat(3 % 2).isEqualTo(1);
}
@Test
public void whenDivisorIsEvenAndModulusIs2_thenResultIs0(){
assertThat(4 % 2).isEqualTo(0);
}
@Test
public void whenItemsIsAddedToCircularQueue_thenNoArrayIndexOutOfBounds(){
int QUEUE_CAPACITY= 10;
int[] circularQueue = new int[QUEUE_CAPACITY];
int itemsInserted = 0;
for (int value = 0; value < 1000; value++) {
int writeIndex = ++itemsInserted % QUEUE_CAPACITY;
circularQueue[writeIndex] = value;
@Test
public void whenIntegerDivision_thenLosesRemainder() {
assertThat(11 / 4).isEqualTo(2);
}
@Test
public void whenDoubleDivision_thenKeepsRemainder() {
assertThat(11 / 4.0).isEqualTo(2.75);
}
@Test
public void whenModulo_thenReturnsRemainder() {
assertThat(11 % 4).isEqualTo(3);
}
@Test(expected = ArithmeticException.class)
public void whenDivisionByZero_thenArithmeticException() {
double result = 1 / 0;
}
@Test(expected = ArithmeticException.class)
public void whenModuloByZero_thenArithmeticException() {
double result = 1 % 0;
}
@Test
public void whenDivisorIsOddAndModulusIs2_thenResultIs1() {
assertThat(3 % 2).isEqualTo(1);
}
@Test
public void whenDivisorIsEvenAndModulusIs2_thenResultIs0() {
assertThat(4 % 2).isEqualTo(0);
}
@Test
public void whenDividendIsNegativeAndModulusIs2_thenResultIsNegative() {
assertEquals(-1, -9 % 2);
}
@Test
public void whenDividendIsNegativeAndRemainderIsCheckedForNegativeValue_thenResultIsPositive() {
int remainder = -9 % 2;
if (remainder < 0) {
remainder += 2;
}
assertEquals(1, remainder);
}
@Test
public void whenDividendIsNegativeAndUsesMathClass_thenResultIsPositive() {
int remainder = Math.floorMod(-9, 2);
assertEquals(1, remainder);
}
@Test
public void whenItemsIsAddedToCircularQueue_thenNoArrayIndexOutOfBounds() {
int QUEUE_CAPACITY = 10;
int[] circularQueue = new int[QUEUE_CAPACITY];
int itemsInserted = 0;
for (int value = 0; value < 1000; value++) {
int writeIndex = ++itemsInserted % QUEUE_CAPACITY;
circularQueue[writeIndex] = value;
}
}
}
}
@@ -0,0 +1,75 @@
package com.baeldung.regex.indexesofmatches;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.junit.jupiter.api.Test;
public class IndexesOfMatchesUnitTest {
private static final String INPUT = "This line contains <the first value>, <the second value>, and <the third value>.";
@Test
void whenUsingNorCharClass_thenGetExpectedTexts() {
Pattern pattern = Pattern.compile("<[^>]*>");
Matcher matcher = pattern.matcher(INPUT);
List<String> result = new ArrayList<>();
while (matcher.find()) {
result.add(matcher.group());
}
assertThat(result).containsExactly("<the first value>", "<the second value>", "<the third value>");
}
@Test
void whenCallingMatcherEnd_thenGetIndexesAfterTheMatchSequence() {
Pattern pattern = Pattern.compile("456");
Matcher matcher = pattern.matcher("0123456789");
String result = null;
int startIdx = -1;
int endIdx = -1;
if (matcher.find()) {
result = matcher.group();
startIdx = matcher.start();
endIdx = matcher.end();
}
assertThat(result).isEqualTo("456");
assertThat(startIdx).isEqualTo(4);
assertThat(endIdx).isEqualTo(7);
}
@Test
void whenUsingMatcherStartAndEnd_thenGetIndexesOfMatches() {
Pattern pattern = Pattern.compile("<[^>]*>");
Matcher matcher = pattern.matcher(INPUT);
List<String> result = new ArrayList<>();
Map<Integer, Integer> indexesOfMatches = new LinkedHashMap<>();
while (matcher.find()) {
result.add(matcher.group());
indexesOfMatches.put(matcher.start(), matcher.end());
}
assertThat(result).containsExactly("<the first value>", "<the second value>", "<the third value>");
assertThat(indexesOfMatches.entrySet()).map(entry -> INPUT.substring(entry.getKey(), entry.getValue()))
.containsExactly("<the first value>", "<the second value>", "<the third value>");
}
@Test
void whenUsingMatcherStartAndEndWithGroupIdx_thenGetIndexesOfMatches() {
Pattern pattern = Pattern.compile("<([^>]*)>");
Matcher matcher = pattern.matcher(INPUT);
List<String> result = new ArrayList<>();
Map<Integer, Integer> indexesOfMatches = new LinkedHashMap<>();
while (matcher.find()) {
result.add(matcher.group(1));
indexesOfMatches.put(matcher.start(1), matcher.end(1));
}
assertThat(result).containsExactly("the first value", "the second value", "the third value");
assertThat(indexesOfMatches.entrySet()).map(entry -> INPUT.substring(entry.getKey(), entry.getValue()))
.containsExactly("the first value", "the second value", "the third value");
}
}
@@ -0,0 +1,98 @@
package com.baeldung.regex.squarebrackets;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.junit.jupiter.api.Test;
import com.google.common.collect.Lists;
public class ExtractTextBetweenSquareBracketsUnitTest {
static final String INPUT1 = "some text [THE IMPORTANT MESSAGE] something else";
static final String EXPECTED1 = "THE IMPORTANT MESSAGE";
static final String INPUT2 = "[La La Land], [The last Emperor], and [Life of Pi] are all great movies.";
static final List<String> EXPECTED2 = Lists.newArrayList("La La Land", "The last Emperor", "Life of Pi");
@Test
void whenUsingDotStarOnInput1_thenGetExpectedResult() {
String result = null;
String rePattern = "\\[(.*)]";
Pattern p = Pattern.compile(rePattern);
Matcher m = p.matcher(INPUT1);
if (m.find()) {
result = m.group(1);
}
assertThat(result).isEqualTo(EXPECTED1);
}
@Test
void whenUsingCharClassOnInput1_thenGetExpectedResult() {
String result = null;
String rePattern = "\\[([^]]*)";
Pattern p = Pattern.compile(rePattern);
Matcher m = p.matcher(INPUT1);
if (m.find()) {
result = m.group(1);
}
assertThat(result).isEqualTo(EXPECTED1);
}
@Test
void whenUsingSplitOnInput1_thenGetExpectedResult() {
String[] strArray = INPUT1.split("[\\[\\]]", -1);
String result = strArray.length == 3 ? strArray[1] : null;
assertThat(result).isEqualTo(EXPECTED1);
}
@Test
void whenUsingSplitWithLimit_thenGetExpectedResult() {
String[] strArray = "[THE IMPORTANT MESSAGE]".split("[\\[\\]]");
assertThat(strArray).hasSize(2)
.containsExactly("", "THE IMPORTANT MESSAGE");
strArray = "[THE IMPORTANT MESSAGE]".split("[\\[\\]]", -1);
assertThat(strArray).hasSize(3)
.containsExactly("", "THE IMPORTANT MESSAGE", "");
}
@Test
void whenUsingNonGreedyOnInput2_thenGetExpectedResult() {
List<String> result = new ArrayList<>();
String rePattern = "\\[(.*?)]";
Pattern p = Pattern.compile(rePattern);
Matcher m = p.matcher(INPUT2);
while (m.find()) {
result.add(m.group(1));
}
assertThat(result).isEqualTo(EXPECTED2);
}
@Test
void whenUsingCharClassOnInput2_thenGetExpectedResult() {
List<String> result = new ArrayList<>();
String rePattern = "\\[([^]]*)";
Pattern p = Pattern.compile(rePattern);
Matcher m = p.matcher(INPUT2);
while (m.find()) {
result.add(m.group(1));
}
assertThat(result).isEqualTo(EXPECTED2);
}
@Test
void whenUsingSplitInput2_thenGetExpectedResult() {
List<String> result = new ArrayList<>();
String[] strArray = INPUT2.split("[\\[\\]]", -1);
for (int i = 1; i < strArray.length; i += 2) {
result.add(strArray[i]);
}
assertThat(result).isEqualTo(EXPECTED2);
}
}
+2 -2
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-scanner</artifactId>
<name>core-java-scanner</name>
@@ -115,7 +115,6 @@
<properties>
<!-- testing -->
<assertj.version>3.23.1</assertj.version>
<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
<rx.java.version>1.2.5</rx.java.version>
@@ -69,7 +69,6 @@
<properties>
<!-- testing -->
<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
<vavr.version>0.10.2</vavr.version>
@@ -58,7 +58,6 @@
<properties>
<!-- testing -->
<maven-compiler-plugin.version>3.1</maven-compiler-plugin.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-java-string-operations-6</artifactId>
<name>core-java-string-operations-6</name>
@@ -15,30 +15,20 @@
<dependencies>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.4.0-b180725.0427</version>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>${jakarta.xml.bind-api.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>${jmh-core.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh-generator.version}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
@@ -57,7 +47,8 @@
</build>
<properties>
<commons-codec.version>1.15</commons-codec.version>
<commons-codec.version>1.16.0</commons-codec.version>
<jakarta.xml.bind-api.version>4.0.0</jakarta.xml.bind-api.version>
</properties>
</project>
@@ -2,7 +2,7 @@ package com.baeldung.base64encodinganddecoding;
import org.junit.Test;
import javax.xml.bind.DatatypeConverter;
import jakarta.xml.bind.DatatypeConverter;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;