\ No newline at end of file
diff --git a/libraries-2/src/test/resources/handlebars/if.html b/libraries-2/src/test/resources/handlebars/if.html
new file mode 100644
index 0000000000..ebdc724f66
--- /dev/null
+++ b/libraries-2/src/test/resources/handlebars/if.html
@@ -0,0 +1,5 @@
+{{#if busy}}
+
{{name}} is busy.
+{{else}}
+
{{name}} is not busy.
+{{/if}}
\ No newline at end of file
diff --git a/libraries-2/src/test/resources/handlebars/if_mustache.html b/libraries-2/src/test/resources/handlebars/if_mustache.html
new file mode 100644
index 0000000000..d75f5fa8f9
--- /dev/null
+++ b/libraries-2/src/test/resources/handlebars/if_mustache.html
@@ -0,0 +1,5 @@
+{{#if busy}}
+
{{name}} is busy.
+{{^}}
+
{{name}} is not busy.
+{{/if}}
\ No newline at end of file
diff --git a/libraries-2/src/test/resources/handlebars/messagebase.html b/libraries-2/src/test/resources/handlebars/messagebase.html
new file mode 100644
index 0000000000..7ee3257e06
--- /dev/null
+++ b/libraries-2/src/test/resources/handlebars/messagebase.html
@@ -0,0 +1,9 @@
+
+
+{{#block "intro"}}
+ This is the intro
+{{/block}}
+{{#block "message"}}
+{{/block}}
+
+
\ No newline at end of file
diff --git a/libraries-2/src/test/resources/handlebars/page.html b/libraries-2/src/test/resources/handlebars/page.html
new file mode 100644
index 0000000000..27b20737f3
--- /dev/null
+++ b/libraries-2/src/test/resources/handlebars/page.html
@@ -0,0 +1,2 @@
+{{>header}}
+
This is the page {{name}}
\ No newline at end of file
diff --git a/libraries-2/src/test/resources/handlebars/person.html b/libraries-2/src/test/resources/handlebars/person.html
new file mode 100644
index 0000000000..9df7850f60
--- /dev/null
+++ b/libraries-2/src/test/resources/handlebars/person.html
@@ -0,0 +1 @@
+{{#isBusy this}}{{/isBusy}}
\ No newline at end of file
diff --git a/libraries-2/src/test/resources/handlebars/simplemessage.html b/libraries-2/src/test/resources/handlebars/simplemessage.html
new file mode 100644
index 0000000000..3b3a01980a
--- /dev/null
+++ b/libraries-2/src/test/resources/handlebars/simplemessage.html
@@ -0,0 +1,4 @@
+{{#partial "message" }}
+ Hi there!
+{{/partial}}
+{{> messagebase}}
\ No newline at end of file
diff --git a/libraries-2/src/test/resources/handlebars/with.html b/libraries-2/src/test/resources/handlebars/with.html
new file mode 100644
index 0000000000..90077b4835
--- /dev/null
+++ b/libraries-2/src/test/resources/handlebars/with.html
@@ -0,0 +1,3 @@
+{{#with address}}
+
I live in {{street}}
+{{/with}}
\ No newline at end of file
diff --git a/libraries-2/src/test/resources/handlebars/with_mustache.html b/libraries-2/src/test/resources/handlebars/with_mustache.html
new file mode 100644
index 0000000000..3adf6a7556
--- /dev/null
+++ b/libraries-2/src/test/resources/handlebars/with_mustache.html
@@ -0,0 +1,3 @@
+{{#address}}
+
+ Upload new Video
+
+
diff --git a/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/templates/photos.html b/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/templates/photos.html
new file mode 100644
index 0000000000..b5d56d020a
--- /dev/null
+++ b/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/templates/photos.html
@@ -0,0 +1,10 @@
+
+
+
View Photo
+ Title: name
+
+
+
+ Back to home page
+
+
\ No newline at end of file
diff --git a/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/templates/uploadPhoto.html b/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/templates/uploadPhoto.html
new file mode 100644
index 0000000000..6d51c06d8f
--- /dev/null
+++ b/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/templates/uploadPhoto.html
@@ -0,0 +1,15 @@
+
+
+
+
Upload new Photo
+
+
+
+
\ No newline at end of file
diff --git a/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/templates/uploadVideo.html b/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/templates/uploadVideo.html
new file mode 100644
index 0000000000..ebc29d98e2
--- /dev/null
+++ b/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/templates/uploadVideo.html
@@ -0,0 +1,15 @@
+
+
+
+
Upload new Video
+
+
+
+
\ No newline at end of file
diff --git a/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/templates/videos.html b/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/templates/videos.html
new file mode 100644
index 0000000000..b0ee0fc577
--- /dev/null
+++ b/persistence-modules/spring-boot-persistence-mongodb/src/main/resources/templates/videos.html
@@ -0,0 +1,15 @@
+
+
+
View Video
+ Title: title
+
+
+
+
+
+
+ Back to home page
+
+
\ No newline at end of file
diff --git a/persistence-modules/spring-data-cassandra-reactive/pom.xml b/persistence-modules/spring-data-cassandra-reactive/pom.xml
index 5a34d90c9f..288f842201 100644
--- a/persistence-modules/spring-data-cassandra-reactive/pom.xml
+++ b/persistence-modules/spring-data-cassandra-reactive/pom.xml
@@ -46,6 +46,13 @@
reactor-testtest
+
+ org.cassandraunit
+ cassandra-unit-spring
+ ${cassandra-unit-spring.version}
+ test
+
+
@@ -53,6 +60,7 @@
UTF-8
2.1.2.RELEASE
+ 3.11.2.0
diff --git a/persistence-modules/spring-data-cassandra-reactive/src/test/java/com/baeldung/cassandra/reactive/ReactiveEmployeeRepositoryIntegrationTest.java b/persistence-modules/spring-data-cassandra-reactive/src/test/java/com/baeldung/cassandra/reactive/ReactiveEmployeeRepositoryIntegrationTest.java
index ad726fe969..ae314db5e7 100644
--- a/persistence-modules/spring-data-cassandra-reactive/src/test/java/com/baeldung/cassandra/reactive/ReactiveEmployeeRepositoryIntegrationTest.java
+++ b/persistence-modules/spring-data-cassandra-reactive/src/test/java/com/baeldung/cassandra/reactive/ReactiveEmployeeRepositoryIntegrationTest.java
@@ -1,13 +1,23 @@
package com.baeldung.cassandra.reactive;
-import com.baeldung.cassandra.reactive.model.Employee;
-import com.baeldung.cassandra.reactive.repository.EmployeeRepository;
+import org.cassandraunit.spring.CassandraDataSet;
+import org.cassandraunit.spring.CassandraUnitDependencyInjectionTestExecutionListener;
+import org.cassandraunit.spring.CassandraUnitTestExecutionListener;
+import org.cassandraunit.spring.EmbeddedCassandra;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
+import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
+import org.springframework.test.context.web.ServletTestExecutionListener;
+
+import com.baeldung.cassandra.reactive.model.Employee;
+import com.baeldung.cassandra.reactive.repository.EmployeeRepository;
+
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
@@ -15,6 +25,15 @@ import reactor.test.StepVerifier;
@RunWith(SpringRunner.class)
@SpringBootTest
+@TestExecutionListeners(listeners = {
+ CassandraUnitDependencyInjectionTestExecutionListener.class,
+ CassandraUnitTestExecutionListener.class,
+ ServletTestExecutionListener.class,
+ DependencyInjectionTestExecutionListener.class,
+ DirtiesContextTestExecutionListener.class
+})
+@EmbeddedCassandra(timeout = 60000, configuration = "cassandra-server.yaml")
+@CassandraDataSet(value = {"cassandra-init.cql"}, keyspace = "practice")
public class ReactiveEmployeeRepositoryIntegrationTest {
@Autowired
diff --git a/persistence-modules/spring-data-cassandra-reactive/src/test/resources/cassandra-init.cql b/persistence-modules/spring-data-cassandra-reactive/src/test/resources/cassandra-init.cql
new file mode 100644
index 0000000000..b28fda5320
--- /dev/null
+++ b/persistence-modules/spring-data-cassandra-reactive/src/test/resources/cassandra-init.cql
@@ -0,0 +1,7 @@
+CREATE TABLE employee(
+ id int PRIMARY KEY,
+ name text,
+ address text,
+ email text,
+ age int
+);
\ No newline at end of file
diff --git a/persistence-modules/spring-data-cassandra-reactive/src/test/resources/cassandra-server.yaml b/persistence-modules/spring-data-cassandra-reactive/src/test/resources/cassandra-server.yaml
new file mode 100644
index 0000000000..af3fb21e54
--- /dev/null
+++ b/persistence-modules/spring-data-cassandra-reactive/src/test/resources/cassandra-server.yaml
@@ -0,0 +1,590 @@
+# Cassandra storage config YAML
+
+# NOTE:
+# See http://wiki.apache.org/cassandra/StorageConfiguration for
+# full explanations of configuration directives
+# /NOTE
+
+# The name of the cluster. This is mainly used to prevent machines in
+# one logical cluster from joining another.
+cluster_name: 'Test Cluster'
+
+# You should always specify InitialToken when setting up a production
+# cluster for the first time, and often when adding capacity later.
+# The principle is that each node should be given an equal slice of
+# the token ring; see http://wiki.apache.org/cassandra/Operations
+# for more details.
+#
+# If blank, Cassandra will request a token bisecting the range of
+# the heaviest-loaded existing node. If there is no load information
+# available, such as is the case with a new cluster, it will pick
+# a random token, which will lead to hot spots.
+#initial_token:
+
+# See http://wiki.apache.org/cassandra/HintedHandoff
+hinted_handoff_enabled: true
+# this defines the maximum amount of time a dead host will have hints
+# generated. After it has been dead this long, new hints for it will not be
+# created until it has been seen alive and gone down again.
+max_hint_window_in_ms: 10800000 # 3 hours
+# Maximum throttle in KBs per second, per delivery thread. This will be
+# reduced proportionally to the number of nodes in the cluster. (If there
+# are two nodes in the cluster, each delivery thread will use the maximum
+# rate; if there are three, each will throttle to half of the maximum,
+# since we expect two nodes to be delivering hints simultaneously.)
+hinted_handoff_throttle_in_kb: 1024
+# Number of threads with which to deliver hints;
+# Consider increasing this number when you have multi-dc deployments, since
+# cross-dc handoff tends to be slower
+max_hints_delivery_threads: 2
+
+hints_directory: target/embeddedCassandra/hints
+
+# The following setting populates the page cache on memtable flush and compaction
+# WARNING: Enable this setting only when the whole node's data fits in memory.
+# Defaults to: false
+# populate_io_cache_on_flush: false
+
+# Authentication backend, implementing IAuthenticator; used to identify users
+# Out of the box, Cassandra provides org.apache.cassandra.auth.{AllowAllAuthenticator,
+# PasswordAuthenticator}.
+#
+# - AllowAllAuthenticator performs no checks - set it to disable authentication.
+# - PasswordAuthenticator relies on username/password pairs to authenticate
+# users. It keeps usernames and hashed passwords in system_auth.credentials table.
+# Please increase system_auth keyspace replication factor if you use this authenticator.
+authenticator: AllowAllAuthenticator
+
+# Authorization backend, implementing IAuthorizer; used to limit access/provide permissions
+# Out of the box, Cassandra provides org.apache.cassandra.auth.{AllowAllAuthorizer,
+# CassandraAuthorizer}.
+#
+# - AllowAllAuthorizer allows any action to any user - set it to disable authorization.
+# - CassandraAuthorizer stores permissions in system_auth.permissions table. Please
+# increase system_auth keyspace replication factor if you use this authorizer.
+authorizer: AllowAllAuthorizer
+
+# Validity period for permissions cache (fetching permissions can be an
+# expensive operation depending on the authorizer, CassandraAuthorizer is
+# one example). Defaults to 2000, set to 0 to disable.
+# Will be disabled automatically for AllowAllAuthorizer.
+permissions_validity_in_ms: 2000
+
+
+# The partitioner is responsible for distributing rows (by key) across
+# nodes in the cluster. Any IPartitioner may be used, including your/m
+# own as long as it is on the classpath. Out of the box, Cassandra
+# provides org.apache.cassandra.dht.{Murmur3Partitioner, RandomPartitioner
+# ByteOrderedPartitioner, OrderPreservingPartitioner (deprecated)}.
+#
+# - RandomPartitioner distributes rows across the cluster evenly by md5.
+# This is the default prior to 1.2 and is retained for compatibility.
+# - Murmur3Partitioner is similar to RandomPartioner but uses Murmur3_128
+# Hash Function instead of md5. When in doubt, this is the best option.
+# - ByteOrderedPartitioner orders rows lexically by key bytes. BOP allows
+# scanning rows in key order, but the ordering can generate hot spots
+# for sequential insertion workloads.
+# - OrderPreservingPartitioner is an obsolete form of BOP, that stores
+# - keys in a less-efficient format and only works with keys that are
+# UTF8-encoded Strings.
+# - CollatingOPP collates according to EN,US rules rather than lexical byte
+# ordering. Use this as an example if you need custom collation.
+#
+# See http://wiki.apache.org/cassandra/Operations for more on
+# partitioners and token selection.
+partitioner: org.apache.cassandra.dht.Murmur3Partitioner
+
+# directories where Cassandra should store data on disk.
+data_file_directories:
+ - target/embeddedCassandra/data
+
+# commit log
+commitlog_directory: target/embeddedCassandra/commitlog
+
+cdc_raw_directory: target/embeddedCassandra/cdc
+
+# policy for data disk failures:
+# stop: shut down gossip and Thrift, leaving the node effectively dead, but
+# can still be inspected via JMX.
+# best_effort: stop using the failed disk and respond to requests based on
+# remaining available sstables. This means you WILL see obsolete
+# data at CL.ONE!
+# ignore: ignore fatal errors and let requests fail, as in pre-1.2 Cassandra
+disk_failure_policy: stop
+
+
+# Maximum size of the key cache in memory.
+#
+# Each key cache hit saves 1 seek and each row cache hit saves 2 seeks at the
+# minimum, sometimes more. The key cache is fairly tiny for the amount of
+# time it saves, so it's worthwhile to use it at large numbers.
+# The row cache saves even more time, but must store the whole values of
+# its rows, so it is extremely space-intensive. It's best to only use the
+# row cache if you have hot rows or static rows.
+#
+# NOTE: if you reduce the size, you may not get you hottest keys loaded on startup.
+#
+# Default value is empty to make it "auto" (min(5% of Heap (in MB), 100MB)). Set to 0 to disable key cache.
+key_cache_size_in_mb:
+
+# Duration in seconds after which Cassandra should
+# safe the keys cache. Caches are saved to saved_caches_directory as
+# specified in this configuration file.
+#
+# Saved caches greatly improve cold-start speeds, and is relatively cheap in
+# terms of I/O for the key cache. Row cache saving is much more expensive and
+# has limited use.
+#
+# Default is 14400 or 4 hours.
+key_cache_save_period: 14400
+
+# Number of keys from the key cache to save
+# Disabled by default, meaning all keys are going to be saved
+# key_cache_keys_to_save: 100
+
+# Maximum size of the row cache in memory.
+# NOTE: if you reduce the size, you may not get you hottest keys loaded on startup.
+#
+# Default value is 0, to disable row caching.
+row_cache_size_in_mb: 0
+
+# Duration in seconds after which Cassandra should
+# safe the row cache. Caches are saved to saved_caches_directory as specified
+# in this configuration file.
+#
+# Saved caches greatly improve cold-start speeds, and is relatively cheap in
+# terms of I/O for the key cache. Row cache saving is much more expensive and
+# has limited use.
+#
+# Default is 0 to disable saving the row cache.
+row_cache_save_period: 0
+
+# Number of keys from the row cache to save
+# Disabled by default, meaning all keys are going to be saved
+# row_cache_keys_to_save: 100
+
+# saved caches
+saved_caches_directory: target/embeddedCassandra/saved_caches
+
+# commitlog_sync may be either "periodic" or "batch."
+# When in batch mode, Cassandra won't ack writes until the commit log
+# has been fsynced to disk. It will wait up to
+# commitlog_sync_batch_window_in_ms milliseconds for other writes, before
+# performing the sync.
+#
+# commitlog_sync: batch
+# commitlog_sync_batch_window_in_ms: 50
+#
+# the other option is "periodic" where writes may be acked immediately
+# and the CommitLog is simply synced every commitlog_sync_period_in_ms
+# milliseconds.
+commitlog_sync: periodic
+commitlog_sync_period_in_ms: 10000
+
+# The size of the individual commitlog file segments. A commitlog
+# segment may be archived, deleted, or recycled once all the data
+# in it (potentially from each columnfamily in the system) has been
+# flushed to sstables.
+#
+# The default size is 32, which is almost always fine, but if you are
+# archiving commitlog segments (see commitlog_archiving.properties),
+# then you probably want a finer granularity of archiving; 8 or 16 MB
+# is reasonable.
+commitlog_segment_size_in_mb: 32
+
+# any class that implements the SeedProvider interface and has a
+# constructor that takes a Map of parameters will do.
+seed_provider:
+ # Addresses of hosts that are deemed contact points.
+ # Cassandra nodes use this list of hosts to find each other and learn
+ # the topology of the ring. You must change this if you are running
+ # multiple nodes!
+ - class_name: org.apache.cassandra.locator.SimpleSeedProvider
+ parameters:
+ # seeds is actually a comma-delimited list of addresses.
+ # Ex: ",,"
+ - seeds: "127.0.0.1"
+
+
+# For workloads with more data than can fit in memory, Cassandra's
+# bottleneck will be reads that need to fetch data from
+# disk. "concurrent_reads" should be set to (16 * number_of_drives) in
+# order to allow the operations to enqueue low enough in the stack
+# that the OS and drives can reorder them.
+#
+# On the other hand, since writes are almost never IO bound, the ideal
+# number of "concurrent_writes" is dependent on the number of cores in
+# your system; (8 * number_of_cores) is a good rule of thumb.
+concurrent_reads: 32
+concurrent_writes: 32
+
+# Total memory to use for memtables. Cassandra will flush the largest
+# memtable when this much memory is used.
+# If omitted, Cassandra will set it to 1/3 of the heap.
+# memtable_total_space_in_mb: 2048
+
+# Total space to use for commitlogs.
+# If space gets above this value (it will round up to the next nearest
+# segment multiple), Cassandra will flush every dirty CF in the oldest
+# segment and remove it.
+# commitlog_total_space_in_mb: 4096
+
+# This sets the amount of memtable flush writer threads. These will
+# be blocked by disk io, and each one will hold a memtable in memory
+# while blocked. If you have a large heap and many data directories,
+# you can increase this value for better flush performance.
+# By default this will be set to the amount of data directories defined.
+#memtable_flush_writers: 1
+
+# the number of full memtables to allow pending flush, that is,
+# waiting for a writer thread. At a minimum, this should be set to
+# the maximum number of secondary indexes created on a single CF.
+#memtable_flush_queue_size: 4
+
+# Whether to, when doing sequential writing, fsync() at intervals in
+# order to force the operating system to flush the dirty
+# buffers. Enable this to avoid sudden dirty buffer flushing from
+# impacting read latencies. Almost always a good idea on SSD:s; not
+# necessarily on platters.
+trickle_fsync: false
+trickle_fsync_interval_in_kb: 10240
+
+# TCP port, for commands and data
+storage_port: 7010
+
+# SSL port, for encrypted communication. Unused unless enabled in
+# encryption_options
+ssl_storage_port: 7011
+
+# Address to bind to and tell other Cassandra nodes to connect to. You
+# _must_ change this if you want multiple nodes to be able to
+# communicate!
+#
+# Leaving it blank leaves it up to InetAddress.getLocalHost(). This
+# will always do the Right Thing *if* the node is properly configured
+# (hostname, name resolution, etc), and the Right Thing is to use the
+# address associated with the hostname (it might not be).
+#
+# Setting this to 0.0.0.0 is always wrong.
+listen_address: 127.0.0.1
+
+start_native_transport: true
+# port for the CQL native transport to listen for clients on
+native_transport_port: 9042
+
+# Whether to start the thrift rpc server.
+start_rpc: true
+
+# Address to broadcast to other Cassandra nodes
+# Leaving this blank will set it to the same value as listen_address
+# broadcast_address: 1.2.3.4
+
+# The address to bind the Thrift RPC service to -- clients connect
+# here. Unlike ListenAddress above, you *can* specify 0.0.0.0 here if
+# you want Thrift to listen on all interfaces.
+#
+# Leaving this blank has the same effect it does for ListenAddress,
+# (i.e. it will be based on the configured hostname of the node).
+rpc_address: localhost
+# port for Thrift to listen for clients on
+rpc_port: 9171
+
+# enable or disable keepalive on rpc connections
+rpc_keepalive: true
+
+# Cassandra provides three options for the RPC Server:
+#
+# sync -> One connection per thread in the rpc pool (see below).
+# For a very large number of clients, memory will be your limiting
+# factor; on a 64 bit JVM, 128KB is the minimum stack size per thread.
+# Connection pooling is very, very strongly recommended.
+#
+# async -> Nonblocking server implementation with one thread to serve
+# rpc connections. This is not recommended for high throughput use
+# cases. Async has been tested to be about 50% slower than sync
+# or hsha and is deprecated: it will be removed in the next major release.
+#
+# hsha -> Stands for "half synchronous, half asynchronous." The rpc thread pool
+# (see below) is used to manage requests, but the threads are multiplexed
+# across the different clients.
+#
+# The default is sync because on Windows hsha is about 30% slower. On Linux,
+# sync/hsha performance is about the same, with hsha of course using less memory.
+rpc_server_type: sync
+
+# Uncomment rpc_min|max|thread to set request pool size.
+# You would primarily set max for the sync server to safeguard against
+# misbehaved clients; if you do hit the max, Cassandra will block until one
+# disconnects before accepting more. The defaults for sync are min of 16 and max
+# unlimited.
+#
+# For the Hsha server, the min and max both default to quadruple the number of
+# CPU cores.
+#
+# This configuration is ignored by the async server.
+#
+# rpc_min_threads: 16
+# rpc_max_threads: 2048
+
+# uncomment to set socket buffer sizes on rpc connections
+# rpc_send_buff_size_in_bytes:
+# rpc_recv_buff_size_in_bytes:
+
+# Frame size for thrift (maximum field length).
+# 0 disables TFramedTransport in favor of TSocket. This option
+# is deprecated; we strongly recommend using Framed mode.
+thrift_framed_transport_size_in_mb: 15
+
+# The max length of a thrift message, including all fields and
+# internal thrift overhead.
+thrift_max_message_length_in_mb: 16
+
+# Set to true to have Cassandra create a hard link to each sstable
+# flushed or streamed locally in a backups/ subdirectory of the
+# Keyspace data. Removing these links is the operator's
+# responsibility.
+incremental_backups: false
+
+# Whether or not to take a snapshot before each compaction. Be
+# careful using this option, since Cassandra won't clean up the
+# snapshots for you. Mostly useful if you're paranoid when there
+# is a data format change.
+snapshot_before_compaction: false
+
+# Whether or not a snapshot is taken of the data before keyspace truncation
+# or dropping of column families. The STRONGLY advised default of true
+# should be used to provide data safety. If you set this flag to false, you will
+# lose data on truncation or drop.
+auto_snapshot: false
+
+# Add column indexes to a row after its contents reach this size.
+# Increase if your column values are large, or if you have a very large
+# number of columns. The competing causes are, Cassandra has to
+# deserialize this much of the row to read a single column, so you want
+# it to be small - at least if you do many partial-row reads - but all
+# the index data is read for each access, so you don't want to generate
+# that wastefully either.
+column_index_size_in_kb: 64
+
+# Size limit for rows being compacted in memory. Larger rows will spill
+# over to disk and use a slower two-pass compaction process. A message
+# will be logged specifying the row key.
+#in_memory_compaction_limit_in_mb: 64
+
+# Number of simultaneous compactions to allow, NOT including
+# validation "compactions" for anti-entropy repair. Simultaneous
+# compactions can help preserve read performance in a mixed read/write
+# workload, by mitigating the tendency of small sstables to accumulate
+# during a single long running compactions. The default is usually
+# fine and if you experience problems with compaction running too
+# slowly or too fast, you should look at
+# compaction_throughput_mb_per_sec first.
+#
+# This setting has no effect on LeveledCompactionStrategy.
+#
+# concurrent_compactors defaults to the number of cores.
+# Uncomment to make compaction mono-threaded, the pre-0.8 default.
+#concurrent_compactors: 1
+
+# Multi-threaded compaction. When enabled, each compaction will use
+# up to one thread per core, plus one thread per sstable being merged.
+# This is usually only useful for SSD-based hardware: otherwise,
+# your concern is usually to get compaction to do LESS i/o (see:
+# compaction_throughput_mb_per_sec), not more.
+#multithreaded_compaction: false
+
+# Throttles compaction to the given total throughput across the entire
+# system. The faster you insert data, the faster you need to compact in
+# order to keep the sstable count down, but in general, setting this to
+# 16 to 32 times the rate you are inserting data is more than sufficient.
+# Setting this to 0 disables throttling. Note that this account for all types
+# of compaction, including validation compaction.
+compaction_throughput_mb_per_sec: 16
+
+# Track cached row keys during compaction, and re-cache their new
+# positions in the compacted sstable. Disable if you use really large
+# key caches.
+#compaction_preheat_key_cache: true
+
+# Throttles all outbound streaming file transfers on this node to the
+# given total throughput in Mbps. This is necessary because Cassandra does
+# mostly sequential IO when streaming data during bootstrap or repair, which
+# can lead to saturating the network connection and degrading rpc performance.
+# When unset, the default is 200 Mbps or 25 MB/s.
+# stream_throughput_outbound_megabits_per_sec: 200
+
+# How long the coordinator should wait for read operations to complete
+read_request_timeout_in_ms: 5000
+# How long the coordinator should wait for seq or index scans to complete
+range_request_timeout_in_ms: 10000
+# How long the coordinator should wait for writes to complete
+write_request_timeout_in_ms: 2000
+# How long a coordinator should continue to retry a CAS operation
+# that contends with other proposals for the same row
+cas_contention_timeout_in_ms: 1000
+# How long the coordinator should wait for truncates to complete
+# (This can be much longer, because unless auto_snapshot is disabled
+# we need to flush first so we can snapshot before removing the data.)
+truncate_request_timeout_in_ms: 60000
+# The default timeout for other, miscellaneous operations
+request_timeout_in_ms: 10000
+
+# Enable operation timeout information exchange between nodes to accurately
+# measure request timeouts. If disabled, replicas will assume that requests
+# were forwarded to them instantly by the coordinator, which means that
+# under overload conditions we will waste that much extra time processing
+# already-timed-out requests.
+#
+# Warning: before enabling this property make sure to ntp is installed
+# and the times are synchronized between the nodes.
+cross_node_timeout: false
+
+# Enable socket timeout for streaming operation.
+# When a timeout occurs during streaming, streaming is retried from the start
+# of the current file. This _can_ involve re-streaming an important amount of
+# data, so you should avoid setting the value too low.
+# Default value is 0, which never timeout streams.
+# streaming_socket_timeout_in_ms: 0
+
+# phi value that must be reached for a host to be marked down.
+# most users should never need to adjust this.
+# phi_convict_threshold: 8
+
+# endpoint_snitch -- Set this to a class that implements
+# IEndpointSnitch. The snitch has two functions:
+# - it teaches Cassandra enough about your network topology to route
+# requests efficiently
+# - it allows Cassandra to spread replicas around your cluster to avoid
+# correlated failures. It does this by grouping machines into
+# "datacenters" and "racks." Cassandra will do its best not to have
+# more than one replica on the same "rack" (which may not actually
+# be a physical location)
+#
+# IF YOU CHANGE THE SNITCH AFTER DATA IS INSERTED INTO THE CLUSTER,
+# YOU MUST RUN A FULL REPAIR, SINCE THE SNITCH AFFECTS WHERE REPLICAS
+# ARE PLACED.
+#
+# Out of the box, Cassandra provides
+# - SimpleSnitch:
+# Treats Strategy order as proximity. This improves cache locality
+# when disabling read repair, which can further improve throughput.
+# Only appropriate for single-datacenter deployments.
+# - PropertyFileSnitch:
+# Proximity is determined by rack and data center, which are
+# explicitly configured in cassandra-topology.properties.
+# - RackInferringSnitch:
+# Proximity is determined by rack and data center, which are
+# assumed to correspond to the 3rd and 2nd octet of each node's
+# IP address, respectively. Unless this happens to match your
+# deployment conventions (as it did Facebook's), this is best used
+# as an example of writing a custom Snitch class.
+# - Ec2Snitch:
+# Appropriate for EC2 deployments in a single Region. Loads Region
+# and Availability Zone information from the EC2 API. The Region is
+# treated as the Datacenter, and the Availability Zone as the rack.
+# Only private IPs are used, so this will not work across multiple
+# Regions.
+# - Ec2MultiRegionSnitch:
+# Uses public IPs as broadcast_address to allow cross-region
+# connectivity. (Thus, you should set seed addresses to the public
+# IP as well.) You will need to open the storage_port or
+# ssl_storage_port on the public IP firewall. (For intra-Region
+# traffic, Cassandra will switch to the private IP after
+# establishing a connection.)
+#
+# You can use a custom Snitch by setting this to the full class name
+# of the snitch, which will be assumed to be on your classpath.
+endpoint_snitch: SimpleSnitch
+
+# controls how often to perform the more expensive part of host score
+# calculation
+dynamic_snitch_update_interval_in_ms: 100
+# controls how often to reset all host scores, allowing a bad host to
+# possibly recover
+dynamic_snitch_reset_interval_in_ms: 600000
+# if set greater than zero and read_repair_chance is < 1.0, this will allow
+# 'pinning' of replicas to hosts in order to increase cache capacity.
+# The badness threshold will control how much worse the pinned host has to be
+# before the dynamic snitch will prefer other replicas over it. This is
+# expressed as a double which represents a percentage. Thus, a value of
+# 0.2 means Cassandra would continue to prefer the static snitch values
+# until the pinned host was 20% worse than the fastest.
+dynamic_snitch_badness_threshold: 0.1
+
+# request_scheduler -- Set this to a class that implements
+# RequestScheduler, which will schedule incoming client requests
+# according to the specific policy. This is useful for multi-tenancy
+# with a single Cassandra cluster.
+# NOTE: This is specifically for requests from the client and does
+# not affect inter node communication.
+# org.apache.cassandra.scheduler.NoScheduler - No scheduling takes place
+# org.apache.cassandra.scheduler.RoundRobinScheduler - Round robin of
+# client requests to a node with a separate queue for each
+# request_scheduler_id. The scheduler is further customized by
+# request_scheduler_options as described below.
+request_scheduler: org.apache.cassandra.scheduler.NoScheduler
+
+# Scheduler Options vary based on the type of scheduler
+# NoScheduler - Has no options
+# RoundRobin
+# - throttle_limit -- The throttle_limit is the number of in-flight
+# requests per client. Requests beyond
+# that limit are queued up until
+# running requests can complete.
+# The value of 80 here is twice the number of
+# concurrent_reads + concurrent_writes.
+# - default_weight -- default_weight is optional and allows for
+# overriding the default which is 1.
+# - weights -- Weights are optional and will default to 1 or the
+# overridden default_weight. The weight translates into how
+# many requests are handled during each turn of the
+# RoundRobin, based on the scheduler id.
+#
+# request_scheduler_options:
+# throttle_limit: 80
+# default_weight: 5
+# weights:
+# Keyspace1: 1
+# Keyspace2: 5
+
+# request_scheduler_id -- An identifer based on which to perform
+# the request scheduling. Currently the only valid option is keyspace.
+# request_scheduler_id: keyspace
+
+# index_interval controls the sampling of entries from the primrary
+# row index in terms of space versus time. The larger the interval,
+# the smaller and less effective the sampling will be. In technicial
+# terms, the interval coresponds to the number of index entries that
+# are skipped between taking each sample. All the sampled entries
+# must fit in memory. Generally, a value between 128 and 512 here
+# coupled with a large key cache size on CFs results in the best trade
+# offs. This value is not often changed, however if you have many
+# very small rows (many to an OS page), then increasing this will
+# often lower memory usage without a impact on performance.
+index_interval: 128
+
+# Enable or disable inter-node encryption
+# Default settings are TLS v1, RSA 1024-bit keys (it is imperative that
+# users generate their own keys) TLS_RSA_WITH_AES_128_CBC_SHA as the cipher
+# suite for authentication, key exchange and encryption of the actual data transfers.
+# NOTE: No custom encryption options are enabled at the moment
+# The available internode options are : all, none, dc, rack
+#
+# If set to dc cassandra will encrypt the traffic between the DCs
+# If set to rack cassandra will encrypt the traffic between the racks
+#
+# The passwords used in these options must match the passwords used when generating
+# the keystore and truststore. For instructions on generating these files, see:
+# http://download.oracle.com/javase/6/docs/technotes/guides/security/jsse/JSSERefGuide.html#CreateKeystore
+#
+encryption_options:
+ internode_encryption: none
+ keystore: conf/.keystore
+ keystore_password: cassandra
+ truststore: conf/.truststore
+ truststore_password: cassandra
+ # More advanced defaults below:
+ # protocol: TLS
+ # algorithm: SunX509
+ # store_type: JKS
+ # cipher_suites: [TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA]
\ No newline at end of file
diff --git a/persistence-modules/spring-data-cassandra/src/test/java/org/baeldung/SpringContextTest.java b/persistence-modules/spring-data-cassandra/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..89e729da86
--- /dev/null
+++ b/persistence-modules/spring-data-cassandra/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,67 @@
+package org.baeldung;
+
+import java.io.IOException;
+import java.util.HashMap;
+
+import org.apache.cassandra.exceptions.ConfigurationException;
+import org.apache.thrift.transport.TTransportException;
+import org.baeldung.spring.data.cassandra.config.CassandraConfig;
+import org.baeldung.spring.data.cassandra.model.Book;
+import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cassandra.core.cql.CqlIdentifier;
+import org.springframework.data.cassandra.core.CassandraAdminOperations;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Session;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = CassandraConfig.class)
+public class SpringContextTest {
+
+ public static final String KEYSPACE_CREATION_QUERY = "CREATE KEYSPACE IF NOT EXISTS testKeySpace " + "WITH replication = { 'class': 'SimpleStrategy', 'replication_factor': '3' };";
+
+ public static final String KEYSPACE_ACTIVATE_QUERY = "USE testKeySpace;";
+
+ public static final String DATA_TABLE_NAME = "book";
+
+ @Autowired
+ private CassandraAdminOperations adminTemplate;
+
+ @BeforeClass
+ public static void startCassandraEmbedded() throws InterruptedException, TTransportException, ConfigurationException, IOException {
+ EmbeddedCassandraServerHelper.startEmbeddedCassandra();
+ final Cluster cluster = Cluster.builder().addContactPoints("127.0.0.1").withPort(9142).build();
+ final Session session = cluster.connect();
+ session.execute(KEYSPACE_CREATION_QUERY);
+ session.execute(KEYSPACE_ACTIVATE_QUERY);
+ Thread.sleep(5000);
+ }
+
+ @Before
+ public void createTable() throws InterruptedException, TTransportException, ConfigurationException, IOException {
+ adminTemplate.createTable(true, CqlIdentifier.cqlId(DATA_TABLE_NAME), Book.class, new HashMap());
+ }
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+
+ @After
+ public void dropTable() {
+ adminTemplate.dropTable(CqlIdentifier.cqlId(DATA_TABLE_NAME));
+ }
+
+ @AfterClass
+ public static void stopCassandraEmbedded() {
+ EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
+ }
+}
diff --git a/persistence-modules/spring-data-dynamodb/src/test/java/org/baeldung/SpringContextTest.java b/persistence-modules/spring-data-dynamodb/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..5e68a8e64f
--- /dev/null
+++ b/persistence-modules/spring-data-dynamodb/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.Application;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/persistence-modules/spring-data-eclipselink/src/test/java/org/baeldung/SpringContextTest.java b/persistence-modules/spring-data-eclipselink/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..4c69245f65
--- /dev/null
+++ b/persistence-modules/spring-data-eclipselink/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.eclipselink.springdata.EclipselinkSpringDataApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = EclipselinkSpringDataApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/persistence-modules/spring-data-gemfire/src/test/java/org/baeldung/SpringContextTest.java b/persistence-modules/spring-data-gemfire/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..3772e22137
--- /dev/null
+++ b/persistence-modules/spring-data-gemfire/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,18 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.support.AnnotationConfigContextLoader;
+
+import com.baeldung.spring.data.gemfire.function.GemfireConfiguration;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes=GemfireConfiguration.class, loader=AnnotationConfigContextLoader.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-2/README.md b/persistence-modules/spring-data-jpa-2/README.md
index 6b73729f9a..1f7de81c02 100644
--- a/persistence-modules/spring-data-jpa-2/README.md
+++ b/persistence-modules/spring-data-jpa-2/README.md
@@ -1,7 +1,3 @@
-=========
-
-## Spring Data JPA Example Project
-
### Relevant Articles:
- [Spring Data JPA – Derived Delete Methods](https://www.baeldung.com/spring-data-jpa-deleteby)
- [JPA Join Types](https://www.baeldung.com/jpa-join-types)
@@ -15,3 +11,5 @@
- [Spring Data JPA and Named Entity Graphs](https://www.baeldung.com/spring-data-jpa-named-entity-graphs)
- [Batch Insert/Update with Hibernate/JPA](https://www.baeldung.com/jpa-hibernate-batch-insert-update)
- [Difference Between save() and saveAndFlush() in Spring Data JPA](https://www.baeldung.com/spring-data-jpa-save-saveandflush)
+- [Derived Query Methods in Spring Data JPA Repositories](https://www.baeldung.com/spring-data-derived-queries)
+- [LIKE Queries in Spring JPA Repositories](https://www.baeldung.com/spring-jpa-like-queries)
diff --git a/persistence-modules/spring-data-jpa-2/pom.xml b/persistence-modules/spring-data-jpa-2/pom.xml
index fbc19810ef..08be64670b 100644
--- a/persistence-modules/spring-data-jpa-2/pom.xml
+++ b/persistence-modules/spring-data-jpa-2/pom.xml
@@ -29,7 +29,7 @@
net.ttddyydatasource-proxy
- 1.4.1
+ ${datasource-proxy.version}
@@ -42,4 +42,8 @@
spring-oxm
+
+
+ 1.4.1
+
\ No newline at end of file
diff --git a/persistence-modules/spring-data-jpa/pom.xml b/persistence-modules/spring-data-jpa/pom.xml
index a7788065c9..af92f331d1 100644
--- a/persistence-modules/spring-data-jpa/pom.xml
+++ b/persistence-modules/spring-data-jpa/pom.xml
@@ -37,14 +37,14 @@
org.testcontainerspostgresql
- 1.10.6
+ ${testcontainers.postgresql.version}testorg.postgresqlpostgresql
- 42.2.5
+ ${postgresql.version}
@@ -66,7 +66,7 @@
com.google.guavaguava
- 21.0
+ ${guava.version}
@@ -92,6 +92,9 @@
com.baeldung.boot.Application
+ 1.10.6
+ 42.2.5
+ 21.0
\ No newline at end of file
diff --git a/persistence-modules/spring-data-jpa/src/test/java/org/baeldung/SpringContextTest.java b/persistence-modules/spring-data-jpa/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..db7b156415
--- /dev/null
+++ b/persistence-modules/spring-data-jpa/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.boot.Application;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/persistence-modules/spring-data-keyvalue/src/test/java/org/baeldung/SpringContextTest.java b/persistence-modules/spring-data-keyvalue/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..e6cc5c15af
--- /dev/null
+++ b/persistence-modules/spring-data-keyvalue/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.spring.data.keyvalue.SpringDataKeyValueApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringDataKeyValueApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/persistence-modules/spring-data-mongodb/pom.xml b/persistence-modules/spring-data-mongodb/pom.xml
index 7156cdf071..33ad3a5267 100644
--- a/persistence-modules/spring-data-mongodb/pom.xml
+++ b/persistence-modules/spring-data-mongodb/pom.xml
@@ -21,7 +21,7 @@
org.springframework.dataspring-data-releasetrain
- Lovelace-SR3
+ Lovelace-SR9pom
@@ -95,7 +95,7 @@
- 2.1.2.RELEASE
+ 2.1.9.RELEASE4.1.41.1.31.9.2
diff --git a/persistence-modules/spring-data-neo4j/src/test/java/org/baeldung/SpringContextTest.java b/persistence-modules/spring-data-neo4j/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..5bf54fc0bd
--- /dev/null
+++ b/persistence-modules/spring-data-neo4j/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,19 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.baeldung.spring.data.neo4j.config.MovieDatabaseNeo4jTestConfiguration;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = MovieDatabaseNeo4jTestConfiguration.class)
+@ActiveProfiles(profiles = "test")
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/persistence-modules/spring-data-redis/pom.xml b/persistence-modules/spring-data-redis/pom.xml
index fb80b0413f..4ae8ac0a87 100644
--- a/persistence-modules/spring-data-redis/pom.xml
+++ b/persistence-modules/spring-data-redis/pom.xml
@@ -79,6 +79,21 @@
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${maven-surefire-plugin.version}
+
+ true
+ true
+ -Xmx1024m
+
+
+
+
+
3.2.42.9.0
diff --git a/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/reactive/redis/template/RedisKeyCommandsIntegrationTest.java b/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/reactive/redis/template/RedisKeyCommandsIntegrationTest.java
index e48aa1e06a..1333f94653 100644
--- a/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/reactive/redis/template/RedisKeyCommandsIntegrationTest.java
+++ b/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/reactive/redis/template/RedisKeyCommandsIntegrationTest.java
@@ -2,6 +2,9 @@ package com.baeldung.spring.data.reactive.redis.template;
import com.baeldung.spring.data.reactive.redis.SpringRedisReactiveApplication;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@@ -9,22 +12,40 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.connection.ReactiveKeyCommands;
import org.springframework.data.redis.connection.ReactiveStringCommands;
import org.springframework.data.redis.connection.ReactiveStringCommands.SetCommand;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.junit4.SpringRunner;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
+import redis.embedded.RedisServerBuilder;
+import java.io.IOException;
import java.nio.ByteBuffer;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = SpringRedisReactiveApplication.class)
+@DirtiesContext(classMode = ClassMode.BEFORE_CLASS)
public class RedisKeyCommandsIntegrationTest {
+
+ private static redis.embedded.RedisServer redisServer;
@Autowired
private ReactiveKeyCommands keyCommands;
@Autowired
private ReactiveStringCommands stringCommands;
+
+ @BeforeClass
+ public static void startRedisServer() throws IOException {
+ redisServer = new RedisServerBuilder().port(6379).setting("maxheap 256M").build();
+ redisServer.start();
+ }
+
+ @AfterClass
+ public static void stopRedisServer() throws IOException {
+ redisServer.stop();
+ }
@Test
public void givenFluxOfKeys_whenPerformOperations_thenPerformOperations() {
diff --git a/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/reactive/redis/template/RedisTemplateListOpsIntegrationTest.java b/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/reactive/redis/template/RedisTemplateListOpsIntegrationTest.java
index 3ebeff87b1..88c4fa6eed 100644
--- a/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/reactive/redis/template/RedisTemplateListOpsIntegrationTest.java
+++ b/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/reactive/redis/template/RedisTemplateListOpsIntegrationTest.java
@@ -2,27 +2,48 @@ package com.baeldung.spring.data.reactive.redis.template;
import com.baeldung.spring.data.reactive.redis.SpringRedisReactiveApplication;
+
+import java.io.IOException;
+
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.ReactiveListOperations;
import org.springframework.data.redis.core.ReactiveRedisTemplate;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.junit4.SpringRunner;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
+import redis.embedded.RedisServerBuilder;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = SpringRedisReactiveApplication.class)
+@DirtiesContext(classMode = ClassMode.BEFORE_CLASS)
public class RedisTemplateListOpsIntegrationTest {
private static final String LIST_NAME = "demo_list";
+ private static redis.embedded.RedisServer redisServer;
@Autowired
private ReactiveRedisTemplate redisTemplate;
private ReactiveListOperations reactiveListOps;
+
+ @BeforeClass
+ public static void startRedisServer() throws IOException {
+ redisServer = new RedisServerBuilder().port(6379).setting("maxheap 128M").build();
+ redisServer.start();
+ }
+
+ @AfterClass
+ public static void stopRedisServer() throws IOException {
+ redisServer.stop();
+ }
@Before
public void setup() {
diff --git a/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/reactive/redis/template/RedisTemplateValueOpsIntegrationTest.java b/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/reactive/redis/template/RedisTemplateValueOpsIntegrationTest.java
index 9490568089..afa5267582 100644
--- a/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/reactive/redis/template/RedisTemplateValueOpsIntegrationTest.java
+++ b/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/reactive/redis/template/RedisTemplateValueOpsIntegrationTest.java
@@ -1,29 +1,51 @@
package com.baeldung.spring.data.reactive.redis.template;
-import com.baeldung.spring.data.reactive.redis.SpringRedisReactiveApplication;
-import com.baeldung.spring.data.reactive.redis.model.Employee;
+import java.io.IOException;
+import java.time.Duration;
+
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.ReactiveRedisTemplate;
import org.springframework.data.redis.core.ReactiveValueOperations;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.spring.data.reactive.redis.SpringRedisReactiveApplication;
+import com.baeldung.spring.data.reactive.redis.model.Employee;
+
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
-
-import java.time.Duration;
+import redis.embedded.RedisServerBuilder;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = SpringRedisReactiveApplication.class)
+@DirtiesContext(classMode = ClassMode.BEFORE_CLASS)
public class RedisTemplateValueOpsIntegrationTest {
+
+ private static redis.embedded.RedisServer redisServer;
@Autowired
private ReactiveRedisTemplate redisTemplate;
private ReactiveValueOperations reactiveValueOps;
+
+ @BeforeClass
+ public static void startRedisServer() throws IOException {
+ redisServer = new RedisServerBuilder().port(6379).setting("maxheap 256M").build();
+ redisServer.start();
+ }
+
+ @AfterClass
+ public static void stopRedisServer() throws IOException {
+ redisServer.stop();
+ }
@Before
public void setup() {
diff --git a/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/redis/RedisMessageListenerIntegrationTest.java b/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/redis/RedisMessageListenerIntegrationTest.java
index 99febb6430..1c69b63c09 100644
--- a/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/redis/RedisMessageListenerIntegrationTest.java
+++ b/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/redis/RedisMessageListenerIntegrationTest.java
@@ -19,9 +19,11 @@ import com.baeldung.spring.data.redis.config.RedisConfig;
import com.baeldung.spring.data.redis.queue.RedisMessagePublisher;
import com.baeldung.spring.data.redis.queue.RedisMessageSubscriber;
+import redis.embedded.RedisServerBuilder;
+
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = RedisConfig.class)
-@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
+@DirtiesContext(classMode = ClassMode.BEFORE_CLASS)
public class RedisMessageListenerIntegrationTest {
private static redis.embedded.RedisServer redisServer;
@@ -31,7 +33,7 @@ public class RedisMessageListenerIntegrationTest {
@BeforeClass
public static void startRedisServer() throws IOException {
- redisServer = new redis.embedded.RedisServer(6380);
+ redisServer = new RedisServerBuilder().port(6379).setting("maxheap 256M").build();
redisServer.start();
}
diff --git a/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/redis/repo/StudentRepositoryIntegrationTest.java b/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/redis/repo/StudentRepositoryIntegrationTest.java
index 43aadefc01..b1a36475c3 100644
--- a/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/redis/repo/StudentRepositoryIntegrationTest.java
+++ b/persistence-modules/spring-data-redis/src/test/java/com/baeldung/spring/data/redis/repo/StudentRepositoryIntegrationTest.java
@@ -20,9 +20,11 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.baeldung.spring.data.redis.config.RedisConfig;
import com.baeldung.spring.data.redis.model.Student;
+import redis.embedded.RedisServerBuilder;
+
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = RedisConfig.class)
-@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
+@DirtiesContext(classMode = ClassMode.BEFORE_CLASS)
public class StudentRepositoryIntegrationTest {
@Autowired
@@ -32,7 +34,7 @@ public class StudentRepositoryIntegrationTest {
@BeforeClass
public static void startRedisServer() throws IOException {
- redisServer = new redis.embedded.RedisServer(6380);
+ redisServer = new RedisServerBuilder().port(6379).setting("maxheap 128M").build();
redisServer.start();
}
diff --git a/persistence-modules/spring-data-redis/src/test/java/org/baeldung/SpringContextTest.java b/persistence-modules/spring-data-redis/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..6652345595
--- /dev/null
+++ b/persistence-modules/spring-data-redis/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.baeldung.spring.data.redis.config.RedisConfig;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = RedisConfig.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/persistence-modules/spring-data-solr/src/test/java/org/baeldung/SpringContextTest.java b/persistence-modules/spring-data-solr/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..09bf0255a0
--- /dev/null
+++ b/persistence-modules/spring-data-solr/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.baeldung.spring.data.solr.config.SolrConfig;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = SolrConfig.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/persistence-modules/spring-hibernate-3/pom.xml b/persistence-modules/spring-hibernate-3/pom.xml
index ec35f35bb3..4349492370 100644
--- a/persistence-modules/spring-hibernate-3/pom.xml
+++ b/persistence-modules/spring-hibernate-3/pom.xml
@@ -93,7 +93,6 @@
8.5.819.0
- 3.5
diff --git a/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/SpringContextTest.java b/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..956d5279a3
--- /dev/null
+++ b/persistence-modules/spring-hibernate-3/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.baeldung.spring.PersistenceConfig;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.support.AnnotationConfigContextLoader;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/persistence-modules/spring-hibernate-5/pom.xml b/persistence-modules/spring-hibernate-5/pom.xml
index 16e55cb0c0..e27775c76f 100644
--- a/persistence-modules/spring-hibernate-5/pom.xml
+++ b/persistence-modules/spring-hibernate-5/pom.xml
@@ -146,7 +146,6 @@
21.0
- 3.5
diff --git a/persistence-modules/spring-hibernate-5/src/test/java/org/baeldung/SpringContextTest.java b/persistence-modules/spring-hibernate-5/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..6815ebf304
--- /dev/null
+++ b/persistence-modules/spring-hibernate-5/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,18 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.support.AnnotationConfigContextLoader;
+
+import com.baeldung.spring.PersistenceConfig;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/persistence-modules/spring-hibernate4/README.md b/persistence-modules/spring-hibernate4/README.md
index 6f8d83aa9d..426944c149 100644
--- a/persistence-modules/spring-hibernate4/README.md
+++ b/persistence-modules/spring-hibernate4/README.md
@@ -9,7 +9,6 @@
- [Stored Procedures with Hibernate](http://www.baeldung.com/stored-procedures-with-hibernate-tutorial)
- [Hibernate: save, persist, update, merge, saveOrUpdate](http://www.baeldung.com/hibernate-save-persist-update-merge-saveorupdate)
- [Eager/Lazy Loading In Hibernate](http://www.baeldung.com/hibernate-lazy-eager-loading)
-- [Hibernate One to Many Annotation Tutorial](http://www.baeldung.com/hibernate-one-to-many)
- [The DAO with Spring and Hibernate](http://www.baeldung.com/persistence-layer-with-spring-and-hibernate)
### Quick Start
diff --git a/persistence-modules/spring-hibernate4/pom.xml b/persistence-modules/spring-hibernate4/pom.xml
index 4289c9c3d5..c22342a34a 100644
--- a/persistence-modules/spring-hibernate4/pom.xml
+++ b/persistence-modules/spring-hibernate4/pom.xml
@@ -7,10 +7,10 @@
spring-hibernate4
+ parent-spring-4com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
- ../../
+ 0.0.1-SNAPSHOT
+ ../../parent-spring-4
@@ -167,7 +167,6 @@
19.0
- 3.54.4.14.5
@@ -176,7 +175,6 @@
2.7
- 1.6.1
diff --git a/persistence-modules/spring-hibernate4/src/test/java/org/baeldung/SpringContextTest.java b/persistence-modules/spring-hibernate4/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..6815ebf304
--- /dev/null
+++ b/persistence-modules/spring-hibernate4/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,18 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.support.AnnotationConfigContextLoader;
+
+import com.baeldung.spring.PersistenceConfig;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = { PersistenceConfig.class }, loader = AnnotationConfigContextLoader.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/persistence-modules/spring-jpa/pom.xml b/persistence-modules/spring-jpa/pom.xml
index 0fdffad8db..0961cabaff 100644
--- a/persistence-modules/spring-jpa/pom.xml
+++ b/persistence-modules/spring-jpa/pom.xml
@@ -174,11 +174,7 @@
21.0
- 3.53.8.0
-
-
- 2.6
\ No newline at end of file
diff --git a/persistence-modules/spring-jpa/src/test/java/com/baeldung/SpringContextTest.java b/persistence-modules/spring-jpa/src/test/java/com/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..291e49d0c4
--- /dev/null
+++ b/persistence-modules/spring-jpa/src/test/java/com/baeldung/SpringContextTest.java
@@ -0,0 +1,21 @@
+package com.baeldung;
+
+import org.baeldung.config.PersistenceJPAConfigL2Cache;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.support.AnnotationConfigContextLoader;
+import org.springframework.test.context.web.WebAppConfiguration;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = { PersistenceJPAConfigL2Cache.class }, loader = AnnotationConfigContextLoader.class)
+@WebAppConfiguration
+@DirtiesContext
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/persistence-modules/spring-persistence-simple/pom.xml b/persistence-modules/spring-persistence-simple/pom.xml
index 1afacab164..d0b3f5fe29 100644
--- a/persistence-modules/spring-persistence-simple/pom.xml
+++ b/persistence-modules/spring-persistence-simple/pom.xml
@@ -147,7 +147,6 @@
21.0
- 3.53.8.0
diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java
index 9fae34d99e..e202e45b32 100644
--- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java
+++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/config/PersistenceJPAConfig.java
@@ -39,7 +39,7 @@ public class PersistenceJPAConfig {
// beans
@Bean
- public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
+ public LocalContainerEntityManagerFactoryBean entityManagerFactoryBean() {
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
em.setPackagesToScan(new String[] { "com.baeldung.persistence.model" });
diff --git a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/EmployeeDAO.java b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/EmployeeDAO.java
index 9ba4ebdb6d..eef085f386 100644
--- a/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/EmployeeDAO.java
+++ b/persistence-modules/spring-persistence-simple/src/main/java/com/baeldung/jdbc/EmployeeDAO.java
@@ -16,6 +16,7 @@ import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
+import org.springframework.jdbc.core.simple.SimpleJdbcCall;
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
import org.springframework.stereotype.Repository;
@@ -27,6 +28,8 @@ public class EmployeeDAO {
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
private SimpleJdbcInsert simpleJdbcInsert;
+
+ private SimpleJdbcCall simpleJdbcCall;
@Autowired
public void setDataSource(final DataSource dataSource) {
@@ -36,7 +39,9 @@ public class EmployeeDAO {
namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
simpleJdbcInsert = new SimpleJdbcInsert(dataSource).withTableName("EMPLOYEE");
-
+
+ // Commented as the database is H2, change the database and create procedure READ_EMPLOYEE before calling getEmployeeUsingSimpleJdbcCall
+ //simpleJdbcCall = new SimpleJdbcCall(dataSource).withProcedureName("READ_EMPLOYEE");
}
public int getCountOfEmployees() {
@@ -110,4 +115,15 @@ public class EmployeeDAO {
final int[] updateCounts = namedParameterJdbcTemplate.batchUpdate("INSERT INTO EMPLOYEE VALUES (:id, :firstName, :lastName, :address)", batch);
return updateCounts;
}
+
+ public Employee getEmployeeUsingSimpleJdbcCall(int id) {
+ SqlParameterSource in = new MapSqlParameterSource().addValue("in_id", id);
+ Map out = simpleJdbcCall.execute(in);
+
+ Employee emp = new Employee();
+ emp.setFirstName((String) out.get("FIRST_NAME"));
+ emp.setLastName((String) out.get("LAST_NAME"));
+
+ return emp;
+ }
}
diff --git a/pom.xml b/pom.xml
index 185c0a4015..21a42f89d6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,18 +1,18 @@
+ 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">
4.0.0com.baeldungparent-modules1.0.0-SNAPSHOT
- parent-modules
+ parent-modulespom
-
- quarkus
-
+
+ quarkus
+
@@ -57,11 +57,11 @@
test
- org.junit.jupiter
- junit-jupiter-api
+ org.junit.jupiter
+ junit-jupiter-api${junit-jupiter.version}test
-
+
org.hamcresthamcrest-core
@@ -123,22 +123,22 @@
-
- org.junit.platform
- junit-platform-surefire-provider
- ${junit-platform.version}
-
-
- org.junit.jupiter
- junit-jupiter-engine
- ${junit-jupiter.version}
-
-
- org.junit.vintage
- junit-vintage-engine
- ${junit-jupiter.version}
-
-
+
+ org.junit.platform
+ junit-platform-surefire-provider
+ ${junit-platform.version}
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ ${junit-jupiter.version}
+
+
+ org.junit.vintage
+ junit-vintage-engine
+ ${junit-jupiter.version}
+
+ org.apache.maven.plugins
@@ -312,6 +312,10 @@
3true
+
+ SpringContextTest
+ **/*UnitTest
+ **/*IntegrationTest.java**/*IntTest.java
@@ -328,62 +332,62 @@
parent-boot-1
- parent-boot-2
- parent-spring-4
- parent-spring-5
- parent-java
- parent-kotlin
-
- akka-streams
- algorithms-genetic
- algorithms-miscellaneous-1
- algorithms-miscellaneous-2
- algorithms-miscellaneous-3
- algorithms-sorting
- animal-sniffer-mvn-plugin
- annotations
- antlr
- apache-avro
- apache-bval
- apache-curator
- apache-cxf
- apache-fop
- apache-geode
- apache-meecrowave
- apache-opennlp
- apache-poi
- apache-pulsar
- apache-shiro
- apache-solrj
- apache-spark
- apache-thrift
- apache-tika
- apache-velocity
- apache-zookeeper
- asciidoctor
- asm
- atomix
- autovalue
- aws
- aws-lambda
- axon
- azure
+ parent-boot-2
+ parent-spring-4
+ parent-spring-5
+ parent-java
+ parent-kotlin
+
+ akka-streams
+ algorithms-genetic
+ algorithms-miscellaneous-1
+ algorithms-miscellaneous-2
+ algorithms-miscellaneous-3
+ algorithms-sorting
+ animal-sniffer-mvn-plugin
+ annotations
+ antlr
+ apache-avro
+ apache-bval
+ apache-curator
+ apache-cxf
+ apache-fop
+ apache-geode
+ apache-meecrowave
+ apache-opennlp
+ apache-poi
+ apache-pulsar
+ apache-shiro
+ apache-solrj
+ apache-spark
+ apache-thrift
+ apache-tika
+ apache-velocity
+ apache-zookeeper
+ asciidoctor
+ asm
+ atomix
+ autovalue
+ aws
+ aws-lambda
+ axon
+ azure
- blade
+ blade
- bootique
+ bootique
- cas
- cdi
- checker-plugin
- core-groovy
- core-groovy-2
- core-groovy-collections
-
-
-
- core-java-modules/core-java-8
- core-java-modules/core-java-8-2
+ cas
+ cdi
+ checker-plugin
+ core-groovy
+ core-groovy-2
+ core-groovy-collections
+
+
+
+ core-java-modules/core-java-8
+ core-java-modules/core-java-8-2core-java-modules/core-java-lambdas
@@ -461,10 +465,11 @@
java-litejava-numbers
+ java-numbers-2java-rmijava-spijava-streams
- java-streams-2
+
java-stringsjava-strings-2java-vavr-stream
@@ -475,83 +480,83 @@
jaxb
- jee-7-security
- jersey
- JGit
- jgroups
- jhipster
- jhipster-5
- jib
- jjwt
- jmeter
- jmh
- jni
- jooby
- jsf
- json
- json-path
- jsoup
- jta
+ jee-7-security
+ jersey
+ JGit
+ jgroups
+ jhipster-5
+ jib
+ jjwt
+ jmeter
+ jmh
+ jni
+ jooby
+ jsf
+ json
+ json-path
+ jsoup
+ jta
-
- kotlin-libraries
- kotlin-libraries-2
+
+ kotlin-libraries
+ kotlin-libraries-2
-
- libraries
- libraries-2
- libraries-data
- libraries-apache-commons
- libraries-primitive
- libraries-security
- libraries-server
- linkrest
- logging-modules
- lombok
- lucene
+
+ libraries
+ libraries-2
+ libraries-data
+ libraries-apache-commons
+ libraries-primitive
+ libraries-security
+ libraries-server
+ libraries-http
+ libraries-io
+ linkrest
+ logging-modules
+ lombok
+ lucene
- mapstruct
- maven
- maven-archetype
-
- maven-polyglot/maven-polyglot-json-extension
-
- mesos-marathon
- metrics
-
- microprofile
- msf4j
-
- mustache
- mybatis
+ mapstruct
+ maven
+ maven-archetype
+
+ maven-polyglot/maven-polyglot-json-extension
+
+ mesos-marathon
+ metrics
+
+ microprofile
+ msf4j
+
+ mustache
+ mybatis
- optaplanner
- orika
- osgi
+ optaplanner
+ orika
+ osgi
- patterns
- pdf
- performance-tests
-
- protobuffer
+ patterns
+ pdf
+ performance-tests
+
+ protobuffer
- persistence-modules
- quarkus
+ persistence-modules
+ quarkus
- rabbitmq
-
- ratpack
- reactor-core
- rest-with-spark-java
- resteasy
- restx
-
- rule-engines
+ rabbitmq
+
+ ratpack
+ reactor-core
+ resteasy
+ restx
+
+ rule-enginesrsocket
- rxjava
- rxjava-2
- software-security/sql-injection-samples
+ rxjava
+ rxjava-2
+ software-security/sql-injection-samplestensorflow-javaspring-boot-flowable
@@ -561,236 +566,239 @@
-
- default-second
-
-
+
+ default-second
+
+
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${maven-surefire-plugin.version}
-
- 3
- true
-
- **/*IntegrationTest.java
- **/*IntTest.java
- **/*LongRunningUnitTest.java
- **/*ManualTest.java
- **/*JdbcTest.java
- **/*LiveTest.java
-
-
-
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${maven-surefire-plugin.version}
+
+ 3
+ true
+
+ SpringContextTest
+ **/*UnitTest
+
+
+ **/*IntegrationTest.java
+ **/*IntTest.java
+ **/*LongRunningUnitTest.java
+ **/*ManualTest.java
+ **/*JdbcTest.java
+ **/*LiveTest.java
+
+
+
-
-
+
+
-
- parent-boot-1
- parent-boot-2
- parent-spring-4
- parent-spring-5
- parent-java
- parent-kotlin
+
+ parent-boot-1
+ parent-boot-2
+ parent-spring-4
+ parent-spring-5
+ parent-java
+ parent-kotlin
- saas
- spark-java
+ saas
+ spark-java
- spring-4
+ spring-4
- spring-5
- spring-5-webflux
- spring-5-data-reactive
- spring-5-mvc
- spring-5-reactive
- spring-5-reactive-client
- spring-5-reactive-oauth
- spring-5-reactive-security
- spring-5-security
- spring-5-security-oauth
- spring-5-security-cognito
+ spring-5
+ spring-5-webflux
+ spring-5-data-reactive
+ spring-5-mvc
+ spring-5-reactive
+ spring-5-reactive-client
+ spring-5-reactive-oauth
+ spring-5-reactive-security
+ spring-5-security
+ spring-5-security-oauth
+ spring-5-security-cognito
- spring-activiti
- spring-akka
- spring-all
- spring-amqp
- spring-amqp-simple
- spring-aop
- spring-apache-camel
- spring-batch
- spring-bom
+ spring-activiti
+ spring-akka
+ spring-all
+ spring-amqp
+ spring-amqp-simple
+ spring-aop
+ spring-apache-camel
+ spring-batch
+ spring-bom
- spring-boot
- spring-boot-admin
- spring-boot-angular
- spring-boot-angular-ecommerce
- spring-boot-autoconfiguration
- spring-boot-bootstrap
- spring-boot-camel
-
- spring-boot-client
+ spring-boot
+ spring-boot-admin
+ spring-boot-angular
+ spring-boot-angular-ecommerce
+ spring-boot-autoconfiguration
+ spring-boot-bootstrap
+ spring-boot-camel
+
+ spring-boot-client
- spring-boot-crud
- spring-boot-ctx-fluent
- spring-boot-custom-starter
- spring-boot-disable-console-logging
-
- spring-boot-jasypt
- spring-boot-keycloak
- spring-boot-logging-log4j2
- spring-boot-mvc
- spring-boot-mvc-birt
- spring-boot-ops
- spring-boot-ops-2
- spring-boot-rest
- spring-boot-data
- spring-boot-property-exp
- spring-boot-security
- spring-boot-testing
- spring-boot-vue
- spring-boot-libraries
+ spring-boot-crud
+ spring-boot-ctx-fluent
+ spring-boot-custom-starter
+ spring-boot-disable-console-logging
+
+ spring-boot-jasypt
+ spring-boot-keycloak
+ spring-boot-kotlin
+ spring-boot-logging-log4j2
+ spring-boot-mvc
+ spring-boot-mvc-birt
+ spring-boot-ops
+ spring-boot-ops-2
+ spring-boot-rest
+ spring-boot-data
+ spring-boot-parent
+ spring-boot-property-exp
+ spring-boot-security
+ spring-boot-testing
+ spring-boot-vue
+ spring-boot-libraries
- spring-cloud
- spring-cloud-bus
-
- spring-cloud-data-flow
+ spring-cloud
+ spring-cloud-bus
+
+ spring-cloud-data-flow
- spring-core
- spring-cucumber
+ spring-core
+ spring-core-2
+ spring-cucumber
- spring-data-rest
- spring-data-rest-querydsl
- spring-dispatcher-servlet
- spring-drools
+ spring-data-rest
+ spring-data-rest-querydsl
+ spring-dispatcher-servlet
+ spring-drools
- spring-ehcache
- spring-ejb
- spring-exceptions
+ spring-ehcache
+ spring-ejb
+ spring-exceptions
- spring-freemarker
+ spring-freemarker
- spring-groovy
+ spring-groovy
- spring-integration
+ spring-integration
- spring-jenkins-pipeline
- spring-jersey
- spring-jinq
- spring-jms
- spring-jooq
+ spring-jenkins-pipeline
+ spring-jersey
+ spring-jinq
+ spring-jms
+ spring-jooq
- spring-kafka
- spring-katharsis
+ spring-kafka
+ spring-katharsis
- spring-ldap
+ spring-ldap
- spring-mobile
- spring-mockito
- spring-mvc-forms-jsp
- spring-mvc-forms-thymeleaf
- spring-mvc-java
- spring-mvc-kotlin
- spring-mvc-simple
- spring-mvc-simple-2
- spring-mvc-velocity
- spring-mvc-webflow
- spring-mvc-xml
+ spring-mobile
+ spring-mockito
+ spring-mvc-forms-jsp
+ spring-mvc-forms-thymeleaf
+ spring-mvc-java
+ spring-mvc-kotlin
+ spring-mvc-simple
+ spring-mvc-simple-2
+ spring-mvc-velocity
+ spring-mvc-webflow
+ spring-mvc-xml
- spring-protobuf
-
+ spring-protobuf
+
- spring-quartz
+ spring-quartz
- spring-reactive-kotlin
- spring-reactor
- spring-remoting
- spring-rest
- spring-rest-angular
- spring-rest-full
- spring-rest-hal-browser
- spring-rest-query-language
- spring-rest-shell
- spring-rest-simple
- spring-resttemplate
- spring-roo
- spring-security-acl
- spring-security-angular/server
- spring-security-cache-control
+ spring-reactive-kotlin
+ spring-reactor
+ spring-remoting
+ spring-rest
+ spring-rest-angular
+ spring-rest-full
+ spring-rest-hal-browser
+ spring-rest-query-language
+ spring-rest-shell
+ spring-rest-simple
+ spring-resttemplate
+ spring-roo
+ spring-security-acl
+ spring-security-angular/server
+ spring-security-cache-control
- spring-security-client
+ spring-security-client
- spring-security-core
- spring-security-mvc-boot
- spring-security-mvc-custom
- spring-security-mvc-digest-auth
+ spring-security-core
+ spring-security-mvc-boot
+ spring-security-mvc-custom
+ spring-security-mvc-digest-authspring-security-mvc-jsonview
- spring-security-mvc-ldap
- spring-security-mvc-login
- spring-security-mvc-persisted-remember-me
- spring-security-mvc-session
- spring-security-mvc-socket
- spring-security-openid
-
- spring-security-rest
- spring-security-rest-basic-auth
- spring-security-rest-custom
- spring-security-sso
- spring-security-stormpath
- spring-security-thymeleaf
- spring-security-x509
- spring-session
- spring-sleuth
- spring-soap
- spring-social-login
- spring-spel
- spring-state-machine
- spring-static-resources
- spring-swagger-codegen
+ spring-security-mvc-ldap
+ spring-security-mvc-login
+ spring-security-mvc-persisted-remember-me
+ spring-security-mvc-session
+ spring-security-mvc-socket
+ spring-security-openid
+
+ spring-security-rest
+ spring-security-rest-basic-auth
+ spring-security-rest-custom
+ spring-security-sso
+ spring-security-stormpath
+ spring-security-thymeleaf
+ spring-security-x509
+ spring-session
+ spring-sleuth
+ spring-soap
+ spring-social-login
+ spring-spel
+ spring-state-machine
+ spring-static-resources
+ spring-swagger-codegen
- spring-thymeleaf
+ spring-thymeleaf
- spring-userservice
+ spring-vault
+ spring-vertx
- spring-vault
- spring-vertx
+ spring-webflux-amqp
- spring-webflux-amqp
+ spring-zuul
- spring-zuul
+ static-analysis
+ stripe
+ structurizr
+ struts-2
- static-analysis
- stripe
- structurizr
- struts-2
+ testing-modules
- testing-modules
+ twilio
+ Twitter4J
- twilio
- Twitter4J
+ undertow
- undertow
+ vertx
+ vertx-and-rxjava
+ video-tutorials
+ vraptor
- vavr
- vertx
- vertx-and-rxjava
- video-tutorials
- vraptor
+ wicket
- wicket
-
- xml
- xmlunit-2
- xstream
+ xml
+ xstreamtensorflow-javaspring-boot-flowablespring-security-kerberos
-
+
-
+
spring-context
@@ -835,6 +843,7 @@
spring-boot-camelspring-boot-clientspring-boot-custom-starter
+ spring-boot-digreeter-spring-boot-autoconfiguregreeter-spring-boot-sample-apppersistence-modules/spring-boot-h2/spring-boot-h2-database
@@ -922,10 +931,10 @@
spring-state-machinespring-swagger-codegen/spring-swagger-codegen-appspring-thymeleaf
- spring-userservicespring-vaultspring-vertxspring-zuul/spring-zuul-foos-resource
+ persistence-modules/hibernate-mappingpersistence-modules/spring-data-dynamodbpersistence-modules/spring-data-eclipselinkpersistence-modules/spring-data-solr
@@ -937,568 +946,572 @@
-
- default-heavy
-
-
+
+ default-heavy
+
+
-
- org.apache.maven.plugins
- maven-surefire-plugin
- ${maven-surefire-plugin.version}
-
- 3
- true
-
- **/*IntegrationTest.java
- **/*IntTest.java
- **/*LongRunningUnitTest.java
- **/*ManualTest.java
- **/*JdbcTest.java
- **/*LiveTest.java
-
-
-
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${maven-surefire-plugin.version}
+
+ 3
+ true
+
+ SpringContextTest
+ **/*UnitTest
+
+
+ **/*IntegrationTest.java
+ **/*IntTest.java
+ **/*LongRunningUnitTest.java
+ **/*ManualTest.java
+ **/*JdbcTest.java
+ **/*LiveTest.java
+
+
+
-
-
+
+
-
- parent-boot-1
- parent-boot-2
- parent-spring-4
- parent-spring-5
- parent-java
- parent-kotlin
+
+ parent-boot-1
+ parent-boot-2
+ parent-spring-4
+ parent-spring-5
+ parent-java
+ parent-kotlin
- core-java-modules/core-java-concurrency-advanced
- core-kotlin
- core-kotlin-2
- core-kotlin-io
+ core-java-modules/core-java-concurrency-advanced
+ core-kotlin
+ core-kotlin-2
+ core-kotlin-io
- jenkins/hello-world
- jws
+ jenkins/hello-world
+ jhipster
+ jws
- libraries
+ libraries
+ persistence-modules/hibernate5
+ persistence-modules/hibernate-mapping
+ persistence-modules/java-jpa
+ persistence-modules/java-mongodb
+ persistence-modules/jnosql
- persistence-modules/hibernate5
- persistence-modules/hibernate-mapping
- persistence-modules/java-jpa
- persistence-modules/java-mongodb
- persistence-modules/jnosql
+ vaadin
+ vavr
+
+
- vaadin
-
-
+
+ integration-lite-first
-
- integration-lite-first
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ **/*ManualTest.java
+ **/*LiveTest.java
+
+
+ **/*IntegrationTest.java
+ **/*IntTest.java
+
+
+
+
+
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- **/*ManualTest.java
- **/*LiveTest.java
-
-
- **/*IntegrationTest.java
- **/*IntTest.java
-
-
-
-
-
+
+ parent-boot-1
+ parent-boot-2
+ parent-spring-4
+ parent-spring-5
+ parent-java
+ parent-kotlin
+
+ akka-streams
+ algorithms-genetic
+ algorithms-miscellaneous-1
+ algorithms-miscellaneous-2
+ algorithms-miscellaneous-3
+ algorithms-sorting
+ animal-sniffer-mvn-plugin
+ annotations
+ antlr
+ apache-avro
+ apache-bval
+ apache-curator
+ apache-cxf
+ apache-fop
+ apache-geode
+ apache-meecrowave
+ apache-opennlp
+ apache-poi
+ apache-pulsar
+ apache-shiro
+ apache-solrj
+ apache-spark
+ apache-thrift
+ apache-tika
+ apache-velocity
+ apache-zookeeper
+ asciidoctor
+ asm
+ atomix
+ autovalue
+ aws
+ aws-lambda
+ axon
+ azure
-
- parent-boot-1
- parent-boot-2
- parent-spring-4
- parent-spring-5
- parent-java
- parent-kotlin
-
- akka-streams
- algorithms-genetic
- algorithms-miscellaneous-1
- algorithms-miscellaneous-2
- algorithms-miscellaneous-3
- algorithms-sorting
- animal-sniffer-mvn-plugin
- annotations
- antlr
- apache-avro
- apache-bval
- apache-curator
- apache-cxf
- apache-fop
- apache-geode
- apache-meecrowave
- apache-opennlp
- apache-poi
- apache-pulsar
- apache-shiro
- apache-solrj
- apache-spark
- apache-thrift
- apache-tika
- apache-velocity
- apache-zookeeper
- asciidoctor
- asm
- atomix
- autovalue
- aws
- aws-lambda
- axon
- azure
+ bootique
- bootique
+ cas
+ cdi
+ checker-plugin
+ core-groovy
+ core-groovy-2
+ core-groovy-collections
+
+
+ core-java-modules/core-java-8
+ core-java-modules/core-java-8-2
+
+
+ core-java-modules/core-java-arrays
+ core-java-modules/core-java-collections
+ core-java-modules/core-java-collections-list
+ core-java-modules/core-java-collections-list-2
+ core-java-modules/core-java-collections-array-list
+ core-java-modules/core-java-collections-set
+ core-java-modules/core-java-concurrency-basic
+ core-java-modules/core-java-concurrency-collections
+ core-java-modules/core-java-io
+ core-java-modules/core-java-nio
+ core-java-modules/core-java-security
+ core-java-modules/core-java-lang-syntax
+ core-java-modules/core-java-lang
+ core-java-modules/core-java-lang-oop
+ core-java-modules/core-java-lang-oop-2
+ core-java-modules
+ core-java-modules/core-java-networking
+ core-java-modules/core-java-perf
+ core-java-modules/core-java-sun
+ core-scala
+ couchbase
+ custom-pmd
- cas
- cdi
- checker-plugin
- core-groovy
- core-groovy-2
- core-groovy-collections
-
-
- core-java-modules/core-java-8
- core-java-modules/core-java-8-2
-
-
- core-java-modules/core-java-arrays
- core-java-modules/core-java-collections
- core-java-modules/core-java-collections-list
- core-java-modules/core-java-collections-list-2
- core-java-modules/core-java-collections-array-list
- core-java-modules/core-java-collections-set
- core-java-modules/core-java-concurrency-basic
- core-java-modules/core-java-concurrency-collections
- core-java-modules/core-java-io
- core-java-modules/core-java-nio
- core-java-modules/core-java-security
- core-java-modules/core-java-lang-syntax
- core-java-modules/core-java-lang
- core-java-modules/core-java-lang-oop
- core-java-modules/core-java-lang-oop-2
- core-java-modules
- core-java-modules/core-java-networking
- core-java-modules/core-java-perf
- core-java-modules/core-java-sun
- core-scala
- couchbase
- custom-pmd
+ dagger
+ data-structures
+ ddd
+ deeplearning4j
+ disruptor
+ dozer
+ drools
+ dubbo
- dagger
- data-structures
- ddd
- deeplearning4j
- disruptor
- dozer
- drools
- dubbo
+ ethereum
- ethereum
+ feign
+ flyway-cdi-extension
- feign
- flyway-cdi-extension
+ geotools
+ google-cloud
+ google-web-toolkit
+
+
+ graphql/graphql-java
+ grpc
+ gson
+ guava
+ guava-collections
+ guava-modules
+
+ guice
- geotools
- google-cloud
- google-web-toolkit
-
-
- graphql/graphql-java
- grpc
- gson
- guava
- guava-collections
- guava-modules
-
- guice
+ hazelcast
+ helidon
+ httpclient
+ httpclient-simple
+ hystrix
- hazelcast
- helidon
- httpclient
- httpclient-simple
- hystrix
+ image-processing
+ immutables
- image-processing
- immutables
-
- jackson
- jackson-2
- jackson-simple
- java-collections-conversions
- java-collections-maps
- java-collections-maps-2
-
- java-ee-8-security-api
- java-lite
- java-numbers
- java-rmi
- java-spi
- java-streams
- java-streams-2
- java-strings
- java-strings-2
- java-vavr-stream
- java-websocket
- javafx
- javax-servlets
- javaxval
- jaxb
-
+ java-ee-8-security-api
+ java-lite
+ java-numbers
+ java-numbers-2
+ java-rmi
+ java-spi
+ java-streams
+
+ java-strings
+ java-strings-2
+ java-vavr-stream
+ java-websocket
+ javafx
+ javax-servlets
+ javaxval
+ jaxb
+
- jee-7-security
- jersey
- JGit
- jgroups
- jhipster
- jhipster-5
- jib
- jjwt
- jmeter
- jmh
- jni
- jooby
- jsf
- json
- json-path
- jsoup
- jta
+ jee-7-security
+ jersey
+ JGit
+ jgroups
+ jhipster-5
+ jib
+ jjwt
+ jmeter
+ jmh
+ jni
+ jooby
+ jsf
+ json
+ json-path
+ jsoup
+ jta
-
- kotlin-libraries
+
+ kotlin-libraries
-
- libraries
- libraries-data
- libraries-apache-commons
- libraries-security
- libraries-server
- linkrest
- logging-modules
- lombok
- lucene
+
+ libraries
+ libraries-data
+ libraries-apache-commons
+ libraries-security
+ libraries-server
+ libraries-http
+ linkrest
+ logging-modules
+ lombok
+ lucene
- mapstruct
- maven
-
- maven-archetype
-
- maven-polyglot/maven-polyglot-json-extension
-
- mesos-marathon
- metrics
-
- microprofile
- msf4j
-
- mustache
- mybatis
+ mapstruct
+ maven
+
+ maven-archetype
+
+ maven-polyglot/maven-polyglot-json-extension
+
+ mesos-marathon
+ metrics
+
+ microprofile
+ msf4j
+
+ mustache
+ mybatis
- optaplanner
- orika
- osgi
+ optaplanner
+ orika
+ osgi
- patterns
- pdf
- performance-tests
-
- protobuffer
+ patterns
+ pdf
+ performance-tests
+
+ protobuffer
- persistence-modules
+ persistence-modules
- rabbitmq
-
- ratpack
- reactor-core
- rest-with-spark-java
- resteasy
- restx
-
- rule-engines
- rsocket
- rxjava
- rxjava-2
+ rabbitmq
+
+ ratpack
+ reactor-core
+ resteasy
+ restx
+
+ rule-engines
+ rsocket
+ rxjava
+ rxjava-2
-
+
-
+
-
- integration-lite-second
+
+ integration-lite-second
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- **/*ManualTest.java
- **/*LiveTest.java
-
-
- **/*IntegrationTest.java
- **/*IntTest.java
-
-
-
-
-
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ **/*ManualTest.java
+ **/*LiveTest.java
+
+
+ **/*IntegrationTest.java
+ **/*IntTest.java
+
+
+
+
+
-
- parent-boot-1
- parent-boot-2
- parent-spring-4
- parent-spring-5
- parent-java
- parent-kotlin
+
+ parent-boot-1
+ parent-boot-2
+ parent-spring-4
+ parent-spring-5
+ parent-java
+ parent-kotlin
- saas
- spark-java
+ saas
+ spark-java
- spring-4
+ spring-4
- spring-5
- spring-5-data-reactive
- spring-5-mvc
- spring-5-reactive
- spring-5-reactive-client
- spring-5-reactive-oauth
- spring-5-reactive-security
- spring-5-security
- spring-5-security-oauth
- spring-5-security-cognito
- spring-activiti
- spring-akka
- spring-all
- spring-amqp
- spring-amqp-simple
- spring-aop
- spring-apache-camel
- spring-batch
- spring-bom
+ spring-5
+ spring-5-data-reactive
+ spring-5-mvc
+ spring-5-reactive
+ spring-5-reactive-client
+ spring-5-reactive-oauth
+ spring-5-reactive-security
+ spring-5-security
+ spring-5-security-oauth
+ spring-5-security-cognito
+ spring-activiti
+ spring-akka
+ spring-all
+ spring-amqp
+ spring-amqp-simple
+ spring-aop
+ spring-apache-camel
+ spring-batch
+ spring-bom
- spring-boot
- spring-boot-admin
- spring-boot-angular
- spring-boot-angular-ecommerce
- spring-boot-autoconfiguration
- spring-boot-bootstrap
- spring-boot-camel
-
- spring-boot-client
- spring-boot-crud
- spring-boot-ctx-fluent
- spring-boot-custom-starter
- spring-boot-disable-console-logging
-
- spring-boot-jasypt
- spring-boot-keycloak
- spring-boot-logging-log4j2
- spring-boot-mvc
- spring-boot-mvc-birt
- spring-boot-ops
- spring-boot-ops-2
- spring-boot-rest
- spring-boot-data
- spring-boot-property-exp
- spring-boot-security
- spring-boot-vue
+ spring-boot
+ spring-boot-admin
+ spring-boot-angular
+ spring-boot-angular-ecommerce
+ spring-boot-autoconfiguration
+ spring-boot-bootstrap
+ spring-boot-camel
+
+ spring-boot-client
+ spring-boot-crud
+ spring-boot-ctx-fluent
+ spring-boot-custom-starter
+ spring-boot-disable-console-logging
+
+ spring-boot-jasypt
+ spring-boot-keycloak
+ spring-boot-logging-log4j2
+ spring-boot-mvc
+ spring-boot-mvc-birt
+ spring-boot-ops
+ spring-boot-ops-2
+ spring-boot-rest
+ spring-boot-data
+ spring-boot-parent
+ spring-boot-property-exp
+ spring-boot-security
+ spring-boot-vue
- spring-cloud
- spring-cloud-bus
-
- spring-cloud-data-flow
+ spring-cloud
+ spring-cloud-bus
+
+ spring-cloud-data-flow
- spring-core
- spring-cucumber
+ spring-core
+ spring-core-2
+ spring-cucumber
- spring-data-rest
- spring-data-rest-querydsl
- spring-dispatcher-servlet
- spring-drools
+ spring-data-rest
+ spring-data-rest-querydsl
+ spring-dispatcher-servlet
+ spring-droolsspring-ehcache
- spring-ejb
- spring-exceptions
+ spring-ejb
+ spring-exceptions
- spring-freemarker
+ spring-freemarker
- spring-groovy
+ spring-groovy
- spring-integration
+ spring-integration
- spring-jenkins-pipeline
- spring-jersey
- spring-jinq
- spring-jms
- spring-jooq
+ spring-jenkins-pipeline
+ spring-jersey
+ spring-jinq
+ spring-jms
+ spring-jooq
- spring-kafka
- spring-katharsis
+ spring-kafka
+ spring-katharsis
- spring-ldap
+ spring-ldap
- spring-mobile
- spring-mockito
- spring-mvc-forms-jsp
- spring-mvc-forms-thymeleaf
- spring-mvc-java
- spring-mvc-kotlin
- spring-mvc-simple
- spring-mvc-simple-2
- spring-mvc-velocity
- spring-mvc-webflow
- spring-mvc-xml
+ spring-mobile
+ spring-mockito
+ spring-mvc-forms-jsp
+ spring-mvc-forms-thymeleaf
+ spring-mvc-java
+ spring-mvc-kotlin
+ spring-mvc-simple
+ spring-mvc-simple-2
+ spring-mvc-velocity
+ spring-mvc-webflow
+ spring-mvc-xml
- spring-protobuf
-
+ spring-protobuf
+
- spring-quartz
+ spring-quartz
- spring-reactive-kotlin
- spring-reactor
- spring-remoting
- spring-rest
- spring-rest-angular
- spring-rest-full
- spring-rest-hal-browser
- spring-rest-query-language
- spring-rest-shell
- spring-rest-simple
- spring-resttemplate
- spring-roo
+ spring-reactive-kotlin
+ spring-reactor
+ spring-remoting
+ spring-rest
+ spring-rest-angular
+ spring-rest-full
+ spring-rest-hal-browser
+ spring-rest-query-language
+ spring-rest-shell
+ spring-rest-simple
+ spring-resttemplate
+ spring-roo
- spring-security-acl
- spring-security-angular/server
- spring-security-cache-control
+ spring-security-acl
+ spring-security-angular/server
+ spring-security-cache-control
- spring-security-client
+ spring-security-client
- spring-security-core
- spring-security-mvc-boot
- spring-security-mvc-custom
- spring-security-mvc-digest-auth
- spring-security-mvc-ldap
- spring-security-mvc-login
- spring-security-mvc-persisted-remember-me
- spring-security-mvc-session
- spring-security-mvc-socket
- spring-security-openid
-
- spring-security-rest
- spring-security-rest-basic-auth
- spring-security-rest-custom
- spring-security-sso
- spring-security-stormpath
- spring-security-thymeleaf
- spring-security-x509
- spring-session
- spring-sleuth
- spring-soap
- spring-social-login
- spring-spel
- spring-state-machine
- spring-static-resources
- spring-swagger-codegen
+ spring-security-core
+ spring-security-mvc-boot
+ spring-security-mvc-custom
+ spring-security-mvc-digest-auth
+ spring-security-mvc-ldap
+ spring-security-mvc-login
+ spring-security-mvc-persisted-remember-me
+ spring-security-mvc-session
+ spring-security-mvc-socket
+ spring-security-openid
+
+ spring-security-rest
+ spring-security-rest-basic-auth
+ spring-security-rest-custom
+ spring-security-sso
+ spring-security-stormpath
+ spring-security-thymeleaf
+ spring-security-x509
+ spring-session
+ spring-sleuth
+ spring-soap
+ spring-social-login
+ spring-spel
+ spring-state-machine
+ spring-static-resources
+ spring-swagger-codegen
- spring-thymeleaf
+ spring-thymeleaf
- spring-userservice
+ spring-vault
+ spring-vertx
- spring-vault
- spring-vertx
+ spring-webflux-amqp
- spring-webflux-amqp
+ spring-zuul
- spring-zuul
+ static-analysis
+ stripe
+ structurizr
+ struts-2
- static-analysis
- stripe
- structurizr
- struts-2
+ testing-modules
- testing-modules
+ twilio
+ Twitter4J
- twilio
- Twitter4J
+ undertow
- undertow
+ vertx
+ vertx-and-rxjava
+ video-tutorials
+ vraptor
- vavr
- vertx
- vertx-and-rxjava
- video-tutorials
- vraptor
+ wicket
- wicket
+ xml
+ xstream
+
- xml
- xmlunit-2
- xstream
+
-
+
+ integration-heavy
-
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ **/*ManualTest.java
+ **/*LiveTest.java
+
+
+ **/*IntegrationTest.java
+ **/*IntTest.java
+
+
+
+
+
-
- integration-heavy
+
+ parent-boot-1
+ parent-boot-2
+ parent-spring-4
+ parent-spring-5
+ parent-java
+ parent-kotlin
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- **/*ManualTest.java
- **/*LiveTest.java
-
-
- **/*IntegrationTest.java
- **/*IntTest.java
-
-
-
-
-
+ core-java-modules/core-java
+ core-java-modules/core-java-concurrency-advanced
+ core-kotlin
+ core-kotlin-2
-
- parent-boot-1
- parent-boot-2
- parent-spring-4
- parent-spring-5
- parent-java
- parent-kotlin
+ jenkins/hello-world
+ jhipster
+ jws
- core-java-modules/core-java
- core-java-modules/core-java-concurrency-advanced
- core-kotlin
- core-kotlin-2
+ libraries
- jenkins/hello-world
- jws
+ persistence-modules/hibernate5
+ persistence-modules/java-jpa
+ persistence-modules/java-mongodb
+ persistence-modules/jnosql
- libraries
+ vaadin
+ vavr
+
- persistence-modules/hibernate5
- persistence-modules/java-jpa
- persistence-modules/java-mongodb
- persistence-modules/jnosql
-
- vaadin
-
-
-
+
@@ -1532,7 +1545,7 @@
1.1.7
-
+
2.21.03.7.01.6.0
@@ -1546,6 +1559,8 @@
1.6.02.21.02.5
+ 2.6
+ 3.51.43.0.03.1.0
diff --git a/quarkus/README.md b/quarkus/README.md
index 01009eab3e..8116d16cb7 100644
--- a/quarkus/README.md
+++ b/quarkus/README.md
@@ -1,3 +1,3 @@
## Relevant articles:
-- [Guide to QuarkusIO](hhttps://www.baeldung.com/quarkus-io)
+- [Guide to QuarkusIO](https://www.baeldung.com/quarkus-io)
diff --git a/ratpack/README.md b/ratpack/README.md
index 14bc3f6c74..78e2f8ccfc 100644
--- a/ratpack/README.md
+++ b/ratpack/README.md
@@ -6,3 +6,4 @@
- [Ratpack with Hystrix](http://www.baeldung.com/ratpack-hystrix)
- [Ratpack HTTP Client](https://www.baeldung.com/ratpack-http-client)
- [Ratpack with RxJava](https://www.baeldung.com/ratpack-rxjava)
+- [Ratpack with Groovy](https://www.baeldung.com/ratpack-groovy)
diff --git a/ratpack/build.gradle b/ratpack/build.gradle
index 25af3ddb51..c997b4e697 100644
--- a/ratpack/build.gradle
+++ b/ratpack/build.gradle
@@ -14,6 +14,8 @@ if (!JavaVersion.current().java8Compatible) {
apply plugin: "io.ratpack.ratpack-java"
apply plugin: 'java'
+apply plugin: 'groovy'
+apply plugin: 'io.ratpack.ratpack-groovy'
repositories {
jcenter()
diff --git a/ratpack/pom.xml b/ratpack/pom.xml
index 7c145eff91..0df313c05e 100644
--- a/ratpack/pom.xml
+++ b/ratpack/pom.xml
@@ -26,11 +26,21 @@
ratpack-core${ratpack.version}
+
+ org.codehaus.groovy
+ groovy-sql
+ ${groovy.sql.version}
+ io.ratpackratpack-hikari${ratpack.version}
+
+ io.ratpack
+ ratpack-groovy-test
+ ${ratpack.test.latest.version}
+ io.ratpackratpack-hystrix
@@ -91,6 +101,7 @@
4.5.34.4.61.5.12
+ 2.4.15
+ 1.6.1
-
diff --git a/ratpack/src/main/groovy/com/baeldung/Ratpack.groovy b/ratpack/src/main/groovy/com/baeldung/Ratpack.groovy
new file mode 100644
index 0000000000..4d8814b627
--- /dev/null
+++ b/ratpack/src/main/groovy/com/baeldung/Ratpack.groovy
@@ -0,0 +1,76 @@
+package com.baeldung;
+
+@Grab('io.ratpack:ratpack-groovy:1.6.1')
+import static ratpack.groovy.Groovy.ratpack
+
+import com.baeldung.model.User
+import com.google.common.reflect.TypeToken
+import ratpack.exec.Promise
+import ratpack.handling.Context
+import ratpack.jackson.Jackson
+import groovy.sql.Sql
+import java.sql.Connection
+import java.sql.PreparedStatement
+import java.sql.ResultSet
+import ratpack.hikari.HikariModule
+import javax.sql.DataSource;
+
+ratpack {
+ serverConfig { port(5050) }
+ bindings {
+ module(HikariModule) { config ->
+ config.dataSourceClassName = 'org.h2.jdbcx.JdbcDataSource'
+ config.addDataSourceProperty('URL', "jdbc:h2:mem:devDB;INIT=RUNSCRIPT FROM 'classpath:/User.sql'")
+ }
+ }
+
+ handlers {
+
+ get { render 'Hello World from Ratpack with Groovy!!' }
+
+ get("greet/:name") { Context ctx ->
+ render "Hello " + ctx.getPathTokens().get("name") + "!!!"
+ }
+
+ get("data") {
+ render Jackson.json([title: "Mr", name: "Norman", country: "USA"])
+ }
+
+ post("user") {
+ Promise user = parse(Jackson.fromJson(User))
+ user.then { u -> render u.name }
+ }
+
+ get('fetchUserName/:id') { Context ctx ->
+ Connection connection = ctx.get(DataSource.class).getConnection()
+ PreparedStatement queryStatement = connection.prepareStatement("SELECT NAME FROM USER WHERE ID=?")
+ queryStatement.setInt(1, Integer.parseInt(ctx.getPathTokens().get("id")))
+ ResultSet resultSet = queryStatement.executeQuery()
+ resultSet.next()
+ render resultSet.getString(1)
+ }
+
+ get('fetchUsers') {
+ def db = [url:'jdbc:h2:mem:devDB']
+ def sql = Sql.newInstance(db.url, db.user, db.password)
+ def users = sql.rows("SELECT * FROM USER");
+ render(Jackson.json(users))
+ }
+
+ post('addUser') {
+ parse(Jackson.fromJson(User))
+ .then { u ->
+ def db = [url:'jdbc:h2:mem:devDB']
+ Sql sql = Sql.newInstance(db.url, db.user, db.password)
+ sql.executeInsert("INSERT INTO USER VALUES (?,?,?,?)", [
+ u.id,
+ u.title,
+ u.name,
+ u.country
+ ])
+ render "User $u.name inserted"
+ }
+ }
+ }
+}
+
diff --git a/ratpack/src/main/groovy/com/baeldung/RatpackGroovyApp.groovy b/ratpack/src/main/groovy/com/baeldung/RatpackGroovyApp.groovy
new file mode 100644
index 0000000000..95ada25e60
--- /dev/null
+++ b/ratpack/src/main/groovy/com/baeldung/RatpackGroovyApp.groovy
@@ -0,0 +1,12 @@
+package com.baeldung;
+
+public class RatpackGroovyApp {
+
+ public static void main(String[] args) {
+ File file = new File("src/main/groovy/com/baeldung/Ratpack.groovy");
+ def shell = new GroovyShell()
+ shell.evaluate(file)
+ }
+
+}
+
diff --git a/ratpack/src/main/groovy/com/baeldung/model/User.groovy b/ratpack/src/main/groovy/com/baeldung/model/User.groovy
new file mode 100644
index 0000000000..0fe4c6c367
--- /dev/null
+++ b/ratpack/src/main/groovy/com/baeldung/model/User.groovy
@@ -0,0 +1,9 @@
+package com.baeldung.model
+
+class User {
+
+ long id
+ String title
+ String name
+ String country
+}
diff --git a/ratpack/src/main/resources/User.sql b/ratpack/src/main/resources/User.sql
new file mode 100644
index 0000000000..a3e2242283
--- /dev/null
+++ b/ratpack/src/main/resources/User.sql
@@ -0,0 +1,10 @@
+DROP TABLE IF EXISTS USER;
+CREATE TABLE USER (
+ ID BIGINT AUTO_INCREMENT PRIMARY KEY,
+ TITLE VARCHAR(255),
+ NAME VARCHAR(255),
+ COUNTRY VARCHAR(255)
+);
+
+INSERT INTO USER VALUES(1,'Mr','Norman Potter', 'USA');
+INSERT INTO USER VALUES(2,'Miss','Ketty Smith', 'FRANCE');
\ No newline at end of file
diff --git a/ratpack/src/test/groovy/com/baeldung/RatpackGroovySpec.groovy b/ratpack/src/test/groovy/com/baeldung/RatpackGroovySpec.groovy
new file mode 100644
index 0000000000..726d703a06
--- /dev/null
+++ b/ratpack/src/test/groovy/com/baeldung/RatpackGroovySpec.groovy
@@ -0,0 +1,46 @@
+package com.baeldung;
+
+import ratpack.groovy.Groovy
+import ratpack.groovy.test.GroovyRatpackMainApplicationUnderTest;
+import ratpack.test.http.TestHttpClient;
+import ratpack.test.ServerBackedApplicationUnderTest;
+import org.junit.Test;
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import ratpack.test.MainClassApplicationUnderTest
+
+class RatpackGroovySpec {
+
+ ServerBackedApplicationUnderTest ratpackGroovyApp = new MainClassApplicationUnderTest(RatpackGroovyApp.class)
+ @Delegate TestHttpClient client = TestHttpClient.testHttpClient(ratpackGroovyApp)
+
+ @Test
+ void "test if app is started"() {
+ when:
+ get("")
+
+ then:
+ assert response.statusCode == 200
+ assert response.body.text == "Hello World from Ratpack with Groovy!!"
+ }
+
+ @Test
+ void "test greet with name"() {
+ when:
+ get("greet/Lewis")
+
+ then:
+ assert response.statusCode == 200
+ assert response.body.text == "Hello Lewis!!!"
+ }
+
+ @Test
+ void "test fetchUsers"() {
+ when:
+ get("fetchUsers")
+
+ then:
+ assert response.statusCode == 200
+ assert response.body.text == '[{"ID":1,"TITLE":"Mr","NAME":"Norman Potter","COUNTRY":"USA"},{"ID":2,"TITLE":"Miss","NAME":"Ketty Smith","COUNTRY":"FRANCE"}]'
+ }
+}
diff --git a/rest-with-spark-java/README.md b/rest-with-spark-java/README.md
deleted file mode 100644
index ff12555376..0000000000
--- a/rest-with-spark-java/README.md
+++ /dev/null
@@ -1 +0,0 @@
-## Relevant articles:
diff --git a/rest-with-spark-java/pom.xml b/rest-with-spark-java/pom.xml
deleted file mode 100644
index fc78ac6b86..0000000000
--- a/rest-with-spark-java/pom.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
- 4.0.0
- com.baeldung
- rest-with-spark-java
- 1.0-SNAPSHOT
- rest-with-spark-java
- http://maven.apache.org
-
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
-
-
-
- com.sparkjava
- spark-core
- ${spark-core.version}
-
-
- com.fasterxml.jackson.core
- jackson-core
- ${jackson.version}
-
-
- com.fasterxml.jackson.core
- jackson-databind
- ${jackson.version}
-
-
-
-
- 2.5.4
-
-
-
diff --git a/rest-with-spark-java/src/main/java/com/baeldung/Router.java b/rest-with-spark-java/src/main/java/com/baeldung/Router.java
deleted file mode 100644
index 3482184e1e..0000000000
--- a/rest-with-spark-java/src/main/java/com/baeldung/Router.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.baeldung;
-
-import static spark.Spark.after;
-import static spark.Spark.before;
-import static spark.Spark.delete;
-import static spark.Spark.get;
-import static spark.Spark.post;
-import static spark.Spark.port;
-
-import com.baeldung.domain.Book;
-import com.baeldung.service.LibraryService;
-
-public class Router {
-
- public static void main( String[] args ){
-
- port(8080);
-
- before((request, response) -> {
-
- //do some filtering stuff
-
- });
-
- after((request, response) -> {
- response.type("application/json");
- });
-
- get("ListOfBooks", (request, response) -> {
- return LibraryService.view();
- });
-
- get("SearchBook/:title", (request, response) -> {
- return LibraryService.view(request.params("title"));
- });
-
- post("AddBook/:title/:author/:publisher", (request, response) -> {
- Book book = new Book();
- book.setTitle(request.params("title"));
- book.setAuthor(request.params("author"));
- book.setPublisher(request.params("publisher"));
- return LibraryService.add(book);
- });
-
- delete("DeleteBook/:title", (request, response) -> {
- return LibraryService.delete(request.params("title"));
- });
-
- }
-}
diff --git a/rest-with-spark-java/src/main/java/com/baeldung/domain/Book.java b/rest-with-spark-java/src/main/java/com/baeldung/domain/Book.java
deleted file mode 100644
index 977d5d9f89..0000000000
--- a/rest-with-spark-java/src/main/java/com/baeldung/domain/Book.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.baeldung.domain;
-
-public class Book {
-
- private String title;
- private String author;
- private String publisher;
-
- public Book() {}
-
- public Book(String title, String author, String publisher) {
- super();
- this.title = title;
- this.author = author;
- this.publisher = publisher;
- }
-
- public String getTitle() {
- return title;
- }
- public void setTitle(String title) {
- this.title = title;
- }
- public String getAuthor() {
- return author;
- }
-
- public void setAuthor(String author) {
- this.author = author;
- }
- public String getPublisher() {
- return publisher;
- }
- public void setPublisher(String publisher) {
- this.publisher = publisher;
- }
-
- protected boolean canEqual(Object other) {
- return other instanceof Book;
- }
-
- @Override
- public boolean equals(Object o) {
- if (o == this) return true;
- if (!(o instanceof Book)) return false;
- Book other = (Book) o;
- if (!other.canEqual((Object)this)) return false;
- if (this.getTitle() == null ? other.getTitle() != null : !this.getTitle().equals(other.getTitle())) return false;
- return true;
- }
-
-}
diff --git a/rest-with-spark-java/src/main/java/com/baeldung/service/LibraryService.java b/rest-with-spark-java/src/main/java/com/baeldung/service/LibraryService.java
deleted file mode 100644
index e4ca4c270c..0000000000
--- a/rest-with-spark-java/src/main/java/com/baeldung/service/LibraryService.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.baeldung.service;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.baeldung.domain.Book;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectWriter;
-
-public class LibraryService {
-
- private static ObjectWriter mapper = new ObjectMapper().writer().withDefaultPrettyPrinter();
- private static Map library = new HashMap();
-
- public static String view() throws JsonProcessingException {
- List books = new ArrayList();
- library.forEach((key, value) -> {
- books.add(value);
- });
- return mapper.writeValueAsString(books);
- }
-
- public static String view(String title) throws JsonProcessingException {
- return mapper.writeValueAsString(library.get(title));
- }
-
- public static String add(Book book) throws JsonProcessingException {
- library.put(book.getTitle(), book);
- return mapper.writeValueAsString(book);
- }
-
- public static String delete(String title) throws JsonProcessingException {
- Book deletedBook = library.remove(title);
- return mapper.writeValueAsString(deletedBook);
- }
-
-}
diff --git a/rest-with-spark-java/src/test/java/com/baeldung/AppLiveTest.java b/rest-with-spark-java/src/test/java/com/baeldung/AppLiveTest.java
deleted file mode 100644
index 9e24879767..0000000000
--- a/rest-with-spark-java/src/test/java/com/baeldung/AppLiveTest.java
+++ /dev/null
@@ -1,148 +0,0 @@
-package com.baeldung;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.baeldung.domain.Book;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class AppLiveTest extends TestCase {
-
- ObjectMapper mapper = new ObjectMapper();
-
- public AppLiveTest( String testName ) {
- super( testName );
- }
-
- public static Test suite() {
- return new TestSuite( AppLiveTest.class );
- }
-
- public void testApp() throws IOException, ClassNotFoundException {
-
- URL url;
- HttpURLConnection conn;
- BufferedReader br;
- String output;
- StringBuffer resp;
- Book book;
- Book temp;
-
- url = new URL("http://localhost:8080/AddBook/Odessy/YannMartel/GreenLeaves");
- conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("POST");
- conn.getContent();
- br = new BufferedReader(new InputStreamReader(
- (conn.getInputStream())));
- resp = new StringBuffer();
-
- while ((output = br.readLine()) != null) {
- resp.append(output);
- }
-
- book = mapper.readValue(resp.toString(), Book.class);
- temp = new Book("Odessy","YannMartel","GreenLeaves");
-
- assertEquals(book, temp);
-
- url = new URL("http://localhost:8080/AddBook/Twilight/StephenieMeyer/LittleBrown");
- conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("POST");
- br = new BufferedReader(new InputStreamReader(
- (conn.getInputStream())));
- resp = new StringBuffer();
-
- while ((output = br.readLine()) != null) {
- resp.append(output);
- }
-
- book = mapper.readValue(resp.toString(), Book.class);
- temp = new Book("Twilight","StephenieMeyer","LittleBrown");
-
- assertEquals(book, temp);
-
- url = new URL("http://localhost:8080/ListOfBooks");
- conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("GET");
- br = new BufferedReader(new InputStreamReader(
- (conn.getInputStream())));
- resp = new StringBuffer();
-
- while ((output = br.readLine()) != null) {
- resp.append(output);
- }
-
- List books = new ArrayList();
-
- books.add(new Book("Odessy","YannMartel","GreenLeaves"));
- books.add(new Book("Twilight","StephenieMeyer","LittleBrown"));
-
- List listOfBooks = mapper.readValue(resp.toString(), new TypeReference>(){});
-
- assertEquals(books, listOfBooks);
-
- url = new URL("http://localhost:8080/SearchBook/Twilight");
- conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("GET");
- br = new BufferedReader(new InputStreamReader(
- (conn.getInputStream())));
- resp = new StringBuffer();
-
- while ((output = br.readLine()) != null) {
- resp.append(output);
- }
-
- book = mapper.readValue(resp.toString(), Book.class);
- temp = new Book("Twilight","StephenieMeyer","LittleBrown");
-
- assertEquals(book, temp);
-
- url = new URL("http://localhost:8080/DeleteBook/Twilight");
- conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("DELETE");
- br = new BufferedReader(new InputStreamReader(
- (conn.getInputStream())));
- resp = new StringBuffer();
-
- while ((output = br.readLine()) != null) {
- resp.append(output);
- }
-
- book = mapper.readValue(resp.toString(), Book.class);
- temp = new Book("Twilight","StephenieMeyer","LittleBrown");
-
- assertEquals(book, temp);
-
- url = new URL("http://localhost:8080/ListOfBooks");
- conn = (HttpURLConnection) url.openConnection();
- conn.setRequestMethod("GET");
- br = new BufferedReader(new InputStreamReader(
- (conn.getInputStream())));
- resp = new StringBuffer();
-
- while ((output = br.readLine()) != null) {
- resp.append(output);
- }
-
- books = new ArrayList();
-
- books.add(new Book("Odessy","YannMartel","GreenLeaves"));
- listOfBooks = mapper.readValue(resp.toString(), new TypeReference>(){});
-
- assertEquals(books, listOfBooks);
-
- conn.disconnect();
-
- }
-
-}
diff --git a/resteasy/pom.xml b/resteasy/pom.xml
index ca4124abca..8aea8077f9 100644
--- a/resteasy/pom.xml
+++ b/resteasy/pom.xml
@@ -143,7 +143,6 @@
3.0.19.Final
- 2.51.6.1
diff --git a/software-security/sql-injection-samples/pom.xml b/software-security/sql-injection-samples/pom.xml
index b12b479614..5c3256319e 100644
--- a/software-security/sql-injection-samples/pom.xml
+++ b/software-security/sql-injection-samples/pom.xml
@@ -16,13 +16,10 @@
-
-
org.springframework.bootspring-boot-starter-jdbc
-
org.apache.derbyderby
@@ -43,18 +40,14 @@
lombokprovided
-
org.springframework.bootspring-boot-starter-data-jpa
-
org.hibernatehibernate-jpamodelgen
-
-
org.springframework.bootspring-boot-devtools
diff --git a/spf4j/README.md b/spf4j/README.md
new file mode 100644
index 0000000000..a39cd01b5e
--- /dev/null
+++ b/spf4j/README.md
@@ -0,0 +1,3 @@
+## Relevant articles:
+
+- [Introduction to SPF4J](https://www.baeldung.com/spf4j)
diff --git a/spf4j/pom.xml b/spf4j/pom.xml
new file mode 100644
index 0000000000..43a8028dc4
--- /dev/null
+++ b/spf4j/pom.xml
@@ -0,0 +1,21 @@
+
+
+ 4.0.0
+ com.baeldung.spf4j
+ spf4j
+ spf4j
+ pom
+
+
+ parent-modules
+ com.baeldung
+ 1.0.0-SNAPSHOT
+
+
+
+ spf4j-core-app
+ spf4j-aspects-app
+
+
+
diff --git a/spf4j/spf4j-aspects-app/pom.xml b/spf4j/spf4j-aspects-app/pom.xml
new file mode 100644
index 0000000000..1c707f4d87
--- /dev/null
+++ b/spf4j/spf4j-aspects-app/pom.xml
@@ -0,0 +1,87 @@
+
+ 4.0.0
+ spf4j-aspects-app
+ 0.0.1-SNAPSHOT
+ jar
+ spf4j-aspects-app
+
+
+ parent-modules
+ com.baeldung
+ 1.0.0-SNAPSHOT
+ ../../
+
+
+
+
+ org.spf4j
+ spf4j-aspects
+ ${spf4j.version}
+
+
+ org.spf4j
+ spf4j-ui
+ ${spf4j.version}
+
+
+ org.slf4j
+ slf4j-api
+ ${org.slf4j.version}
+
+
+
+
+ spf4j-aspects-app
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.0
+
+
+ 1.8
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 3.1.1
+
+
+ copy-dependencies
+ package
+
+ copy-dependencies
+
+
+
+ ${project.build.directory}/dependency-jars/
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ com.baeldung.spf4j.aspects.App
+ true
+ dependency-jars/
+
+
+
+
+
+
+
+
+ UTF-8
+ 8.6.10
+ 1.7.21
+
+
diff --git a/spf4j/spf4j-aspects-app/src/main/java/com/baeldung/spf4j/aspects/App.java b/spf4j/spf4j-aspects-app/src/main/java/com/baeldung/spf4j/aspects/App.java
new file mode 100644
index 0000000000..6d74292c75
--- /dev/null
+++ b/spf4j/spf4j-aspects-app/src/main/java/com/baeldung/spf4j/aspects/App.java
@@ -0,0 +1,28 @@
+package com.baeldung.spf4j.aspects;
+
+import java.util.Random;
+
+import org.spf4j.annotations.PerformanceMonitor;
+
+public class App {
+
+ public static void main(String[] args) throws InterruptedException {
+ Spf4jConfig.initialize();
+ Random random = new Random();
+ for (int i = 0; i < 100; i++) {
+ long numberToCheck = random.nextInt(999_999_999 - 100_000_000 + 1) + 100_000_000;
+ isPrimeNumber(numberToCheck);
+ }
+ System.exit(0);
+ }
+
+ @PerformanceMonitor(warnThresholdMillis = 1, errorThresholdMillis = 100, recorderSource = Spf4jConfig.RecorderSourceForIsPrimeNumber.class)
+ public static boolean isPrimeNumber(long number) {
+ for (long i = 2; i <= number / 2; i++) {
+ if (number % i == 0)
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/spf4j/spf4j-aspects-app/src/main/java/com/baeldung/spf4j/aspects/Spf4jConfig.java b/spf4j/spf4j-aspects-app/src/main/java/com/baeldung/spf4j/aspects/Spf4jConfig.java
new file mode 100644
index 0000000000..a12213f0cd
--- /dev/null
+++ b/spf4j/spf4j-aspects-app/src/main/java/com/baeldung/spf4j/aspects/Spf4jConfig.java
@@ -0,0 +1,37 @@
+package com.baeldung.spf4j.aspects;
+
+import java.io.File;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.spf4j.annotations.RecorderSourceInstance;
+import org.spf4j.perf.MeasurementRecorderSource;
+import org.spf4j.perf.impl.RecorderFactory;
+
+public class Spf4jConfig {
+ private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
+
+ public static void initialize() {
+ String tsDbFile = System.getProperty("user.dir") + File.separator + "spf4j-performance-monitoring.tsdb2";
+ String tsTextFile = System.getProperty("user.dir") + File.separator + "spf4j-performance-monitoring.txt";
+
+ LOGGER.info("\nTime Series DB (TSDB) : {}\nTime Series text file : {}", tsDbFile, tsTextFile);
+ System.setProperty("spf4j.perf.ms.config", "TSDB@" + tsDbFile + "," + "TSDB_TXT@" + tsTextFile);
+ }
+
+ public static final class RecorderSourceForIsPrimeNumber extends RecorderSourceInstance {
+ public static final MeasurementRecorderSource INSTANCE;
+
+ static {
+ Object forWhat = App.class + " isPrimeNumber";
+ String unitOfMeasurement = "ms";
+ int sampleTimeMillis = 1_000;
+ int factor = 10;
+ int lowerMagnitude = 0;
+ int higherMagnitude = 4;
+ int quantasPerMagnitude = 10;
+ INSTANCE = RecorderFactory.createScalableQuantizedRecorderSource(forWhat, unitOfMeasurement,
+ sampleTimeMillis, factor, lowerMagnitude, higherMagnitude, quantasPerMagnitude);
+ }
+ }
+}
diff --git a/spf4j/spf4j-aspects-app/src/main/resources/META-INF/aop.xml b/spf4j/spf4j-aspects-app/src/main/resources/META-INF/aop.xml
new file mode 100644
index 0000000000..1643f5fba9
--- /dev/null
+++ b/spf4j/spf4j-aspects-app/src/main/resources/META-INF/aop.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spf4j/spf4j-aspects-app/src/main/resources/logback.xml b/spf4j/spf4j-aspects-app/src/main/resources/logback.xml
new file mode 100644
index 0000000000..4677fac9bf
--- /dev/null
+++ b/spf4j/spf4j-aspects-app/src/main/resources/logback.xml
@@ -0,0 +1,11 @@
+
+
+
+ [%level] %msg%n
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spf4j/spf4j-core-app/pom.xml b/spf4j/spf4j-core-app/pom.xml
new file mode 100644
index 0000000000..9f490d9f06
--- /dev/null
+++ b/spf4j/spf4j-core-app/pom.xml
@@ -0,0 +1,87 @@
+
+ 4.0.0
+ spf4j-core-app
+ 0.0.1-SNAPSHOT
+ jar
+ spf4j-core-app
+
+
+ parent-modules
+ com.baeldung
+ 1.0.0-SNAPSHOT
+ ../../
+
+
+
+
+ org.spf4j
+ spf4j-core
+ ${spf4j.version}
+
+
+ org.spf4j
+ spf4j-ui
+ ${spf4j.version}
+
+
+ org.slf4j
+ slf4j-api
+ ${org.slf4j.version}
+
+
+
+
+ spf4j-core-app
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.0
+
+
+ 1.8
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+ 3.1.1
+
+
+ copy-dependencies
+ package
+
+ copy-dependencies
+
+
+
+ ${project.build.directory}/dependency-jars/
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ com.baeldung.spf4j.core.App
+ true
+ dependency-jars/
+
+
+
+
+
+
+
+
+ UTF-8
+ 8.6.10
+ 1.7.21
+
+
diff --git a/spf4j/spf4j-core-app/src/main/java/com/baeldung/spf4j/core/App.java b/spf4j/spf4j-core-app/src/main/java/com/baeldung/spf4j/core/App.java
new file mode 100644
index 0000000000..fa107d8e4f
--- /dev/null
+++ b/spf4j/spf4j-core-app/src/main/java/com/baeldung/spf4j/core/App.java
@@ -0,0 +1,34 @@
+package com.baeldung.spf4j.core;
+
+import java.util.Random;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.spf4j.perf.MeasurementRecorder;
+
+public class App {
+ private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
+
+ public static void main(String[] args) throws InterruptedException {
+ Spf4jConfig.initialize();
+ MeasurementRecorder measurementRecorder = Spf4jConfig.getMeasurementRecorder(App.class + " isPrimeNumber");
+ Random random = new Random();
+ for (int i = 0; i < 100; i++) {
+ long numberToCheck = random.nextInt(999_999_999 - 100_000_000 + 1) + 100_000_000;
+ long startTime = System.currentTimeMillis();
+ boolean isPrime = isPrimeNumber(numberToCheck);
+ measurementRecorder.record(System.currentTimeMillis() - startTime);
+ LOGGER.info("{}. {} is prime? {}", i + 1, numberToCheck, isPrime);
+ }
+ System.exit(0);
+ }
+
+ private static boolean isPrimeNumber(long number) {
+ for (long i = 2; i <= number / 2; i++) {
+ if (number % i == 0)
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/spf4j/spf4j-core-app/src/main/java/com/baeldung/spf4j/core/Spf4jConfig.java b/spf4j/spf4j-core-app/src/main/java/com/baeldung/spf4j/core/Spf4jConfig.java
new file mode 100644
index 0000000000..0f806e1576
--- /dev/null
+++ b/spf4j/spf4j-core-app/src/main/java/com/baeldung/spf4j/core/Spf4jConfig.java
@@ -0,0 +1,31 @@
+package com.baeldung.spf4j.core;
+
+import java.io.File;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.spf4j.perf.MeasurementRecorder;
+import org.spf4j.perf.impl.RecorderFactory;
+
+public class Spf4jConfig {
+ private static final Logger LOGGER = LoggerFactory.getLogger(App.class);
+
+ public static void initialize() {
+ String tsDbFile = System.getProperty("user.dir") + File.separator + "spf4j-performance-monitoring.tsdb2";
+ String tsTextFile = System.getProperty("user.dir") + File.separator + "spf4j-performance-monitoring.txt";
+
+ LOGGER.info("\nTime Series DB (TSDB) : {}\nTime Series text file : {}", tsDbFile, tsTextFile);
+ System.setProperty("spf4j.perf.ms.config", "TSDB@" + tsDbFile + "," + "TSDB_TXT@" + tsTextFile);
+ }
+
+ public static MeasurementRecorder getMeasurementRecorder(Object forWhat) {
+ String unitOfMeasurement = "ms";
+ int sampleTimeMillis = 1_000;
+ int factor = 10;
+ int lowerMagnitude = 0;
+ int higherMagnitude = 4;
+ int quantasPerMagnitude = 10;
+
+ return RecorderFactory.createScalableQuantizedRecorder(forWhat, unitOfMeasurement, sampleTimeMillis, factor, lowerMagnitude, higherMagnitude, quantasPerMagnitude);
+ }
+}
diff --git a/spf4j/spf4j-core-app/src/main/resources/logback.xml b/spf4j/spf4j-core-app/src/main/resources/logback.xml
new file mode 100644
index 0000000000..4677fac9bf
--- /dev/null
+++ b/spf4j/spf4j-core-app/src/main/resources/logback.xml
@@ -0,0 +1,11 @@
+
+
+
+ [%level] %msg%n
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-4/src/test/java/org/baeldung/SpringContextTest.java b/spring-4/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..cccdaff0cd
--- /dev/null
+++ b/spring-4/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,20 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+
+import com.baeldung.flips.ApplicationConfig;
+
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = ApplicationConfig.class)
+@WebAppConfiguration
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-5-data-reactive/README.md b/spring-5-data-reactive/README.md
index f8886ac18b..f3205c23bc 100644
--- a/spring-5-data-reactive/README.md
+++ b/spring-5-data-reactive/README.md
@@ -6,3 +6,4 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
### Relevant Articles
- [Reactive Flow with MongoDB, Kotlin, and Spring WebFlux](http://www.baeldung.com/kotlin-mongodb-spring-webflux)
- [Spring Data Reactive Repositories with MongoDB](http://www.baeldung.com/spring-data-mongodb-reactive)
+- [Spring Data MongoDB Tailable Cursors](https://www.baeldung.com/spring-data-mongodb-tailable-cursors)
diff --git a/spring-5-data-reactive/pom.xml b/spring-5-data-reactive/pom.xml
index aa73cf11ae..5372803842 100644
--- a/spring-5-data-reactive/pom.xml
+++ b/spring-5-data-reactive/pom.xml
@@ -1,9 +1,9 @@
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0spring-5-data-reactive
- spring-5-data-reactive
+ spring-5-data-reactivejar
@@ -49,11 +49,11 @@
${kotlin.version}test
-
+ io.reactivex.rxjava2rxjava
-
+
org.springframeworkspring-test
@@ -63,6 +63,49 @@
spring-boot-starter-testtest
+
+ de.flapdoodle.embed
+ de.flapdoodle.embed.mongo
+ test
+
+
+
+ org.springframework.boot
+ spring-boot-starter-webflux
+
+
+
+ org.springframework
+ spring-tx
+ ${spring-tx.version}
+
+
+
+ org.springframework.data
+ spring-data-r2dbc
+ ${spring-data-r2dbc.version}
+
+
+ io.r2dbc
+ r2dbc-h2
+ ${r2dbc-h2.version}
+
+
+ com.h2database
+ h2
+ ${h2.version}
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.apache.httpcomponents
+ httpclient
+ ${httpclient.version}
+
+
@@ -74,7 +117,7 @@
kotlin-maven-plugin${kotlin-maven-plugin.version}
-
+ compile
@@ -118,7 +161,7 @@
-
+ org.apache.maven.pluginsmaven-compiler-plugin
@@ -126,13 +169,13 @@
${java.version}
-
default-compilenone
-
default-testCompile
@@ -157,9 +200,30 @@
+
+
+ spring-snapshots
+ Spring Snapshots
+ https://repo.spring.io/snapshot
+
+ true
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+
+
1.2.401.2.40
+ 5.2.0.M2
+ 1.0.0.M2
+ 0.8.0.M8
+ 4.5.2
+ 1.4.199
diff --git a/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/R2dbcApplication.java b/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/R2dbcApplication.java
new file mode 100644
index 0000000000..557b6ff42a
--- /dev/null
+++ b/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/R2dbcApplication.java
@@ -0,0 +1,15 @@
+package com.baeldung.r2dbc;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+
+@SpringBootApplication
+@ComponentScan(basePackages = "com.baeldung.r2dbc")
+public class R2dbcApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(R2dbcApplication.class, args);
+ }
+
+}
\ No newline at end of file
diff --git a/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/configuration/R2DBCConfiguration.java b/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/configuration/R2DBCConfiguration.java
new file mode 100644
index 0000000000..17eac7fee2
--- /dev/null
+++ b/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/configuration/R2DBCConfiguration.java
@@ -0,0 +1,21 @@
+package com.baeldung.r2dbc.configuration;
+
+import io.r2dbc.h2.H2ConnectionConfiguration;
+import io.r2dbc.h2.H2ConnectionFactory;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration;
+import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;
+
+@Configuration
+//@EnableR2dbcRepositories(basePackages = "com.baeldung.r2dbc.repository")
+public class R2DBCConfiguration extends AbstractR2dbcConfiguration {
+ @Bean
+ public H2ConnectionFactory connectionFactory() {
+ return new H2ConnectionFactory(
+ H2ConnectionConfiguration.builder()
+ .url("mem:testdb;DB_CLOSE_DELAY=-1;TRACE_LEVEL_FILE=4")
+ .username("sa")
+ .build());
+ }
+}
\ No newline at end of file
diff --git a/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/model/Player.java b/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/model/Player.java
new file mode 100644
index 0000000000..1926997e97
--- /dev/null
+++ b/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/model/Player.java
@@ -0,0 +1,16 @@
+package com.baeldung.r2dbc.model;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.annotation.Id;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class Player {
+ @Id
+ Integer id;
+ String name;
+ Integer age;
+}
\ No newline at end of file
diff --git a/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/repository/PlayerRepository.java b/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/repository/PlayerRepository.java
new file mode 100644
index 0000000000..33b653140e
--- /dev/null
+++ b/spring-5-data-reactive/src/main/java/com/baeldung/r2dbc/repository/PlayerRepository.java
@@ -0,0 +1,15 @@
+package com.baeldung.r2dbc.repository;
+
+import com.baeldung.r2dbc.model.Player;
+import org.springframework.data.r2dbc.repository.query.Query;
+import org.springframework.data.repository.reactive.ReactiveCrudRepository;
+import reactor.core.publisher.Flux;
+
+public interface PlayerRepository extends ReactiveCrudRepository {
+
+ @Query("select id, name, age from player where name = $1")
+ Flux findAllByName(String name);
+
+ @Query("select * from player where age = $1")
+ Flux findByAge(int age);
+}
\ No newline at end of file
diff --git a/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/LogsCounterApplication.java b/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/LogsCounterApplication.java
new file mode 100644
index 0000000000..8b2511a8f3
--- /dev/null
+++ b/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/LogsCounterApplication.java
@@ -0,0 +1,11 @@
+package com.baeldung.tailablecursor;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class LogsCounterApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(LogsCounterApplication.class, args);
+ }
+}
diff --git a/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/domain/Log.java b/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/domain/Log.java
new file mode 100644
index 0000000000..717a367751
--- /dev/null
+++ b/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/domain/Log.java
@@ -0,0 +1,21 @@
+package com.baeldung.tailablecursor.domain;
+
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.springframework.data.annotation.Id;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+@Data
+@Document
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class Log {
+ @Id
+ private String id;
+ private String service;
+ private LogLevel level;
+ private String message;
+}
diff --git a/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/domain/LogLevel.java b/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/domain/LogLevel.java
new file mode 100644
index 0000000000..6826fbffd3
--- /dev/null
+++ b/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/domain/LogLevel.java
@@ -0,0 +1,5 @@
+package com.baeldung.tailablecursor.domain;
+
+public enum LogLevel {
+ ERROR, WARN, INFO
+}
diff --git a/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/repository/LogsRepository.java b/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/repository/LogsRepository.java
new file mode 100644
index 0000000000..dce11c548c
--- /dev/null
+++ b/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/repository/LogsRepository.java
@@ -0,0 +1,12 @@
+package com.baeldung.tailablecursor.repository;
+
+import com.baeldung.tailablecursor.domain.Log;
+import com.baeldung.tailablecursor.domain.LogLevel;
+import org.springframework.data.mongodb.repository.Tailable;
+import org.springframework.data.repository.reactive.ReactiveCrudRepository;
+import reactor.core.publisher.Flux;
+
+public interface LogsRepository extends ReactiveCrudRepository {
+ @Tailable
+ Flux findByLevel(LogLevel level);
+}
diff --git a/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/service/ErrorLogsCounter.java b/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/service/ErrorLogsCounter.java
new file mode 100644
index 0000000000..c243e64f97
--- /dev/null
+++ b/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/service/ErrorLogsCounter.java
@@ -0,0 +1,62 @@
+package com.baeldung.tailablecursor.service;
+
+import com.baeldung.tailablecursor.domain.Log;
+import com.baeldung.tailablecursor.domain.LogLevel;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.mapping.Document;
+import org.springframework.data.mongodb.core.messaging.DefaultMessageListenerContainer;
+import org.springframework.data.mongodb.core.messaging.MessageListener;
+import org.springframework.data.mongodb.core.messaging.MessageListenerContainer;
+import org.springframework.data.mongodb.core.messaging.TailableCursorRequest;
+
+import javax.annotation.PreDestroy;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.springframework.data.mongodb.core.query.Criteria.where;
+import static org.springframework.data.mongodb.core.query.Query.query;
+
+@Slf4j
+public class ErrorLogsCounter implements LogsCounter {
+
+ private static final String LEVEL_FIELD_NAME = "level";
+
+ private final String collectionName;
+ private final MessageListenerContainer container;
+
+ private final AtomicInteger counter = new AtomicInteger();
+
+ public ErrorLogsCounter(MongoTemplate mongoTemplate,
+ String collectionName) {
+ this.collectionName = collectionName;
+ this.container = new DefaultMessageListenerContainer(mongoTemplate);
+
+ container.start();
+ TailableCursorRequest request = getTailableCursorRequest();
+ container.register(request, Log.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ private TailableCursorRequest getTailableCursorRequest() {
+ MessageListener listener = message -> {
+ log.info("ERROR log received: {}", message.getBody());
+ counter.incrementAndGet();
+ };
+
+ return TailableCursorRequest.builder()
+ .collection(collectionName)
+ .filter(query(where(LEVEL_FIELD_NAME).is(LogLevel.ERROR)))
+ .publishTo(listener)
+ .build();
+ }
+
+ @Override
+ public int count() {
+ return counter.get();
+ }
+
+ @PreDestroy
+ public void close() {
+ container.stop();
+ }
+}
diff --git a/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/service/InfoLogsCounter.java b/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/service/InfoLogsCounter.java
new file mode 100644
index 0000000000..29301bffec
--- /dev/null
+++ b/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/service/InfoLogsCounter.java
@@ -0,0 +1,36 @@
+package com.baeldung.tailablecursor.service;
+
+import com.baeldung.tailablecursor.domain.Log;
+import com.baeldung.tailablecursor.domain.LogLevel;
+import com.baeldung.tailablecursor.repository.LogsRepository;
+import lombok.extern.slf4j.Slf4j;
+import reactor.core.Disposable;
+import reactor.core.publisher.Flux;
+
+import javax.annotation.PreDestroy;
+import java.util.concurrent.atomic.AtomicInteger;
+
+@Slf4j
+public class InfoLogsCounter implements LogsCounter {
+
+ private final AtomicInteger counter = new AtomicInteger();
+ private final Disposable subscription;
+
+ public InfoLogsCounter(LogsRepository repository) {
+ Flux stream = repository.findByLevel(LogLevel.INFO);
+ this.subscription = stream.subscribe(logEntity -> {
+ log.info("INFO log received: " + logEntity);
+ counter.incrementAndGet();
+ });
+ }
+
+ @Override
+ public int count() {
+ return this.counter.get();
+ }
+
+ @PreDestroy
+ public void close() {
+ this.subscription.dispose();
+ }
+}
diff --git a/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/service/LogsCounter.java b/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/service/LogsCounter.java
new file mode 100644
index 0000000000..e14a3eadd7
--- /dev/null
+++ b/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/service/LogsCounter.java
@@ -0,0 +1,5 @@
+package com.baeldung.tailablecursor.service;
+
+public interface LogsCounter {
+ int count();
+}
diff --git a/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/service/WarnLogsCounter.java b/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/service/WarnLogsCounter.java
new file mode 100644
index 0000000000..2dff8e8e40
--- /dev/null
+++ b/spring-5-data-reactive/src/main/java/com/baeldung/tailablecursor/service/WarnLogsCounter.java
@@ -0,0 +1,41 @@
+package com.baeldung.tailablecursor.service;
+
+import com.baeldung.tailablecursor.domain.Log;
+import com.baeldung.tailablecursor.domain.LogLevel;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.mongodb.core.ReactiveMongoOperations;
+import reactor.core.Disposable;
+import reactor.core.publisher.Flux;
+
+import javax.annotation.PreDestroy;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static org.springframework.data.mongodb.core.query.Criteria.where;
+import static org.springframework.data.mongodb.core.query.Query.query;
+
+@Slf4j
+public class WarnLogsCounter implements LogsCounter {
+
+ private static final String LEVEL_FIELD_NAME = "level";
+
+ private final AtomicInteger counter = new AtomicInteger();
+ private final Disposable subscription;
+
+ public WarnLogsCounter(ReactiveMongoOperations template) {
+ Flux stream = template.tail(query(where(LEVEL_FIELD_NAME).is(LogLevel.WARN)), Log.class);
+ subscription = stream.subscribe(logEntity -> {
+ log.warn("WARN log received: " + logEntity);
+ counter.incrementAndGet();
+ });
+ }
+
+ @Override
+ public int count() {
+ return counter.get();
+ }
+
+ @PreDestroy
+ public void close() {
+ subscription.dispose();
+ }
+}
diff --git a/spring-5-data-reactive/src/test/java/com/baeldung/r2dbc/R2dbcApplicationIntegrationTest.java b/spring-5-data-reactive/src/test/java/com/baeldung/r2dbc/R2dbcApplicationIntegrationTest.java
new file mode 100644
index 0000000000..a31ef4458d
--- /dev/null
+++ b/spring-5-data-reactive/src/test/java/com/baeldung/r2dbc/R2dbcApplicationIntegrationTest.java
@@ -0,0 +1,125 @@
+package com.baeldung.r2dbc;
+
+
+import com.baeldung.r2dbc.model.Player;
+import com.baeldung.r2dbc.repository.PlayerRepository;
+import io.r2dbc.h2.H2ConnectionFactory;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.data.r2dbc.core.DatabaseClient;
+import org.springframework.test.context.junit4.SpringRunner;
+import reactor.core.publisher.Flux;
+import reactor.core.publisher.Hooks;
+import reactor.core.publisher.Mono;
+import reactor.test.StepVerifier;
+
+import java.util.Arrays;
+import java.util.List;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class R2dbcApplicationIntegrationTest {
+
+
+ @Autowired
+ PlayerRepository playerRepository;
+
+ @Autowired
+ DatabaseClient client;
+
+ @Autowired
+ H2ConnectionFactory factory;
+
+
+ @Before
+ public void setup() {
+
+ Hooks.onOperatorDebug();
+
+ List statements = Arrays.asList(//
+ "DROP TABLE IF EXISTS player;",
+ "CREATE table player (id INT AUTO_INCREMENT NOT NULL, name VARCHAR2, age INT NOT NULL);");
+
+ statements.forEach(it -> client.execute() //
+ .sql(it) //
+ .fetch() //
+ .rowsUpdated() //
+ .as(StepVerifier::create) //
+ .expectNextCount(1) //
+ .verifyComplete());
+
+ }
+
+ @Test
+ public void whenDeleteAll_then0IsExpected() {
+
+
+ playerRepository.deleteAll()
+ .as(StepVerifier::create)
+ .expectNextCount(0)
+ .verifyComplete();
+ }
+
+ @Test
+ public void whenInsert6_then6AreExpected() {
+
+ insertPlayers();
+
+ playerRepository.findAll()
+ .as(StepVerifier::create)
+ .expectNextCount(6)
+ .verifyComplete();
+ }
+
+ @Test
+ public void whenSearchForCR7_then1IsExpected() {
+
+ insertPlayers();
+
+ playerRepository.findAllByName("CR7")
+ .as(StepVerifier::create)
+ .expectNextCount(1)
+ .verifyComplete();
+ }
+
+ @Test
+ public void whenSearchFor32YearsOld_then2AreExpected() {
+ insertPlayers();
+
+ playerRepository.findByAge(32)
+ .as(StepVerifier::create)
+ .expectNextCount(2)
+ .verifyComplete();
+ }
+
+ @Test
+ public void whenBatchHas2Operations_then2AreExpected() {
+ Mono.from(factory.create())
+ .flatMapMany(connection -> Flux.from(connection
+ .createBatch()
+ .add("select * from player")
+ .add("select * from player")
+ .execute()))
+ .as(StepVerifier::create)
+ .expectNextCount(2)
+ .verifyComplete();
+
+ }
+
+ private void insertPlayers() {
+ List players = Arrays.asList(
+ new Player(1, "Kaka", 37),
+ new Player(2, "Messi", 32),
+ new Player(3, "Mbappé", 20),
+ new Player(4, "CR7", 34),
+ new Player(5, "Lewandowski", 30),
+ new Player(6, "Cavani", 32)
+ );
+
+ playerRepository.saveAll(players).subscribe();
+ }
+}
+
diff --git a/spring-5-data-reactive/src/test/java/com/baeldung/tailablecursor/service/ErrorLogsCounterManualTest.java b/spring-5-data-reactive/src/test/java/com/baeldung/tailablecursor/service/ErrorLogsCounterManualTest.java
new file mode 100644
index 0000000000..5e20d3ec79
--- /dev/null
+++ b/spring-5-data-reactive/src/test/java/com/baeldung/tailablecursor/service/ErrorLogsCounterManualTest.java
@@ -0,0 +1,112 @@
+package com.baeldung.tailablecursor.service;
+
+import com.baeldung.tailablecursor.domain.Log;
+import com.baeldung.tailablecursor.domain.LogLevel;
+import com.mongodb.MongoClient;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+import com.mongodb.client.model.CreateCollectionOptions;
+import de.flapdoodle.embed.mongo.MongodExecutable;
+import de.flapdoodle.embed.mongo.MongodProcess;
+import de.flapdoodle.embed.mongo.MongodStarter;
+import de.flapdoodle.embed.mongo.config.MongodConfigBuilder;
+import de.flapdoodle.embed.mongo.config.Net;
+import de.flapdoodle.embed.mongo.distribution.Version;
+import de.flapdoodle.embed.process.runtime.Network;
+import org.bson.Document;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.util.SocketUtils;
+
+import java.io.IOException;
+import java.util.stream.IntStream;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+public class ErrorLogsCounterManualTest {
+
+ private static final String SERVER = "localhost";
+ private static final int PORT = SocketUtils.findAvailableTcpPort(10000);
+ private static final String DB_NAME = "test";
+ private static final String COLLECTION_NAME = Log.class.getName().toLowerCase();
+
+ private static final MongodStarter starter = MongodStarter.getDefaultInstance();
+ private static final int MAX_DOCUMENTS_IN_COLLECTION = 3;
+
+ private ErrorLogsCounter errorLogsCounter;
+ private MongodExecutable mongodExecutable;
+ private MongodProcess mongoDaemon;
+ private MongoDatabase db;
+
+ @Before
+ public void setup() throws Exception {
+ MongoTemplate mongoTemplate = initMongoTemplate();
+
+ MongoCollection collection = createCappedCollection();
+
+ persistDocument(collection, -1, LogLevel.ERROR, "my-service", "Initial log");
+
+ errorLogsCounter = new ErrorLogsCounter(mongoTemplate, COLLECTION_NAME);
+ Thread.sleep(1000L); // wait for initialization
+ }
+
+ private MongoTemplate initMongoTemplate() throws IOException {
+ mongodExecutable = starter.prepare(new MongodConfigBuilder()
+ .version(Version.Main.PRODUCTION)
+ .net(new Net(SERVER, PORT, Network.localhostIsIPv6()))
+ .build());
+ mongoDaemon = mongodExecutable.start();
+
+ MongoClient mongoClient = new MongoClient(SERVER, PORT);
+ db = mongoClient.getDatabase(DB_NAME);
+
+ return new MongoTemplate(mongoClient, DB_NAME);
+ }
+
+ private MongoCollection createCappedCollection() {
+ db.createCollection(COLLECTION_NAME, new CreateCollectionOptions()
+ .capped(true)
+ .sizeInBytes(100000)
+ .maxDocuments(MAX_DOCUMENTS_IN_COLLECTION));
+ return db.getCollection(COLLECTION_NAME);
+ }
+
+ private void persistDocument(MongoCollection collection,
+ int i, LogLevel level, String service, String message) {
+ Document logMessage = new Document();
+ logMessage.append("_id", i);
+ logMessage.append("level", level.toString());
+ logMessage.append("service", service);
+ logMessage.append("message", message);
+ collection.insertOne(logMessage);
+ }
+
+ @After
+ public void tearDown() {
+ errorLogsCounter.close();
+ mongoDaemon.stop();
+ mongodExecutable.stop();
+ }
+
+ @Test
+ public void whenErrorLogsArePersisted_thenTheyAreReceivedByLogsCounter() throws Exception {
+ MongoCollection collection = db.getCollection(COLLECTION_NAME);
+
+ IntStream.range(1, 10)
+ .forEach(i -> persistDocument(collection,
+ i,
+ i > 5 ? LogLevel.ERROR : LogLevel.INFO,
+ "service" + i,
+ "Message from service " + i)
+ );
+
+ Thread.sleep(1000L); // wait to receive all messages from the reactive mongodb driver
+
+ assertThat(collection.countDocuments(), is((long) MAX_DOCUMENTS_IN_COLLECTION));
+ assertThat(errorLogsCounter.count(), is(5));
+ }
+
+}
diff --git a/spring-5-data-reactive/src/test/java/com/baeldung/tailablecursor/service/InfoLogsCounterManualTest.java b/spring-5-data-reactive/src/test/java/com/baeldung/tailablecursor/service/InfoLogsCounterManualTest.java
new file mode 100644
index 0000000000..cd8bd68257
--- /dev/null
+++ b/spring-5-data-reactive/src/test/java/com/baeldung/tailablecursor/service/InfoLogsCounterManualTest.java
@@ -0,0 +1,75 @@
+package com.baeldung.tailablecursor.service;
+
+import com.baeldung.tailablecursor.LogsCounterApplication;
+import com.baeldung.tailablecursor.domain.Log;
+import com.baeldung.tailablecursor.domain.LogLevel;
+import com.baeldung.tailablecursor.repository.LogsRepository;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.data.mongodb.core.CollectionOptions;
+import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
+import org.springframework.test.context.junit4.SpringRunner;
+import reactor.core.publisher.Flux;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = LogsCounterApplication.class)
+@Slf4j
+public class InfoLogsCounterManualTest {
+ @Autowired
+ private LogsRepository repository;
+
+ @Autowired
+ private ReactiveMongoTemplate template;
+
+ @Before
+ public void setUp() {
+ createCappedCollectionUsingReactiveMongoTemplate(template);
+
+ persistDocument(Log.builder()
+ .level(LogLevel.INFO)
+ .service("Service 2")
+ .message("Initial INFO message")
+ .build());
+ }
+
+ private void createCappedCollectionUsingReactiveMongoTemplate(ReactiveMongoTemplate reactiveMongoTemplate) {
+ reactiveMongoTemplate.dropCollection(Log.class).block();
+ reactiveMongoTemplate.createCollection(Log.class, CollectionOptions.empty()
+ .maxDocuments(5)
+ .size(1024 * 1024L)
+ .capped()).block();
+ }
+
+ private void persistDocument(Log log) {
+ repository.save(log).block();
+ }
+
+ @Test
+ public void wheInfoLogsArePersisted_thenTheyAreReceivedByLogsCounter() throws Exception {
+ InfoLogsCounter infoLogsCounter = new InfoLogsCounter(repository);
+
+ Thread.sleep(1000L); // wait for initialization
+
+ Flux.range(0,10)
+ .map(i -> Log.builder()
+ .level(i > 5 ? LogLevel.WARN : LogLevel.INFO)
+ .service("some-service")
+ .message("some log message")
+ .build())
+ .map(entity -> repository.save(entity).subscribe())
+ .blockLast();
+
+ Thread.sleep(1000L); // wait to receive all messages from the reactive mongodb driver
+
+ assertThat(infoLogsCounter.count(), is(7));
+ infoLogsCounter.close();
+ }
+}
\ No newline at end of file
diff --git a/spring-5-data-reactive/src/test/java/com/baeldung/tailablecursor/service/WarnLogsCounterManualTest.java b/spring-5-data-reactive/src/test/java/com/baeldung/tailablecursor/service/WarnLogsCounterManualTest.java
new file mode 100644
index 0000000000..79d94b6784
--- /dev/null
+++ b/spring-5-data-reactive/src/test/java/com/baeldung/tailablecursor/service/WarnLogsCounterManualTest.java
@@ -0,0 +1,75 @@
+package com.baeldung.tailablecursor.service;
+
+import com.baeldung.tailablecursor.LogsCounterApplication;
+import com.baeldung.tailablecursor.domain.Log;
+import com.baeldung.tailablecursor.domain.LogLevel;
+import com.baeldung.tailablecursor.repository.LogsRepository;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.data.mongodb.core.CollectionOptions;
+import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
+import org.springframework.test.context.junit4.SpringRunner;
+import reactor.core.publisher.Flux;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = LogsCounterApplication.class)
+@Slf4j
+public class WarnLogsCounterManualTest {
+ @Autowired
+ private LogsRepository repository;
+
+ @Autowired
+ private ReactiveMongoTemplate template;
+
+ @Before
+ public void setUp() {
+ createCappedCollectionUsingReactiveMongoTemplate(template);
+
+ persistDocument(Log.builder()
+ .level(LogLevel.WARN)
+ .service("Service 1")
+ .message("Initial Warn message")
+ .build());
+ }
+
+ private void createCappedCollectionUsingReactiveMongoTemplate(ReactiveMongoTemplate reactiveMongoTemplate) {
+ reactiveMongoTemplate.dropCollection(Log.class).block();
+ reactiveMongoTemplate.createCollection(Log.class, CollectionOptions.empty()
+ .maxDocuments(5)
+ .size(1024 * 1024L)
+ .capped()).block();
+ }
+
+ private void persistDocument(Log log) {
+ repository.save(log).block();
+ }
+
+ @Test
+ public void whenWarnLogsArePersisted_thenTheyAreReceivedByLogsCounter() throws Exception {
+ WarnLogsCounter warnLogsCounter = new WarnLogsCounter(template);
+
+ Thread.sleep(1000L); // wait for initialization
+
+ Flux.range(0,10)
+ .map(i -> Log.builder()
+ .level(i > 5 ? LogLevel.WARN : LogLevel.INFO)
+ .service("some-service")
+ .message("some log message")
+ .build())
+ .map(entity -> repository.save(entity).subscribe())
+ .blockLast();
+
+ Thread.sleep(1000L); // wait to receive all messages from the reactive mongodb driver
+
+ assertThat(warnLogsCounter.count(), is(5));
+ warnLogsCounter.close();
+ }
+}
\ No newline at end of file
diff --git a/spring-5-data-reactive/src/test/java/org/baeldung/SpringContextTest.java b/spring-5-data-reactive/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..c3ea1d8435
--- /dev/null
+++ b/spring-5-data-reactive/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.reactive.Spring5ReactiveApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Spring5ReactiveApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-5-mvc/pom.xml b/spring-5-mvc/pom.xml
index 5fb8f66f71..302080a8b4 100644
--- a/spring-5-mvc/pom.xml
+++ b/spring-5-mvc/pom.xml
@@ -1,5 +1,6 @@
-4.0.0com.baeldung
@@ -51,12 +52,10 @@
org.jetbrains.kotlinkotlin-stdlib-jre8
- ${kotlin.version}org.jetbrains.kotlinkotlin-reflect
- ${kotlin.version}com.fasterxml.jackson.module
@@ -91,7 +90,6 @@
- ${project.basedir}/src/main/kotlin${project.basedir}/src/test/kotlin
@@ -132,11 +130,43 @@
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+
+
+ generate-sources
+
+ add-source
+
+
+
+
+
+
+
+
+
+ test-compile
+ test-compile
+
+ add-test-source
+
+
+
+
+
+
+
+
+
+
-
+
2.9.01.1.2
+ com.baeldung.Spring5Application
diff --git a/spring-5-reactive-client/src/test/java/org/baeldung/SpringContextTest.java b/spring-5-reactive-client/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..678d04897b
--- /dev/null
+++ b/spring-5-reactive-client/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.reactive.Spring5ReactiveTestApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Spring5ReactiveTestApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/DownstreamServiceReactiveHealthIndicator.java b/spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/DownstreamServiceHealthIndicator.java
similarity index 87%
rename from spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/DownstreamServiceReactiveHealthIndicator.java
rename to spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/DownstreamServiceHealthIndicator.java
index 7360def71e..81e77d9c61 100644
--- a/spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/DownstreamServiceReactiveHealthIndicator.java
+++ b/spring-5-reactive-security/src/main/java/com/baeldung/reactive/actuator/DownstreamServiceHealthIndicator.java
@@ -6,7 +6,7 @@ import org.springframework.stereotype.Component;
import reactor.core.publisher.Mono;
@Component
-public class DownstreamServiceReactiveHealthIndicator implements ReactiveHealthIndicator {
+public class DownstreamServiceHealthIndicator implements ReactiveHealthIndicator {
@Override
public Mono health() {
diff --git a/spring-5-reactive-security/src/test/java/org/baeldung/SpringContextTest.java b/spring-5-reactive-security/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..479c35d986
--- /dev/null
+++ b/spring-5-reactive-security/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.reactive.security.SpringSecurity5Application;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringSecurity5Application.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-5-reactive/src/test/java/com/baeldung/reactive/errorhandling/ErrorHandlingIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/reactive/errorhandling/ErrorHandlingIntegrationTest.java
index 10cfaffce4..42da90ecd5 100644
--- a/spring-5-reactive/src/test/java/com/baeldung/reactive/errorhandling/ErrorHandlingIntegrationTest.java
+++ b/spring-5-reactive/src/test/java/com/baeldung/reactive/errorhandling/ErrorHandlingIntegrationTest.java
@@ -1,10 +1,13 @@
package com.baeldung.reactive.errorhandling;
-import java.io.IOException;
import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.http.MediaType;
@@ -15,6 +18,7 @@ import org.springframework.test.web.reactive.server.WebTestClient;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT)
@WithMockUser
+@AutoConfigureWebTestClient(timeout = "10000")
public class ErrorHandlingIntegrationTest {
@Autowired
diff --git a/spring-5-reactive/src/test/java/com/baeldung/reactive/filters/PlayerHandlerIntegrationTest.java b/spring-5-reactive/src/test/java/com/baeldung/reactive/filters/PlayerHandlerIntegrationTest.java
index fbf46a93cc..c1523cb5ee 100644
--- a/spring-5-reactive/src/test/java/com/baeldung/reactive/filters/PlayerHandlerIntegrationTest.java
+++ b/spring-5-reactive/src/test/java/com/baeldung/reactive/filters/PlayerHandlerIntegrationTest.java
@@ -3,6 +3,7 @@ package com.baeldung.reactive.filters;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.context.junit4.SpringRunner;
@@ -14,6 +15,7 @@ import static org.junit.Assert.assertEquals;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@WithMockUser
+@AutoConfigureWebTestClient(timeout = "10000")
public class PlayerHandlerIntegrationTest {
@Autowired
diff --git a/spring-5-reactive/src/test/java/com/baeldung/stepverifier/PostExecutionUnitTest.java b/spring-5-reactive/src/test/java/com/baeldung/stepverifier/PostExecutionUnitTest.java
index 17fea6b50b..4395e0b048 100644
--- a/spring-5-reactive/src/test/java/com/baeldung/stepverifier/PostExecutionUnitTest.java
+++ b/spring-5-reactive/src/test/java/com/baeldung/stepverifier/PostExecutionUnitTest.java
@@ -28,7 +28,7 @@ public class PostExecutionUnitTest {
.expectComplete()
.verifyThenAssertThat()
.hasDropped(4)
- .tookLessThan(Duration.ofMillis(1050));
+ .tookLessThan(Duration.ofMillis(1500));
}
}
diff --git a/spring-5-reactive/src/test/java/org/baeldung/SpringContextTest.java b/spring-5-reactive/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..c3ea1d8435
--- /dev/null
+++ b/spring-5-reactive/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.reactive.Spring5ReactiveApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Spring5ReactiveApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-5-security-cognito/pom.xml b/spring-5-security-cognito/pom.xml
index c7314d6f9f..431c9b8d9c 100644
--- a/spring-5-security-cognito/pom.xml
+++ b/spring-5-security-cognito/pom.xml
@@ -48,7 +48,6 @@
org.springframework.securityspring-security-oauth2-jose
-
org.springframeworkspring-test
diff --git a/spring-5-security/src/test/java/org/baeldung/SpringContextTest.java b/spring-5-security/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..729790bd14
--- /dev/null
+++ b/spring-5-security/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.dsl.CustomConfigurerApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = CustomConfigurerApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-5-webflux/README.md b/spring-5-webflux/README.md
index e84ee863bf..87d9ae0dd3 100644
--- a/spring-5-webflux/README.md
+++ b/spring-5-webflux/README.md
@@ -3,3 +3,4 @@
- [Spring Boot Reactor Netty Configuration](https://www.baeldung.com/spring-boot-reactor-netty)
- [How to Return 404 with Spring WebFlux](https://www.baeldung.com/spring-webflux-404)
- [Spring WebClient Requests with Parameters](https://www.baeldung.com/webflux-webclient-parameters)
+- [RSocket Using Spring Boot](https://www.baeldung.com/spring-boot-rsocket)
diff --git a/spring-5-webflux/pom.xml b/spring-5-webflux/pom.xml
index c1f537d2fe..6887f01753 100644
--- a/spring-5-webflux/pom.xml
+++ b/spring-5-webflux/pom.xml
@@ -28,11 +28,6 @@
-
- 1.8
- 2.2.0.M3
-
-
org.springframework.boot
@@ -86,6 +81,7 @@
https://repo.spring.io/milestone
+
spring-snapshots
@@ -101,4 +97,8 @@
https://repo.spring.io/milestone
+
+
+ 2.2.0.M3
+
diff --git a/spring-5/src/main/java/com/baeldung/annotationconfigvscomponentscan/components/AccountService.java b/spring-5/src/main/java/com/baeldung/annotationconfigvscomponentscan/components/AccountService.java
new file mode 100644
index 0000000000..1997163954
--- /dev/null
+++ b/spring-5/src/main/java/com/baeldung/annotationconfigvscomponentscan/components/AccountService.java
@@ -0,0 +1,8 @@
+package com.baeldung.annotationconfigvscomponentscan.components;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class AccountService {
+
+}
diff --git a/spring-5/src/main/java/com/baeldung/annotationconfigvscomponentscan/components/UserService.java b/spring-5/src/main/java/com/baeldung/annotationconfigvscomponentscan/components/UserService.java
new file mode 100644
index 0000000000..8dd5ae2ef0
--- /dev/null
+++ b/spring-5/src/main/java/com/baeldung/annotationconfigvscomponentscan/components/UserService.java
@@ -0,0 +1,16 @@
+package com.baeldung.annotationconfigvscomponentscan.components;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class UserService {
+
+ @Autowired
+ private AccountService accountService;
+
+ public AccountService getAccountService() {
+ return accountService;
+ }
+
+}
diff --git a/spring-5/src/main/resources/annotationconfigvscomponentscan-beans.xml b/spring-5/src/main/resources/annotationconfigvscomponentscan-beans.xml
new file mode 100644
index 0000000000..ee4bbb6573
--- /dev/null
+++ b/spring-5/src/main/resources/annotationconfigvscomponentscan-beans.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-5/src/test/java/com/baeldung/SpringXMLConfigurationIntegrationTest.java b/spring-5/src/test/java/com/baeldung/SpringXMLConfigurationIntegrationTest.java
new file mode 100644
index 0000000000..7cd7b81def
--- /dev/null
+++ b/spring-5/src/test/java/com/baeldung/SpringXMLConfigurationIntegrationTest.java
@@ -0,0 +1,23 @@
+package com.baeldung;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import com.baeldung.annotationconfigvscomponentscan.components.AccountService;
+import com.baeldung.annotationconfigvscomponentscan.components.UserService;
+
+public class SpringXMLConfigurationIntegrationTest {
+
+ @Test
+ public void givenContextAnnotationConfigOrContextComponentScan_whenDependenciesAndBeansAnnotated_thenNoXMLNeeded() {
+ ApplicationContext context = new ClassPathXmlApplicationContext("classpath:annotationconfigvscomponentscan-beans.xml");
+ UserService userService = context.getBean(UserService.class);
+ AccountService accountService = context.getBean(AccountService.class);
+ Assert.assertNotNull(userService);
+ Assert.assertNotNull(accountService);
+ Assert.assertNotNull(userService.getAccountService());
+ }
+
+}
diff --git a/spring-5/src/test/java/org/baeldung/SpringContextTest.java b/spring-5/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..56e8697f5c
--- /dev/null
+++ b/spring-5/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.Spring5Application;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Spring5Application.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-activiti/src/test/java/com/baeldung/SpringContextIntegrationTest.java b/spring-activiti/src/test/java/com/baeldung/SpringContextIntegrationTest.java
index ce48080753..89411df976 100644
--- a/spring-activiti/src/test/java/com/baeldung/SpringContextIntegrationTest.java
+++ b/spring-activiti/src/test/java/com/baeldung/SpringContextIntegrationTest.java
@@ -2,6 +2,7 @@ package com.baeldung;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@@ -9,6 +10,7 @@ import com.baeldung.activitiwithspring.ActivitiWithSpringApplication;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ActivitiWithSpringApplication.class)
+@AutoConfigureTestDatabase
public class SpringContextIntegrationTest {
@Test
diff --git a/spring-activiti/src/test/java/com/baeldung/SpringContextTest.java b/spring-activiti/src/test/java/com/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..14df617b1f
--- /dev/null
+++ b/spring-activiti/src/test/java/com/baeldung/SpringContextTest.java
@@ -0,0 +1,19 @@
+package com.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.activitiwithspring.ActivitiWithSpringApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = ActivitiWithSpringApplication.class)
+@AutoConfigureTestDatabase
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-activiti/src/test/java/com/baeldung/activitiwithspring/ActivitiSpringSecurityIntegrationTest.java b/spring-activiti/src/test/java/com/baeldung/activitiwithspring/ActivitiSpringSecurityIntegrationTest.java
index 53bdcee888..7f99483fcf 100644
--- a/spring-activiti/src/test/java/com/baeldung/activitiwithspring/ActivitiSpringSecurityIntegrationTest.java
+++ b/spring-activiti/src/test/java/com/baeldung/activitiwithspring/ActivitiSpringSecurityIntegrationTest.java
@@ -4,6 +4,7 @@ import org.activiti.engine.IdentityService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.test.context.junit4.SpringRunner;
@@ -14,6 +15,7 @@ import com.baeldung.activiti.security.withspring.ActivitiSpringSecurityApplicati
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ActivitiSpringSecurityApplication.class)
@WebAppConfiguration
+@AutoConfigureTestDatabase
public class ActivitiSpringSecurityIntegrationTest {
@Autowired
private IdentityService identityService;
diff --git a/spring-activiti/src/test/java/com/baeldung/activitiwithspring/ActivitiWithSpringApplicationIntegrationTest.java b/spring-activiti/src/test/java/com/baeldung/activitiwithspring/ActivitiWithSpringApplicationIntegrationTest.java
index 8c1e400215..d289693a73 100644
--- a/spring-activiti/src/test/java/com/baeldung/activitiwithspring/ActivitiWithSpringApplicationIntegrationTest.java
+++ b/spring-activiti/src/test/java/com/baeldung/activitiwithspring/ActivitiWithSpringApplicationIntegrationTest.java
@@ -2,11 +2,13 @@ package com.baeldung.activitiwithspring;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
-@SpringBootTest
+@SpringBootTest(classes = ActivitiWithSpringApplication.class)
+@AutoConfigureTestDatabase
public class ActivitiWithSpringApplicationIntegrationTest {
@Test
diff --git a/spring-activiti/src/test/java/com/baeldung/activitiwithspring/ProcessEngineCreationIntegrationTest.java b/spring-activiti/src/test/java/com/baeldung/activitiwithspring/ProcessEngineCreationIntegrationTest.java
index 00538f8e6e..5052f84d6a 100644
--- a/spring-activiti/src/test/java/com/baeldung/activitiwithspring/ProcessEngineCreationIntegrationTest.java
+++ b/spring-activiti/src/test/java/com/baeldung/activitiwithspring/ProcessEngineCreationIntegrationTest.java
@@ -4,7 +4,7 @@ import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.ProcessEngines;
import org.junit.Test;
-
+import org.junit.After;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -62,4 +62,9 @@ public class ProcessEngineCreationIntegrationTest {
assertNotNull(processEngine);
assertEquals("sa", processEngine.getProcessEngineConfiguration().getJdbcUsername());
}
+
+ @After
+ public void cleanup() {
+ ProcessEngines.destroy();
+ }
}
diff --git a/spring-all/src/main/java/org/baeldung/primary/Config.java b/spring-all/src/main/java/org/baeldung/primary/Config.java
index b39f2b9db3..bdcfe019e6 100644
--- a/spring-all/src/main/java/org/baeldung/primary/Config.java
+++ b/spring-all/src/main/java/org/baeldung/primary/Config.java
@@ -10,13 +10,13 @@ import org.springframework.context.annotation.Primary;
public class Config {
@Bean
- public Employee JohnEmployee(){
+ public Employee johnEmployee(){
return new Employee("John");
}
@Bean
@Primary
- public Employee TonyEmployee(){
+ public Employee tonyEmployee(){
return new Employee("Tony");
}
}
diff --git a/spring-all/src/main/java/org/baeldung/startup/ProfileManager.java b/spring-all/src/main/java/org/baeldung/startup/ProfileManager.java
new file mode 100644
index 0000000000..41db539265
--- /dev/null
+++ b/spring-all/src/main/java/org/baeldung/startup/ProfileManager.java
@@ -0,0 +1,18 @@
+package org.baeldung.startup;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ProfileManager {
+
+ @Autowired
+ private Environment environment;
+
+ public void getActiveProfiles() {
+ for (final String profileName : environment.getActiveProfiles()) {
+ System.out.println("Currently active profile - " + profileName);
+ }
+ }
+}
diff --git a/spring-all/src/test/java/org/baeldung/scopes/ScopesIntegrationTest.java b/spring-all/src/test/java/org/baeldung/scopes/ScopesIntegrationTest.java
index aa88a3775e..0ae99610f6 100644
--- a/spring-all/src/test/java/org/baeldung/scopes/ScopesIntegrationTest.java
+++ b/spring-all/src/test/java/org/baeldung/scopes/ScopesIntegrationTest.java
@@ -12,7 +12,7 @@ public class ScopesIntegrationTest {
private static final String NAME_OTHER = "Anna Jones";
@Test
- public void testScopeSingleton() {
+ public void givenSingletonScope_whenSetName_thenEqualNames() {
final ApplicationContext applicationContext = new ClassPathXmlApplicationContext("scopes.xml");
final Person personSingletonA = (Person) applicationContext.getBean("personSingleton");
@@ -25,7 +25,7 @@ public class ScopesIntegrationTest {
}
@Test
- public void testScopePrototype() {
+ public void givenPrototypeScope_whenSetNames_thenDifferentNames() {
final ApplicationContext applicationContext = new ClassPathXmlApplicationContext("scopes.xml");
final Person personPrototypeA = (Person) applicationContext.getBean("personPrototype");
diff --git a/spring-aop/src/test/java/org/baeldung/SpringContextTest.java b/spring-aop/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..4d3ed953c4
--- /dev/null
+++ b/spring-aop/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,15 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-apache-camel/.gitignore b/spring-apache-camel/.gitignore
new file mode 100644
index 0000000000..eac473ac50
--- /dev/null
+++ b/spring-apache-camel/.gitignore
@@ -0,0 +1 @@
+/src/test/destination-folder/*
\ No newline at end of file
diff --git a/spring-apache-camel/src/test/destination-folder/2016-12-18 22-00-11File2.txt b/spring-apache-camel/src/test/destination-folder/2016-12-18 22-00-11File2.txt
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/spring-apache-camel/src/test/java/org/baeldung/SpringContextTest.java b/spring-apache-camel/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..1c098a56ab
--- /dev/null
+++ b/spring-apache-camel/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,13 @@
+package org.baeldung;
+
+import org.junit.Test;
+
+import com.baeldung.camel.main.App;
+
+public class SpringContextTest {
+
+ @Test
+ public final void testMain() throws Exception {
+ App.main(null);
+ }
+}
diff --git a/spring-batch/.gitignore b/spring-batch/.gitignore
new file mode 100644
index 0000000000..0ef6d10b38
--- /dev/null
+++ b/spring-batch/.gitignore
@@ -0,0 +1 @@
+output.csv
\ No newline at end of file
diff --git a/spring-batch/src/test/java/org/baeldung/SpringContextTest.java b/spring-batch/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..0de9a07b0a
--- /dev/null
+++ b/spring-batch/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,12 @@
+package org.baeldung;
+
+import org.baeldung.batch.App;
+import org.junit.Test;
+
+public class SpringContextTest {
+
+ @Test
+ public final void testMain() throws Exception {
+ App.main(null);
+ }
+}
diff --git a/spring-bom/src/test/java/org/baeldung/SpringContextTest.java b/spring-bom/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..783567cdfa
--- /dev/null
+++ b/spring-bom/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,13 @@
+package org.baeldung;
+
+import org.junit.Test;
+
+import com.baeldung.spring.bom.HelloWorldApp;
+
+public class SpringContextTest {
+
+ @Test
+ public final void testMain() throws Exception {
+ HelloWorldApp.main(null);
+ }
+}
diff --git a/spring-boot-admin/spring-boot-admin-client/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-admin/spring-boot-admin-client/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..834f26dacf
--- /dev/null
+++ b/spring-boot-admin/spring-boot-admin-client/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.springbootadminclient.SpringBootAdminClientApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringBootAdminClientApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-boot-admin/spring-boot-admin-server/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-admin/spring-boot-admin-server/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..c185456019
--- /dev/null
+++ b/spring-boot-admin/spring-boot-admin-server/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.springbootadminserver.SpringBootAdminServerApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringBootAdminServerApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-boot-angular-ecommerce/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-angular-ecommerce/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..961d756a68
--- /dev/null
+++ b/spring-boot-angular-ecommerce/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.ecommerce.EcommerceApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = EcommerceApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-boot-angular/pom.xml b/spring-boot-angular/pom.xml
index 6ea98eb3d0..71c46cb7f5 100644
--- a/spring-boot-angular/pom.xml
+++ b/spring-boot-angular/pom.xml
@@ -6,15 +6,13 @@
spring-boot-angular1.0jar
+
parent-boot-2com.baeldung0.0.1-SNAPSHOT../../parent-boot-2
-
- 1.8
-
@@ -46,5 +44,4 @@
-
diff --git a/spring-boot-autoconfiguration/README.MD b/spring-boot-autoconfiguration/README.MD
index a71af54dff..dc9cad539a 100644
--- a/spring-boot-autoconfiguration/README.MD
+++ b/spring-boot-autoconfiguration/README.MD
@@ -3,4 +3,5 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
### Relevant Articles:
-- [Create a Custom Auto-Configuration with Spring Boot](http://www.baeldung.com/spring-boot-custom-auto-configuration)
\ No newline at end of file
+- [Create a Custom Auto-Configuration with Spring Boot](http://www.baeldung.com/spring-boot-custom-auto-configuration)
+- [Guide to ApplicationContextRunner in Spring Boot](https://www.baeldung.com/spring-boot-context-runner)
diff --git a/spring-boot-bootstrap/src/test/java/com/baeldung/SpringContextTest.java b/spring-boot-bootstrap/src/test/java/com/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..4340e27fb4
--- /dev/null
+++ b/spring-boot-bootstrap/src/test/java/com/baeldung/SpringContextTest.java
@@ -0,0 +1,15 @@
+package com.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SpringContextTest {
+
+ @Test
+ public void contextLoads() {
+ }
+}
diff --git a/spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..8324fabfca
--- /dev/null
+++ b/spring-boot-camel/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.camel.Application;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-boot-client/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-client/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..9c3b83ea79
--- /dev/null
+++ b/spring-boot-client/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,16 @@
+package org.baeldung;
+
+import org.baeldung.boot.Application;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-boot-crud/pom.xml b/spring-boot-crud/pom.xml
index 15ff6c5d11..1d956bdba6 100644
--- a/spring-boot-crud/pom.xml
+++ b/spring-boot-crud/pom.xml
@@ -54,7 +54,28 @@
org.springframework.bootspring-boot-maven-plugin
+
+ exec
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+
+
+ jar-with-dependencies
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
@@ -62,4 +83,4 @@
UTF-8
-
\ No newline at end of file
+
diff --git a/spring-boot-ctx-fluent/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-ctx-fluent/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..ff3e795778
--- /dev/null
+++ b/spring-boot-ctx-fluent/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,13 @@
+package org.baeldung;
+
+import org.junit.Test;
+
+import com.baeldung.parent.App;
+
+public class SpringContextTest {
+
+ @Test
+ public final void testMain() throws Exception {
+ App.main(new String[] {});
+ }
+}
diff --git a/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..e6ce83fab5
--- /dev/null
+++ b/spring-boot-custom-starter/greeter-spring-boot-autoconfigure/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.baeldung.greeter.autoconfigure.GreeterAutoConfiguration;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = GreeterAutoConfiguration.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..b82b67df68
--- /dev/null
+++ b/spring-boot-custom-starter/greeter-spring-boot-sample-app/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.greeter.sample.GreeterSampleApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = GreeterSampleApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-boot-data/pom.xml b/spring-boot-data/pom.xml
index 8735a54e7b..9c11e09f4a 100644
--- a/spring-boot-data/pom.xml
+++ b/spring-boot-data/pom.xml
@@ -15,6 +15,30 @@
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+ 2.1.6.RELEASE
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-mongodb
+ 2.1.6.RELEASE
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+ 2.1.6.RELEASE
+
+
+
+ com.h2database
+ h2
+ 1.4.197
+
+
org.springframework.bootspring-boot-starter-web
diff --git a/spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataJPA.java b/spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataJPA.java
new file mode 100644
index 0000000000..8e4ee76a25
--- /dev/null
+++ b/spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataJPA.java
@@ -0,0 +1,16 @@
+package com.baeldung.disableautoconfig;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
+import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
+
+@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class,
+ DataSourceTransactionManagerAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
+public class SpringDataJPA {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SpringDataJPA.class, args);
+ }
+}
diff --git a/spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataMongoDB.java b/spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataMongoDB.java
new file mode 100644
index 0000000000..865c137a8d
--- /dev/null
+++ b/spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataMongoDB.java
@@ -0,0 +1,14 @@
+package com.baeldung.disableautoconfig;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
+import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
+
+@SpringBootApplication(exclude = {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class})
+public class SpringDataMongoDB {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SpringDataMongoDB.class, args);
+ }
+}
diff --git a/spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataRedis.java b/spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataRedis.java
new file mode 100644
index 0000000000..9ec831c446
--- /dev/null
+++ b/spring-boot-data/src/main/java/com/baeldung/disableautoconfig/SpringDataRedis.java
@@ -0,0 +1,14 @@
+package com.baeldung.disableautoconfig;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
+import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration;
+
+@SpringBootApplication(exclude = {RedisAutoConfiguration.class, RedisRepositoriesAutoConfiguration.class})
+public class SpringDataRedis {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SpringDataRedis.class, args);
+ }
+}
diff --git a/spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataJPAIntegrationTest.java b/spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataJPAIntegrationTest.java
new file mode 100644
index 0000000000..a465979b3c
--- /dev/null
+++ b/spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataJPAIntegrationTest.java
@@ -0,0 +1,26 @@
+package com.baeldung.disableautoconfig;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.ApplicationContext;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.sql.DataSource;
+
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringDataJPA.class)
+public class SpringDataJPAIntegrationTest {
+
+ @Autowired
+ private ApplicationContext context;
+
+ @Test(expected = NoSuchBeanDefinitionException.class)
+ public void givenAutoconfigurationIsDisable_whenApplicationStarts_thenContextWillNotHaveTheAutoconfiguredClasses() {
+ context.getBean(DataSource.class);
+ }
+
+}
diff --git a/spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataMongoDBIntegrationTest.java b/spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataMongoDBIntegrationTest.java
new file mode 100644
index 0000000000..bdfadf76ce
--- /dev/null
+++ b/spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataMongoDBIntegrationTest.java
@@ -0,0 +1,25 @@
+package com.baeldung.disableautoconfig;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.ApplicationContext;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.test.context.junit4.SpringRunner;
+
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringDataMongoDB.class)
+public class SpringDataMongoDBIntegrationTest {
+
+ @Autowired
+ private ApplicationContext context;
+
+ @Test(expected = NoSuchBeanDefinitionException.class)
+ public void givenAutoconfigurationIsDisable_whenApplicationStarts_thenContextWillNotHaveTheAutoconfiguredClasses() {
+ context.getBean(MongoTemplate.class);
+ }
+
+}
diff --git a/spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataRedisIntegrationTest.java b/spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataRedisIntegrationTest.java
new file mode 100644
index 0000000000..10133cace3
--- /dev/null
+++ b/spring-boot-data/src/test/java/com/baeldung/disableautoconfig/SpringDataRedisIntegrationTest.java
@@ -0,0 +1,25 @@
+package com.baeldung.disableautoconfig;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.ApplicationContext;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.test.context.junit4.SpringRunner;
+
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringDataRedis.class)
+public class SpringDataRedisIntegrationTest {
+
+ @Autowired
+ private ApplicationContext context;
+
+ @Test(expected = NoSuchBeanDefinitionException.class)
+ public void givenAutoconfigurationIsDisable_whenApplicationStarts_thenContextWillNotHaveTheAutoconfiguredClasses() {
+ context.getBean(RedisTemplate.class);
+ }
+
+}
diff --git a/spring-boot-di/README.MD b/spring-boot-di/README.MD
new file mode 100644
index 0000000000..78cd163668
--- /dev/null
+++ b/spring-boot-di/README.MD
@@ -0,0 +1,6 @@
+### The Course
+The "REST With Spring" Classes: http://bit.ly/restwithspring
+
+### Relevant Articles:
+
+- [Spring Component Scanning](https://www.baeldung.com/spring-component-scanning)
diff --git a/spring-boot-di/pom.xml b/spring-boot-di/pom.xml
new file mode 100644
index 0000000000..ec40c04566
--- /dev/null
+++ b/spring-boot-di/pom.xml
@@ -0,0 +1,55 @@
+
+
+ 4.0.0
+ spring-boot-mvc
+ spring-boot-mvc
+ jar
+ Module For Spring Boot DI
+
+
+ parent-boot-2
+ com.baeldung
+ 0.0.1-SNAPSHOT
+ ../parent-boot-2
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-tomcat
+ provided
+
+
+
+ org.apache.tomcat.embed
+ tomcat-embed-jasper
+ provided
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+ com.baeldung.SpringBootDiApplication
+ JAR
+
+
+
+
+
+
+ com.baeldung.SpringBootDiApplication
+
+
+
diff --git a/spring-boot-di/src/main/java/com/baeldung/SpringBootDiApplication.java b/spring-boot-di/src/main/java/com/baeldung/SpringBootDiApplication.java
new file mode 100644
index 0000000000..b9d2d7ecef
--- /dev/null
+++ b/spring-boot-di/src/main/java/com/baeldung/SpringBootDiApplication.java
@@ -0,0 +1,12 @@
+package com.baeldung;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SpringBootDiApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SpringBootDiApplication.class, args);
+ }
+}
diff --git a/spring-boot/src/main/java/com/baeldung/componentscan/ExampleBean.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/ExampleBean.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/componentscan/ExampleBean.java
rename to spring-boot-di/src/main/java/com/baeldung/componentscan/ExampleBean.java
diff --git a/spring-boot/src/main/java/com/baeldung/componentscan/springapp/SpringComponentScanApp.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/SpringComponentScanApp.java
similarity index 88%
rename from spring-boot/src/main/java/com/baeldung/componentscan/springapp/SpringComponentScanApp.java
rename to spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/SpringComponentScanApp.java
index 2377ed7a56..83b91f7860 100644
--- a/spring-boot/src/main/java/com/baeldung/componentscan/springapp/SpringComponentScanApp.java
+++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/SpringComponentScanApp.java
@@ -1,10 +1,6 @@
package com.baeldung.componentscan.springapp;
-import org.springframework.context.annotation.FilterType;
-import org.springframework.stereotype.Component;
-
import com.baeldung.componentscan.ExampleBean;
-import com.baeldung.componentscan.springapp.flowers.Rose;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
diff --git a/spring-boot/src/main/java/com/baeldung/componentscan/springapp/animals/Cat.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/animals/Cat.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/componentscan/springapp/animals/Cat.java
rename to spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/animals/Cat.java
diff --git a/spring-boot/src/main/java/com/baeldung/componentscan/springapp/animals/Dog.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/animals/Dog.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/componentscan/springapp/animals/Dog.java
rename to spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/animals/Dog.java
diff --git a/spring-boot/src/main/java/com/baeldung/componentscan/springapp/flowers/Rose.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/flowers/Rose.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/componentscan/springapp/flowers/Rose.java
rename to spring-boot-di/src/main/java/com/baeldung/componentscan/springapp/flowers/Rose.java
diff --git a/spring-boot/src/main/java/com/baeldung/componentscan/springbootapp/SpringBootComponentScanApp.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/SpringBootComponentScanApp.java
similarity index 88%
rename from spring-boot/src/main/java/com/baeldung/componentscan/springbootapp/SpringBootComponentScanApp.java
rename to spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/SpringBootComponentScanApp.java
index ba29a4e1f5..4362caefbb 100644
--- a/spring-boot/src/main/java/com/baeldung/componentscan/springbootapp/SpringBootComponentScanApp.java
+++ b/spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/SpringBootComponentScanApp.java
@@ -1,14 +1,11 @@
package com.baeldung.componentscan.springbootapp;
import org.springframework.boot.SpringApplication;
-import org.springframework.context.annotation.FilterType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.ComponentScan;
import com.baeldung.componentscan.ExampleBean;
-import com.baeldung.componentscan.springbootapp.flowers.Rose;
@SpringBootApplication
//@ComponentScan(basePackages = "com.baeldung.componentscan.springbootapp.animals")
diff --git a/spring-boot/src/main/java/com/baeldung/componentscan/springbootapp/animals/Cat.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/animals/Cat.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/componentscan/springbootapp/animals/Cat.java
rename to spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/animals/Cat.java
diff --git a/spring-boot/src/main/java/com/baeldung/componentscan/springbootapp/animals/Dog.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/animals/Dog.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/componentscan/springbootapp/animals/Dog.java
rename to spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/animals/Dog.java
diff --git a/spring-boot/src/main/java/com/baeldung/componentscan/springbootapp/flowers/Rose.java b/spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/flowers/Rose.java
similarity index 100%
rename from spring-boot/src/main/java/com/baeldung/componentscan/springbootapp/flowers/Rose.java
rename to spring-boot-di/src/main/java/com/baeldung/componentscan/springbootapp/flowers/Rose.java
diff --git a/spring-boot-flowable/pom.xml b/spring-boot-flowable/pom.xml
index f9531a1e6a..f7fc943389 100644
--- a/spring-boot-flowable/pom.xml
+++ b/spring-boot-flowable/pom.xml
@@ -7,12 +7,14 @@
warspring-boot-flowableSpring Boot Flowable Module
+
parent-boot-2com.baeldung0.0.1-SNAPSHOT../parent-boot-2
+
org.springframework.boot
@@ -44,6 +46,7 @@
test
+
@@ -52,6 +55,7 @@
+
6.4.1
diff --git a/spring-boot-jasypt/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-jasypt/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..ab6e4557d5
--- /dev/null
+++ b/spring-boot-jasypt/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.jasypt.Main;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Main.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-boot-keycloak/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-keycloak/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..4effccc083
--- /dev/null
+++ b/spring-boot-keycloak/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.keycloak.SpringBoot;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringBoot.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-boot-kotlin/README.md b/spring-boot-kotlin/README.md
new file mode 100644
index 0000000000..dc50c24aa0
--- /dev/null
+++ b/spring-boot-kotlin/README.md
@@ -0,0 +1,2 @@
+### Relevant Articles:
+- [Non-blocking Spring Boot with Kotlin Coroutines](http://www.baeldung.com/non-blocking-spring-boot-with-kotlin-coroutines)
diff --git a/spring-boot-kotlin/pom.xml b/spring-boot-kotlin/pom.xml
new file mode 100644
index 0000000000..25508c52b9
--- /dev/null
+++ b/spring-boot-kotlin/pom.xml
@@ -0,0 +1,166 @@
+
+
+ 4.0.0
+ spring-boot-kotlin
+ spring-boot-kotlin
+ jar
+ Demo project showing how to use non-blocking in Kotlin with Spring Boot
+
+
+ parent-kotlin
+ com.baeldung
+ 1.0.0-SNAPSHOT
+ ../parent-kotlin
+
+
+
+
+ spring-snapshots
+ Spring Snapshots
+ https://repo.spring.io/snapshot
+
+ true
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-dependencies
+ ${spring-boot.version}
+ pom
+ import
+
+
+
+
+
+
+ spring-snapshots
+ Spring Snapshots
+ https://repo.spring.io/snapshot
+
+ true
+
+
+
+ spring-milestones
+ Spring Milestones
+ https://repo.spring.io/milestone
+
+
+
+
+
+ org.jetbrains.kotlin
+ kotlin-reflect
+
+
+ org.jetbrains.kotlin
+ kotlin-stdlib-jdk8
+
+
+ org.jetbrains.kotlinx
+ kotlinx-coroutines-core
+ ${kotlinx-coroutines.version}
+
+
+ org.jetbrains.kotlinx
+ kotlinx-coroutines-reactor
+ ${kotlinx-coroutines.version}
+
+
+ org.springframework.boot
+ spring-boot-starter-webflux
+ ${spring-boot.version}
+
+
+ com.fasterxml.jackson.module
+ jackson-module-kotlin
+
+
+ org.springframework.data
+ spring-data-r2dbc
+ ${r2dbc.version}
+
+
+ io.r2dbc
+ r2dbc-h2
+ ${h2-r2dbc.version}
+
+
+ io.r2dbc
+ r2dbc-spi
+ ${r2dbc-spi.version}
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ junit
+ junit
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ io.projectreactor
+ reactor-test
+ test
+
+
+
+
+
+
+ org.jetbrains.kotlin
+ kotlin-maven-plugin
+
+
+ -Xjsr305=strict
+
+
+ spring
+
+
+
+
+ org.jetbrains.kotlin
+ kotlin-maven-allopen
+ ${kotlin.version}
+
+
+
+
+
+
+
+ 1.3.31
+ 1.0.0.M1
+ 1.0.0.M7
+ 1.0.0.BUILD-SNAPSHOT
+ 1.2.1
+ 2.2.0.M2
+
+
+
diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/SpringApplication.kt b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/SpringApplication.kt
new file mode 100644
index 0000000000..23af4fe90b
--- /dev/null
+++ b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/SpringApplication.kt
@@ -0,0 +1,11 @@
+package com.baeldung.nonblockingcoroutines
+
+import org.springframework.boot.SpringApplication.run
+import org.springframework.boot.autoconfigure.SpringBootApplication
+
+@SpringBootApplication
+class SpringApplication
+
+fun main(args: Array) {
+ run(SpringApplication::class.java, *args)
+}
diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/DatastoreConfig.kt b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/DatastoreConfig.kt
new file mode 100644
index 0000000000..52ef8a708b
--- /dev/null
+++ b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/DatastoreConfig.kt
@@ -0,0 +1,32 @@
+package com.baeldung.nonblockingcoroutines.config
+
+import io.r2dbc.h2.H2ConnectionConfiguration
+import io.r2dbc.h2.H2ConnectionFactory
+import io.r2dbc.spi.ConnectionFactory
+import org.springframework.beans.factory.annotation.Value
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration
+import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories
+
+@Configuration
+@EnableR2dbcRepositories
+class DatastoreConfig : AbstractR2dbcConfiguration() {
+ @Value("\${spring.datasource.username}")
+ private val userName: String = ""
+
+ @Value("\${spring.datasource.password}")
+ private val password: String = ""
+
+ @Value("\${spring.datasource.dbname}")
+ private val dbName: String = ""
+
+ @Bean
+ override fun connectionFactory(): ConnectionFactory {
+ return H2ConnectionFactory(H2ConnectionConfiguration.builder()
+ .inMemory(dbName)
+ .username(userName)
+ .password(password)
+ .build())
+ }
+}
\ No newline at end of file
diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/RouterConfiguration.kt b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/RouterConfiguration.kt
new file mode 100644
index 0000000000..bda1d26278
--- /dev/null
+++ b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/RouterConfiguration.kt
@@ -0,0 +1,19 @@
+package com.baeldung.nonblockingcoroutines.config
+
+import com.baeldung.nonblockingcoroutines.handlers.ProductsHandler
+import kotlinx.coroutines.FlowPreview
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import org.springframework.web.reactive.function.server.coRouter
+
+@Configuration
+class RouterConfiguration {
+
+ @FlowPreview
+ @Bean
+ fun productRoutes(productsHandler: ProductsHandler) = coRouter {
+ GET("/", productsHandler::findAll)
+ GET("/{id}", productsHandler::findOne)
+ GET("/{id}/stock", productsHandler::findOneInStock)
+ }
+}
\ No newline at end of file
diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/WebClientConfiguration.kt b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/WebClientConfiguration.kt
new file mode 100644
index 0000000000..85938b8be2
--- /dev/null
+++ b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/config/WebClientConfiguration.kt
@@ -0,0 +1,12 @@
+package com.baeldung.nonblockingcoroutines.config
+
+import org.springframework.context.annotation.Bean
+import org.springframework.context.annotation.Configuration
+import org.springframework.web.reactive.function.client.WebClient
+
+@Configuration
+class WebClientConfiguration {
+
+ @Bean
+ fun webClient() = WebClient.builder().baseUrl("http://localhost:8080").build()
+}
\ No newline at end of file
diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductController.kt b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductController.kt
new file mode 100644
index 0000000000..91b091859a
--- /dev/null
+++ b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductController.kt
@@ -0,0 +1,49 @@
+package com.baeldung.nonblockingcoroutines.controller
+
+import com.baeldung.nonblockingcoroutines.model.Product
+import com.baeldung.nonblockingcoroutines.repository.ProductRepository
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.http.MediaType
+import org.springframework.web.bind.annotation.GetMapping
+import org.springframework.web.bind.annotation.PathVariable
+import org.springframework.web.reactive.function.client.WebClient
+import org.springframework.web.reactive.function.client.bodyToMono
+import reactor.core.publisher.Flux
+import reactor.core.publisher.Mono
+
+class ProductController {
+ @Autowired
+ lateinit var webClient: WebClient
+ @Autowired
+ lateinit var productRepository: ProductRepository
+
+ @GetMapping("/{id}")
+ fun findOne(@PathVariable id: Int): Mono {
+ return productRepository
+ .getProductById(id)
+ }
+
+ @GetMapping("/{id}/stock")
+ fun findOneInStock(@PathVariable id: Int): Mono {
+ val product = productRepository.getProductById(id)
+
+ val stockQuantity = webClient.get()
+ .uri("/stock-service/product/$id/quantity")
+ .accept(MediaType.APPLICATION_JSON)
+ .retrieve()
+ .bodyToMono()
+ return product.zipWith(stockQuantity) { productInStock, stockQty ->
+ ProductStockView(productInStock, stockQty)
+ }
+ }
+
+ @GetMapping("/stock-service/product/{id}/quantity")
+ fun getStockQuantity(): Mono {
+ return Mono.just(2)
+ }
+
+ @GetMapping("/")
+ fun findAll(): Flux {
+ return productRepository.getAllProducts()
+ }
+}
diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductControllerCoroutines.kt b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductControllerCoroutines.kt
new file mode 100644
index 0000000000..d70d352cda
--- /dev/null
+++ b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductControllerCoroutines.kt
@@ -0,0 +1,49 @@
+package com.baeldung.nonblockingcoroutines.controller
+
+import com.baeldung.nonblockingcoroutines.model.Product
+import com.baeldung.nonblockingcoroutines.repository.ProductRepositoryCoroutines
+import kotlinx.coroutines.Deferred
+import kotlinx.coroutines.FlowPreview
+import kotlinx.coroutines.GlobalScope
+import kotlinx.coroutines.async
+import kotlinx.coroutines.flow.Flow
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.http.MediaType.APPLICATION_JSON
+import org.springframework.web.bind.annotation.GetMapping
+import org.springframework.web.bind.annotation.PathVariable
+import org.springframework.web.reactive.function.client.WebClient
+import org.springframework.web.reactive.function.client.awaitBody
+import org.springframework.web.reactive.function.client.awaitExchange
+
+class ProductControllerCoroutines {
+ @Autowired
+ lateinit var webClient: WebClient
+
+ @Autowired
+ lateinit var productRepository: ProductRepositoryCoroutines
+
+ @GetMapping("/{id}")
+ suspend fun findOne(@PathVariable id: Int): Product? {
+ return productRepository.getProductById(id)
+ }
+
+ @GetMapping("/{id}/stock")
+ suspend fun findOneInStock(@PathVariable id: Int): ProductStockView {
+ val product: Deferred = GlobalScope.async {
+ productRepository.getProductById(id)
+ }
+ val quantity: Deferred = GlobalScope.async {
+ webClient.get()
+ .uri("/stock-service/product/$id/quantity")
+ .accept(APPLICATION_JSON)
+ .awaitExchange().awaitBody()
+ }
+ return ProductStockView(product.await()!!, quantity.await())
+ }
+
+ @FlowPreview
+ @GetMapping("/")
+ fun findAll(): Flow {
+ return productRepository.getAllProducts()
+ }
+}
\ No newline at end of file
diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductStockView.kt b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductStockView.kt
new file mode 100644
index 0000000000..44611fd1de
--- /dev/null
+++ b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/controller/ProductStockView.kt
@@ -0,0 +1,15 @@
+package com.baeldung.nonblockingcoroutines.controller
+
+import com.baeldung.nonblockingcoroutines.model.Product
+
+class ProductStockView(product: Product, var stockQuantity: Int) {
+ var id: Int = 0
+ var name: String = ""
+ var price: Float = 0.0f
+
+ init {
+ this.id = product.id
+ this.name = product.name
+ this.price = product.price
+ }
+}
\ No newline at end of file
diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/handlers/ProductsHandler.kt b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/handlers/ProductsHandler.kt
new file mode 100644
index 0000000000..41c4510e0d
--- /dev/null
+++ b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/handlers/ProductsHandler.kt
@@ -0,0 +1,49 @@
+package com.baeldung.nonblockingcoroutines.handlers
+
+import com.baeldung.nonblockingcoroutines.controller.ProductStockView
+import com.baeldung.nonblockingcoroutines.model.Product
+import com.baeldung.nonblockingcoroutines.repository.ProductRepositoryCoroutines
+import kotlinx.coroutines.Deferred
+import kotlinx.coroutines.FlowPreview
+import kotlinx.coroutines.GlobalScope
+import kotlinx.coroutines.async
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.http.MediaType
+import org.springframework.stereotype.Component
+import org.springframework.web.reactive.function.client.WebClient
+import org.springframework.web.reactive.function.client.awaitBody
+import org.springframework.web.reactive.function.client.awaitExchange
+import org.springframework.web.reactive.function.server.ServerRequest
+import org.springframework.web.reactive.function.server.ServerResponse
+import org.springframework.web.reactive.function.server.bodyAndAwait
+import org.springframework.web.reactive.function.server.json
+
+@Component
+class ProductsHandler(
+ @Autowired var webClient: WebClient,
+ @Autowired var productRepository: ProductRepositoryCoroutines) {
+
+ @FlowPreview
+ suspend fun findAll(request: ServerRequest): ServerResponse =
+ ServerResponse.ok().json().bodyAndAwait(productRepository.getAllProducts())
+
+ suspend fun findOneInStock(request: ServerRequest): ServerResponse {
+ val id = request.pathVariable("id").toInt()
+
+ val product: Deferred = GlobalScope.async {
+ productRepository.getProductById(id)
+ }
+ val quantity: Deferred = GlobalScope.async {
+ webClient.get()
+ .uri("/stock-service/product/$id/quantity")
+ .accept(MediaType.APPLICATION_JSON)
+ .awaitExchange().awaitBody()
+ }
+ return ServerResponse.ok().json().bodyAndAwait(ProductStockView(product.await()!!, quantity.await()))
+ }
+
+ suspend fun findOne(request: ServerRequest): ServerResponse {
+ val id = request.pathVariable("id").toInt()
+ return ServerResponse.ok().json().bodyAndAwait(productRepository.getProductById(id)!!)
+ }
+}
\ No newline at end of file
diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/model/Product.kt b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/model/Product.kt
new file mode 100644
index 0000000000..c6dcbdc9c4
--- /dev/null
+++ b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/model/Product.kt
@@ -0,0 +1,7 @@
+package com.baeldung.nonblockingcoroutines.model
+
+data class Product(
+ var id: Int = 0,
+ var name: String = "",
+ var price: Float = 0.0f
+)
diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/repository/ProductRepository.kt b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/repository/ProductRepository.kt
new file mode 100644
index 0000000000..20c3827c26
--- /dev/null
+++ b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/repository/ProductRepository.kt
@@ -0,0 +1,34 @@
+package com.baeldung.nonblockingcoroutines.repository
+
+import com.baeldung.nonblockingcoroutines.model.Product
+import org.springframework.data.r2dbc.function.DatabaseClient
+import org.springframework.stereotype.Repository
+import reactor.core.publisher.Flux
+import reactor.core.publisher.Mono
+
+@Repository
+class ProductRepository(private val client: DatabaseClient) {
+
+ fun getProductById(id: Int): Mono {
+ return client.execute().sql("SELECT * FROM products WHERE id = $1")
+ .bind(0, id)
+ .`as`(Product::class.java)
+ .fetch()
+ .one()
+ }
+
+ fun addNewProduct(name: String, price: Float): Mono {
+ return client.execute()
+ .sql("INSERT INTO products (name, price) VALUES($1, $2)")
+ .bind(0, name)
+ .bind(1, price)
+ .then()
+ }
+
+ fun getAllProducts(): Flux {
+ return client.select().from("products")
+ .`as`(Product::class.java)
+ .fetch()
+ .all()
+ }
+}
\ No newline at end of file
diff --git a/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/repository/ProductRepositoryCoroutines.kt b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/repository/ProductRepositoryCoroutines.kt
new file mode 100644
index 0000000000..60a19d4d00
--- /dev/null
+++ b/spring-boot-kotlin/src/main/kotlin/com/baeldung/nonblockingcoroutines/repository/ProductRepositoryCoroutines.kt
@@ -0,0 +1,40 @@
+package com.baeldung.nonblockingcoroutines.repository
+
+
+import com.baeldung.nonblockingcoroutines.model.Product
+import kotlinx.coroutines.FlowPreview
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.reactive.awaitFirstOrNull
+import kotlinx.coroutines.reactive.flow.asFlow
+import org.springframework.data.r2dbc.function.DatabaseClient
+import org.springframework.stereotype.Repository
+
+@Repository
+class ProductRepositoryCoroutines(private val client: DatabaseClient) {
+
+ suspend fun getProductById(id: Int): Product? =
+ client.execute().sql("SELECT * FROM products WHERE id = $1")
+ .bind(0, id)
+ .`as`(Product::class.java)
+ .fetch()
+ .one()
+ .awaitFirstOrNull()
+
+ suspend fun addNewProduct(name: String, price: Float) =
+ client.execute()
+ .sql("INSERT INTO products (name, price) VALUES($1, $2)")
+ .bind(0, name)
+ .bind(1, price)
+ .then()
+ .awaitFirstOrNull()
+
+ @FlowPreview
+ fun getAllProducts(): Flow =
+ client.select()
+ .from("products")
+ .`as`(Product::class.java)
+ .fetch()
+ .all()
+ .log()
+ .asFlow()
+}
\ No newline at end of file
diff --git a/spring-boot-kotlin/src/main/resources/application.properties b/spring-boot-kotlin/src/main/resources/application.properties
new file mode 100644
index 0000000000..0f84ff2d75
--- /dev/null
+++ b/spring-boot-kotlin/src/main/resources/application.properties
@@ -0,0 +1,8 @@
+logging.level.org.springframework.data.r2dbc=DEBUG
+logging.level.org.springframework.web.reactive.function.client.ExchangeFunctions=TRACE
+spring.http.log-request-details=true
+spring.h2.console.enabled=true
+spring.datasource.username=sa
+spring.datasource.url=jdbc:h2:mem:testdb
+spring.datasource.password=
+spring.datasource.dbname=testdb
\ No newline at end of file
diff --git a/spring-userservice/src/main/resources/logback.xml b/spring-boot-kotlin/src/main/resources/logback.xml
similarity index 100%
rename from spring-userservice/src/main/resources/logback.xml
rename to spring-boot-kotlin/src/main/resources/logback.xml
diff --git a/spring-boot-kotlin/src/test/kotlin/com/baeldung/nonblockingcoroutines/ProductHandlerTest.kt b/spring-boot-kotlin/src/test/kotlin/com/baeldung/nonblockingcoroutines/ProductHandlerTest.kt
new file mode 100644
index 0000000000..53b1d50f21
--- /dev/null
+++ b/spring-boot-kotlin/src/test/kotlin/com/baeldung/nonblockingcoroutines/ProductHandlerTest.kt
@@ -0,0 +1,58 @@
+package com.baeldung.nonblockingcoroutines
+
+import com.baeldung.nonblockingcoroutines.config.RouterConfiguration
+import com.baeldung.nonblockingcoroutines.handlers.ProductsHandler
+import com.baeldung.nonblockingcoroutines.model.Product
+import com.baeldung.nonblockingcoroutines.repository.ProductRepositoryCoroutines
+import kotlinx.coroutines.FlowPreview
+import kotlinx.coroutines.reactive.flow.asFlow
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.BDDMockito.given
+import org.springframework.beans.factory.annotation.Autowired
+import org.springframework.boot.autoconfigure.security.reactive.ReactiveSecurityAutoConfiguration
+import org.springframework.boot.autoconfigure.security.reactive.ReactiveUserDetailsServiceAutoConfiguration
+import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest
+import org.springframework.boot.test.mock.mockito.MockBean
+import org.springframework.test.context.junit4.SpringRunner
+import org.springframework.test.web.reactive.server.WebTestClient
+import org.springframework.test.web.reactive.server.expectBodyList
+import org.springframework.web.reactive.function.client.WebClient
+import reactor.core.publisher.Flux
+import org.springframework.test.context.ContextConfiguration
+
+@WebFluxTest(
+ excludeAutoConfiguration = [ReactiveUserDetailsServiceAutoConfiguration::class, ReactiveSecurityAutoConfiguration::class]
+)
+@RunWith(SpringRunner::class)
+@ContextConfiguration(classes = [ProductsHandler::class, RouterConfiguration::class])
+class ProductHandlerTest {
+
+ @Autowired
+ private lateinit var client: WebTestClient
+
+ @MockBean
+ private lateinit var webClient: WebClient
+
+ @MockBean
+ private lateinit var productsRepository: ProductRepositoryCoroutines
+
+
+ @FlowPreview
+ @Test
+ public fun `get all products`() {
+ val productsFlow = Flux.just(
+ Product(1, "product1", 1000.0F),
+ Product(2, "product2", 2000.0F),
+ Product(3, "product3", 3000.0F)
+ ).asFlow()
+ given(productsRepository.getAllProducts()).willReturn(productsFlow)
+ client.get()
+ .uri("/")
+ .exchange()
+ .expectStatus()
+ .isOk
+ .expectBodyList()
+ }
+
+}
diff --git a/spring-boot-logging-log4j2/pom.xml b/spring-boot-logging-log4j2/pom.xml
index 6cc60da52c..64696969ca 100644
--- a/spring-boot-logging-log4j2/pom.xml
+++ b/spring-boot-logging-log4j2/pom.xml
@@ -34,6 +34,12 @@
org.springframework.bootspring-boot-starter-log4j2
+
+ org.projectlombok
+ lombok
+ 1.18.4
+ provided
+
diff --git a/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/LombokLoggingController.java b/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/LombokLoggingController.java
new file mode 100644
index 0000000000..5f75dbd5a1
--- /dev/null
+++ b/spring-boot-logging-log4j2/src/main/java/com/baeldung/springbootlogging/LombokLoggingController.java
@@ -0,0 +1,28 @@
+package com.baeldung.springbootlogging;
+
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import lombok.extern.slf4j.Slf4j;
+
+//import lombok.extern.log4j.Log4j2;
+//import lombok.extern.apachecommons.CommonsLog;
+
+@RestController("LombokLoggingController")
+@Slf4j
+// @CommonsLog (Comment any other Lombok logging annotation and uncomment this
+// to work with Apache Commons Logging)
+// @Log4j2 (Comment any other Lombok logging annotation and uncomment this to
+// work directly with Log4j2)
+public class LombokLoggingController {
+
+ @GetMapping("/lombok")
+ public String index() {
+ log.trace("A TRACE Message");
+ log.debug("A DEBUG Message");
+ log.info("An INFO Message");
+ log.warn("A WARN Message");
+ log.error("An ERROR Message");
+ return "Howdy! Check out the Logs to see the output...";
+ }
+}
diff --git a/spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..9817522e68
--- /dev/null
+++ b/spring-boot-logging-log4j2/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.springbootlogging.SpringBootLoggingApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringBootLoggingApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-boot-mvc-birt/pom.xml b/spring-boot-mvc-birt/pom.xml
index 8f41e8410a..bf6bbbf71d 100644
--- a/spring-boot-mvc-birt/pom.xml
+++ b/spring-boot-mvc-birt/pom.xml
@@ -9,10 +9,12 @@
0.0.1-SNAPSHOTjarModule For Spring Boot Integration with BIRT
+
- org.springframework.boot
- spring-boot-starter-parent
- 2.1.1.RELEASE
+ parent-boot-2
+ com.baeldung
+ 0.0.1-SNAPSHOT
+ ../parent-boot-2
diff --git a/spring-boot-mvc/README.md b/spring-boot-mvc/README.md
index d5a39cdc9f..e3e3dbdb74 100644
--- a/spring-boot-mvc/README.md
+++ b/spring-boot-mvc/README.md
@@ -12,3 +12,5 @@
- [Setting Up Swagger 2 with a Spring REST API](http://www.baeldung.com/swagger-2-documentation-for-spring-rest-api)
- [Conditionally Enable Scheduled Jobs in Spring](https://www.baeldung.com/spring-scheduled-enabled-conditionally)
- [Accessing Spring MVC Model Objects in JavaScript](https://www.baeldung.com/spring-mvc-model-objects-js)
+- [Using Spring ResponseEntity to Manipulate the HTTP Response](http://www.baeldung.com/spring-response-entity)
+- [Spring Bean Annotations](http://www.baeldung.com/spring-bean-annotations)
diff --git a/spring-boot-mvc/pom.xml b/spring-boot-mvc/pom.xml
index e17c1d39b9..fee725847f 100644
--- a/spring-boot-mvc/pom.xml
+++ b/spring-boot-mvc/pom.xml
@@ -40,7 +40,7 @@
org.glassfishjavax.faces
- 2.3.7
+ ${javax.faces.version}
@@ -108,6 +108,7 @@
2.9.21.10.0
+ 2.3.7com.baeldung.springbootmvc.SpringBootMvcApplication
diff --git a/spring-boot-mvc/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-mvc/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..16e0708fc9
--- /dev/null
+++ b/spring-boot-mvc/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.springbootmvc.SpringBootMvcApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringBootMvcApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-boot-ops-2/README.MD b/spring-boot-ops-2/README.MD
index 20b30515fb..b4218dc395 100644
--- a/spring-boot-ops-2/README.MD
+++ b/spring-boot-ops-2/README.MD
@@ -1,3 +1,4 @@
### Relevant Articles
-- [How to Configure Spring Boot Tomcat](https://www.baeldung.com/spring-boot-configure-tomcat)
\ No newline at end of file
+- [How to Configure Spring Boot Tomcat](https://www.baeldung.com/spring-boot-configure-tomcat)
+- [Spring Boot Embedded Tomcat Logs](https://www.baeldung.com/spring-boot-embedded-tomcat-logs)
diff --git a/spring-boot-ops-2/pom.xml b/spring-boot-ops-2/pom.xml
index dc5280df48..74fcd79169 100644
--- a/spring-boot-ops-2/pom.xml
+++ b/spring-boot-ops-2/pom.xml
@@ -3,6 +3,10 @@
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">
4.0.0
+ com.baeldung
+ spring-boot-ops-2
+ 0.0.1-SNAPSHOT
+ spring-boot-ops-2parent-boot-2
@@ -11,11 +15,6 @@
../parent-boot-2
- com.baeldung
- spring-boot-ops-2
- 0.0.1-SNAPSHOT
- spring-boot-ops-2
-
org.springframework.boot
diff --git a/spring-boot-ops-2/src/test/java/com/baeldung/springbootconfiguration/SpringContextTest.java b/spring-boot-ops-2/src/test/java/com/baeldung/springbootconfiguration/SpringContextTest.java
new file mode 100644
index 0000000000..11bbad8bb2
--- /dev/null
+++ b/spring-boot-ops-2/src/test/java/com/baeldung/springbootconfiguration/SpringContextTest.java
@@ -0,0 +1,15 @@
+package com.baeldung.springbootconfiguration;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SpringContextTest {
+
+ @Test
+ public void contextLoads() {
+ }
+}
diff --git a/spring-boot-parent/README.md b/spring-boot-parent/README.md
new file mode 100644
index 0000000000..c3bb4c700d
--- /dev/null
+++ b/spring-boot-parent/README.md
@@ -0,0 +1,3 @@
+### Relevant Articles
+
+- [The Spring Boot Starter Parent](https://www.baeldung.com/spring-boot-starter-parent)
diff --git a/spring-boot-parent/pom.xml b/spring-boot-parent/pom.xml
new file mode 100644
index 0000000000..0924917505
--- /dev/null
+++ b/spring-boot-parent/pom.xml
@@ -0,0 +1,26 @@
+
+
+
+ 4.0.0
+ com.baeldung
+ spring-boot-parent
+ 1.0.0-SNAPSHOT
+ spring-boot-parent
+ spring-boot-parent
+ pom
+
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+ ..
+
+
+
+ spring-boot-with-starter-parent
+ spring-boot-with-custom-parent
+
+
+
diff --git a/spring-boot-parent/spring-boot-with-custom-parent/pom.xml b/spring-boot-parent/spring-boot-with-custom-parent/pom.xml
new file mode 100644
index 0000000000..de2946fbb2
--- /dev/null
+++ b/spring-boot-parent/spring-boot-with-custom-parent/pom.xml
@@ -0,0 +1,41 @@
+
+
+
+ 4.0.0
+ spring-boot-with-custom-parent
+ 1.0.0-SNAPSHOT
+ spring-boot-with-custom-parent
+
+
+ com.baeldung
+ spring-boot-parent
+ 1.0.0-SNAPSHOT
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-dependencies
+ ${spring-boot.version}
+ pom
+ import
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
+ 1.8
+ 2.1.5.RELEASE
+
+
+
diff --git a/spring-boot-parent/spring-boot-with-custom-parent/src/main/java/com/baeldung/customparent/SpringBootStarterCustomParentApplication.java b/spring-boot-parent/spring-boot-with-custom-parent/src/main/java/com/baeldung/customparent/SpringBootStarterCustomParentApplication.java
new file mode 100644
index 0000000000..169717d7bb
--- /dev/null
+++ b/spring-boot-parent/spring-boot-with-custom-parent/src/main/java/com/baeldung/customparent/SpringBootStarterCustomParentApplication.java
@@ -0,0 +1,13 @@
+package com.baeldung.customparent;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SpringBootStarterCustomParentApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SpringBootStarterCustomParentApplication.class, args);
+ System.out.println("Spring boot application running without starter parent");
+ }
+}
diff --git a/spring-boot-parent/spring-boot-with-starter-parent/pom.xml b/spring-boot-parent/spring-boot-with-starter-parent/pom.xml
new file mode 100644
index 0000000000..1c6479ca60
--- /dev/null
+++ b/spring-boot-parent/spring-boot-with-starter-parent/pom.xml
@@ -0,0 +1,45 @@
+
+
+
+ 4.0.0
+ com.baeldung
+ spring-boot-with-starter-parent
+ 1.0.0-SNAPSHOT
+ spring-boot-with-starter-parent
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.1.5.RELEASE
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+ 2.1.1.RELEASE
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ junit
+ junit
+
+
+
+
+ 1.8
+ 4.11
+
+
+
diff --git a/spring-boot-parent/spring-boot-with-starter-parent/src/main/java/com/baeldung/starterparent/SpringBootStarterParentApplication.java b/spring-boot-parent/spring-boot-with-starter-parent/src/main/java/com/baeldung/starterparent/SpringBootStarterParentApplication.java
new file mode 100644
index 0000000000..f987165ce0
--- /dev/null
+++ b/spring-boot-parent/spring-boot-with-starter-parent/src/main/java/com/baeldung/starterparent/SpringBootStarterParentApplication.java
@@ -0,0 +1,14 @@
+package com.baeldung.starterparent;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SpringBootStarterParentApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SpringBootStarterParentApplication.class, args);
+ System.out.println("Spring boot application running with starter parent");
+ }
+
+}
diff --git a/spring-boot-performance/README.md b/spring-boot-performance/README.md
new file mode 100644
index 0000000000..015dd759a8
--- /dev/null
+++ b/spring-boot-performance/README.md
@@ -0,0 +1,3 @@
+### Relevant Articles
+
+- [Lazy Initialization in Spring Boot 2](https://www.baeldung.com/spring-boot-lazy-initialization)
diff --git a/spring-boot-performance/pom.xml b/spring-boot-performance/pom.xml
new file mode 100644
index 0000000000..f51df8bc0c
--- /dev/null
+++ b/spring-boot-performance/pom.xml
@@ -0,0 +1,45 @@
+
+ 4.0.0
+ spring-boot-performance
+ spring-boot-performance
+ war
+ This is a simple Spring Boot application taking advantage of the latest Spring Boot improvements/features. Current version: 2.2
+
+
+ parent-boot-performance
+ com.baeldung
+ 0.0.1-SNAPSHOT
+ ../parent-boot-performance
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+
+
+ spring-boot-performance
+
+
+ src/main/resources
+ true
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+
+
+
+
+
+
+ com.baeldung.lazyinitialization.Application
+
+
\ No newline at end of file
diff --git a/spring-boot-performance/src/main/java/com/baeldung/lazyinitialization/Application.java b/spring-boot-performance/src/main/java/com/baeldung/lazyinitialization/Application.java
new file mode 100644
index 0000000000..195b260399
--- /dev/null
+++ b/spring-boot-performance/src/main/java/com/baeldung/lazyinitialization/Application.java
@@ -0,0 +1,32 @@
+package com.baeldung.lazyinitialization;
+
+import com.baeldung.lazyinitialization.services.Writer;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+
+@SpringBootApplication
+public class Application {
+
+ @Bean("writer1")
+ public Writer getWriter1() {
+ return new Writer("Writer 1");
+ }
+
+ @Bean("writer2")
+ public Writer getWriter2() {
+ return new Writer("Writer 2");
+ }
+
+ public static void main(String[] args) {
+ ApplicationContext ctx = SpringApplication.run(Application.class, args);
+ System.out.println("Application context initialized!!!");
+
+ Writer writer1 = ctx.getBean("writer1", Writer.class);
+ writer1.write("First message");
+
+ Writer writer2 = ctx.getBean("writer2", Writer.class);
+ writer2.write("Second message");
+ }
+}
diff --git a/spring-boot-performance/src/main/java/com/baeldung/lazyinitialization/services/Writer.java b/spring-boot-performance/src/main/java/com/baeldung/lazyinitialization/services/Writer.java
new file mode 100644
index 0000000000..7c67fb7ea4
--- /dev/null
+++ b/spring-boot-performance/src/main/java/com/baeldung/lazyinitialization/services/Writer.java
@@ -0,0 +1,16 @@
+package com.baeldung.lazyinitialization.services;
+
+public class Writer {
+
+ private final String writerId;
+
+ public Writer(String writerId) {
+ this.writerId = writerId;
+ System.out.println(writerId + " initialized!!!");
+ }
+
+ public void write(String message) {
+ System.out.println(writerId + ": " + message);
+ }
+
+}
diff --git a/spring-boot-performance/src/main/resources/application.yml b/spring-boot-performance/src/main/resources/application.yml
new file mode 100644
index 0000000000..25f03eed56
--- /dev/null
+++ b/spring-boot-performance/src/main/resources/application.yml
@@ -0,0 +1,3 @@
+spring:
+ main:
+ lazy-initialization: true
\ No newline at end of file
diff --git a/spring-boot-property-exp/property-exp-custom-config/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-property-exp/property-exp-custom-config/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..874c4f582f
--- /dev/null
+++ b/spring-boot-property-exp/property-exp-custom-config/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.propertyexpansion.SpringBootPropertyExpansionApp;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringBootPropertyExpansionApp.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-boot-property-exp/property-exp-default-config/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-property-exp/property-exp-default-config/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..874c4f582f
--- /dev/null
+++ b/spring-boot-property-exp/property-exp-default-config/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.propertyexpansion.SpringBootPropertyExpansionApp;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringBootPropertyExpansionApp.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/exception/BadRequestException.java b/spring-boot-rest/src/main/java/com/baeldung/web/exception/BadRequestException.java
new file mode 100644
index 0000000000..9ebf885d4b
--- /dev/null
+++ b/spring-boot-rest/src/main/java/com/baeldung/web/exception/BadRequestException.java
@@ -0,0 +1,8 @@
+package com.baeldung.web.exception;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+@ResponseStatus(value = HttpStatus.BAD_REQUEST)
+public class BadRequestException extends RuntimeException {
+}
diff --git a/spring-boot-rest/src/main/java/com/baeldung/web/exception/ResourceNotFoundException.java b/spring-boot-rest/src/main/java/com/baeldung/web/exception/ResourceNotFoundException.java
new file mode 100644
index 0000000000..a80802eadf
--- /dev/null
+++ b/spring-boot-rest/src/main/java/com/baeldung/web/exception/ResourceNotFoundException.java
@@ -0,0 +1,8 @@
+package com.baeldung.web.exception;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+@ResponseStatus(value = HttpStatus.NOT_FOUND)
+public class ResourceNotFoundException extends RuntimeException {
+}
diff --git a/spring-boot-rest/src/test/java/com/baeldung/SpringContextTest.java b/spring-boot-rest/src/test/java/com/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..9cba7f8fc1
--- /dev/null
+++ b/spring-boot-rest/src/test/java/com/baeldung/SpringContextTest.java
@@ -0,0 +1,16 @@
+package com.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = {SpringBootRestApplication.class})
+public class SpringContextTest {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/spring-boot-security/src/main/java/com/baeldung/springbootsecurity/basic_auth/config/BasicAuthConfiguration.java b/spring-boot-security/src/main/java/com/baeldung/springbootsecurity/basic_auth/config/BasicConfiguration.java
similarity index 94%
rename from spring-boot-security/src/main/java/com/baeldung/springbootsecurity/basic_auth/config/BasicAuthConfiguration.java
rename to spring-boot-security/src/main/java/com/baeldung/springbootsecurity/basic_auth/config/BasicConfiguration.java
index 592ef5354d..3cfa45421c 100644
--- a/spring-boot-security/src/main/java/com/baeldung/springbootsecurity/basic_auth/config/BasicAuthConfiguration.java
+++ b/spring-boot-security/src/main/java/com/baeldung/springbootsecurity/basic_auth/config/BasicConfiguration.java
@@ -10,7 +10,7 @@ import org.springframework.security.crypto.password.PasswordEncoder;
@Configuration
@EnableWebSecurity
-public class BasicAuthConfiguration extends WebSecurityConfigurerAdapter {
+public class BasicConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
diff --git a/spring-boot-security/src/test/java/com/baeldung/springbootsecurity/basic_auth/BasicAuthConfigurationIntegrationTest.java b/spring-boot-security/src/test/java/com/baeldung/springbootsecurity/basic_auth/BasicConfigurationIntegrationTest.java
similarity index 90%
rename from spring-boot-security/src/test/java/com/baeldung/springbootsecurity/basic_auth/BasicAuthConfigurationIntegrationTest.java
rename to spring-boot-security/src/test/java/com/baeldung/springbootsecurity/basic_auth/BasicConfigurationIntegrationTest.java
index c091aa6d75..f221712513 100644
--- a/spring-boot-security/src/test/java/com/baeldung/springbootsecurity/basic_auth/BasicAuthConfigurationIntegrationTest.java
+++ b/spring-boot-security/src/test/java/com/baeldung/springbootsecurity/basic_auth/BasicConfigurationIntegrationTest.java
@@ -1,27 +1,26 @@
package com.baeldung.springbootsecurity.basic_auth;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.web.server.LocalServerPort;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.web.client.TestRestTemplate;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.test.context.junit4.SpringRunner;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.web.client.TestRestTemplate;
+import org.springframework.boot.web.server.LocalServerPort;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = RANDOM_PORT, classes = SpringBootSecurityApplication.class)
-public class BasicAuthConfigurationIntegrationTest {
+public class BasicConfigurationIntegrationTest {
TestRestTemplate restTemplate;
URL base;
@@ -45,7 +44,7 @@ public class BasicAuthConfigurationIntegrationTest {
}
@Test
- public void whenUserWithWrongCredentialsRequestsHomePage_ThenUnauthorizedPage() throws IllegalStateException, IOException {
+ public void whenUserWithWrongCredentials_thenUnauthorizedPage() throws IllegalStateException, IOException {
restTemplate = new TestRestTemplate("user", "wrongpassword");
ResponseEntity response = restTemplate.getForEntity(base.toString(), String.class);
diff --git a/spring-boot-testing/pom.xml b/spring-boot-testing/pom.xml
index 84107070bd..12fb14b366 100644
--- a/spring-boot-testing/pom.xml
+++ b/spring-boot-testing/pom.xml
@@ -15,6 +15,10 @@
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+ org.springframework.bootspring-boot-starter-web
@@ -33,6 +37,13 @@
test
+
+
+ it.ozimov
+ embedded-redis
+ 0.7.2
+ test
+ org.spockframework
diff --git a/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/configuration/RedisConfiguration.java b/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/configuration/RedisConfiguration.java
new file mode 100644
index 0000000000..6b5b20892f
--- /dev/null
+++ b/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/configuration/RedisConfiguration.java
@@ -0,0 +1,24 @@
+package com.baeldung.boot.embeddedRedis.configuration;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.repository.configuration.EnableRedisRepositories;
+
+@Configuration
+@EnableRedisRepositories
+public class RedisConfiguration {
+
+ @Bean
+ public LettuceConnectionFactory redisConnectionFactory(final RedisProperties redisProperties) {
+ return new LettuceConnectionFactory(redisProperties.getRedisHost(), redisProperties.getRedisPort());
+ }
+
+ @Bean
+ public RedisTemplate, ?> redisTemplate(final LettuceConnectionFactory connectionFactory) {
+ RedisTemplate template = new RedisTemplate<>();
+ template.setConnectionFactory(connectionFactory);
+ return template;
+ }
+}
diff --git a/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/configuration/RedisProperties.java b/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/configuration/RedisProperties.java
new file mode 100644
index 0000000000..76f2e1bbfe
--- /dev/null
+++ b/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/configuration/RedisProperties.java
@@ -0,0 +1,23 @@
+package com.baeldung.boot.embeddedRedis.configuration;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class RedisProperties {
+ private final int redisPort;
+ private final String redisHost;
+
+ public RedisProperties(@Value("${spring.redis.port}") final int redisPort, @Value("${spring.redis.host}") final String redisHost) {
+ this.redisPort = redisPort;
+ this.redisHost = redisHost;
+ }
+
+ public int getRedisPort() {
+ return redisPort;
+ }
+
+ public String getRedisHost() {
+ return redisHost;
+ }
+}
diff --git a/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/domain/User.java b/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/domain/User.java
new file mode 100644
index 0000000000..41657aaa66
--- /dev/null
+++ b/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/domain/User.java
@@ -0,0 +1,25 @@
+package com.baeldung.boot.embeddedRedis.domain;
+
+import org.springframework.data.annotation.Id;
+import org.springframework.data.redis.core.RedisHash;
+
+import java.util.UUID;
+
+@RedisHash("user")
+public class User {
+ @Id private UUID id;
+ private String name;
+
+ public User(UUID id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ public UUID getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
diff --git a/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/domain/repository/UserRepository.java b/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/domain/repository/UserRepository.java
new file mode 100644
index 0000000000..0558bb8482
--- /dev/null
+++ b/spring-boot-testing/src/main/java/com/baeldung/boot/embeddedRedis/domain/repository/UserRepository.java
@@ -0,0 +1,10 @@
+package com.baeldung.boot.embeddedRedis.domain.repository;
+
+import com.baeldung.boot.embeddedRedis.domain.User;
+import org.springframework.data.repository.CrudRepository;
+
+import java.util.UUID;
+
+public interface UserRepository extends CrudRepository {
+
+}
diff --git a/spring-boot-testing/src/main/resources/application.properties b/spring-boot-testing/src/main/resources/application.properties
index e378aacdd5..8dc7f6e3c3 100644
--- a/spring-boot-testing/src/main/resources/application.properties
+++ b/spring-boot-testing/src/main/resources/application.properties
@@ -1,3 +1,6 @@
+# embedded redis
+spring.redis.host= localhost
+spring.redis.port= 6379
# security
spring.security.user.name=john
diff --git a/spring-boot-testing/src/test/java/com/baeldung/boot/SpringContextTest.java b/spring-boot-testing/src/test/java/com/baeldung/boot/SpringContextTest.java
new file mode 100644
index 0000000000..f3c8b9a954
--- /dev/null
+++ b/spring-boot-testing/src/test/java/com/baeldung/boot/SpringContextTest.java
@@ -0,0 +1,15 @@
+package com.baeldung.boot;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/TestRedisConfiguration.java b/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/TestRedisConfiguration.java
new file mode 100644
index 0000000000..b4748bcd38
--- /dev/null
+++ b/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/TestRedisConfiguration.java
@@ -0,0 +1,28 @@
+package com.baeldung.boot.embeddedRedis;
+
+import com.baeldung.boot.embeddedRedis.configuration.RedisProperties;
+import org.springframework.boot.test.context.TestConfiguration;
+import redis.embedded.RedisServer;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+@TestConfiguration
+public class TestRedisConfiguration {
+
+ private final RedisServer redisServer;
+
+ public TestRedisConfiguration(final RedisProperties redisProperties) {
+ this.redisServer = new RedisServer(redisProperties.getRedisPort());
+ }
+
+ @PostConstruct
+ public void postConstruct() {
+ redisServer.start();
+ }
+
+ @PreDestroy
+ public void preDestroy() {
+ redisServer.stop();
+ }
+}
diff --git a/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/domain/repository/UserRepositoryIntegrationTest.java b/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/domain/repository/UserRepositoryIntegrationTest.java
new file mode 100644
index 0000000000..9577ccf0e8
--- /dev/null
+++ b/spring-boot-testing/src/test/java/com/baeldung/boot/embeddedRedis/domain/repository/UserRepositoryIntegrationTest.java
@@ -0,0 +1,31 @@
+package com.baeldung.boot.embeddedRedis.domain.repository;
+
+import com.baeldung.boot.embeddedRedis.TestRedisConfiguration;
+import com.baeldung.boot.embeddedRedis.domain.User;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.UUID;
+
+import static org.junit.Assert.assertNotNull;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = TestRedisConfiguration.class)
+public class UserRepositoryIntegrationTest {
+
+ @Autowired
+ private UserRepository userRepository;
+
+ @Test
+ public void shouldSaveUser_toRedis() {
+ final UUID id = UUID.randomUUID();
+ final User user = new User(id, "name");
+
+ final User saved = userRepository.save(user);
+
+ assertNotNull(saved);
+ }
+}
\ No newline at end of file
diff --git a/spring-boot-testing/src/test/resources/application-test.properties b/spring-boot-testing/src/test/resources/application-test.properties
new file mode 100644
index 0000000000..a2c9b6d480
--- /dev/null
+++ b/spring-boot-testing/src/test/resources/application-test.properties
@@ -0,0 +1,2 @@
+# test properties
+spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration
\ No newline at end of file
diff --git a/spring-boot-testing/src/test/resources/application.properties b/spring-boot-testing/src/test/resources/application.properties
new file mode 100644
index 0000000000..0c5b0e13e6
--- /dev/null
+++ b/spring-boot-testing/src/test/resources/application.properties
@@ -0,0 +1,6 @@
+#embedded redis
+spring.redis.host= localhost
+spring.redis.port= 6370
+# security
+spring.security.user.name=john
+spring.security.user.password=123
\ No newline at end of file
diff --git a/spring-boot-vue/src/test/java/org/baeldung/SpringContextTest.java b/spring-boot-vue/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..16e0708fc9
--- /dev/null
+++ b/spring-boot-vue/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.springbootmvc.SpringBootMvcApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringBootMvcApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-boot/.attach_pid12812 b/spring-boot/.attach_pid12812
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/spring-boot/README.MD b/spring-boot/README.MD
index d7af3f4614..e159220cbc 100644
--- a/spring-boot/README.MD
+++ b/spring-boot/README.MD
@@ -5,7 +5,6 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
- [A Guide to Spring in Eclipse STS](http://www.baeldung.com/eclipse-sts-spring)
- [The @ServletComponentScan Annotation in Spring Boot](http://www.baeldung.com/spring-servletcomponentscan)
-- [Intro to Building an Application with Spring Boot](http://www.baeldung.com/intro-to-spring-boot)
- [How to Register a Servlet in Java](http://www.baeldung.com/register-servlet)
- [Guide to Spring WebUtils and ServletRequestUtils](http://www.baeldung.com/spring-webutils-servletrequestutils)
- [Using Custom Banners in Spring Boot](http://www.baeldung.com/spring-boot-custom-banners)
@@ -30,10 +29,9 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
- [Spring Shutdown Callbacks](http://www.baeldung.com/spring-shutdown-callbacks)
- [Container Configuration in Spring Boot 2](http://www.baeldung.com/embeddedservletcontainercustomizer-configurableembeddedservletcontainer-spring-boot)
- [Introduction to Chaos Monkey](https://www.baeldung.com/spring-boot-chaos-monkey)
-- [Spring Component Scanning](https://www.baeldung.com/spring-component-scanning)
- [Load Spring Boot Properties From a JSON File](https://www.baeldung.com/spring-boot-json-properties)
- [Display Auto-Configuration Report in Spring Boot](https://www.baeldung.com/spring-boot-auto-configuration-report)
- [Injecting Git Information Into Spring](https://www.baeldung.com/spring-git-information)
- [Validation in Spring Boot](https://www.baeldung.com/spring-boot-bean-validation)
- [Guide to Creating and Running a Jar File in Java](https://www.baeldung.com/java-create-jar)
-- [Entity To DTO Conversion for a Spring REST API](https://www.baeldung.com/entity-to-and-from-dto-for-a-java-spring-application)
+- [Guide to @EnableConfigurationProperties](https://www.baeldung.com/spring-enable-config-properties)
diff --git a/spring-boot/src/main/java/com/baeldung/properties/conversion/Employee.java b/spring-boot/src/main/java/com/baeldung/properties/conversion/Employee.java
new file mode 100644
index 0000000000..52c7881dfc
--- /dev/null
+++ b/spring-boot/src/main/java/com/baeldung/properties/conversion/Employee.java
@@ -0,0 +1,30 @@
+package com.baeldung.properties.conversion;
+
+public class Employee {
+
+ private String name;
+ private double salary;
+
+ public Employee(String name, double salary) {
+ super();
+ this.name = name;
+ this.salary = salary;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public double getSalary() {
+ return salary;
+ }
+
+ public void setSalary(double salary) {
+ this.salary = salary;
+ }
+
+}
diff --git a/spring-boot/src/main/java/com/baeldung/properties/conversion/EmployeeConverter.java b/spring-boot/src/main/java/com/baeldung/properties/conversion/EmployeeConverter.java
new file mode 100644
index 0000000000..6ec19cae72
--- /dev/null
+++ b/spring-boot/src/main/java/com/baeldung/properties/conversion/EmployeeConverter.java
@@ -0,0 +1,16 @@
+package com.baeldung.properties.conversion;
+
+import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;
+import org.springframework.core.convert.converter.Converter;
+import org.springframework.stereotype.Component;
+
+@Component
+@ConfigurationPropertiesBinding
+public class EmployeeConverter implements Converter {
+
+ @Override
+ public Employee convert(String from) {
+ String[] data = from.split(",");
+ return new Employee(data[0], Double.parseDouble(data[1]));
+ }
+}
diff --git a/spring-boot/src/main/java/com/baeldung/properties/conversion/PropertiesConversionApplication.java b/spring-boot/src/main/java/com/baeldung/properties/conversion/PropertiesConversionApplication.java
new file mode 100644
index 0000000000..f00a26e9c4
--- /dev/null
+++ b/spring-boot/src/main/java/com/baeldung/properties/conversion/PropertiesConversionApplication.java
@@ -0,0 +1,14 @@
+package com.baeldung.properties.conversion;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+
+@SpringBootApplication
+@ComponentScan(basePackageClasses = { PropertyConversion.class, EmployeeConverter.class })
+public class PropertiesConversionApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(PropertiesConversionApplication.class, args);
+ }
+
+}
diff --git a/spring-boot/src/main/java/com/baeldung/properties/conversion/PropertyConversion.java b/spring-boot/src/main/java/com/baeldung/properties/conversion/PropertyConversion.java
new file mode 100644
index 0000000000..b9c890306f
--- /dev/null
+++ b/spring-boot/src/main/java/com/baeldung/properties/conversion/PropertyConversion.java
@@ -0,0 +1,92 @@
+package com.baeldung.properties.conversion;
+
+import java.time.Duration;
+import java.time.temporal.ChronoUnit;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.convert.DataSizeUnit;
+import org.springframework.boot.convert.DurationUnit;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
+import org.springframework.util.unit.DataSize;
+import org.springframework.util.unit.DataUnit;
+
+@Configuration
+@PropertySource("classpath:conversion.properties")
+@ConfigurationProperties(prefix = "conversion")
+public class PropertyConversion {
+ private Duration timeInDefaultUnit;
+
+ private Duration timeInNano;
+
+ @DurationUnit(ChronoUnit.DAYS)
+ private Duration timeInDays;
+
+ private DataSize sizeInDefaultUnit;
+
+ private DataSize sizeInGB;
+
+ @DataSizeUnit(DataUnit.TERABYTES)
+ private DataSize sizeInTB;
+
+ private Employee employee;
+
+ // Getters and setters
+
+ public Duration getTimeInDefaultUnit() {
+ return timeInDefaultUnit;
+ }
+
+ public void setTimeInDefaultUnit(Duration timeInDefaultUnit) {
+ this.timeInDefaultUnit = timeInDefaultUnit;
+ }
+
+ public Duration getTimeInNano() {
+ return timeInNano;
+ }
+
+ public void setTimeInNano(Duration timeInNano) {
+ this.timeInNano = timeInNano;
+ }
+
+ public Duration getTimeInDays() {
+ return timeInDays;
+ }
+
+ public void setTimeInDays(Duration timeInDays) {
+ this.timeInDays = timeInDays;
+ }
+
+ public DataSize getSizeInDefaultUnit() {
+ return sizeInDefaultUnit;
+ }
+
+ public void setSizeInDefaultUnit(DataSize sizeInDefaultUnit) {
+ this.sizeInDefaultUnit = sizeInDefaultUnit;
+ }
+
+ public DataSize getSizeInGB() {
+ return sizeInGB;
+ }
+
+ public void setSizeInGB(DataSize sizeInGB) {
+ this.sizeInGB = sizeInGB;
+ }
+
+ public DataSize getSizeInTB() {
+ return sizeInTB;
+ }
+
+ public void setSizeInTB(DataSize sizeInTB) {
+ this.sizeInTB = sizeInTB;
+ }
+
+ public Employee getEmployee() {
+ return employee;
+ }
+
+ public void setEmployee(Employee employee) {
+ this.employee = employee;
+ }
+
+}
diff --git a/spring-boot/src/main/java/org/baeldung/properties/AdditionalConfiguration.java b/spring-boot/src/main/java/org/baeldung/properties/AdditionalConfiguration.java
new file mode 100644
index 0000000000..499666c143
--- /dev/null
+++ b/spring-boot/src/main/java/org/baeldung/properties/AdditionalConfiguration.java
@@ -0,0 +1,14 @@
+package org.baeldung.properties;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@EnableConfigurationProperties(AdditionalProperties.class)
+public class AdditionalConfiguration {
+
+ @Autowired
+ private AdditionalProperties additionalProperties;
+
+}
diff --git a/spring-boot/src/main/java/org/baeldung/properties/AdditionalProperties.java b/spring-boot/src/main/java/org/baeldung/properties/AdditionalProperties.java
new file mode 100644
index 0000000000..64e39b1475
--- /dev/null
+++ b/spring-boot/src/main/java/org/baeldung/properties/AdditionalProperties.java
@@ -0,0 +1,26 @@
+package org.baeldung.properties;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+@ConfigurationProperties(prefix = "additional")
+public class AdditionalProperties {
+
+ private String unit;
+ private int max;
+
+ public String getUnit() {
+ return unit;
+ }
+
+ public void setUnit(String unit) {
+ this.unit = unit;
+ }
+
+ public int getMax() {
+ return max;
+ }
+
+ public void setMax(int max) {
+ this.max = max;
+ }
+}
diff --git a/spring-boot/src/main/java/org/baeldung/properties/ConfigPropertiesDemoApplication.java b/spring-boot/src/main/java/org/baeldung/properties/ConfigPropertiesDemoApplication.java
index 395d68060b..7b8f2c3411 100644
--- a/spring-boot/src/main/java/org/baeldung/properties/ConfigPropertiesDemoApplication.java
+++ b/spring-boot/src/main/java/org/baeldung/properties/ConfigPropertiesDemoApplication.java
@@ -5,11 +5,14 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
-@ComponentScan(basePackageClasses = { ConfigProperties.class, JsonProperties.class, CustomJsonProperties.class })
+@ComponentScan(basePackageClasses = {ConfigProperties.class,
+ JsonProperties.class,
+ CustomJsonProperties.class,
+ AdditionalConfiguration.class})
public class ConfigPropertiesDemoApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(ConfigPropertiesDemoApplication.class).initializers(new JsonPropertyContextInitializer())
- .run();
+ .run();
}
}
diff --git a/spring-boot/src/test/java/com/baeldung/properties/ConfigPropertiesIntegrationTest.java b/spring-boot/src/test/java/com/baeldung/properties/ConfigPropertiesIntegrationTest.java
index 3a4b6551b1..8f07b2da35 100644
--- a/spring-boot/src/test/java/com/baeldung/properties/ConfigPropertiesIntegrationTest.java
+++ b/spring-boot/src/test/java/com/baeldung/properties/ConfigPropertiesIntegrationTest.java
@@ -1,5 +1,6 @@
package com.baeldung.properties;
+import org.baeldung.properties.AdditionalProperties;
import org.baeldung.properties.ConfigProperties;
import org.baeldung.properties.ConfigPropertiesDemoApplication;
import org.junit.Assert;
@@ -18,6 +19,9 @@ public class ConfigPropertiesIntegrationTest {
@Autowired
private ConfigProperties properties;
+ @Autowired
+ private AdditionalProperties additionalProperties;
+
@Test
public void whenSimplePropertyQueriedthenReturnsProperty() throws Exception {
Assert.assertTrue("From address is read as null!", properties.getFrom() != null);
@@ -42,4 +46,10 @@ public class ConfigPropertiesIntegrationTest {
Assert.assertTrue("Incorrectly bound object property!", properties.getCredentials().getUsername().equals("john"));
Assert.assertTrue("Incorrectly bound object property!", properties.getCredentials().getPassword().equals("password"));
}
+
+ @Test
+ public void whenAdditionalPropertyQueriedthenReturnsProperty() {
+ Assert.assertTrue(additionalProperties.getUnit().equals("km"));
+ Assert.assertTrue(additionalProperties.getMax() == 100);
+ }
}
diff --git a/spring-boot/src/test/java/com/baeldung/properties/conversion/PropertiesConversionIntegrationTest.java b/spring-boot/src/test/java/com/baeldung/properties/conversion/PropertiesConversionIntegrationTest.java
new file mode 100644
index 0000000000..53bad329ea
--- /dev/null
+++ b/spring-boot/src/test/java/com/baeldung/properties/conversion/PropertiesConversionIntegrationTest.java
@@ -0,0 +1,46 @@
+package com.baeldung.properties.conversion;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.time.Duration;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.TestPropertySource;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.util.unit.DataSize;
+
+import com.baeldung.properties.conversion.PropertiesConversionApplication;
+import com.baeldung.properties.conversion.PropertyConversion;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = PropertiesConversionApplication.class)
+@TestPropertySource("classpath:conversion.properties")
+public class PropertiesConversionIntegrationTest {
+
+ @Autowired
+ private PropertyConversion properties;
+
+ @Test
+ public void whenUseTimeUnitPropertyConversion_thenSuccess() throws Exception {
+ assertEquals(Duration.ofMillis(10), properties.getTimeInDefaultUnit());
+ assertEquals(Duration.ofNanos(9), properties.getTimeInNano());
+ assertEquals(Duration.ofDays(2), properties.getTimeInDays());
+ }
+
+ @Test
+ public void whenUseDataSizePropertyConversion_thenSuccess() throws Exception {
+ assertEquals(DataSize.ofBytes(300), properties.getSizeInDefaultUnit());
+ assertEquals(DataSize.ofGigabytes(2), properties.getSizeInGB());
+ assertEquals(DataSize.ofTerabytes(4), properties.getSizeInTB());
+ }
+
+ @Test
+ public void whenUseCustomPropertyConverter_thenSuccess() throws Exception {
+ assertEquals("john", properties.getEmployee().getName());
+ assertEquals(2000.0, properties.getEmployee().getSalary());
+ }
+
+}
diff --git a/spring-boot/src/test/resources/configprops-test.properties b/spring-boot/src/test/resources/configprops-test.properties
index ea11f2159e..5eed93a22b 100644
--- a/spring-boot/src/test/resources/configprops-test.properties
+++ b/spring-boot/src/test/resources/configprops-test.properties
@@ -20,3 +20,7 @@ mail.credentials.authMethod=SHA1
#Bean method properties
item.name=Test item name
item.size=21
+
+#Additional properties
+additional.unit=km
+additional.max=100
diff --git a/spring-boot/src/test/resources/conversion.properties b/spring-boot/src/test/resources/conversion.properties
new file mode 100644
index 0000000000..640442ec33
--- /dev/null
+++ b/spring-boot/src/test/resources/conversion.properties
@@ -0,0 +1,11 @@
+###### time unit
+conversion.timeInDefaultUnit=10
+conversion.timeInNano=9ns
+conversion.timeInDays=2
+
+###### data size
+conversion.sizeInDefaultUnit=300
+conversion.sizeInGB=2GB
+conversion.sizeInTB=4
+
+conversion.employee=john,2000
\ No newline at end of file
diff --git a/spring-cloud-bus/spring-cloud-config-client/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud-bus/spring-cloud-config-client/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..a5ab1342a1
--- /dev/null
+++ b/spring-cloud-bus/spring-cloud-config-client/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,18 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.SpringCloudConfigClientApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringCloudConfigClientApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/spring-cloud-bus/spring-cloud-config-server/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud-bus/spring-cloud-config-server/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..19ca53c4a7
--- /dev/null
+++ b/spring-cloud-bus/spring-cloud-config-server/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,18 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.SpringCloudConfigServerApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringCloudConfigServerApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/spring-cloud-data-flow/batch-job/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud-data-flow/batch-job/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..3ac11452d3
--- /dev/null
+++ b/spring-cloud-data-flow/batch-job/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,18 @@
+package org.baeldung;
+
+import org.baeldung.spring.cloud.JobConfiguration;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+@ContextConfiguration(classes = JobConfiguration.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud-data-flow/data-flow-server/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud-data-flow/data-flow-server/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..83cb8067cf
--- /dev/null
+++ b/spring-cloud-data-flow/data-flow-server/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,16 @@
+package org.baeldung;
+
+import org.baeldung.spring.cloud.DataFlowServerApplication;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = DataFlowServerApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud-data-flow/data-flow-shell/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud-data-flow/data-flow-shell/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..c456f69979
--- /dev/null
+++ b/spring-cloud-data-flow/data-flow-shell/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.baeldung.spring.cloud.DataFlowShellApplication;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = DataFlowShellApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/spring-cloud-data-flow/log-sink/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud-data-flow/log-sink/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..42903189d3
--- /dev/null
+++ b/spring-cloud-data-flow/log-sink/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.baeldung.spring.cloud.LogSinkApplication;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = LogSinkApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/spring-cloud-data-flow/time-processor/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud-data-flow/time-processor/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..d090e626d2
--- /dev/null
+++ b/spring-cloud-data-flow/time-processor/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.baeldung.spring.cloud.TimeProcessorApplication;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = TimeProcessorApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/spring-cloud-data-flow/time-source/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud-data-flow/time-source/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..e19b88de90
--- /dev/null
+++ b/spring-cloud-data-flow/time-source/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.baeldung.spring.cloud.TimeSourceApplication;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = TimeSourceApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-archaius/additional-sources-simple/src/test/java/com/baeldung/spring/cloud/archaius/additionalsources/SpringContextTest.java b/spring-cloud/spring-cloud-archaius/additional-sources-simple/src/test/java/com/baeldung/spring/cloud/archaius/additionalsources/SpringContextTest.java
new file mode 100644
index 0000000000..7e38329f88
--- /dev/null
+++ b/spring-cloud/spring-cloud-archaius/additional-sources-simple/src/test/java/com/baeldung/spring/cloud/archaius/additionalsources/SpringContextTest.java
@@ -0,0 +1,15 @@
+package com.baeldung.spring.cloud.archaius.additionalsources;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = AdditionalSourcesSimpleApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-archaius/basic-config/src/test/java/com/baeldung/spring/cloud/archaius/basic/SpringContextIntegrationTest.java b/spring-cloud/spring-cloud-archaius/basic-config/src/test/java/com/baeldung/spring/cloud/archaius/basic/SpringContextIntegrationTest.java
new file mode 100644
index 0000000000..818e313c98
--- /dev/null
+++ b/spring-cloud/spring-cloud-archaius/basic-config/src/test/java/com/baeldung/spring/cloud/archaius/basic/SpringContextIntegrationTest.java
@@ -0,0 +1,16 @@
+package com.baeldung.spring.cloud.archaius.basic;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SpringContextIntegrationTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-archaius/basic-config/src/test/java/com/baeldung/spring/cloud/archaius/basic/SpringContextTest.java b/spring-cloud/spring-cloud-archaius/basic-config/src/test/java/com/baeldung/spring/cloud/archaius/basic/SpringContextTest.java
new file mode 100644
index 0000000000..e88ec436c6
--- /dev/null
+++ b/spring-cloud/spring-cloud-archaius/basic-config/src/test/java/com/baeldung/spring/cloud/archaius/basic/SpringContextTest.java
@@ -0,0 +1,16 @@
+package com.baeldung.spring.cloud.archaius.basic;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-archaius/basic-config/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-archaius/basic-config/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..7674713ff8
--- /dev/null
+++ b/spring-cloud/spring-cloud-archaius/basic-config/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.spring.cloud.archaius.basic.BasicArchaiusApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = BasicArchaiusApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-archaius/extra-configs/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-archaius/extra-configs/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..a03bd8c23b
--- /dev/null
+++ b/spring-cloud/spring-cloud-archaius/extra-configs/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.spring.cloud.archaius.extraconfigs.ExtraConfigsApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = ExtraConfigsApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-archaius/jdbc-config/src/test/java/com/baeldung/spring/cloud/archaius/jdbconfig/SpringContextTest.java b/spring-cloud/spring-cloud-archaius/jdbc-config/src/test/java/com/baeldung/spring/cloud/archaius/jdbconfig/SpringContextTest.java
new file mode 100644
index 0000000000..5d3bc8e741
--- /dev/null
+++ b/spring-cloud/spring-cloud-archaius/jdbc-config/src/test/java/com/baeldung/spring/cloud/archaius/jdbconfig/SpringContextTest.java
@@ -0,0 +1,15 @@
+package com.baeldung.spring.cloud.archaius.jdbconfig;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = JdbcSourcesApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-aws/.attach_pid23938 b/spring-cloud/spring-cloud-aws/.attach_pid23938
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/spring-cloud/spring-cloud-bootstrap/config/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-bootstrap/config/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..98ae3e4895
--- /dev/null
+++ b/spring-cloud/spring-cloud-bootstrap/config/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.spring.cloud.bootstrap.config.ConfigApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = ConfigApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-bootstrap/gateway/pom.xml b/spring-cloud/spring-cloud-bootstrap/gateway/pom.xml
index 4f9c60a26a..6cbaa5ac2d 100644
--- a/spring-cloud/spring-cloud-bootstrap/gateway/pom.xml
+++ b/spring-cloud/spring-cloud-bootstrap/gateway/pom.xml
@@ -97,6 +97,7 @@
+
Dalston.RELEASE
diff --git a/spring-cloud/spring-cloud-bootstrap/gateway/src/test/java/com/baeldung/spring/cloud/bootstrap/gateway/SpringContextIntegrationTest.java b/spring-cloud/spring-cloud-bootstrap/gateway/src/test/java/com/baeldung/spring/cloud/bootstrap/gateway/SpringContextIntegrationTest.java
new file mode 100644
index 0000000000..dc635cd003
--- /dev/null
+++ b/spring-cloud/spring-cloud-bootstrap/gateway/src/test/java/com/baeldung/spring/cloud/bootstrap/gateway/SpringContextIntegrationTest.java
@@ -0,0 +1,16 @@
+package com.baeldung.spring.cloud.bootstrap.gateway;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SpringContextIntegrationTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-bootstrap/gateway/src/test/java/com/baeldung/spring/cloud/bootstrap/gateway/SpringContextTest.java b/spring-cloud/spring-cloud-bootstrap/gateway/src/test/java/com/baeldung/spring/cloud/bootstrap/gateway/SpringContextTest.java
new file mode 100644
index 0000000000..a2d1cd1087
--- /dev/null
+++ b/spring-cloud/spring-cloud-bootstrap/gateway/src/test/java/com/baeldung/spring/cloud/bootstrap/gateway/SpringContextTest.java
@@ -0,0 +1,16 @@
+package com.baeldung.spring.cloud.bootstrap.gateway;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-bootstrap/zipkin/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-bootstrap/zipkin/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..76b7539b6b
--- /dev/null
+++ b/spring-cloud/spring-cloud-bootstrap/zipkin/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.spring.cloud.bootstrap.zipkin.ZipkinApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = ZipkinApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-config/client/pom.xml b/spring-cloud/spring-cloud-config/client/pom.xml
index c55f9bc471..14b0d2f9b1 100644
--- a/spring-cloud/spring-cloud-config/client/pom.xml
+++ b/spring-cloud/spring-cloud-config/client/pom.xml
@@ -20,8 +20,7 @@
org.springframework.bootspring-boot-starter-web
-
-
+ org.springframework.bootspring-boot-starter-test
diff --git a/spring-cloud/spring-cloud-config/server/pom.xml b/spring-cloud/spring-cloud-config/server/pom.xml
index b4be7663e2..674749a48d 100644
--- a/spring-cloud/spring-cloud-config/server/pom.xml
+++ b/spring-cloud/spring-cloud-config/server/pom.xml
@@ -24,8 +24,7 @@
org.springframework.bootspring-boot-starter-web
-
-
+ org.springframework.bootspring-boot-starter-test
diff --git a/spring-cloud/spring-cloud-config/server/src/test/java/com/baeldung/spring/cloud/config/server/SpringContextTest.java b/spring-cloud/spring-cloud-config/server/src/test/java/com/baeldung/spring/cloud/config/server/SpringContextTest.java
new file mode 100644
index 0000000000..d879737553
--- /dev/null
+++ b/spring-cloud/spring-cloud-config/server/src/test/java/com/baeldung/spring/cloud/config/server/SpringContextTest.java
@@ -0,0 +1,16 @@
+package com.baeldung.spring.cloud.config.server;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringBootTest(classes = ConfigServer.class)
+@WebAppConfiguration
+public class SpringContextTest {
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-connectors-heroku/src/test/java/com/baeldung/spring/cloud/connectors/heroku/SpringContextTest.java b/spring-cloud/spring-cloud-connectors-heroku/src/test/java/com/baeldung/spring/cloud/connectors/heroku/SpringContextTest.java
new file mode 100644
index 0000000000..c6066027f5
--- /dev/null
+++ b/spring-cloud/spring-cloud-connectors-heroku/src/test/java/com/baeldung/spring/cloud/connectors/heroku/SpringContextTest.java
@@ -0,0 +1,17 @@
+package com.baeldung.spring.cloud.connectors.heroku;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.spring.cloud.connectors.heroku.ConnectorsHerokuApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = ConnectorsHerokuApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-contract/pom.xml b/spring-cloud/spring-cloud-contract/pom.xml
index ea71891648..a7ee52e954 100644
--- a/spring-cloud/spring-cloud-contract/pom.xml
+++ b/spring-cloud/spring-cloud-contract/pom.xml
@@ -56,7 +56,6 @@
UTF-8UTF-8
- 1.82.1.1.RELEASE2.1.4.RELEASE
diff --git a/spring-cloud/spring-cloud-contract/spring-cloud-contract-consumer/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-contract/spring-cloud-contract-consumer/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..e9098b1467
--- /dev/null
+++ b/spring-cloud/spring-cloud-contract/spring-cloud-contract-consumer/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.spring.cloud.springcloudcontractconsumer.SpringCloudContractConsumerApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringCloudContractConsumerApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-contract/spring-cloud-contract-producer/pom.xml b/spring-cloud/spring-cloud-contract/spring-cloud-contract-producer/pom.xml
index dffbd29206..7a0fa7db10 100644
--- a/spring-cloud/spring-cloud-contract/spring-cloud-contract-producer/pom.xml
+++ b/spring-cloud/spring-cloud-contract/spring-cloud-contract-producer/pom.xml
@@ -31,6 +31,7 @@
spring-boot-starter-data-rest
+
diff --git a/spring-cloud/spring-cloud-contract/spring-cloud-contract-producer/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-contract/spring-cloud-contract-producer/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..7d77cbbd7a
--- /dev/null
+++ b/spring-cloud/spring-cloud-contract/spring-cloud-contract-producer/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.spring.cloud.springcloudcontractproducer.SpringCloudContractProducerApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringCloudContractProducerApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-eureka/pom.xml b/spring-cloud/spring-cloud-eureka/pom.xml
index e8e3d67805..5afb006d41 100644
--- a/spring-cloud/spring-cloud-eureka/pom.xml
+++ b/spring-cloud/spring-cloud-eureka/pom.xml
@@ -9,18 +9,18 @@
Spring Cloud Eureka Server and Sample Clientspom
-
- spring-cloud-eureka-server
- spring-cloud-eureka-client
- spring-cloud-eureka-feign-client
-
-
com.baeldung.spring.cloudspring-cloud1.0.0-SNAPSHOT..
+
+
+ spring-cloud-eureka-server
+ spring-cloud-eureka-client
+ spring-cloud-eureka-feign-client
+
diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-client/src/test/java/com/baeldung/spring/cloud/eureka/client/SpringContextTest.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-client/src/test/java/com/baeldung/spring/cloud/eureka/client/SpringContextTest.java
new file mode 100644
index 0000000000..a3ed012abb
--- /dev/null
+++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-client/src/test/java/com/baeldung/spring/cloud/eureka/client/SpringContextTest.java
@@ -0,0 +1,16 @@
+package com.baeldung.spring.cloud.eureka.client;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/test/java/com/baeldung/spring/cloud/feign/client/SpringContextTest.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/test/java/com/baeldung/spring/cloud/feign/client/SpringContextTest.java
new file mode 100644
index 0000000000..ac8150defa
--- /dev/null
+++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-feign-client/src/test/java/com/baeldung/spring/cloud/feign/client/SpringContextTest.java
@@ -0,0 +1,16 @@
+package com.baeldung.spring.cloud.feign.client;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-server/src/test/java/com/baeldung/spring/cloud/eureka/server/SpringContextTest.java b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-server/src/test/java/com/baeldung/spring/cloud/eureka/server/SpringContextTest.java
new file mode 100644
index 0000000000..e7996bd316
--- /dev/null
+++ b/spring-cloud/spring-cloud-eureka/spring-cloud-eureka-server/src/test/java/com/baeldung/spring/cloud/eureka/server/SpringContextTest.java
@@ -0,0 +1,16 @@
+package com.baeldung.spring.cloud.eureka.server;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-functions/pom.xml b/spring-cloud/spring-cloud-functions/pom.xml
index 7a44e4ae0f..82147cea28 100644
--- a/spring-cloud/spring-cloud-functions/pom.xml
+++ b/spring-cloud/spring-cloud-functions/pom.xml
@@ -29,7 +29,7 @@
org.springframework.cloudspring-cloud-starter-function-web
- 1.0.1.RELEASE
+ ${spring-cloud-function.version}com.amazonaws
@@ -40,7 +40,7 @@
com.amazonawsaws-lambda-java-core
- 1.1.0
+ ${aws-lambda-java-core.version}provided
@@ -87,6 +87,7 @@
UTF-81.0.1.RELEASE2.0.2
+ 1.1.02.0.4.RELEASE
diff --git a/spring-cloud/spring-cloud-functions/src/test/java/com/baeldung/spring/cloudfunction/aws/SpringContextTest.java b/spring-cloud/spring-cloud-functions/src/test/java/com/baeldung/spring/cloudfunction/aws/SpringContextTest.java
new file mode 100644
index 0000000000..67411ebd4a
--- /dev/null
+++ b/spring-cloud/spring-cloud-functions/src/test/java/com/baeldung/spring/cloudfunction/aws/SpringContextTest.java
@@ -0,0 +1,15 @@
+package com.baeldung.spring.cloudfunction.aws;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = CloudFunctionAwsApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-gateway/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-gateway/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..b7e2acf7a8
--- /dev/null
+++ b/spring-cloud/spring-cloud-gateway/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.spring.cloud.GatewayApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = GatewayApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-hystrix/feign-rest-consumer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/consumer/SpringContextTest.java b/spring-cloud/spring-cloud-hystrix/feign-rest-consumer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/consumer/SpringContextTest.java
new file mode 100644
index 0000000000..d5f8180f20
--- /dev/null
+++ b/spring-cloud/spring-cloud-hystrix/feign-rest-consumer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/consumer/SpringContextTest.java
@@ -0,0 +1,18 @@
+package com.baeldung.spring.cloud.hystrix.rest.consumer;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = RestConsumerFeignApplication.class)
+@WebAppConfiguration
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-hystrix/rest-consumer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/consumer/SpringContextTest.java b/spring-cloud/spring-cloud-hystrix/rest-consumer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/consumer/SpringContextTest.java
new file mode 100644
index 0000000000..d3260a4517
--- /dev/null
+++ b/spring-cloud/spring-cloud-hystrix/rest-consumer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/consumer/SpringContextTest.java
@@ -0,0 +1,18 @@
+package com.baeldung.spring.cloud.hystrix.rest.consumer;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = RestConsumerApplication.class)
+@WebAppConfiguration
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-hystrix/rest-producer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/producer/SpringContextTest.java b/spring-cloud/spring-cloud-hystrix/rest-producer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/producer/SpringContextTest.java
new file mode 100644
index 0000000000..bd871fc1da
--- /dev/null
+++ b/spring-cloud/spring-cloud-hystrix/rest-producer/src/test/java/com/baeldung/spring/cloud/hystrix/rest/producer/SpringContextTest.java
@@ -0,0 +1,16 @@
+package com.baeldung.spring.cloud.hystrix.rest.producer;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-kubernetes/client-service/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-kubernetes/client-service/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..af59614f7c
--- /dev/null
+++ b/spring-cloud/spring-cloud-kubernetes/client-service/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.spring.cloud.kubernetes.client.Application;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+public class SpringContextTest {
+
+ @Test
+ public void contextLoads() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-kubernetes/demo-backend/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-kubernetes/demo-backend/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..af393cb697
--- /dev/null
+++ b/spring-cloud/spring-cloud-kubernetes/demo-backend/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,18 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.spring.cloud.kubernetes.backend.KubernetesBackendApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = KubernetesBackendApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-kubernetes/demo-frontend/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-kubernetes/demo-frontend/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..17cb5a5f39
--- /dev/null
+++ b/spring-cloud/spring-cloud-kubernetes/demo-frontend/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,18 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.spring.cloud.kubernetes.frontend.KubernetesFrontendApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = KubernetesFrontendApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-kubernetes/liveness-example/src/test/java/com/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-kubernetes/liveness-example/src/test/java/com/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..7c605567d8
--- /dev/null
+++ b/spring-cloud/spring-cloud-kubernetes/liveness-example/src/test/java/com/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package com.baeldung;
+
+import com.baeldung.liveness.Application;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+public class SpringContextTest {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-kubernetes/readiness-example/src/test/java/com/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-kubernetes/readiness-example/src/test/java/com/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..59802d220a
--- /dev/null
+++ b/spring-cloud/spring-cloud-kubernetes/readiness-example/src/test/java/com/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package com.baeldung;
+
+import com.baeldung.readiness.Application;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+public class SpringContextTest {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-kubernetes/travel-agency-service/src/test/java/com/baeldung/spring/cloud/kubernetes/travelagency/SpringContextTest.java b/spring-cloud/spring-cloud-kubernetes/travel-agency-service/src/test/java/com/baeldung/spring/cloud/kubernetes/travelagency/SpringContextTest.java
new file mode 100644
index 0000000000..6e7f99fb0d
--- /dev/null
+++ b/spring-cloud/spring-cloud-kubernetes/travel-agency-service/src/test/java/com/baeldung/spring/cloud/kubernetes/travelagency/SpringContextTest.java
@@ -0,0 +1,16 @@
+package com.baeldung.spring.cloud.kubernetes.travelagency;
+
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-openfeign/pom.xml b/spring-cloud/spring-cloud-openfeign/pom.xml
index 002a333749..92de33572b 100644
--- a/spring-cloud/spring-cloud-openfeign/pom.xml
+++ b/spring-cloud/spring-cloud-openfeign/pom.xml
@@ -9,7 +9,6 @@
openfeignOpenFeign project for Spring Boot
-
parent-boot-2com.baeldung
@@ -17,12 +16,6 @@
../../parent-boot-2
-
- 2.0.1.RELEASE
- Finchley.SR2
-
-
-
org.springframework.cloud
@@ -58,4 +51,9 @@
+
+ 2.0.1.RELEASE
+ Finchley.SR2
+
+
diff --git a/spring-cloud/spring-cloud-openfeign/src/test/java/com/baeldung/cloud/openfeign/SpringContextTest.java b/spring-cloud/spring-cloud-openfeign/src/test/java/com/baeldung/cloud/openfeign/SpringContextTest.java
new file mode 100644
index 0000000000..4bf35f74f4
--- /dev/null
+++ b/spring-cloud/spring-cloud-openfeign/src/test/java/com/baeldung/cloud/openfeign/SpringContextTest.java
@@ -0,0 +1,16 @@
+package com.baeldung.cloud.openfeign;
+
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = ExampleApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-rest/spring-cloud-rest-config-server/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-rest/spring-cloud-rest-config-server/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..1b4083e7a6
--- /dev/null
+++ b/spring-cloud/spring-cloud-rest/spring-cloud-rest-config-server/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,15 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringCloudRestConfigApplication.class)
+public class SpringContextTest {
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-ribbon-client/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-ribbon-client/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..23dbcf8ff6
--- /dev/null
+++ b/spring-cloud/spring-cloud-ribbon-client/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.spring.cloud.ribbon.client.ServerLocationApp;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = ServerLocationApp.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-security/auth-client/pom.xml b/spring-cloud/spring-cloud-security/auth-client/pom.xml
index 4f64f470f0..c414e584e5 100644
--- a/spring-cloud/spring-cloud-security/auth-client/pom.xml
+++ b/spring-cloud/spring-cloud-security/auth-client/pom.xml
@@ -13,6 +13,18 @@
1.0.0-SNAPSHOT
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
+
org.springframework.boot
@@ -24,7 +36,7 @@
org.springframework.cloud
- spring-cloud-starter-zuul
+ spring-cloud-starter-netflix-zuulorg.springframework.boot
@@ -34,14 +46,16 @@
org.webjarsjquery
+ ${jquery.version}org.webjarsbootstrap
+ ${bootstrap.version}org.webjars
- webjars-locator
+ webjars-locator-coreorg.springframework.boot
@@ -62,8 +76,8 @@
spring-boot-starter-thymeleaf
- org.springframework.security.oauth
- spring-security-oauth2
+ org.springframework.security.oauth.boot
+ spring-security-oauth2-autoconfigure
@@ -76,21 +90,11 @@
-
-
-
- org.springframework.cloud
- spring-cloud-dependencies
- ${spring-cloud.version}
- pom
- import
-
-
-
-
- 2.1.0
- Dalston.SR4
+ 2.2.0
+ Greenwich.SR1
+ 3.4.1
+ 4.3.1
diff --git a/spring-cloud/spring-cloud-security/auth-client/src/main/resources/application.properties b/spring-cloud/spring-cloud-security/auth-client/src/main/resources/application.properties
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/spring-cloud/spring-cloud-security/auth-client/src/main/resources/application.yml b/spring-cloud/spring-cloud-security/auth-client/src/main/resources/application.yml
index 2a758faeae..69617555d9 100644
--- a/spring-cloud/spring-cloud-security/auth-client/src/main/resources/application.yml
+++ b/spring-cloud/spring-cloud-security/auth-client/src/main/resources/application.yml
@@ -2,7 +2,8 @@
# These are default settings, but we add them for clarity.
server:
port: 8080
- contextPath: /
+ servlet:
+ context-path: /
# Configure the Authorization Server and User Info Resource Server details
security:
@@ -21,6 +22,7 @@ person:
# Proxies the calls to http://localhost:8080/api/* to our REST service at http://localhost:8081/*
# and automatically includes our OAuth2 token in the request headers
zuul:
+ sensitiveHeaders: Cookie,Set-Cookie
routes:
resource:
path: /api/**
diff --git a/spring-cloud/spring-cloud-security/auth-client/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-security/auth-client/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..02c429acf5
--- /dev/null
+++ b/spring-cloud/spring-cloud-security/auth-client/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,18 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.CloudSite;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = CloudSite.class)
+public class SpringContextTest {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-security/auth-resource/pom.xml b/spring-cloud/spring-cloud-security/auth-resource/pom.xml
index 22ee0528c3..a60eca740c 100644
--- a/spring-cloud/spring-cloud-security/auth-resource/pom.xml
+++ b/spring-cloud/spring-cloud-security/auth-resource/pom.xml
@@ -19,8 +19,8 @@
spring-boot-starter-web
- org.springframework.security.oauth
- spring-security-oauth2
+ org.springframework.security.oauth.boot
+ spring-security-oauth2-autoconfigureorg.springframework.boot
@@ -30,6 +30,7 @@
org.springframework.securityspring-security-jwt
+ ${spring-jwt.version}
@@ -55,7 +56,8 @@
- Edgware.RELEASE
+ Greenwich.SR1
+ 1.0.10.RELEASE
diff --git a/spring-cloud/spring-cloud-security/auth-resource/src/main/java/com/baeldung/config/ResourceConfigurer.java b/spring-cloud/spring-cloud-security/auth-resource/src/main/java/com/baeldung/config/ResourceConfigurer.java
index 977d74093a..abe942325f 100644
--- a/spring-cloud/spring-cloud-security/auth-resource/src/main/java/com/baeldung/config/ResourceConfigurer.java
+++ b/spring-cloud/spring-cloud-security/auth-resource/src/main/java/com/baeldung/config/ResourceConfigurer.java
@@ -3,7 +3,7 @@ package com.baeldung.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
@@ -11,15 +11,18 @@ import org.springframework.security.oauth2.config.annotation.web.configuration.R
* REST API Resource Server.
*/
@Configuration
-@EnableWebSecurity
@EnableResourceServer
@EnableGlobalMethodSecurity(prePostEnabled = true) // Allow method annotations like @PreAuthorize
public class ResourceConfigurer extends ResourceServerConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
- http.httpBasic().disable();
- http.authorizeRequests().anyRequest().authenticated();
+ http.sessionManagement()
+ .sessionCreationPolicy(SessionCreationPolicy.NEVER)
+ .and()
+ .authorizeRequests()
+ .anyRequest().authenticated();
+
}
}
diff --git a/spring-cloud/spring-cloud-security/auth-resource/src/main/resources/application.yml b/spring-cloud/spring-cloud-security/auth-resource/src/main/resources/application.yml
index 52e02ba41b..35063a7879 100644
--- a/spring-cloud/spring-cloud-security/auth-resource/src/main/resources/application.yml
+++ b/spring-cloud/spring-cloud-security/auth-resource/src/main/resources/application.yml
@@ -5,7 +5,6 @@ server:
# Configure the public key to use for verifying the incoming JWT tokens
security:
- sessions: NEVER
oauth2:
resource:
jwt:
diff --git a/spring-cloud/spring-cloud-security/auth-resource/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-security/auth-resource/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..a061928bf5
--- /dev/null
+++ b/spring-cloud/spring-cloud-security/auth-resource/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,18 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.Application;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+public class SpringContextTest {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-security/auth-server/pom.xml b/spring-cloud/spring-cloud-security/auth-server/pom.xml
index 4b3f94b825..afd8dbef44 100644
--- a/spring-cloud/spring-cloud-security/auth-server/pom.xml
+++ b/spring-cloud/spring-cloud-security/auth-server/pom.xml
@@ -38,7 +38,7 @@
- 1.1.2.RELEASE
+ 2.1.2.RELEASE
\ No newline at end of file
diff --git a/spring-cloud/spring-cloud-security/auth-server/src/main/java/com/baeldung/config/AuthServerConfigurer.java b/spring-cloud/spring-cloud-security/auth-server/src/main/java/com/baeldung/config/AuthServerConfigurer.java
index 32e445f998..7c9ee9ae18 100644
--- a/spring-cloud/spring-cloud-security/auth-server/src/main/java/com/baeldung/config/AuthServerConfigurer.java
+++ b/spring-cloud/spring-cloud-security/auth-server/src/main/java/com/baeldung/config/AuthServerConfigurer.java
@@ -9,6 +9,7 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.core.io.Resource;
import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
@@ -19,9 +20,7 @@ import org.springframework.security.oauth2.provider.token.store.KeyStoreKeyFacto
@Configuration
@EnableAuthorizationServer
@Order(6)
-public class AuthServerConfigurer
- extends
- AuthorizationServerConfigurerAdapter {
+public class AuthServerConfigurer extends AuthorizationServerConfigurerAdapter {
@Value("${jwt.certificate.store.file}")
private Resource keystore;
@@ -37,6 +36,9 @@ public class AuthServerConfigurer
@Autowired
private UserDetailsService userDetailsService;
+
+ @Autowired
+ private BCryptPasswordEncoder passwordEncoder;
@Override
public void configure(
@@ -45,8 +47,8 @@ public class AuthServerConfigurer
clients
.inMemory()
.withClient("authserver")
- .secret("passwordforauthserver")
- .redirectUris("http://localhost:8080/")
+ .secret(passwordEncoder.encode("passwordforauthserver"))
+ .redirectUris("http://localhost:8080/login")
.authorizedGrantTypes("authorization_code",
"refresh_token")
.scopes("myscope")
diff --git a/spring-cloud/spring-cloud-security/auth-server/src/main/java/com/baeldung/config/WebMvcConfigurer.java b/spring-cloud/spring-cloud-security/auth-server/src/main/java/com/baeldung/config/WebMvcConfig.java
similarity index 83%
rename from spring-cloud/spring-cloud-security/auth-server/src/main/java/com/baeldung/config/WebMvcConfigurer.java
rename to spring-cloud/spring-cloud-security/auth-server/src/main/java/com/baeldung/config/WebMvcConfig.java
index 23b56151e7..3cefd323b3 100644
--- a/spring-cloud/spring-cloud-security/auth-server/src/main/java/com/baeldung/config/WebMvcConfigurer.java
+++ b/spring-cloud/spring-cloud-security/auth-server/src/main/java/com/baeldung/config/WebMvcConfig.java
@@ -2,10 +2,10 @@ package com.baeldung.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
-public class WebMvcConfigurer extends WebMvcConfigurerAdapter {
+public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
diff --git a/spring-cloud/spring-cloud-security/auth-server/src/main/java/com/baeldung/config/WebSecurityConfigurer.java b/spring-cloud/spring-cloud-security/auth-server/src/main/java/com/baeldung/config/WebSecurityConfigurer.java
index 44406b8fa0..6a48c62097 100644
--- a/spring-cloud/spring-cloud-security/auth-server/src/main/java/com/baeldung/config/WebSecurityConfigurer.java
+++ b/spring-cloud/spring-cloud-security/auth-server/src/main/java/com/baeldung/config/WebSecurityConfigurer.java
@@ -6,8 +6,8 @@ import org.springframework.security.config.annotation.authentication.builders.Au
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-
import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableOAuth2Client;
@Configuration
@@ -34,7 +34,7 @@ public class WebSecurityConfigurer
AuthenticationManagerBuilder auth) throws Exception {
auth
.inMemoryAuthentication()
- .withUser("user").password("user")
+ .withUser("user").password(passwordEncoder().encode("user"))
.roles("USER")
.and()
.withUser("admin").password("admin")
@@ -48,5 +48,9 @@ public class WebSecurityConfigurer
return super.userDetailsServiceBean();
}
+ @Bean
+ public BCryptPasswordEncoder passwordEncoder() {
+ return new BCryptPasswordEncoder();
+ }
}
diff --git a/spring-cloud/spring-cloud-security/auth-server/src/main/resources/application.yml b/spring-cloud/spring-cloud-security/auth-server/src/main/resources/application.yml
index 1dc63d3f0e..b6e385e5c7 100644
--- a/spring-cloud/spring-cloud-security/auth-server/src/main/resources/application.yml
+++ b/spring-cloud/spring-cloud-security/auth-server/src/main/resources/application.yml
@@ -1,7 +1,8 @@
# Make the application available at http://localhost:7070/authserver
server:
port: 7070
- contextPath: /authserver
+ servlet:
+ context-path: /authserver
# Our certificate settings for enabling JWT tokens
jwt:
@@ -11,11 +12,4 @@ jwt:
password: abirkhan04
key:
alias: myauthkey
- password: abirkhan04
-
-
-security:
- oauth2:
- resource:
- filter-order: 3
-
\ No newline at end of file
+ password: abirkhan04
\ No newline at end of file
diff --git a/spring-cloud/spring-cloud-security/auth-server/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-security/auth-server/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..aec56a574c
--- /dev/null
+++ b/spring-cloud/spring-cloud-security/auth-server/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,18 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.AuthServer;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = AuthServer.class)
+public class SpringContextTest {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-security/pom.xml b/spring-cloud/spring-cloud-security/pom.xml
index 2eecf579a5..d65fd6520b 100644
--- a/spring-cloud/spring-cloud-security/pom.xml
+++ b/spring-cloud/spring-cloud-security/pom.xml
@@ -8,10 +8,10 @@
pom
- parent-boot-1
+ parent-boot-2com.baeldung0.0.1-SNAPSHOT
- ../../parent-boot-1
+ ../../parent-boot-2
diff --git a/spring-cloud/spring-cloud-stream-starters/twitterhdfs/src/test/java/com/baeldung/twitterhdfs/aggregate/SpringContextTest.java b/spring-cloud/spring-cloud-stream-starters/twitterhdfs/src/test/java/com/baeldung/twitterhdfs/aggregate/SpringContextTest.java
new file mode 100644
index 0000000000..d78a18d557
--- /dev/null
+++ b/spring-cloud/spring-cloud-stream-starters/twitterhdfs/src/test/java/com/baeldung/twitterhdfs/aggregate/SpringContextTest.java
@@ -0,0 +1,15 @@
+package com.baeldung.twitterhdfs.aggregate;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = AggregateApp.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/pom.xml b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/pom.xml
new file mode 100644
index 0000000000..13ad18810e
--- /dev/null
+++ b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/pom.xml
@@ -0,0 +1,109 @@
+
+ 4.0.0
+
+
+ spring-cloud-stream-kafka
+ spring-cloud-stream-kafka
+ Simple Spring Cloud Stream
+ jar
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.1.5.RELEASE
+
+
+
+ 1.8
+ Greenwich.SR1
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-stream-binder-kafka
+
+
+
+ org.springframework.cloud
+ spring-cloud-stream-schema
+
+
+
+ org.springframework.cloud
+ spring-cloud-stream-test-support
+ test
+
+
+
+ io.confluent
+ kafka-avro-serializer
+ 4.0.0
+
+
+
+ org.apache.avro
+ avro-compiler
+ 1.8.2
+
+
+
+ org.apache.avro
+ avro-maven-plugin
+ 1.8.2
+
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+ org.apache.avro
+ avro-maven-plugin
+ 1.8.2
+
+
+ schemas
+ generate-sources
+
+ schema
+ protocol
+ idl-protocol
+
+
+ ${project.basedir}/src/main/resources/
+ ${project.basedir}/src/main/java/
+
+
+
+
+
+
+
+
+
+ confluent
+ https://packages.confluent.io/maven/
+
+
+
+
diff --git a/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/java/com/baeldung/AvroKafkaApplication.java b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/java/com/baeldung/AvroKafkaApplication.java
new file mode 100644
index 0000000000..47c060c143
--- /dev/null
+++ b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/java/com/baeldung/AvroKafkaApplication.java
@@ -0,0 +1,18 @@
+package com.baeldung;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.stream.annotation.EnableBinding;
+import org.springframework.cloud.stream.messaging.Processor;
+import org.springframework.cloud.stream.schema.client.EnableSchemaRegistryClient;
+
+@SpringBootApplication
+@EnableBinding(Processor.class)
+@EnableSchemaRegistryClient
+public class AvroKafkaApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(AvroKafkaApplication.class, args);
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/java/com/baeldung/config/SchemRegistryConfig.java b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/java/com/baeldung/config/SchemRegistryConfig.java
new file mode 100644
index 0000000000..38ac94d952
--- /dev/null
+++ b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/java/com/baeldung/config/SchemRegistryConfig.java
@@ -0,0 +1,18 @@
+package com.baeldung.config;
+
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.stream.schema.client.ConfluentSchemaRegistryClient;
+import org.springframework.cloud.stream.schema.client.SchemaRegistryClient;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class SchemRegistryConfig {
+
+ @Bean
+ public SchemaRegistryClient schemaRegistryClient(@Value("${spring.cloud.stream.kafka.binder.producer-properties.schema.registry.url}") String endPoint) {
+ ConfluentSchemaRegistryClient client = new ConfluentSchemaRegistryClient();
+ client.setEndpoint(endPoint);
+ return client;
+ }
+}
diff --git a/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/java/com/baeldung/consumer/AvroConsumer.java b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/java/com/baeldung/consumer/AvroConsumer.java
new file mode 100644
index 0000000000..477946dd73
--- /dev/null
+++ b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/java/com/baeldung/consumer/AvroConsumer.java
@@ -0,0 +1,21 @@
+package com.baeldung.consumer;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.cloud.stream.annotation.StreamListener;
+import org.springframework.cloud.stream.messaging.Processor;
+import org.springframework.stereotype.Service;
+
+import com.baeldung.schema.Employee;
+
+@Service
+public class AvroConsumer {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AvroConsumer.class);
+
+ @StreamListener(Processor.INPUT)
+ public void consumeEmployeeDetails(Employee employeeDetails) {
+ LOGGER.info("Let's process employee details: {}", employeeDetails);
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/java/com/baeldung/controller/AvroController.java b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/java/com/baeldung/controller/AvroController.java
new file mode 100644
index 0000000000..b98b27c9fe
--- /dev/null
+++ b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/java/com/baeldung/controller/AvroController.java
@@ -0,0 +1,22 @@
+package com.baeldung.controller;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.baeldung.producer.AvroProducer;
+
+@RestController
+public class AvroController {
+
+ @Autowired
+ private AvroProducer avroProducer;
+
+ @PostMapping("/employees/{id}/{firstName}/{lastName}")
+ public String producerAvroMessage(@PathVariable int id, @PathVariable String firstName, @PathVariable String lastName) {
+ avroProducer.produceEmployeeDetails(id, firstName, lastName);
+ return "Sent employee details to consumer";
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/java/com/baeldung/producer/AvroProducer.java b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/java/com/baeldung/producer/AvroProducer.java
new file mode 100644
index 0000000000..ff7729dd8c
--- /dev/null
+++ b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/java/com/baeldung/producer/AvroProducer.java
@@ -0,0 +1,42 @@
+package com.baeldung.producer;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cloud.stream.messaging.Processor;
+import org.springframework.kafka.support.KafkaHeaders;
+import org.springframework.messaging.Message;
+import org.springframework.messaging.support.MessageBuilder;
+import org.springframework.stereotype.Service;
+
+import com.baeldung.schema.Employee;
+import com.baeldung.schema.EmployeeKey;
+
+@Service
+public class AvroProducer {
+
+ @Autowired
+ private Processor processor;
+
+ public void produceEmployeeDetails(int empId, String firstName, String lastName) {
+
+ // creating employee details
+ Employee employee = new Employee();
+ employee.setId(empId);
+ employee.setFirstName(firstName);
+ employee.setLastName(lastName);
+ employee.setDepartment("IT");
+ employee.setDesignation("Engineer");
+
+ // creating partition key for kafka topic
+ EmployeeKey employeeKey = new EmployeeKey();
+ employeeKey.setId(empId);
+ employeeKey.setDepartmentName("IT");
+
+ Message message = MessageBuilder.withPayload(employee)
+ .setHeader(KafkaHeaders.MESSAGE_KEY, employeeKey)
+ .build();
+
+ processor.output()
+ .send(message);
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/resources/application.yaml b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/resources/application.yaml
new file mode 100644
index 0000000000..2e30c07374
--- /dev/null
+++ b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/resources/application.yaml
@@ -0,0 +1,29 @@
+spring:
+ cloud:
+ stream:
+ default:
+ producer:
+ useNativeEncoding: true
+ consumer:
+ useNativeEncoding: true
+ bindings:
+ input:
+ destination: employee-details
+ content-type: application/*+avro
+ group: group-1
+ concurrency: 3
+ output:
+ destination: employee-details
+ content-type: application/*+avro
+ kafka:
+ binder:
+ producer-properties:
+ key.serializer: io.confluent.kafka.serializers.KafkaAvroSerializer
+ value.serializer: io.confluent.kafka.serializers.KafkaAvroSerializer
+ schema.registry.url: http://localhost:8081
+ consumer-properties:
+ key.deserializer: io.confluent.kafka.serializers.KafkaAvroDeserializer
+ value.deserializer: io.confluent.kafka.serializers.KafkaAvroDeserializer
+ schema.registry.url: http://localhost:8081
+ specific.avro.reader: true
+
\ No newline at end of file
diff --git a/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/resources/employee-key-schema.avsc b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/resources/employee-key-schema.avsc
new file mode 100644
index 0000000000..d18d657e99
--- /dev/null
+++ b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/resources/employee-key-schema.avsc
@@ -0,0 +1,14 @@
+{
+ "type": "record",
+ "name": "EmployeeKey",
+ "namespace": "com.baeldung.schema",
+ "fields": [
+ {
+ "name": "id",
+ "type": "int"
+ },
+ {
+ "name": "departmentName",
+ "type": "string"
+ }]
+}
\ No newline at end of file
diff --git a/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/resources/employee-schema.avsc b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/resources/employee-schema.avsc
new file mode 100644
index 0000000000..2abf57e4a2
--- /dev/null
+++ b/spring-cloud/spring-cloud-stream/spring-cloud-stream-kafka/src/main/resources/employee-schema.avsc
@@ -0,0 +1,29 @@
+{
+ "type": "record",
+ "name": "Employee",
+ "namespace": "com.baeldung.schema",
+ "fields": [
+ {
+ "name": "id",
+ "type": "int"
+ },
+ {
+ "name": "firstName",
+ "type": "string"
+ },
+ {
+ "name": "lastName",
+ "type": "string"
+ },
+ {
+ "name": "department",
+ "type": "string",
+ "default": "IT "
+ },
+ {
+ "name": "designation",
+ "type": "string",
+ "default": "Software Engineer"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/spring-cloud/spring-cloud-stream/spring-cloud-stream-rabbit/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-stream/spring-cloud-stream-rabbit/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..0f3b8de901
--- /dev/null
+++ b/spring-cloud/spring-cloud-stream/spring-cloud-stream-rabbit/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.spring.cloud.stream.rabbit.MultipleOutputsServiceApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = MultipleOutputsServiceApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-task/springcloudtasksink/src/test/java/org/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-task/springcloudtasksink/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..51f0926429
--- /dev/null
+++ b/spring-cloud/spring-cloud-task/springcloudtasksink/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.SpringCloudTaskFinal.SpringCloudTaskSinkApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringCloudTaskSinkApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-vault/src/test/java/org/baeldung/spring/cloud/vaultsample/SpringContextTest.java b/spring-cloud/spring-cloud-vault/src/test/java/org/baeldung/spring/cloud/vaultsample/SpringContextTest.java
new file mode 100644
index 0000000000..73fcbe55f0
--- /dev/null
+++ b/spring-cloud/spring-cloud-vault/src/test/java/org/baeldung/spring/cloud/vaultsample/SpringContextTest.java
@@ -0,0 +1,15 @@
+package org.baeldung.spring.cloud.vaultsample;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = VaultSampleApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-zookeeper/Greeting/src/test/baeldung/SpringContextTest.java b/spring-cloud/spring-cloud-zookeeper/Greeting/src/test/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..b45e7b9889
--- /dev/null
+++ b/spring-cloud/spring-cloud-zookeeper/Greeting/src/test/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.spring.cloud.ribbon.client.ServerLocationApp;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = GreetingApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-zookeeper/HelloWorld/src/test/java/com/baeldung/spring/cloud/helloworld/SpringContextTest.java b/spring-cloud/spring-cloud-zookeeper/HelloWorld/src/test/java/com/baeldung/spring/cloud/helloworld/SpringContextTest.java
new file mode 100644
index 0000000000..df7335dfa6
--- /dev/null
+++ b/spring-cloud/spring-cloud-zookeeper/HelloWorld/src/test/java/com/baeldung/spring/cloud/helloworld/SpringContextTest.java
@@ -0,0 +1,16 @@
+package com.baeldung.spring.cloud.helloworld;
+
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = HelloWorldApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-cloud/spring-cloud-zuul-eureka-integration/eureka-client/src/test/java/com/baeldung/spring/cloud/eureka/client/SpringContextTest.java b/spring-cloud/spring-cloud-zuul-eureka-integration/eureka-client/src/test/java/com/baeldung/spring/cloud/eureka/client/SpringContextTest.java
new file mode 100644
index 0000000000..9e3680b244
--- /dev/null
+++ b/spring-cloud/spring-cloud-zuul-eureka-integration/eureka-client/src/test/java/com/baeldung/spring/cloud/eureka/client/SpringContextTest.java
@@ -0,0 +1,16 @@
+package com.baeldung.spring.cloud.eureka.client;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-zuul-eureka-integration/eureka-server/src/test/java/com/baeldung/spring/cloud/eureka/server/SpringContextTest.java b/spring-cloud/spring-cloud-zuul-eureka-integration/eureka-server/src/test/java/com/baeldung/spring/cloud/eureka/server/SpringContextTest.java
new file mode 100644
index 0000000000..e7996bd316
--- /dev/null
+++ b/spring-cloud/spring-cloud-zuul-eureka-integration/eureka-server/src/test/java/com/baeldung/spring/cloud/eureka/server/SpringContextTest.java
@@ -0,0 +1,16 @@
+package com.baeldung.spring.cloud.eureka.server;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-zuul-eureka-integration/zuul-server/src/test/java/com/baeldung/spring/cloud/zuul/config/SpringContextTest.java b/spring-cloud/spring-cloud-zuul-eureka-integration/zuul-server/src/test/java/com/baeldung/spring/cloud/zuul/config/SpringContextTest.java
new file mode 100644
index 0000000000..a5350655fb
--- /dev/null
+++ b/spring-cloud/spring-cloud-zuul-eureka-integration/zuul-server/src/test/java/com/baeldung/spring/cloud/zuul/config/SpringContextTest.java
@@ -0,0 +1,16 @@
+package com.baeldung.spring.cloud.zuul.config;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+
+}
diff --git a/spring-cloud/spring-cloud-zuul/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/SpringContextTest.java b/spring-cloud/spring-cloud-zuul/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/SpringContextTest.java
new file mode 100644
index 0000000000..b5ddf6f65c
--- /dev/null
+++ b/spring-cloud/spring-cloud-zuul/src/test/java/com/baeldung/spring/cloud/zuulratelimitdemo/controller/SpringContextTest.java
@@ -0,0 +1,17 @@
+package com.baeldung.spring.cloud.zuulratelimitdemo.controller;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.spring.cloud.zuulratelimitdemo.ZuulRatelimitDemoApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = ZuulRatelimitDemoApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-core-2/pom.xml b/spring-core-2/pom.xml
new file mode 100644
index 0000000000..20cd900e00
--- /dev/null
+++ b/spring-core-2/pom.xml
@@ -0,0 +1,59 @@
+
+
+ 4.0.0
+ spring-core-2
+
+
+ com.baeldung
+ parent-spring-5
+ 0.0.1-SNAPSHOT
+ ../parent-spring-5
+
+
+
+
+ org.springframework
+ spring-beans
+ ${spring.version}
+
+
+ org.springframework
+ spring-context
+ ${spring.version}
+
+
+ org.springframework
+ spring-core
+ ${spring.version}
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ ${junit-jupiter.version}
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-api
+ ${junit-jupiter.version}
+ test
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.22.1
+
+
+
+
+
+ 5.1.4.RELEASE
+
+
+
\ No newline at end of file
diff --git a/spring-core-2/src/main/java/com/baeldung/getbean/AnnotationConfig.java b/spring-core-2/src/main/java/com/baeldung/getbean/AnnotationConfig.java
new file mode 100644
index 0000000000..12e3ab55e3
--- /dev/null
+++ b/spring-core-2/src/main/java/com/baeldung/getbean/AnnotationConfig.java
@@ -0,0 +1,22 @@
+package com.baeldung.getbean;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Scope;
+
+@Configuration
+class AnnotationConfig {
+
+ @Bean(name = {"tiger", "kitty"})
+ @Scope(value = "prototype")
+ Tiger getTiger(String name) {
+ return new Tiger(name);
+ }
+
+ @Bean(name = "lion")
+ Lion getLion() {
+ return new Lion("Hardcoded lion name");
+ }
+
+ interface Animal {}
+}
diff --git a/spring-core-2/src/main/java/com/baeldung/getbean/Lion.java b/spring-core-2/src/main/java/com/baeldung/getbean/Lion.java
new file mode 100644
index 0000000000..96c569aeb9
--- /dev/null
+++ b/spring-core-2/src/main/java/com/baeldung/getbean/Lion.java
@@ -0,0 +1,13 @@
+package com.baeldung.getbean;
+
+class Lion implements AnnotationConfig.Animal {
+ private String name;
+
+ Lion(String name) {
+ this.name = name;
+ }
+
+ String getName() {
+ return name;
+ }
+}
diff --git a/spring-core-2/src/main/java/com/baeldung/getbean/Tiger.java b/spring-core-2/src/main/java/com/baeldung/getbean/Tiger.java
new file mode 100644
index 0000000000..85b9626c79
--- /dev/null
+++ b/spring-core-2/src/main/java/com/baeldung/getbean/Tiger.java
@@ -0,0 +1,13 @@
+package com.baeldung.getbean;
+
+class Tiger implements AnnotationConfig.Animal {
+ private String name;
+
+ Tiger(String name) {
+ this.name = name;
+ }
+
+ String getName() {
+ return name;
+ }
+}
diff --git a/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameAndTypeUnitTest.java b/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameAndTypeUnitTest.java
new file mode 100644
index 0000000000..e06804c28e
--- /dev/null
+++ b/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameAndTypeUnitTest.java
@@ -0,0 +1,33 @@
+package com.baeldung.getbean;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.springframework.beans.factory.BeanNotOfRequiredTypeException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+class GetBeanByNameAndTypeUnitTest {
+ private ApplicationContext context;
+
+ @BeforeAll
+ void setup() {
+ context = new AnnotationConfigApplicationContext(AnnotationConfig.class);
+ }
+
+ @Test
+ void whenSpecifiedMatchingNameAndType_thenShouldReturnRelatedBean() {
+ Lion lion = context.getBean("lion", Lion.class);
+
+ assertEquals("Hardcoded lion name", lion.getName());
+ }
+
+ @Test
+ void whenSpecifiedNotMatchingNameAndType_thenShouldThrowException() {
+ assertThrows(BeanNotOfRequiredTypeException.class, () -> context.getBean("lion", Tiger.class));
+ }
+}
diff --git a/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameUnitTest.java b/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameUnitTest.java
new file mode 100644
index 0000000000..4d6d77e39d
--- /dev/null
+++ b/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameUnitTest.java
@@ -0,0 +1,40 @@
+package com.baeldung.getbean;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+class GetBeanByNameUnitTest {
+ private ApplicationContext context;
+
+ @BeforeAll
+ void setup() {
+ context = new AnnotationConfigApplicationContext(AnnotationConfig.class);
+ }
+
+ @Test
+ void whenGivenExistingBeanName_shouldReturnThatBean() {
+ Object lion = context.getBean("lion");
+
+ assertEquals(lion.getClass(), Lion.class);
+ }
+
+ @Test
+ void whenGivenNonExistingBeanName_shouldThrowException() {
+ assertThrows(NoSuchBeanDefinitionException.class, () -> context.getBean("non-existing"));
+ }
+
+ @Test
+ void whenCastingToWrongType_thenShouldThrowException() {
+ assertThrows(ClassCastException.class, () -> {
+ Tiger tiger = (Tiger) context.getBean("lion");
+ });
+ }
+}
diff --git a/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameWithConstructorParametersUnitTest.java b/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameWithConstructorParametersUnitTest.java
new file mode 100644
index 0000000000..32d37e4ff2
--- /dev/null
+++ b/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByNameWithConstructorParametersUnitTest.java
@@ -0,0 +1,44 @@
+package com.baeldung.getbean;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.springframework.beans.factory.UnsatisfiedDependencyException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+class GetBeanByNameWithConstructorParametersUnitTest {
+ private ApplicationContext context;
+
+ @BeforeAll
+ void setup() {
+ context = new AnnotationConfigApplicationContext(AnnotationConfig.class);
+ }
+
+ @Test
+ void whenGivenCorrectName_thenShouldReturnBeanWithSpecifiedName() {
+ Tiger tiger = (Tiger) context.getBean("tiger", "Siberian");
+
+ assertEquals("Siberian", tiger.getName());
+ }
+
+ @Test
+ void whenGivenCorrectNameOrAlias_shouldReturnBeanWithSpecifiedName() {
+ Tiger tiger = (Tiger) context.getBean("tiger", "Siberian");
+ Tiger secondTiger = (Tiger) context.getBean("tiger", "Striped");
+
+ assertEquals("Siberian", tiger.getName());
+ assertEquals("Striped", secondTiger.getName());
+ }
+
+ @Test
+ void whenNoArgumentSpecifiedForPrototypeBean_thenShouldThrowException() {
+ assertThrows(UnsatisfiedDependencyException.class, () -> {
+ Tiger tiger = (Tiger) context.getBean("tiger");
+ });
+ }
+}
diff --git a/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByTypeUnitTest.java b/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByTypeUnitTest.java
new file mode 100644
index 0000000000..a4d4ab732b
--- /dev/null
+++ b/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByTypeUnitTest.java
@@ -0,0 +1,33 @@
+package com.baeldung.getbean;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+class GetBeanByTypeUnitTest {
+ private ApplicationContext context;
+
+ @BeforeAll
+ void setup() {
+ context = new AnnotationConfigApplicationContext(AnnotationConfig.class);
+ }
+
+ @Test
+ void whenGivenExistingUniqueType_thenShouldReturnRelatedBean() {
+ Lion lion = context.getBean(Lion.class);
+
+ assertNotNull(lion);
+ }
+
+ @Test
+ void whenGivenAmbiguousType_thenShouldThrowException() {
+ assertThrows(NoUniqueBeanDefinitionException.class, () -> context.getBean(AnnotationConfig.Animal.class));
+ }
+}
diff --git a/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByTypeWithConstructorParametersUnitTest.java b/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByTypeWithConstructorParametersUnitTest.java
new file mode 100644
index 0000000000..08bcb92145
--- /dev/null
+++ b/spring-core-2/src/test/java/com/baeldung/getbean/GetBeanByTypeWithConstructorParametersUnitTest.java
@@ -0,0 +1,26 @@
+package com.baeldung.getbean;
+
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestInstance;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+@TestInstance(TestInstance.Lifecycle.PER_CLASS)
+class GetBeanByTypeWithConstructorParametersUnitTest {
+ private ApplicationContext context;
+
+ @BeforeAll
+ void setup() {
+ context = new AnnotationConfigApplicationContext(AnnotationConfig.class);
+ }
+
+ @Test
+ void whenGivenExistingTypeAndValidParameters_thenShouldReturnRelatedBean() {
+ Tiger tiger = context.getBean(Tiger.class, "Shere Khan");
+
+ assertEquals("Shere Khan", tiger.getName());
+ }
+}
diff --git a/spring-core/README.md b/spring-core/README.md
index d542fa8ed1..18d14b7ecf 100644
--- a/spring-core/README.md
+++ b/spring-core/README.md
@@ -8,7 +8,6 @@
- [Spring YAML Configuration](http://www.baeldung.com/spring-yaml)
- [Introduction to Spring’s StreamUtils](http://www.baeldung.com/spring-stream-utils)
- [Using Spring @Value with Defaults](http://www.baeldung.com/spring-value-defaults)
-- [Groovy Bean Definitions](http://www.baeldung.com/spring-groovy-beans)
- [XML-Based Injection in Spring](http://www.baeldung.com/spring-xml-injection)
- [A Quick Guide to the Spring @Lazy Annotation](http://www.baeldung.com/spring-lazy-annotation)
- [Injecting Prototype Beans into a Singleton Instance in Spring](http://www.baeldung.com/spring-inject-prototype-bean-into-singleton)
@@ -24,3 +23,4 @@
- [What is a Spring Bean?](https://www.baeldung.com/spring-bean)
- [Spring PostConstruct and PreDestroy Annotations](https://www.baeldung.com/spring-postconstruct-predestroy)
- [Guice vs Spring – Dependency Injection](https://www.baeldung.com/guice-spring-dependency-injection)
+- [Circular Dependencies in Spring](http://www.baeldung.com/circular-dependencies-in-spring)
diff --git a/spring-core/pom.xml b/spring-core/pom.xml
index 814addecdd..7e5a9b3feb 100644
--- a/spring-core/pom.xml
+++ b/spring-core/pom.xml
@@ -56,6 +56,12 @@
spring-boot-test${mockito.spring.boot.version}test
+
+
+ org.assertj
+ assertj-core
+ ${assertj.version}
+ testcommons-io
@@ -81,10 +87,10 @@
1.4.4.RELEASE120.0
- 2.62.51.5.2.RELEASE1.10.19
+ 3.12.2
\ No newline at end of file
diff --git a/spring-mvc-java/src/main/java/com/baeldung/circulardependency/CircularDependencyA.java b/spring-core/src/main/java/com/baeldung/circulardependency/CircularDependencyA.java
similarity index 100%
rename from spring-mvc-java/src/main/java/com/baeldung/circulardependency/CircularDependencyA.java
rename to spring-core/src/main/java/com/baeldung/circulardependency/CircularDependencyA.java
diff --git a/spring-mvc-java/src/main/java/com/baeldung/circulardependency/CircularDependencyB.java b/spring-core/src/main/java/com/baeldung/circulardependency/CircularDependencyB.java
similarity index 100%
rename from spring-mvc-java/src/main/java/com/baeldung/circulardependency/CircularDependencyB.java
rename to spring-core/src/main/java/com/baeldung/circulardependency/CircularDependencyB.java
diff --git a/spring-core/src/main/resources/constructordi.xml b/spring-core/src/main/resources/constructordi.xml
index 231e72adcb..983a00a80f 100644
--- a/spring-core/src/main/resources/constructordi.xml
+++ b/spring-core/src/main/resources/constructordi.xml
@@ -1,19 +1,21 @@
+ https://www.springframework.org/schema/beans/spring-beans.xsd">
-
+
-
+
diff --git a/spring-mvc-java/src/test/java/com/baeldung/circulardependency/CircularDependencyIntegrationTest.java b/spring-core/src/test/java/com/baeldung/circulardependency/CircularDependencyIntegrationTest.java
similarity index 100%
rename from spring-mvc-java/src/test/java/com/baeldung/circulardependency/CircularDependencyIntegrationTest.java
rename to spring-core/src/test/java/com/baeldung/circulardependency/CircularDependencyIntegrationTest.java
diff --git a/spring-mvc-java/src/test/java/com/baeldung/circulardependency/TestConfig.java b/spring-core/src/test/java/com/baeldung/circulardependency/TestConfig.java
similarity index 100%
rename from spring-mvc-java/src/test/java/com/baeldung/circulardependency/TestConfig.java
rename to spring-core/src/test/java/com/baeldung/circulardependency/TestConfig.java
diff --git a/spring-core/src/test/java/com/baeldung/constructordi/ConstructorDependencyInjectionIntegrationTest.java b/spring-core/src/test/java/com/baeldung/constructordi/ConstructorDependencyInjectionIntegrationTest.java
new file mode 100644
index 0000000000..7bd0ad0c86
--- /dev/null
+++ b/spring-core/src/test/java/com/baeldung/constructordi/ConstructorDependencyInjectionIntegrationTest.java
@@ -0,0 +1,33 @@
+package com.baeldung.constructordi;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.support.AnnotationConfigContextLoader;
+
+import com.baeldung.constructordi.domain.Car;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(loader = AnnotationConfigContextLoader.class, classes = Config.class)
+public class ConstructorDependencyInjectionIntegrationTest {
+
+ @Test
+ public void givenPrototypeInjection_WhenObjectFactory_ThenNewInstanceReturn() {
+ ApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
+ Car firstContextCar = context.getBean(Car.class);
+
+ ApplicationContext xmlContext = new ClassPathXmlApplicationContext("constructordi.xml");
+ Car secondContextCar = xmlContext.getBean(Car.class);
+
+ assertThat(firstContextCar).isNotSameAs(secondContextCar);
+ assertThat(firstContextCar).hasToString("Engine: v8 5 Transmission: sliding");
+ assertThat(secondContextCar).hasToString("Engine: v4 2 Transmission: sliding");
+ }
+
+}
diff --git a/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java b/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java
index a7a2a9032a..c7a2984045 100644
--- a/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java
+++ b/spring-core/src/test/java/com/baeldung/resource/SpringResourceIntegrationTest.java
@@ -4,6 +4,7 @@ import static org.junit.Assert.assertEquals;
import java.io.BufferedReader;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@@ -77,7 +78,7 @@ public class SpringResourceIntegrationTest {
@Test
public void whenResourceUtils_thenReadSuccessful() throws IOException {
- final File employeeFile = ResourceUtils.getFile("classpath:data/employees.dat");
+ final File employeeFile = loadEmployeesWithSpringInternalClass();
final String employees = new String(Files.readAllBytes(employeeFile.toPath()));
assertEquals(EMPLOYEES_EXPECTED, employees);
}
@@ -112,4 +113,8 @@ public class SpringResourceIntegrationTest {
final String employees = new String(Files.readAllBytes(resource.toPath()));
assertEquals(EMPLOYEES_EXPECTED, employees);
}
+
+ public File loadEmployeesWithSpringInternalClass() throws FileNotFoundException {
+ return ResourceUtils.getFile("classpath:data/employees.dat");
+ }
}
diff --git a/spring-cucumber/src/test/java/org/baeldung/SpringContextTest.java b/spring-cucumber/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..7b8fa74fc9
--- /dev/null
+++ b/spring-cucumber/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.SpringDemoApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringDemoApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-data-rest-querydsl/src/test/java/org/baeldung/SpringContextTest.java b/spring-data-rest-querydsl/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..5e68a8e64f
--- /dev/null
+++ b/spring-data-rest-querydsl/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.Application;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-data-rest/src/main/java/com/baeldung/SpringDataRestApplication.java b/spring-data-rest/src/main/java/com/baeldung/books/SpringDataRestApplication.java
similarity index 91%
rename from spring-data-rest/src/main/java/com/baeldung/SpringDataRestApplication.java
rename to spring-data-rest/src/main/java/com/baeldung/books/SpringDataRestApplication.java
index 702acb5b65..097a6aabd7 100644
--- a/spring-data-rest/src/main/java/com/baeldung/SpringDataRestApplication.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/SpringDataRestApplication.java
@@ -1,4 +1,4 @@
-package com.baeldung;
+package com.baeldung.books;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
diff --git a/spring-data-rest/src/main/java/com/baeldung/config/DbConfig.java b/spring-data-rest/src/main/java/com/baeldung/books/config/DbConfig.java
similarity index 94%
rename from spring-data-rest/src/main/java/com/baeldung/config/DbConfig.java
rename to spring-data-rest/src/main/java/com/baeldung/books/config/DbConfig.java
index 3ca728ec94..20008eb583 100644
--- a/spring-data-rest/src/main/java/com/baeldung/config/DbConfig.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/config/DbConfig.java
@@ -1,4 +1,4 @@
-package com.baeldung.config;
+package com.baeldung.books.config;
import java.util.Properties;
@@ -16,7 +16,7 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
@Configuration
-@EnableJpaRepositories(basePackages = "com.baeldung.repositories")
+@EnableJpaRepositories(basePackages = "com.baeldung.books.repositories")
// @PropertySource("persistence-h2.properties")
// @PropertySource("persistence-hsqldb.properties")
// @PropertySource("persistence-derby.properties")
@@ -40,7 +40,7 @@ public class DbConfig {
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
final LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(dataSource());
- em.setPackagesToScan(new String[] { "com.baeldung.models" });
+ em.setPackagesToScan(new String[] { "com.baeldung.books.models" });
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
em.setJpaProperties(additionalProperties());
return em;
diff --git a/spring-data-rest/src/main/java/com/baeldung/config/MvcConfig.java b/spring-data-rest/src/main/java/com/baeldung/books/config/MvcConfig.java
similarity index 85%
rename from spring-data-rest/src/main/java/com/baeldung/config/MvcConfig.java
rename to spring-data-rest/src/main/java/com/baeldung/books/config/MvcConfig.java
index 9d0d3a6687..69e984ad06 100644
--- a/spring-data-rest/src/main/java/com/baeldung/config/MvcConfig.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/config/MvcConfig.java
@@ -1,13 +1,14 @@
-package com.baeldung.config;
+package com.baeldung.books.config;
-import com.baeldung.events.AuthorEventHandler;
-import com.baeldung.events.BookEventHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import com.baeldung.books.events.AuthorEventHandler;
+import com.baeldung.books.events.BookEventHandler;
+
@Configuration
@EnableWebMvc
public class MvcConfig implements WebMvcConfigurer {
diff --git a/spring-data-rest/src/main/java/com/baeldung/config/RestConfig.java b/spring-data-rest/src/main/java/com/baeldung/books/config/RestConfig.java
similarity index 86%
rename from spring-data-rest/src/main/java/com/baeldung/config/RestConfig.java
rename to spring-data-rest/src/main/java/com/baeldung/books/config/RestConfig.java
index 47cb95693b..1c6f04331e 100644
--- a/spring-data-rest/src/main/java/com/baeldung/config/RestConfig.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/config/RestConfig.java
@@ -1,7 +1,8 @@
-package com.baeldung.config;
+package com.baeldung.books.config;
+
+import com.baeldung.books.models.WebsiteUser;
+import com.baeldung.books.projections.CustomBook;
-import com.baeldung.models.WebsiteUser;
-import com.baeldung.projections.CustomBook;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.rest.core.config.RepositoryRestConfiguration;
import org.springframework.data.rest.core.mapping.ExposureConfiguration;
diff --git a/spring-data-rest/src/main/java/com/baeldung/config/ValidatorEventRegister.java b/spring-data-rest/src/main/java/com/baeldung/books/config/ValidatorEventRegister.java
similarity index 94%
rename from spring-data-rest/src/main/java/com/baeldung/config/ValidatorEventRegister.java
rename to spring-data-rest/src/main/java/com/baeldung/books/config/ValidatorEventRegister.java
index 632ad9183a..bbaf9a2771 100644
--- a/spring-data-rest/src/main/java/com/baeldung/config/ValidatorEventRegister.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/config/ValidatorEventRegister.java
@@ -1,4 +1,4 @@
-package com.baeldung.config;
+package com.baeldung.books.config;
import java.util.Arrays;
import java.util.List;
diff --git a/spring-data-rest/src/main/java/com/baeldung/dialect/SQLiteDialect.java b/spring-data-rest/src/main/java/com/baeldung/books/dialect/SQLiteDialect.java
similarity index 98%
rename from spring-data-rest/src/main/java/com/baeldung/dialect/SQLiteDialect.java
rename to spring-data-rest/src/main/java/com/baeldung/books/dialect/SQLiteDialect.java
index 4512f7d34d..6e840eec43 100644
--- a/spring-data-rest/src/main/java/com/baeldung/dialect/SQLiteDialect.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/dialect/SQLiteDialect.java
@@ -1,4 +1,4 @@
-package com.baeldung.dialect;
+package com.baeldung.books.dialect;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.identity.IdentityColumnSupport;
diff --git a/spring-data-rest/src/main/java/com/baeldung/dialect/SQLiteIdentityColumnSupport.java b/spring-data-rest/src/main/java/com/baeldung/books/dialect/SQLiteIdentityColumnSupport.java
similarity index 94%
rename from spring-data-rest/src/main/java/com/baeldung/dialect/SQLiteIdentityColumnSupport.java
rename to spring-data-rest/src/main/java/com/baeldung/books/dialect/SQLiteIdentityColumnSupport.java
index cf6e3a9a97..682d82c6f1 100644
--- a/spring-data-rest/src/main/java/com/baeldung/dialect/SQLiteIdentityColumnSupport.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/dialect/SQLiteIdentityColumnSupport.java
@@ -1,4 +1,4 @@
-package com.baeldung.dialect;
+package com.baeldung.books.dialect;
import org.hibernate.MappingException;
import org.hibernate.dialect.identity.IdentityColumnSupportImpl;
diff --git a/spring-data-rest/src/main/java/com/baeldung/events/AuthorEventHandler.java b/spring-data-rest/src/main/java/com/baeldung/books/events/AuthorEventHandler.java
similarity index 89%
rename from spring-data-rest/src/main/java/com/baeldung/events/AuthorEventHandler.java
rename to spring-data-rest/src/main/java/com/baeldung/books/events/AuthorEventHandler.java
index 485dc8e221..b390a529ba 100644
--- a/spring-data-rest/src/main/java/com/baeldung/events/AuthorEventHandler.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/events/AuthorEventHandler.java
@@ -1,9 +1,10 @@
-package com.baeldung.events;
+package com.baeldung.books.events;
-import com.baeldung.models.Author;
-import com.baeldung.models.Book;
import org.springframework.data.rest.core.annotation.*;
+import com.baeldung.books.models.Author;
+import com.baeldung.books.models.Book;
+
import java.util.logging.Logger;
@RepositoryEventHandler
diff --git a/spring-data-rest/src/main/java/com/baeldung/events/BookEventHandler.java b/spring-data-rest/src/main/java/com/baeldung/books/events/BookEventHandler.java
similarity index 86%
rename from spring-data-rest/src/main/java/com/baeldung/events/BookEventHandler.java
rename to spring-data-rest/src/main/java/com/baeldung/books/events/BookEventHandler.java
index 36ae62b926..0afb3a6279 100644
--- a/spring-data-rest/src/main/java/com/baeldung/events/BookEventHandler.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/events/BookEventHandler.java
@@ -1,13 +1,15 @@
-package com.baeldung.events;
+package com.baeldung.books.events;
import java.util.logging.Logger;
-import com.baeldung.models.Author;
-import com.baeldung.models.Book;
+
import org.apache.commons.logging.Log;
import org.springframework.data.rest.core.annotation.HandleAfterDelete;
import org.springframework.data.rest.core.annotation.HandleBeforeCreate;
import org.springframework.data.rest.core.annotation.RepositoryEventHandler;
+import com.baeldung.books.models.Author;
+import com.baeldung.books.models.Book;
+
@RepositoryEventHandler
public class BookEventHandler {
Logger logger = Logger.getLogger("Class BookEventHandler");
diff --git a/spring-data-rest/src/main/java/com/baeldung/exception/handlers/RestResponseEntityExceptionHandler.java b/spring-data-rest/src/main/java/com/baeldung/books/exception/handlers/RestResponseEntityExceptionHandler.java
similarity index 94%
rename from spring-data-rest/src/main/java/com/baeldung/exception/handlers/RestResponseEntityExceptionHandler.java
rename to spring-data-rest/src/main/java/com/baeldung/books/exception/handlers/RestResponseEntityExceptionHandler.java
index a3ef91f6d6..4a961e5250 100644
--- a/spring-data-rest/src/main/java/com/baeldung/exception/handlers/RestResponseEntityExceptionHandler.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/exception/handlers/RestResponseEntityExceptionHandler.java
@@ -1,4 +1,4 @@
-package com.baeldung.exception.handlers;
+package com.baeldung.books.exception.handlers;
import org.springframework.data.rest.core.RepositoryConstraintViolationException;
import org.springframework.http.HttpHeaders;
diff --git a/spring-data-rest/src/main/java/com/baeldung/models/Address.java b/spring-data-rest/src/main/java/com/baeldung/books/models/Address.java
similarity index 96%
rename from spring-data-rest/src/main/java/com/baeldung/models/Address.java
rename to spring-data-rest/src/main/java/com/baeldung/books/models/Address.java
index 713af58ae6..3c36db0f3c 100644
--- a/spring-data-rest/src/main/java/com/baeldung/models/Address.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/models/Address.java
@@ -1,4 +1,4 @@
-package com.baeldung.models;
+package com.baeldung.books.models;
import javax.persistence.Column;
import javax.persistence.Entity;
diff --git a/spring-data-rest/src/main/java/com/baeldung/models/Author.java b/spring-data-rest/src/main/java/com/baeldung/books/models/Author.java
similarity index 97%
rename from spring-data-rest/src/main/java/com/baeldung/models/Author.java
rename to spring-data-rest/src/main/java/com/baeldung/books/models/Author.java
index 3f43af9c47..aec2e62ebf 100644
--- a/spring-data-rest/src/main/java/com/baeldung/models/Author.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/models/Author.java
@@ -1,4 +1,4 @@
-package com.baeldung.models;
+package com.baeldung.books.models;
import java.util.List;
diff --git a/spring-data-rest/src/main/java/com/baeldung/models/Book.java b/spring-data-rest/src/main/java/com/baeldung/books/models/Book.java
similarity index 97%
rename from spring-data-rest/src/main/java/com/baeldung/models/Book.java
rename to spring-data-rest/src/main/java/com/baeldung/books/models/Book.java
index 07b0d08b84..7451b04b3b 100644
--- a/spring-data-rest/src/main/java/com/baeldung/models/Book.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/models/Book.java
@@ -1,4 +1,4 @@
-package com.baeldung.models;
+package com.baeldung.books.models;
import java.util.List;
diff --git a/spring-data-rest/src/main/java/com/baeldung/models/Library.java b/spring-data-rest/src/main/java/com/baeldung/books/models/Library.java
similarity index 97%
rename from spring-data-rest/src/main/java/com/baeldung/models/Library.java
rename to spring-data-rest/src/main/java/com/baeldung/books/models/Library.java
index 091975f5d0..5f95169a9b 100644
--- a/spring-data-rest/src/main/java/com/baeldung/models/Library.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/models/Library.java
@@ -1,4 +1,4 @@
-package com.baeldung.models;
+package com.baeldung.books.models;
import java.util.List;
diff --git a/spring-data-rest/src/main/java/com/baeldung/models/Subject.java b/spring-data-rest/src/main/java/com/baeldung/books/models/Subject.java
similarity index 94%
rename from spring-data-rest/src/main/java/com/baeldung/models/Subject.java
rename to spring-data-rest/src/main/java/com/baeldung/books/models/Subject.java
index 4e5fa82148..11a4425fdd 100644
--- a/spring-data-rest/src/main/java/com/baeldung/models/Subject.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/models/Subject.java
@@ -1,4 +1,4 @@
-package com.baeldung.models;
+package com.baeldung.books.models;
import javax.persistence.Column;
import javax.persistence.Entity;
diff --git a/spring-data-rest/src/main/java/com/baeldung/models/WebsiteUser.java b/spring-data-rest/src/main/java/com/baeldung/books/models/WebsiteUser.java
similarity index 95%
rename from spring-data-rest/src/main/java/com/baeldung/models/WebsiteUser.java
rename to spring-data-rest/src/main/java/com/baeldung/books/models/WebsiteUser.java
index 4eb9773e36..e632623019 100644
--- a/spring-data-rest/src/main/java/com/baeldung/models/WebsiteUser.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/models/WebsiteUser.java
@@ -1,4 +1,4 @@
-package com.baeldung.models;
+package com.baeldung.books.models;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
diff --git a/spring-data-rest/src/main/java/com/baeldung/projections/CustomBook.java b/spring-data-rest/src/main/java/com/baeldung/books/projections/CustomBook.java
similarity index 77%
rename from spring-data-rest/src/main/java/com/baeldung/projections/CustomBook.java
rename to spring-data-rest/src/main/java/com/baeldung/books/projections/CustomBook.java
index 3dc6938f5c..5fe78c869d 100644
--- a/spring-data-rest/src/main/java/com/baeldung/projections/CustomBook.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/projections/CustomBook.java
@@ -1,12 +1,12 @@
-package com.baeldung.projections;
+package com.baeldung.books.projections;
import java.util.List;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.rest.core.config.Projection;
-import com.baeldung.models.Author;
-import com.baeldung.models.Book;
+import com.baeldung.books.models.Author;
+import com.baeldung.books.models.Book;
@Projection(name = "customBook", types = { Book.class })
public interface CustomBook {
diff --git a/spring-data-rest/src/main/java/com/baeldung/repositories/AddressRepository.java b/spring-data-rest/src/main/java/com/baeldung/books/repositories/AddressRepository.java
similarity index 62%
rename from spring-data-rest/src/main/java/com/baeldung/repositories/AddressRepository.java
rename to spring-data-rest/src/main/java/com/baeldung/books/repositories/AddressRepository.java
index 1cc7527e80..5e3900f439 100644
--- a/spring-data-rest/src/main/java/com/baeldung/repositories/AddressRepository.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/repositories/AddressRepository.java
@@ -1,8 +1,8 @@
-package com.baeldung.repositories;
+package com.baeldung.books.repositories;
import org.springframework.data.repository.CrudRepository;
-import com.baeldung.models.Address;
+import com.baeldung.books.models.Address;
public interface AddressRepository extends CrudRepository {
diff --git a/spring-data-rest/src/main/java/com/baeldung/repositories/AuthorRepository.java b/spring-data-rest/src/main/java/com/baeldung/books/repositories/AuthorRepository.java
similarity index 62%
rename from spring-data-rest/src/main/java/com/baeldung/repositories/AuthorRepository.java
rename to spring-data-rest/src/main/java/com/baeldung/books/repositories/AuthorRepository.java
index 2d470367ef..837e13b1d2 100644
--- a/spring-data-rest/src/main/java/com/baeldung/repositories/AuthorRepository.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/repositories/AuthorRepository.java
@@ -1,8 +1,8 @@
-package com.baeldung.repositories;
+package com.baeldung.books.repositories;
import org.springframework.data.repository.CrudRepository;
-import com.baeldung.models.Author;
+import com.baeldung.books.models.Author;
public interface AuthorRepository extends CrudRepository {
diff --git a/spring-data-rest/src/main/java/com/baeldung/repositories/BookRepository.java b/spring-data-rest/src/main/java/com/baeldung/books/repositories/BookRepository.java
similarity index 67%
rename from spring-data-rest/src/main/java/com/baeldung/repositories/BookRepository.java
rename to spring-data-rest/src/main/java/com/baeldung/books/repositories/BookRepository.java
index eee44f35d4..5d7e277526 100644
--- a/spring-data-rest/src/main/java/com/baeldung/repositories/BookRepository.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/repositories/BookRepository.java
@@ -1,10 +1,10 @@
-package com.baeldung.repositories;
+package com.baeldung.books.repositories;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
-import com.baeldung.models.Book;
-import com.baeldung.projections.CustomBook;
+import com.baeldung.books.models.Book;
+import com.baeldung.books.projections.CustomBook;
@RepositoryRestResource(excerptProjection = CustomBook.class)
public interface BookRepository extends CrudRepository {
diff --git a/spring-data-rest/src/main/java/com/baeldung/repositories/LibraryRepository.java b/spring-data-rest/src/main/java/com/baeldung/books/repositories/LibraryRepository.java
similarity index 62%
rename from spring-data-rest/src/main/java/com/baeldung/repositories/LibraryRepository.java
rename to spring-data-rest/src/main/java/com/baeldung/books/repositories/LibraryRepository.java
index c00787f03c..92518339a0 100644
--- a/spring-data-rest/src/main/java/com/baeldung/repositories/LibraryRepository.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/repositories/LibraryRepository.java
@@ -1,8 +1,8 @@
-package com.baeldung.repositories;
+package com.baeldung.books.repositories;
import org.springframework.data.repository.CrudRepository;
-import com.baeldung.models.Library;
+import com.baeldung.books.models.Library;
public interface LibraryRepository extends CrudRepository {
diff --git a/spring-data-rest/src/main/java/com/baeldung/repositories/SubjectRepository.java b/spring-data-rest/src/main/java/com/baeldung/books/repositories/SubjectRepository.java
similarity index 85%
rename from spring-data-rest/src/main/java/com/baeldung/repositories/SubjectRepository.java
rename to spring-data-rest/src/main/java/com/baeldung/books/repositories/SubjectRepository.java
index 76e34b0799..187b01f222 100644
--- a/spring-data-rest/src/main/java/com/baeldung/repositories/SubjectRepository.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/repositories/SubjectRepository.java
@@ -1,11 +1,12 @@
-package com.baeldung.repositories;
+package com.baeldung.books.repositories;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RestResource;
-import com.baeldung.models.Subject;
+
+import com.baeldung.books.models.Subject;
public interface SubjectRepository extends PagingAndSortingRepository {
diff --git a/spring-data-rest/src/main/java/com/baeldung/repositories/UserRepository.java b/spring-data-rest/src/main/java/com/baeldung/books/repositories/UserRepository.java
similarity index 91%
rename from spring-data-rest/src/main/java/com/baeldung/repositories/UserRepository.java
rename to spring-data-rest/src/main/java/com/baeldung/books/repositories/UserRepository.java
index a3fed1c318..f0823338bc 100644
--- a/spring-data-rest/src/main/java/com/baeldung/repositories/UserRepository.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/repositories/UserRepository.java
@@ -1,11 +1,12 @@
-package com.baeldung.repositories;
+package com.baeldung.books.repositories;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.data.rest.core.annotation.RestResource;
import org.springframework.web.bind.annotation.CrossOrigin;
-import com.baeldung.models.WebsiteUser;
+
+import com.baeldung.books.models.WebsiteUser;
@CrossOrigin
@RepositoryRestResource(collectionResourceRel = "users", path = "users")
diff --git a/spring-data-rest/src/main/java/com/baeldung/validators/WebsiteUserValidator.java b/spring-data-rest/src/main/java/com/baeldung/books/validators/WebsiteUserValidator.java
similarity index 87%
rename from spring-data-rest/src/main/java/com/baeldung/validators/WebsiteUserValidator.java
rename to spring-data-rest/src/main/java/com/baeldung/books/validators/WebsiteUserValidator.java
index 0380332708..ad7511c2ba 100644
--- a/spring-data-rest/src/main/java/com/baeldung/validators/WebsiteUserValidator.java
+++ b/spring-data-rest/src/main/java/com/baeldung/books/validators/WebsiteUserValidator.java
@@ -1,10 +1,10 @@
-package com.baeldung.validators;
+package com.baeldung.books.validators;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
-import com.baeldung.models.WebsiteUser;
+import com.baeldung.books.models.WebsiteUser;
@Component("beforeCreateWebsiteUserValidator")
public class WebsiteUserValidator implements Validator {
diff --git a/spring-data-rest/src/test/java/com/baeldung/events/AuthorEventHandlerUnitTest.java b/spring-data-rest/src/test/java/com/baeldung/books/events/AuthorEventHandlerUnitTest.java
similarity index 86%
rename from spring-data-rest/src/test/java/com/baeldung/events/AuthorEventHandlerUnitTest.java
rename to spring-data-rest/src/test/java/com/baeldung/books/events/AuthorEventHandlerUnitTest.java
index c01d5882a0..719c4d7c86 100644
--- a/spring-data-rest/src/test/java/com/baeldung/events/AuthorEventHandlerUnitTest.java
+++ b/spring-data-rest/src/test/java/com/baeldung/books/events/AuthorEventHandlerUnitTest.java
@@ -1,6 +1,8 @@
-package com.baeldung.events;
+package com.baeldung.books.events;
+
+import com.baeldung.books.events.AuthorEventHandler;
+import com.baeldung.books.models.Author;
-import com.baeldung.models.Author;
import org.junit.Test;
import org.mockito.Mockito;
import org.springframework.data.rest.core.annotation.RepositoryEventHandler;
diff --git a/spring-data-rest/src/test/java/com/baeldung/events/BookEventHandlerUnitTest.java b/spring-data-rest/src/test/java/com/baeldung/books/events/BookEventHandlerUnitTest.java
similarity index 81%
rename from spring-data-rest/src/test/java/com/baeldung/events/BookEventHandlerUnitTest.java
rename to spring-data-rest/src/test/java/com/baeldung/books/events/BookEventHandlerUnitTest.java
index d6b8b3b25e..4b9d77afa2 100644
--- a/spring-data-rest/src/test/java/com/baeldung/events/BookEventHandlerUnitTest.java
+++ b/spring-data-rest/src/test/java/com/baeldung/books/events/BookEventHandlerUnitTest.java
@@ -1,7 +1,9 @@
-package com.baeldung.events;
+package com.baeldung.books.events;
+
+import com.baeldung.books.events.BookEventHandler;
+import com.baeldung.books.models.Author;
+import com.baeldung.books.models.Book;
-import com.baeldung.models.Author;
-import com.baeldung.models.Book;
import org.junit.Test;
import org.mockito.Mockito;
diff --git a/spring-data-rest/src/test/java/com/baeldung/projection/SpringDataProjectionLiveTest.java b/spring-data-rest/src/test/java/com/baeldung/books/projections/SpringDataProjectionLiveTest.java
similarity index 91%
rename from spring-data-rest/src/test/java/com/baeldung/projection/SpringDataProjectionLiveTest.java
rename to spring-data-rest/src/test/java/com/baeldung/books/projections/SpringDataProjectionLiveTest.java
index 274ae3bc1d..98b5831b96 100644
--- a/spring-data-rest/src/test/java/com/baeldung/projection/SpringDataProjectionLiveTest.java
+++ b/spring-data-rest/src/test/java/com/baeldung/books/projections/SpringDataProjectionLiveTest.java
@@ -1,4 +1,4 @@
-package com.baeldung.projection;
+package com.baeldung.books.projections;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -16,11 +16,11 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.test.context.junit4.SpringRunner;
-import com.baeldung.SpringDataRestApplication;
-import com.baeldung.models.Author;
-import com.baeldung.models.Book;
-import com.baeldung.repositories.AuthorRepository;
-import com.baeldung.repositories.BookRepository;
+import com.baeldung.books.SpringDataRestApplication;
+import com.baeldung.books.models.Author;
+import com.baeldung.books.models.Book;
+import com.baeldung.books.repositories.AuthorRepository;
+import com.baeldung.books.repositories.BookRepository;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringDataRestApplication.class, webEnvironment = WebEnvironment.DEFINED_PORT)
diff --git a/spring-data-rest/src/test/java/com/baeldung/validator/SpringDataRestValidatorIntegrationTest.java b/spring-data-rest/src/test/java/com/baeldung/books/validator/SpringDataRestValidatorIntegrationTest.java
similarity index 97%
rename from spring-data-rest/src/test/java/com/baeldung/validator/SpringDataRestValidatorIntegrationTest.java
rename to spring-data-rest/src/test/java/com/baeldung/books/validator/SpringDataRestValidatorIntegrationTest.java
index 6da76d6a33..75733475e7 100644
--- a/spring-data-rest/src/test/java/com/baeldung/validator/SpringDataRestValidatorIntegrationTest.java
+++ b/spring-data-rest/src/test/java/com/baeldung/books/validator/SpringDataRestValidatorIntegrationTest.java
@@ -1,4 +1,4 @@
-package com.baeldung.validator;
+package com.baeldung.books.validator;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
@@ -19,8 +19,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.context.WebApplicationContext;
-import com.baeldung.SpringDataRestApplication;
-import com.baeldung.models.WebsiteUser;
+import com.baeldung.books.SpringDataRestApplication;
+import com.baeldung.books.models.WebsiteUser;
import com.fasterxml.jackson.databind.ObjectMapper;
@RunWith(SpringJUnit4ClassRunner.class)
diff --git a/spring-data-rest/src/test/java/com/baeldung/springdatawebsupport/application/test/UserControllerIntegrationTest.java b/spring-data-rest/src/test/java/com/baeldung/springdatawebsupport/application/test/UserControllerIntegrationTest.java
index e1aff7e09d..d7ef361783 100644
--- a/spring-data-rest/src/test/java/com/baeldung/springdatawebsupport/application/test/UserControllerIntegrationTest.java
+++ b/spring-data-rest/src/test/java/com/baeldung/springdatawebsupport/application/test/UserControllerIntegrationTest.java
@@ -42,7 +42,7 @@ public class UserControllerIntegrationTest {
@Test
public void whenGetRequestToUserEndPointWithNameRequestParameter_thenCorrectResponse() throws Exception {
- mockMvc.perform(MockMvcRequestBuilders.get("/user").param("name", "John").contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(MockMvcResultMatchers.status().isOk())
+ mockMvc.perform(MockMvcRequestBuilders.get("/users").param("name", "John").contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(MockMvcResultMatchers.jsonPath("$['content'][0].['name']").value("John"));
}
diff --git a/spring-data-rest/src/test/java/org/baeldung/SpringContextIntegrationTest.java b/spring-data-rest/src/test/java/org/baeldung/SpringContextIntegrationTest.java
index 0380e3dc2f..c2682855b8 100644
--- a/spring-data-rest/src/test/java/org/baeldung/SpringContextIntegrationTest.java
+++ b/spring-data-rest/src/test/java/org/baeldung/SpringContextIntegrationTest.java
@@ -5,7 +5,7 @@ import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
-import com.baeldung.SpringDataRestApplication;
+import com.baeldung.books.SpringDataRestApplication;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringDataRestApplication.class)
diff --git a/spring-data-rest/src/test/java/org/baeldung/SpringContextTest.java b/spring-data-rest/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..7e7fccadef
--- /dev/null
+++ b/spring-data-rest/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.books.SpringDataRestApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringDataRestApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-dispatcher-servlet/pom.xml b/spring-dispatcher-servlet/pom.xml
index eb0fdfea46..6f816986be 100644
--- a/spring-dispatcher-servlet/pom.xml
+++ b/spring-dispatcher-servlet/pom.xml
@@ -96,7 +96,6 @@
3.0-r1655215
- 3.0.0
\ No newline at end of file
diff --git a/spring-dispatcher-servlet/src/test/java/org/baeldung/SpringContextTest.java b/spring-dispatcher-servlet/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..d1de77b1e6
--- /dev/null
+++ b/spring-dispatcher-servlet/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,19 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+
+import com.baeldung.springdispatcherservlet.configuration.AppConfig;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = AppConfig.class)
+@WebAppConfiguration
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-drools/src/test/java/org/baeldung/SpringContextTest.java b/spring-drools/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..9a36a521f1
--- /dev/null
+++ b/spring-drools/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.baeldung.spring.drools.service.TaxiFareConfiguration;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = TaxiFareConfiguration.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-ejb/spring-ejb-client/src/test/java/org/baeldung/SpringContextTest.java b/spring-ejb/spring-ejb-client/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..3e9af8a336
--- /dev/null
+++ b/spring-ejb/spring-ejb-client/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.springejbclient.SpringEjbClientApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringEjbClientApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-exceptions/pom.xml b/spring-exceptions/pom.xml
index ff28ac89bb..45c80f2c9f 100644
--- a/spring-exceptions/pom.xml
+++ b/spring-exceptions/pom.xml
@@ -192,7 +192,6 @@
19.0
- 3.54.4.54.5.2
@@ -200,7 +199,6 @@
2.9.0
- 2.62.71.6.1
diff --git a/spring-freemarker/src/test/java/org/baeldung/SpringContextTest.java b/spring-freemarker/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..49b8fe94d1
--- /dev/null
+++ b/spring-freemarker/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,20 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+
+import com.baeldung.freemarker.config.SpringWebConfig;
+import com.baeldung.freemarker.config.WebConfiguration;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = { SpringWebConfig.class, WebConfiguration.class })
+@WebAppConfiguration
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-integration/src/test/java/org/baeldung/SpringContextTest.java b/spring-integration/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..e45997b71e
--- /dev/null
+++ b/spring-integration/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,21 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.baeldung.si.security.MessageConsumer;
+import com.baeldung.si.security.SecuredDirectChannel;
+import com.baeldung.si.security.SecurityConfig;
+import com.baeldung.si.security.SecurityPubSubChannel;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = { SecurityConfig.class, SecuredDirectChannel.class, SecurityPubSubChannel.class,
+ MessageConsumer.class })
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-jenkins-pipeline/src/test/java/org/baeldung/SpringContextTest.java b/spring-jenkins-pipeline/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..79ab2f48b8
--- /dev/null
+++ b/spring-jenkins-pipeline/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,19 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.DirtiesContext;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.SpringJenkinsPipelineApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = SpringJenkinsPipelineApplication.class)
+@DirtiesContext
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-jersey/pom.xml b/spring-jersey/pom.xml
index 5a12d27180..e053ee7b4b 100644
--- a/spring-jersey/pom.xml
+++ b/spring-jersey/pom.xml
@@ -38,7 +38,7 @@
javax.servletjavax.servlet-api
- ${servlet-api-version}
+ ${javax.servlet-api.version}provided
@@ -223,11 +223,10 @@
2.27
- 3.2.01.6.14.4.94.5.5
- 4.0.0
+ 4.0.01.583.10.01.5.10.RELEASE
diff --git a/spring-jersey/src/test/java/org/baeldung/SpringContextTest.java b/spring-jersey/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..f480e597b3
--- /dev/null
+++ b/spring-jersey/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.baeldung.server.config.RestConfig;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = RestConfig.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-jinq/src/test/java/org/baeldung/SpringContextTest.java b/spring-jinq/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..e0da75c7af
--- /dev/null
+++ b/spring-jinq/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.spring.jinq.JinqApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = JinqApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-jms/pom.xml b/spring-jms/pom.xml
index 2ed58c0c95..ea4af32216 100644
--- a/spring-jms/pom.xml
+++ b/spring-jms/pom.xml
@@ -64,7 +64,6 @@
4.3.4.RELEASE5.14.1
- 2.6
diff --git a/spring-jms/src/test/java/org/baeldung/SpringContextTest.java b/spring-jms/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..e89faeebb7
--- /dev/null
+++ b/spring-jms/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,15 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {"classpath:applicationContext.xml", "classpath:EmbeddedActiveMQ.xml"})
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-jooq/pom.xml b/spring-jooq/pom.xml
index 8bce500a86..8a1fa877da 100644
--- a/spring-jooq/pom.xml
+++ b/spring-jooq/pom.xml
@@ -102,7 +102,7 @@
com.h2databaseh2
- ${com.h2database.version}
+ ${h2.version}
@@ -189,8 +189,6 @@
3.11.7
- 1.4.193
-
1.0.01.51.0.0
diff --git a/spring-kafka/pom.xml b/spring-kafka/pom.xml
index 2fb4c776fe..3d08aaa928 100644
--- a/spring-kafka/pom.xml
+++ b/spring-kafka/pom.xml
@@ -33,7 +33,7 @@
- 2.2.2.RELEASE
+ 2.2.7.RELEASE
\ No newline at end of file
diff --git a/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaConsumerConfig.java b/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaConsumerConfig.java
index 9353e63ff6..933d2353aa 100644
--- a/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaConsumerConfig.java
+++ b/spring-kafka/src/main/java/com/baeldung/spring/kafka/KafkaConsumerConfig.java
@@ -29,39 +29,36 @@ public class KafkaConsumerConfig {
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
return new DefaultKafkaConsumerFactory<>(props);
}
+
+ public ConcurrentKafkaListenerContainerFactory kafkaListenerContainerFactory(String groupId) {
+ ConcurrentKafkaListenerContainerFactory factory = new ConcurrentKafkaListenerContainerFactory<>();
+ factory.setConsumerFactory(consumerFactory(groupId));
+ return factory;
+ }
@Bean
public ConcurrentKafkaListenerContainerFactory fooKafkaListenerContainerFactory() {
- ConcurrentKafkaListenerContainerFactory factory = new ConcurrentKafkaListenerContainerFactory<>();
- factory.setConsumerFactory(consumerFactory("foo"));
- return factory;
+ return kafkaListenerContainerFactory("foo");
}
@Bean
public ConcurrentKafkaListenerContainerFactory barKafkaListenerContainerFactory() {
- ConcurrentKafkaListenerContainerFactory factory = new ConcurrentKafkaListenerContainerFactory<>();
- factory.setConsumerFactory(consumerFactory("bar"));
- return factory;
+ return kafkaListenerContainerFactory("bar");
}
@Bean
public ConcurrentKafkaListenerContainerFactory headersKafkaListenerContainerFactory() {
- ConcurrentKafkaListenerContainerFactory factory = new ConcurrentKafkaListenerContainerFactory<>();
- factory.setConsumerFactory(consumerFactory("headers"));
- return factory;
+ return kafkaListenerContainerFactory("headers");
}
@Bean
public ConcurrentKafkaListenerContainerFactory partitionsKafkaListenerContainerFactory() {
- ConcurrentKafkaListenerContainerFactory factory = new ConcurrentKafkaListenerContainerFactory<>();
- factory.setConsumerFactory(consumerFactory("partitions"));
- return factory;
+ return kafkaListenerContainerFactory("partitions");
}
@Bean
public ConcurrentKafkaListenerContainerFactory filterKafkaListenerContainerFactory() {
- ConcurrentKafkaListenerContainerFactory factory = new ConcurrentKafkaListenerContainerFactory<>();
- factory.setConsumerFactory(consumerFactory("filter"));
+ ConcurrentKafkaListenerContainerFactory factory = kafkaListenerContainerFactory("filter");
factory.setRecordFilterStrategy(record -> record.value()
.contains("World"));
return factory;
diff --git a/spring-katharsis/pom.xml b/spring-katharsis/pom.xml
index 74786e7926..18bf198948 100644
--- a/spring-katharsis/pom.xml
+++ b/spring-katharsis/pom.xml
@@ -137,7 +137,6 @@
3.0.20.9.101.6.1
- 3.7
diff --git a/spring-katharsis/src/test/java/org/baeldung/SpringContextTest.java b/spring-katharsis/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..769a436778
--- /dev/null
+++ b/spring-katharsis/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,16 @@
+package org.baeldung;
+
+import org.baeldung.Application;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-ldap/src/test/java/org/baeldung/SpringContextTest.java b/spring-ldap/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..8f0c3d4612
--- /dev/null
+++ b/spring-ldap/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import com.baeldung.ldap.javaconfig.AppConfig;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = AppConfig.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-mobile/src/test/java/org/baeldung/SpringContextTest.java b/spring-mobile/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..5e68a8e64f
--- /dev/null
+++ b/spring-mobile/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.Application;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-mockito/src/test/java/org/baeldung/SpringContextTest.java b/spring-mockito/src/test/java/org/baeldung/SpringContextTest.java
new file mode 100644
index 0000000000..b6a4e8e389
--- /dev/null
+++ b/spring-mockito/src/test/java/org/baeldung/SpringContextTest.java
@@ -0,0 +1,17 @@
+package org.baeldung;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import com.baeldung.MocksApplication;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = MocksApplication.class)
+public class SpringContextTest {
+
+ @Test
+ public void whenSpringContextIsBootstrapped_thenNoExceptions() {
+ }
+}
diff --git a/spring-mvc-basics/.gitignore b/spring-mvc-basics/.gitignore
new file mode 100644
index 0000000000..83c05e60c8
--- /dev/null
+++ b/spring-mvc-basics/.gitignore
@@ -0,0 +1,13 @@
+*.class
+
+#folders#
+/target
+/neoDb*
+/data
+/src/main/webapp/WEB-INF/classes
+*/META-INF/*
+
+# Packaged files #
+*.jar
+*.war
+*.ear
\ No newline at end of file
diff --git a/spring-mvc-basics/README.md b/spring-mvc-basics/README.md
new file mode 100644
index 0000000000..b257b3587b
--- /dev/null
+++ b/spring-mvc-basics/README.md
@@ -0,0 +1,18 @@
+=========
+
+## Spring MVC Basics with Java Configuration Example Project
+
+### The Course
+The "REST With Spring" Classes: http://bit.ly/restwithspring
+
+### Relevant Articles:
+- [Spring MVC Tutorial](https://www.baeldung.com/spring-mvc-tutorial)
+- [The Spring @Controller and @RestController Annotations](http://www.baeldung.com/spring-controller-vs-restcontroller)
+- [A Guide to the ViewResolver in Spring MVC](http://www.baeldung.com/spring-mvc-view-resolver-tutorial)
+- [Guide to Spring Handler Mappings](http://www.baeldung.com/spring-handler-mappings)
+- [Spring MVC Content Negotiation](http://www.baeldung.com/spring-mvc-content-negotiation-json-xml)
+- [Spring @RequestMapping New Shortcut Annotations](http://www.baeldung.com/spring-new-requestmapping-shortcuts)
+- [Spring MVC Custom Validation](http://www.baeldung.com/spring-mvc-custom-validator)
+- [Using Spring @ResponseStatus to Set HTTP Status Code](http://www.baeldung.com/spring-response-status)
+- [Spring MVC and the @ModelAttribute Annotation](http://www.baeldung.com/spring-mvc-and-the-modelattribute-annotation)
+- [The HttpMediaTypeNotAcceptableException in Spring MVC](http://www.baeldung.com/spring-httpmediatypenotacceptable)
\ No newline at end of file
diff --git a/spring-mvc-basics/pom.xml b/spring-mvc-basics/pom.xml
new file mode 100644
index 0000000000..8c52c60b65
--- /dev/null
+++ b/spring-mvc-basics/pom.xml
@@ -0,0 +1,54 @@
+
+
+ 4.0.0
+ com.baeldung
+ spring-mvc-basics
+ 0.1-SNAPSHOT
+ spring-mvc-basics
+ jar
+
+
+ parent-boot-2
+ com.baeldung
+ 0.0.1-SNAPSHOT
+ ../parent-boot-2
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.apache.tomcat.embed
+ tomcat-embed-jasper
+ provided
+
+
+ javax.servlet
+ jstl
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+ com.baeldung.Application
+ JAR
+
+
+
+
+
+
diff --git a/spring-mvc-basics/src/main/java/com/baeldung/Application.java b/spring-mvc-basics/src/main/java/com/baeldung/Application.java
new file mode 100644
index 0000000000..d58049fb35
--- /dev/null
+++ b/spring-mvc-basics/src/main/java/com/baeldung/Application.java
@@ -0,0 +1,11 @@
+package com.baeldung;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class Application {
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+}
diff --git a/spring-mvc-basics/src/main/java/com/baeldung/config/AppInitializer.java b/spring-mvc-basics/src/main/java/com/baeldung/config/AppInitializer.java
new file mode 100644
index 0000000000..a76d955e4f
--- /dev/null
+++ b/spring-mvc-basics/src/main/java/com/baeldung/config/AppInitializer.java
@@ -0,0 +1,27 @@
+package com.baeldung.config;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRegistration;
+
+import org.springframework.web.WebApplicationInitializer;
+import org.springframework.web.context.ContextLoaderListener;
+import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
+import org.springframework.web.servlet.DispatcherServlet;
+
+public class AppInitializer implements WebApplicationInitializer {
+
+ @Override
+ public void onStartup(ServletContext container) throws ServletException {
+ AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
+
+ context.scan("com.baeldung");
+
+ container.addListener(new ContextLoaderListener(context));
+
+ ServletRegistration.Dynamic dispatcher = container.addServlet("mvc", new DispatcherServlet(context));
+ dispatcher.setLoadOnStartup(1);
+ dispatcher.addMapping("/");
+ }
+
+}
diff --git a/spring-mvc-java/src/main/java/com/baeldung/customvalidator/ContactNumberConstraint.java b/spring-mvc-basics/src/main/java/com/baeldung/customvalidator/ContactNumberConstraint.java
similarity index 89%
rename from spring-mvc-java/src/main/java/com/baeldung/customvalidator/ContactNumberConstraint.java
rename to spring-mvc-basics/src/main/java/com/baeldung/customvalidator/ContactNumberConstraint.java
index dbd38c1122..42e441f8f9 100644
--- a/spring-mvc-java/src/main/java/com/baeldung/customvalidator/ContactNumberConstraint.java
+++ b/spring-mvc-basics/src/main/java/com/baeldung/customvalidator/ContactNumberConstraint.java
@@ -1,24 +1,24 @@
-package com.baeldung.customvalidator;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import javax.validation.Constraint;
-import javax.validation.Payload;
-
-@Documented
-@Constraint(validatedBy = ContactNumberValidator.class)
-@Target({ElementType.METHOD, ElementType.FIELD})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface ContactNumberConstraint {
-
- String message() default "Invalid phone number";
-
- Class>[] groups() default {};
-
- Class extends Payload>[] payload() default {};
-
-}
+package com.baeldung.customvalidator;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
+@Documented
+@Constraint(validatedBy = ContactNumberValidator.class)
+@Target({ ElementType.METHOD, ElementType.FIELD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ContactNumberConstraint {
+
+ String message() default "Invalid phone number";
+
+ Class>[] groups() default {};
+
+ Class extends Payload>[] payload() default {};
+
+}
diff --git a/spring-mvc-java/src/main/java/com/baeldung/customvalidator/ContactNumberValidator.java b/spring-mvc-basics/src/main/java/com/baeldung/customvalidator/ContactNumberValidator.java
similarity index 97%
rename from spring-mvc-java/src/main/java/com/baeldung/customvalidator/ContactNumberValidator.java
rename to spring-mvc-basics/src/main/java/com/baeldung/customvalidator/ContactNumberValidator.java
index dea6b9099b..fe14f3ccf1 100644
--- a/spring-mvc-java/src/main/java/com/baeldung/customvalidator/ContactNumberValidator.java
+++ b/spring-mvc-basics/src/main/java/com/baeldung/customvalidator/ContactNumberValidator.java
@@ -1,17 +1,17 @@
-package com.baeldung.customvalidator;
-
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-
-public class ContactNumberValidator implements ConstraintValidator {
-
- @Override
- public void initialize(ContactNumberConstraint contactNumber) {
- }
-
- @Override
- public boolean isValid(String contactField, ConstraintValidatorContext cxt) {
- return contactField != null && contactField.matches("[0-9]+") && (contactField.length() > 8) && (contactField.length() < 14);
- }
-
-}
+package com.baeldung.customvalidator;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+public class ContactNumberValidator implements ConstraintValidator {
+
+ @Override
+ public void initialize(ContactNumberConstraint contactNumber) {
+ }
+
+ @Override
+ public boolean isValid(String contactField, ConstraintValidatorContext cxt) {
+ return contactField != null && contactField.matches("[0-9]+") && (contactField.length() > 8) && (contactField.length() < 14);
+ }
+
+}
diff --git a/spring-mvc-java/src/main/java/com/baeldung/customvalidator/FieldsValueMatch.java b/spring-mvc-basics/src/main/java/com/baeldung/customvalidator/FieldsValueMatch.java
similarity index 100%
rename from spring-mvc-java/src/main/java/com/baeldung/customvalidator/FieldsValueMatch.java
rename to spring-mvc-basics/src/main/java/com/baeldung/customvalidator/FieldsValueMatch.java
diff --git a/spring-mvc-java/src/main/java/com/baeldung/customvalidator/FieldsValueMatchValidator.java b/spring-mvc-basics/src/main/java/com/baeldung/customvalidator/FieldsValueMatchValidator.java
similarity index 100%
rename from spring-mvc-java/src/main/java/com/baeldung/customvalidator/FieldsValueMatchValidator.java
rename to spring-mvc-basics/src/main/java/com/baeldung/customvalidator/FieldsValueMatchValidator.java
diff --git a/spring-mvc-java/src/main/java/com/baeldung/exception/HttpMediaTypeNotAcceptableExceptionExampleController.java b/spring-mvc-basics/src/main/java/com/baeldung/exception/HttpMediaTypeNotAcceptableExceptionExampleController.java
similarity index 92%
rename from spring-mvc-java/src/main/java/com/baeldung/exception/HttpMediaTypeNotAcceptableExceptionExampleController.java
rename to spring-mvc-basics/src/main/java/com/baeldung/exception/HttpMediaTypeNotAcceptableExceptionExampleController.java
index 539a6032a6..1e3591b7aa 100644
--- a/spring-mvc-java/src/main/java/com/baeldung/exception/HttpMediaTypeNotAcceptableExceptionExampleController.java
+++ b/spring-mvc-basics/src/main/java/com/baeldung/exception/HttpMediaTypeNotAcceptableExceptionExampleController.java
@@ -1,16 +1,18 @@
package com.baeldung.exception;
+import java.util.Collections;
+import java.util.Map;
+
import org.springframework.http.MediaType;
import org.springframework.web.HttpMediaTypeNotAcceptableException;
+import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
-import java.util.Collections;
-import java.util.Map;
-
@RestController
+@ControllerAdvice
public class HttpMediaTypeNotAcceptableExceptionExampleController {
@PostMapping(value = "/test", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
diff --git a/spring-mvc-basics/src/main/java/com/baeldung/model/Book.java b/spring-mvc-basics/src/main/java/com/baeldung/model/Book.java
new file mode 100644
index 0000000000..bdfa1d835a
--- /dev/null
+++ b/spring-mvc-basics/src/main/java/com/baeldung/model/Book.java
@@ -0,0 +1,42 @@
+package com.baeldung.model;
+
+public class Book {
+
+ private int id;
+ private String author;
+ private String title;
+
+ public Book() {
+ }
+
+ public Book(int id, String author, String title) {
+ this.id = id;
+ this.author = author;
+ this.title = title;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+}
diff --git a/spring-mvc-basics/src/main/java/com/baeldung/model/Employee.java b/spring-mvc-basics/src/main/java/com/baeldung/model/Employee.java
new file mode 100644
index 0000000000..fb0a452219
--- /dev/null
+++ b/spring-mvc-basics/src/main/java/com/baeldung/model/Employee.java
@@ -0,0 +1,61 @@
+package com.baeldung.model;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement
+public class Employee {
+
+ private long id;
+ private String name;
+ private String contactNumber;
+ private String workingArea;
+
+ public Employee() {
+ super();
+ }
+
+ public Employee(final long id, final String name, final String contactNumber, final String workingArea) {
+ this.id = id;
+ this.name = name;
+ this.contactNumber = contactNumber;
+ this.workingArea = workingArea;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(final long id) {
+ this.id = id;
+ }
+
+ public String getContactNumber() {
+ return contactNumber;
+ }
+
+ public void setContactNumber(final String contactNumber) {
+ this.contactNumber = contactNumber;
+ }
+
+ public String getWorkingArea() {
+ return workingArea;
+ }
+
+ public void setWorkingArea(final String workingArea) {
+ this.workingArea = workingArea;
+ }
+
+ @Override
+ public String toString() {
+ return "Employee [id=" + id + ", name=" + name + ", contactNumber=" + contactNumber + ", workingArea=" + workingArea + "]";
+ }
+
+}
diff --git a/spring-mvc-java/src/main/java/com/baeldung/model/NewUserForm.java b/spring-mvc-basics/src/main/java/com/baeldung/model/NewUserForm.java
similarity index 82%
rename from spring-mvc-java/src/main/java/com/baeldung/model/NewUserForm.java
rename to spring-mvc-basics/src/main/java/com/baeldung/model/NewUserForm.java
index 12969b6002..b4fe82ab4a 100644
--- a/spring-mvc-java/src/main/java/com/baeldung/model/NewUserForm.java
+++ b/spring-mvc-basics/src/main/java/com/baeldung/model/NewUserForm.java
@@ -2,10 +2,7 @@ package com.baeldung.model;
import com.baeldung.customvalidator.FieldsValueMatch;
-@FieldsValueMatch.List({
- @FieldsValueMatch(field = "password", fieldMatch = "verifyPassword", message = "Passwords do not match!"),
- @FieldsValueMatch(field = "email", fieldMatch = "verifyEmail", message = "Email addresses do not match!")
-})
+@FieldsValueMatch.List({ @FieldsValueMatch(field = "password", fieldMatch = "verifyPassword", message = "Passwords do not match!"), @FieldsValueMatch(field = "email", fieldMatch = "verifyEmail", message = "Email addresses do not match!") })
public class NewUserForm {
private String email;
private String verifyEmail;
diff --git a/spring-mvc-java/src/main/java/com/baeldung/model/ValidatedPhone.java b/spring-mvc-basics/src/main/java/com/baeldung/model/ValidatedPhone.java
similarity index 94%
rename from spring-mvc-java/src/main/java/com/baeldung/model/ValidatedPhone.java
rename to spring-mvc-basics/src/main/java/com/baeldung/model/ValidatedPhone.java
index be702a8517..8cea915e6e 100644
--- a/spring-mvc-java/src/main/java/com/baeldung/model/ValidatedPhone.java
+++ b/spring-mvc-basics/src/main/java/com/baeldung/model/ValidatedPhone.java
@@ -1,22 +1,22 @@
-package com.baeldung.model;
-
-import com.baeldung.customvalidator.ContactNumberConstraint;
-
-public class ValidatedPhone {
-
- @ContactNumberConstraint
- private String phone;
-
- public String getPhone() {
- return phone;
- }
-
- public void setPhone(String phone) {
- this.phone = phone;
- }
-
- @Override
- public String toString() {
- return phone;
- }
-}
+package com.baeldung.model;
+
+import com.baeldung.customvalidator.ContactNumberConstraint;
+
+public class ValidatedPhone {
+
+ @ContactNumberConstraint
+ private String phone;
+
+ public String getPhone() {
+ return phone;
+ }
+
+ public void setPhone(String phone) {
+ this.phone = phone;
+ }
+
+ @Override
+ public String toString() {
+ return phone;
+ }
+}
diff --git a/spring-mvc-basics/src/main/java/com/baeldung/spring/web/config/WebConfig.java b/spring-mvc-basics/src/main/java/com/baeldung/spring/web/config/WebConfig.java
new file mode 100644
index 0000000000..9a321f65a2
--- /dev/null
+++ b/spring-mvc-basics/src/main/java/com/baeldung/spring/web/config/WebConfig.java
@@ -0,0 +1,67 @@
+package com.baeldung.spring.web.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.http.MediaType;
+import org.springframework.web.servlet.ViewResolver;
+import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
+import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import org.springframework.web.servlet.view.InternalResourceViewResolver;
+import org.springframework.web.servlet.view.JstlView;
+import org.springframework.web.servlet.view.ResourceBundleViewResolver;
+import org.springframework.web.servlet.view.XmlViewResolver;
+
+//@EnableWebMvc
+//@ComponentScan(basePackages = { "com.baeldung.web.controller" })
+@Configuration
+public class WebConfig implements WebMvcConfigurer {
+
+ @Override
+ public void addViewControllers(final ViewControllerRegistry registry) {
+ registry.addViewController("/")
+ .setViewName("index");
+ }
+
+ @Bean
+ public ViewResolver viewResolver() {
+ final InternalResourceViewResolver bean = new InternalResourceViewResolver();
+ bean.setViewClass(JstlView.class);
+ bean.setPrefix("/WEB-INF/view/");
+ bean.setSuffix(".jsp");
+ bean.setOrder(2);
+ return bean;
+ }
+
+ @Bean
+ public ViewResolver resourceBundleViewResolver() {
+ final ResourceBundleViewResolver bean = new ResourceBundleViewResolver();
+ bean.setBasename("views");
+ bean.setOrder(0);
+ return bean;
+ }
+
+ @Bean
+ public ViewResolver xmlViewResolver() {
+ final XmlViewResolver bean = new XmlViewResolver();
+ bean.setLocation(new ClassPathResource("views.xml"));
+ bean.setOrder(1);
+ return bean;
+ }
+
+ /**
+ * Spring Boot allows configuring Content Negotiation using properties
+ */
+ @Override
+ public void configureContentNegotiation(final ContentNegotiationConfigurer configurer) {
+ configurer.favorPathExtension(true)
+ .favorParameter(true)
+ .parameterName("mediaType")
+ .ignoreAcceptHeader(false)
+ .useRegisteredExtensionsOnly(false)
+ .defaultContentType(MediaType.APPLICATION_JSON)
+ .mediaType("xml", MediaType.APPLICATION_XML)
+ .mediaType("json", MediaType.APPLICATION_JSON);
+ }
+}
\ No newline at end of file
diff --git a/spring-mvc-basics/src/main/java/com/baeldung/web/controller/EmployeeController.java b/spring-mvc-basics/src/main/java/com/baeldung/web/controller/EmployeeController.java
new file mode 100644
index 0000000000..cbea4c98c6
--- /dev/null
+++ b/spring-mvc-basics/src/main/java/com/baeldung/web/controller/EmployeeController.java
@@ -0,0 +1,60 @@
+package com.baeldung.web.controller;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.ui.ModelMap;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.ModelAndView;
+
+import com.baeldung.model.Employee;
+
+@Controller
+public class EmployeeController {
+
+ Map employeeMap = new HashMap<>();
+
+ @ModelAttribute("employees")
+ public void initEmployees() {
+ employeeMap.put(1L, new Employee(1L, "John", "223334411", "rh"));
+ employeeMap.put(2L, new Employee(2L, "Peter", "22001543", "informatics"));
+ employeeMap.put(3L, new Employee(3L, "Mike", "223334411", "admin"));
+ }
+
+ @RequestMapping(value = "/employee", method = RequestMethod.GET)
+ public ModelAndView showForm() {
+ return new ModelAndView("employeeHome", "employee", new Employee());
+ }
+
+ @RequestMapping(value = "/employee/{Id}", produces = { "application/json", "application/xml" }, method = RequestMethod.GET)
+ public @ResponseBody Employee getEmployeeById(@PathVariable final Long Id) {
+ return employeeMap.get(Id);
+ }
+
+ @RequestMapping(value = "/addEmployee", method = RequestMethod.POST)
+ public String submit(@ModelAttribute("employee") final Employee employee, final BindingResult result, final ModelMap model) {
+ if (result.hasErrors()) {
+ return "error";
+ }
+ model.addAttribute("name", employee.getName());
+ model.addAttribute("contactNumber", employee.getContactNumber());
+ model.addAttribute("workingArea", employee.getWorkingArea());
+ model.addAttribute("id", employee.getId());
+
+ employeeMap.put(employee.getId(), employee);
+
+ return "employeeView";
+ }
+
+ @ModelAttribute
+ public void addAttributes(final Model model) {
+ model.addAttribute("msg", "Welcome to the Netherlands!");
+ }
+}
diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/NewUserController.java b/spring-mvc-basics/src/main/java/com/baeldung/web/controller/NewUserController.java
similarity index 100%
rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/NewUserController.java
rename to spring-mvc-basics/src/main/java/com/baeldung/web/controller/NewUserController.java
diff --git a/spring-mvc-basics/src/main/java/com/baeldung/web/controller/RequestMappingShortcutsController.java b/spring-mvc-basics/src/main/java/com/baeldung/web/controller/RequestMappingShortcutsController.java
new file mode 100644
index 0000000000..e91a914c6d
--- /dev/null
+++ b/spring-mvc-basics/src/main/java/com/baeldung/web/controller/RequestMappingShortcutsController.java
@@ -0,0 +1,47 @@
+package com.baeldung.web.controller;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PatchMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+public class RequestMappingShortcutsController {
+
+ @GetMapping("/get")
+ public @ResponseBody ResponseEntity get() {
+ return new ResponseEntity("GET Response", HttpStatus.OK);
+ }
+
+ @GetMapping("/get/{id}")
+ public @ResponseBody ResponseEntity getById(@PathVariable String id) {
+ return new ResponseEntity("GET Response : " + id, HttpStatus.OK);
+ }
+
+ @PostMapping("/post")
+ public @ResponseBody ResponseEntity post() {
+ return new ResponseEntity("POST Response", HttpStatus.OK);
+ }
+
+ @PutMapping("/put")
+ public @ResponseBody ResponseEntity put() {
+ return new ResponseEntity("PUT Response", HttpStatus.OK);
+ }
+
+ @DeleteMapping("/delete")
+ public @ResponseBody ResponseEntity delete() {
+ return new ResponseEntity("DELETE Response", HttpStatus.OK);
+ }
+
+ @PatchMapping("/patch")
+ public @ResponseBody ResponseEntity patch() {
+ return new ResponseEntity("PATCH Response", HttpStatus.OK);
+ }
+
+}
diff --git a/spring-mvc-basics/src/main/java/com/baeldung/web/controller/ResponseStatusRestController.java b/spring-mvc-basics/src/main/java/com/baeldung/web/controller/ResponseStatusRestController.java
new file mode 100644
index 0000000000..4cc7589bc8
--- /dev/null
+++ b/spring-mvc-basics/src/main/java/com/baeldung/web/controller/ResponseStatusRestController.java
@@ -0,0 +1,48 @@
+package com.baeldung.web.controller;
+
+import java.util.concurrent.ThreadLocalRandom;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.ResponseStatus;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.baeldung.model.Book;
+
+@RestController
+public class ResponseStatusRestController {
+
+ @GetMapping("/teapot")
+ @ResponseStatus(HttpStatus.I_AM_A_TEAPOT)
+ public void teaPot() {
+ }
+
+ @GetMapping("empty")
+ @ResponseStatus(HttpStatus.NO_CONTENT)
+ public void emptyResponse() {
+ }
+
+ @GetMapping("empty-no-responsestatus")
+ public void emptyResponseWithoutResponseStatus() {
+ }
+
+ @PostMapping("create")
+ @ResponseStatus(HttpStatus.CREATED)
+ public Book createEntity() {
+ // here we would create and persist an entity
+ int randomInt = ThreadLocalRandom.current()
+ .nextInt(1, 100);
+ Book entity = new Book(randomInt, "author" + randomInt, "title" + randomInt);
+ return entity;
+ }
+
+ @PostMapping("create-no-responsestatus")
+ public Book createEntityWithoutResponseStatus() {
+ // here we would create and persist an entity
+ int randomInt = ThreadLocalRandom.current()
+ .nextInt(1, 100);
+ Book entity = new Book(randomInt, "author" + randomInt, "title" + randomInt);
+ return entity;
+ }
+}
diff --git a/spring-mvc-basics/src/main/java/com/baeldung/web/controller/SampleController.java b/spring-mvc-basics/src/main/java/com/baeldung/web/controller/SampleController.java
new file mode 100644
index 0000000000..ce89669fde
--- /dev/null
+++ b/spring-mvc-basics/src/main/java/com/baeldung/web/controller/SampleController.java
@@ -0,0 +1,24 @@
+package com.baeldung.web.controller;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+
+@Controller
+public class SampleController {
+
+ @GetMapping("/sample")
+ public String showForm() {
+ return "sample";
+ }
+
+ @GetMapping("/sample2")
+ public String showForm2() {
+ return "sample2";
+ }
+
+ @GetMapping("/sample3")
+ public String showForm3() {
+ return "sample3";
+ }
+
+}
diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/SimpleBookController.java b/spring-mvc-basics/src/main/java/com/baeldung/web/controller/SimpleBookController.java
similarity index 100%
rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/SimpleBookController.java
rename to spring-mvc-basics/src/main/java/com/baeldung/web/controller/SimpleBookController.java
diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/SimpleBookRestController.java b/spring-mvc-basics/src/main/java/com/baeldung/web/controller/SimpleBookRestController.java
similarity index 100%
rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/SimpleBookRestController.java
rename to spring-mvc-basics/src/main/java/com/baeldung/web/controller/SimpleBookRestController.java
diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/ValidatedPhoneController.java b/spring-mvc-basics/src/main/java/com/baeldung/web/controller/ValidatedPhoneController.java
similarity index 96%
rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/ValidatedPhoneController.java
rename to spring-mvc-basics/src/main/java/com/baeldung/web/controller/ValidatedPhoneController.java
index 9b3a6b3a4c..73e1e4bb25 100644
--- a/spring-mvc-java/src/main/java/com/baeldung/web/controller/ValidatedPhoneController.java
+++ b/spring-mvc-basics/src/main/java/com/baeldung/web/controller/ValidatedPhoneController.java
@@ -1,32 +1,32 @@
-package com.baeldung.web.controller;
-
-import com.baeldung.model.ValidatedPhone;
-import org.springframework.stereotype.Controller;
-import org.springframework.ui.Model;
-import org.springframework.validation.BindingResult;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-
-import javax.validation.Valid;
-
-@Controller
-public class ValidatedPhoneController {
-
- @GetMapping("/validatePhone")
- public String loadFormPage(Model m) {
- m.addAttribute("validatedPhone", new ValidatedPhone());
- return "phoneHome";
- }
-
- @PostMapping("/addValidatePhone")
- public String submitForm(@Valid ValidatedPhone validatedPhone, BindingResult result, Model m) {
- if (result.hasErrors()) {
- return "phoneHome";
- }
-
- m.addAttribute("message", "Successfully saved phone: " + validatedPhone.toString());
- return "phoneHome";
- }
-
-
-}
+package com.baeldung.web.controller;
+
+import javax.validation.Valid;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+
+import com.baeldung.model.ValidatedPhone;
+
+@Controller
+public class ValidatedPhoneController {
+
+ @GetMapping("/validatePhone")
+ public String loadFormPage(Model m) {
+ m.addAttribute("validatedPhone", new ValidatedPhone());
+ return "phoneHome";
+ }
+
+ @PostMapping("/addValidatePhone")
+ public String submitForm(@Valid ValidatedPhone validatedPhone, BindingResult result, Model m) {
+ if (result.hasErrors()) {
+ return "phoneHome";
+ }
+
+ m.addAttribute("message", "Successfully saved phone: " + validatedPhone.toString());
+ return "phoneHome";
+ }
+
+}
diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/handlermapping/BeanNameHandlerMappingController.java b/spring-mvc-basics/src/main/java/com/baeldung/web/controller/handlermapping/BeanNameHandlerMappingController.java
similarity index 100%
rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/handlermapping/BeanNameHandlerMappingController.java
rename to spring-mvc-basics/src/main/java/com/baeldung/web/controller/handlermapping/BeanNameHandlerMappingController.java
diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/handlermapping/SimpleUrlMappingController.java b/spring-mvc-basics/src/main/java/com/baeldung/web/controller/handlermapping/SimpleUrlMappingController.java
similarity index 100%
rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/handlermapping/SimpleUrlMappingController.java
rename to spring-mvc-basics/src/main/java/com/baeldung/web/controller/handlermapping/SimpleUrlMappingController.java
diff --git a/spring-mvc-java/src/main/java/com/baeldung/web/controller/handlermapping/WelcomeController.java b/spring-mvc-basics/src/main/java/com/baeldung/web/controller/handlermapping/WelcomeController.java
similarity index 100%
rename from spring-mvc-java/src/main/java/com/baeldung/web/controller/handlermapping/WelcomeController.java
rename to spring-mvc-basics/src/main/java/com/baeldung/web/controller/handlermapping/WelcomeController.java
diff --git a/spring-mvc-basics/src/main/resources/application.properties b/spring-mvc-basics/src/main/resources/application.properties
new file mode 100644
index 0000000000..b8a9be0b40
--- /dev/null
+++ b/spring-mvc-basics/src/main/resources/application.properties
@@ -0,0 +1,7 @@
+server.servlet.context-path=/spring-mvc-basics
+
+### Content Negotiation (already defined programatically)
+spring.mvc.pathmatch.use-suffix-pattern=true
+#spring.mvc.contentnegotiation.favor-path-extension=true
+#spring.mvc.contentnegotiation.favor-parameter=true
+#spring.mvc.contentnegotiation.parameter-name=mediaType
diff --git a/spring-mvc-basics/src/main/resources/mvc-configuration.xml b/spring-mvc-basics/src/main/resources/mvc-configuration.xml
new file mode 100644
index 0000000000..7505614c99
--- /dev/null
+++ b/spring-mvc-basics/src/main/resources/mvc-configuration.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+ /WEB-INF/view/
+
+
+ .jsp
+
+
+
+
\ No newline at end of file
diff --git a/spring-mvc-basics/src/main/resources/views.properties b/spring-mvc-basics/src/main/resources/views.properties
new file mode 100644
index 0000000000..06d042b446
--- /dev/null
+++ b/spring-mvc-basics/src/main/resources/views.properties
@@ -0,0 +1,3 @@
+sample2.(class)=org.springframework.web.servlet.view.JstlView
+sample2.url=/WEB-INF/view2/sample2.jsp
+
diff --git a/spring-mvc-java/src/main/resources/views.xml b/spring-mvc-basics/src/main/resources/views.xml
similarity index 65%
rename from spring-mvc-java/src/main/resources/views.xml
rename to spring-mvc-basics/src/main/resources/views.xml
index 83bca5293d..a44d3deae4 100644
--- a/spring-mvc-java/src/main/resources/views.xml
+++ b/spring-mvc-basics/src/main/resources/views.xml
@@ -1,10 +1,10 @@
-
-
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-mvc-basics/src/main/webapp/WEB-INF/view/employeeHome.jsp b/spring-mvc-basics/src/main/webapp/WEB-INF/view/employeeHome.jsp
new file mode 100644
index 0000000000..fa5812faea
--- /dev/null
+++ b/spring-mvc-basics/src/main/webapp/WEB-INF/view/employeeHome.jsp
@@ -0,0 +1,33 @@
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
+<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
+
+
+
+Form Example - Register an Employee
+
+
+
Welcome, Enter The Employee Details
+
+
+
+
+
Name
+
+
+
+
Id
+
+
+
+
Contact Number
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/spring-mvc-basics/src/main/webapp/WEB-INF/view/employeeView.jsp b/spring-mvc-basics/src/main/webapp/WEB-INF/view/employeeView.jsp
new file mode 100644
index 0000000000..9a9b879a35
--- /dev/null
+++ b/spring-mvc-basics/src/main/webapp/WEB-INF/view/employeeView.jsp
@@ -0,0 +1,25 @@
+<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
+
+
+Spring MVC Form Handling
+
+
+
+
Submitted Employee Information
+
${msg}
+
+
+
Name :
+
${name}
+
+
+
ID :
+
${id}
+
+
+
Contact Number :
+
${contactNumber}
+
+
+
+
\ No newline at end of file
diff --git a/spring-mvc-basics/src/main/webapp/WEB-INF/view/index.jsp b/spring-mvc-basics/src/main/webapp/WEB-INF/view/index.jsp
new file mode 100644
index 0000000000..4f4eb0068d
--- /dev/null
+++ b/spring-mvc-basics/src/main/webapp/WEB-INF/view/index.jsp
@@ -0,0 +1,7 @@
+
+
+
+
+
This is the body of the index view
+
+
\ No newline at end of file
diff --git a/spring-mvc-java/src/main/webapp/WEB-INF/view/phoneHome.jsp b/spring-mvc-basics/src/main/webapp/WEB-INF/view/phoneHome.jsp
similarity index 89%
rename from spring-mvc-java/src/main/webapp/WEB-INF/view/phoneHome.jsp
rename to spring-mvc-basics/src/main/webapp/WEB-INF/view/phoneHome.jsp
index b873e9bc5f..ebc9052639 100644
--- a/spring-mvc-java/src/main/webapp/WEB-INF/view/phoneHome.jsp
+++ b/spring-mvc-basics/src/main/webapp/WEB-INF/view/phoneHome.jsp
@@ -1,38 +1,38 @@
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
-<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
-
-
-
-
- Sample Form
-
-
-
-
-
+ * This test application is meant to maintain a set of {@link Person} models. It
+ * exposes a "/persons" endpoint which supports the following operations:
+ *
+ *
+ *
{@code POST} XML for adding a new {@link Person} to the set
+ *
{@code GET} for retrieving the set of {@link Person} models as XML
+ *
+ *
+ * The {@code POST} handler is vulnerable to an RCE exploit.
+ */
+public final class App {
+
+ public static App createHardened(int port) {
+ final XStream xstream = new XStream();
+ xstream.addPermission(NoTypePermission.NONE);
+ xstream.addPermission(NullPermission.NULL);
+ xstream.addPermission(PrimitiveTypePermission.PRIMITIVES);
+ xstream.allowTypes(new Class>[] { Person.class });
+ return new App(port, xstream);
+ }
+
+ public static App createVulnerable(int port) {
+ return new App(port, new XStream());
+ }
+
+ private final int port;
+ private final Set persons;
+ private final XStream xstream;
+ private HttpServer server;
+
+ private App(int port, XStream xstream) {
+ this.port = port;
+ persons = new HashSet<>();
+ // this app is vulnerable because XStream security is not configured
+ this.xstream = xstream;
+ this.xstream.alias("person", Person.class);
+ }
+
+ void start() throws IOException {
+ server = HttpServer.create(new InetSocketAddress("localhost", port), 0);
+ server.createContext("/persons", exchange -> {
+ switch (exchange.getRequestMethod()) {
+ case "POST":
+ final Person person = (Person) xstream.fromXML(exchange.getRequestBody());
+ persons.add(person);
+ exchange.sendResponseHeaders(201, 0);
+ exchange.close();
+ break;
+ case "GET":
+ exchange.sendResponseHeaders(200, 0);
+ xstream.toXML(persons, exchange.getResponseBody());
+ exchange.close();
+ break;
+ default:
+ exchange.sendResponseHeaders(405, 0);
+ exchange.close();
+ }
+ });
+ server.start();
+ }
+
+ void stop() {
+ if (server != null) {
+ server.stop(0);
+ }
+ }
+
+ int port() {
+ if (server == null)
+ throw new IllegalStateException("Server not started");
+ return server.getAddress()
+ .getPort();
+ }
+}
diff --git a/xstream/src/main/java/com/baeldung/rce/Person.java b/xstream/src/main/java/com/baeldung/rce/Person.java
new file mode 100644
index 0000000000..336c47798b
--- /dev/null
+++ b/xstream/src/main/java/com/baeldung/rce/Person.java
@@ -0,0 +1,43 @@
+package com.baeldung.rce;
+
+import java.util.Objects;
+
+/** Person model */
+public final class Person {
+
+ private String first;
+ private String last;
+
+ public String getFirst() {
+ return first;
+ }
+
+ public void setFirst(String first) {
+ this.first = first;
+ }
+
+ public String getLast() {
+ return last;
+ }
+
+ public void setLast(String last) {
+ this.last = last;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof Person)) {
+ return false;
+ }
+ Person person = (Person) o;
+ return Objects.equals(first, person.first) && Objects.equals(last, person.last);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(first, last);
+ }
+}
diff --git a/xstream/src/test/java/com/baeldung/rce/AppUnitTest.java b/xstream/src/test/java/com/baeldung/rce/AppUnitTest.java
new file mode 100644
index 0000000000..3b541ae099
--- /dev/null
+++ b/xstream/src/test/java/com/baeldung/rce/AppUnitTest.java
@@ -0,0 +1,65 @@
+package com.baeldung.rce;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.SocketException;
+import java.net.URL;
+
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Unit test which demonstrates a remote code exploit against the {@link App}
+ * server. Sends an XML request containing an attack payload to the {@code POST}
+ * endpoint.
+ */
+public final class AppUnitTest {
+
+ private App app;
+
+ /** start a new web server */
+ @Before
+ public void before() throws IOException {
+ app = App.createVulnerable(0);
+ app.start();
+ }
+
+ /** stop the web server */
+ @After
+ public void after() {
+ if (app != null)
+ app.stop();
+ }
+
+ /**
+ * Test passes when an {@link IOException} is thrown because this indicates that
+ * the attacker caused the application to fail in some way. This does not
+ * actually confirm that the exploit took place, because the RCE is a
+ * side-effect that is difficult to observe.
+ */
+ @Test(expected = SocketException.class)
+ public void givenAppIsVulneable_whenExecuteRemoteCodeWhichThrowsException_thenThrowsException() throws IOException {
+ // POST the attack.xml to the application's /persons endpoint
+ final URL url = new URL("http://localhost:" + app.port() + "/persons");
+ final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod("POST");
+ connection.setDoOutput(true);
+ connection.setUseCaches(false);
+ connection.setRequestProperty("Content-Type", "application/xml");
+ connection.connect();
+ try (OutputStream os = connection.getOutputStream(); InputStream is = AppUnitTest.class.getResourceAsStream("/attack.xml")) {
+ byte[] buffer = new byte[1024];
+ while (is.read(buffer) > 0) {
+ os.write(buffer);
+ }
+ }
+ final int rc = connection.getResponseCode();
+ connection.disconnect();
+ assertTrue(rc >= 400);
+ }
+}
diff --git a/xstream/src/test/java/com/baeldung/rce/AttackExploitedException.java b/xstream/src/test/java/com/baeldung/rce/AttackExploitedException.java
new file mode 100644
index 0000000000..16c906abfc
--- /dev/null
+++ b/xstream/src/test/java/com/baeldung/rce/AttackExploitedException.java
@@ -0,0 +1,7 @@
+package com.baeldung.rce;
+
+/**
+ * Indicates a successful remote code execution attack has taken place.
+ */
+final class AttackExploitedException extends RuntimeException {
+}
diff --git a/xstream/src/test/java/com/baeldung/rce/AttackExploitedExceptionThrower.java b/xstream/src/test/java/com/baeldung/rce/AttackExploitedExceptionThrower.java
new file mode 100644
index 0000000000..16ed143f7a
--- /dev/null
+++ b/xstream/src/test/java/com/baeldung/rce/AttackExploitedExceptionThrower.java
@@ -0,0 +1,13 @@
+package com.baeldung.rce;
+
+/**
+ * Class which contains an action to throw {@link AttackExploitedException}.
+ * This helper is used by {@link AppTest} to determine when the remote code
+ * exploit has taken place.
+ */
+final class AttackExploitedExceptionThrower {
+
+ public void throwAttackExploitedException() {
+ throw new AttackExploitedException();
+ }
+}
diff --git a/xstream/src/test/java/com/baeldung/rce/XStreamBasicsUnitTest.java b/xstream/src/test/java/com/baeldung/rce/XStreamBasicsUnitTest.java
new file mode 100644
index 0000000000..d762813b22
--- /dev/null
+++ b/xstream/src/test/java/com/baeldung/rce/XStreamBasicsUnitTest.java
@@ -0,0 +1,82 @@
+package com.baeldung.rce;
+
+import com.thoughtworks.xstream.XStream;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Demonstrates XStream basics
+ */
+public final class XStreamBasicsUnitTest {
+
+ private XStream xstream;
+
+ @Before
+ public void before() {
+ xstream = new XStream();
+ xstream.alias("person", Person.class);
+ }
+
+ @Test
+ public void whenWritePerson_thenWritesExpectedXml() {
+ Person person = new Person();
+ person.setFirst("John");
+ person.setLast("Smith");
+
+ String xml = xstream.toXML(person);
+
+ // @formatter:off
+ String expected = ""
+ + "\n"
+ + " John\n"
+ + " Smith\n"
+ + "";
+ // @formatter:on
+ assertEquals(expected, xml);
+
+ }
+
+ @Test
+ public void whenReadXmlAsPerson_thenReturnsNewPerson() {
+ // @formatter:off
+ String xml = ""
+ + ""
+ + " John"
+ + " Smith"
+ + "";
+ // @formatter:on
+
+ Person person = (Person) xstream.fromXML(xml);
+
+ Person expected = new Person();
+ expected.setFirst("John");
+ expected.setLast("Smith");
+ assertEquals(person, expected);
+ }
+
+ @Test
+ public void givenXmlRepresentationOfMap_whenDeserialize_thenBuildsMap() {
+ // @formatter:off
+ String xml = ""
+ + "";
+ // @formatter:on
+ @SuppressWarnings("unchecked")
+ Map actual = (Map) xstream.fromXML(xml);
+
+ final Map expected = Collections.singletonMap("foo", 10);
+
+ assertEquals(expected, actual);
+ }
+
+}
diff --git a/xstream/src/test/resources/attack.xml b/xstream/src/test/resources/attack.xml
new file mode 100644
index 0000000000..8a5713648c
--- /dev/null
+++ b/xstream/src/test/resources/attack.xml
@@ -0,0 +1,12 @@
+
+ foo
+
+ java.lang.Comparable
+
+
+
+ throwAttackExploitedException
+
+
+
diff --git a/xstream/src/test/resources/calculator-attack.xml b/xstream/src/test/resources/calculator-attack.xml
new file mode 100644
index 0000000000..ae24843dc6
--- /dev/null
+++ b/xstream/src/test/resources/calculator-attack.xml
@@ -0,0 +1,16 @@
+
+ foo
+
+ java.lang.Comparable
+
+
+
+ open
+ /Applications/Calculator.app
+
+
+ start
+
+
+