Merge remote-tracking branch 'eugenp/master'

This commit is contained in:
DOHA 2019-07-21 13:52:00 +03:00
commit ba9d52a1ec
239 changed files with 3531 additions and 138 deletions

View File

@ -0,0 +1,34 @@
package com.baeldung.java_8_features.groupingby;
public class Tuple {
private BlogPostType type;
private String author;
public Tuple(BlogPostType type, String author) {
super();
this.type = type;
this.author = author;
}
public BlogPostType getType() {
return type;
}
public void setType(BlogPostType type) {
this.type = type;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
@Override
public String toString() {
return "Tuple [type=" + type + ", author=" + author + ", getType()=" + getType() + ", getAuthor()=" + getAuthor() + ", getClass()=" + getClass() + ", hashCode()=" + hashCode() + ", toString()=" + super.toString() + "]";
}
}

View File

@ -54,3 +54,15 @@ class BankAccountCopyConstructor extends BankAccount {
this.balance = 0.0f;
}
}
class BankAccountChainedConstructors extends BankAccount {
public BankAccountChainedConstructors(String name, LocalDateTime opened, double balance) {
this.name = name;
this.opened = opened;
this.balance = balance;
}
public BankAccountChainedConstructors(String name) {
this(name, LocalDateTime.now(), 0.0f);
}
}

View File

@ -1,15 +1,14 @@
package com.baeldung.constructors;
import com.baeldung.constructors.*;
import com.google.common.collect.Comparators;
import org.junit.Test;
import java.util.logging.Logger;
import java.time.LocalDateTime;
import java.time.Month;
import java.util.ArrayList;
import java.util.logging.Logger;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.*;
public class ConstructorUnitTest {
final static Logger LOGGER = Logger.getLogger(ConstructorUnitTest.class.getName());
@ -17,26 +16,28 @@ public class ConstructorUnitTest {
@Test
public void givenNoExplicitContructor_whenUsed_thenFails() {
BankAccount account = new BankAccount();
assertThatThrownBy(() -> { account.toString(); }).isInstanceOf(Exception.class);
assertThatThrownBy(() -> {
account.toString();
}).isInstanceOf(Exception.class);
}
@Test
public void givenNoArgumentConstructor_whenUsed_thenSucceeds() {
BankAccountEmptyConstructor account = new BankAccountEmptyConstructor();
assertThatCode(() -> {
account.toString();
}).doesNotThrowAnyException();
account.toString();
}).doesNotThrowAnyException();
}
@Test
public void givenParameterisedConstructor_whenUsed_thenSucceeds() {
LocalDateTime opened = LocalDateTime.of(2018, Month.JUNE, 29, 06, 30, 00);
BankAccountParameterizedConstructor account =
new BankAccountParameterizedConstructor("Tom", opened, 1000.0f);
new BankAccountParameterizedConstructor("Tom", opened, 1000.0f);
assertThatCode(() -> {
account.toString();
}).doesNotThrowAnyException();
account.toString();
}).doesNotThrowAnyException();
}
@Test
@ -47,7 +48,16 @@ public class ConstructorUnitTest {
assertThat(account.getName()).isEqualTo(newAccount.getName());
assertThat(account.getOpened()).isNotEqualTo(newAccount.getOpened());
assertThat(newAccount.getBalance()).isEqualTo(0.0f);
}
@Test
public void givenChainedConstructor_whenUsed_thenMaintainsLogic() {
BankAccountChainedConstructors account = new BankAccountChainedConstructors("Tim");
BankAccountChainedConstructors newAccount = new BankAccountChainedConstructors("Tim", LocalDateTime.now(), 0.0f);
assertThat(account.getName()).isEqualTo(newAccount.getName());
assertThat(account.getBalance()).isEqualTo(newAccount.getBalance());
}
}

View File

@ -18,7 +18,6 @@
- [A Guide to Inner Interfaces in Java](http://www.baeldung.com/java-inner-interfaces)
- [Recursion In Java](http://www.baeldung.com/java-recursion)
- [A Guide to the finalize Method in Java](http://www.baeldung.com/java-finalize)
- [A Guide to Java Enums](http://www.baeldung.com/a-guide-to-java-enums)
- [Infinite Loops in Java](http://www.baeldung.com/infinite-loops-java)
- [Quick Guide to java.lang.System](http://www.baeldung.com/java-lang-system)
- [Using Java Assertions](http://www.baeldung.com/java-assert)

View File

@ -0,0 +1,40 @@
package com.baeldung.core.pwd;
import java.io.File;
import java.nio.file.FileSystems;
import java.nio.file.Paths;
public final class CurrentDirectoryFetcher {
public static void main(String[] args) {
System.out.printf("Current Directory Using Java System API: %s%n", currentDirectoryUsingSystemProperties());
System.out.printf("Current Directory Using Java IO File API: %s%n", currentDirectoryUsingFile());
System.out.printf("Current Directory Using Java NIO FileSystems API: %s%n", currentDirectoryUsingFileSystems());
System.out.printf("Current Directory Using Java NIO Paths API: %s%n", currentDirectoryUsingPaths());
}
public static String currentDirectoryUsingSystemProperties() {
return System.getProperty("user.dir");
}
public static String currentDirectoryUsingPaths() {
return Paths.get("")
.toAbsolutePath()
.toString();
}
public static String currentDirectoryUsingFileSystems() {
return FileSystems.getDefault()
.getPath("")
.toAbsolutePath()
.toString();
}
public static String currentDirectoryUsingFile() {
return new File("").getAbsolutePath();
}
}

View File

@ -0,0 +1,34 @@
package com.baeldung.core.pwd;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class CurrentDirectoryFetcherTest {
private static final String CURRENT_DIR = "core-java-os";
@Test
public void whenUsingSystemProperties_thenReturnCurrentDirectory() {
assertTrue(CurrentDirectoryFetcher.currentDirectoryUsingSystemProperties()
.endsWith(CURRENT_DIR));
}
@Test
public void whenUsingJavaNioPaths_thenReturnCurrentDirectory() {
assertTrue(CurrentDirectoryFetcher.currentDirectoryUsingPaths()
.endsWith(CURRENT_DIR));
}
@Test
public void whenUsingJavaNioFileSystems_thenReturnCurrentDirectory() {
assertTrue(CurrentDirectoryFetcher.currentDirectoryUsingFileSystems()
.endsWith(CURRENT_DIR));
}
@Test
public void whenUsingJavaIoFile_thenReturnCurrentDirectory() {
assertTrue(CurrentDirectoryFetcher.currentDirectoryUsingFile()
.endsWith(CURRENT_DIR));
}
}

View File

@ -37,7 +37,6 @@
- [Common Java Exceptions](http://www.baeldung.com/java-common-exceptions)
- [Throw Exception in Optional in Java 8](https://www.baeldung.com/java-optional-throw-exception)
- [Merging java.util.Properties Objects](https://www.baeldung.com/java-merging-properties)
- [Merging java.util.Properties Objects](https://www.baeldung.com/java-merging-properties)
- [Java Try with Resources](https://www.baeldung.com/java-try-with-resources)
- [Abstract Classes in Java](https://www.baeldung.com/java-abstract-class)
- [Guide to Character Encoding](https://www.baeldung.com/java-char-encoding)

Binary file not shown.

View File

@ -22,6 +22,10 @@ public class UnitTestNamingConventionRule extends AbstractJavaRule {
String className = node.getImage();
Objects.requireNonNull(className);
if (className.endsWith("SpringContextTest")) {
return data;
}
if (className.endsWith("Tests")
|| (className.endsWith("Test") && allowedEndings.stream().noneMatch(className::endsWith))) {
addViolation(data, node);

View File

@ -165,7 +165,7 @@ public class JacksonSerializationIgnoreUnitTest {
}
@Test
public final void givenIgnoringNullFieldsOnClass_whenWritingObjectWithNullField_thenFieldIsIgnored() throws JsonProcessingException {
public final void givenNullsIgnoredOnClass_whenWritingObjectWithNullField_thenIgnored() throws JsonProcessingException {
final ObjectMapper mapper = new ObjectMapper();
final MyDtoIgnoreNull dtoObject = new MyDtoIgnoreNull();
@ -178,7 +178,7 @@ public class JacksonSerializationIgnoreUnitTest {
}
@Test
public final void givenIgnoringNullFieldsGlobally_whenWritingObjectWithNullField_thenIgnored() throws JsonProcessingException {
public final void givenNullsIgnoredGlobally_whenWritingObjectWithNullField_thenIgnored() throws JsonProcessingException {
final ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(Include.NON_NULL);
final MyDto dtoObject = new MyDto();

View File

@ -1,4 +1,4 @@
package com.baeldung.string;
package com.baeldung.string.multiline;
import org.junit.Test;
import static org.junit.Assert.assertEquals;

View File

@ -1,4 +1,5 @@
### Relevant Articles:
- [Transferring a File Through SFTP in Java](https://www.baeldung.com/java-file-sftp)

View File

@ -42,7 +42,6 @@
- [Introduction to Akka Actors in Java](http://www.baeldung.com/akka-actors-java)
- [Introduction to Smooks](http://www.baeldung.com/smooks)
- [A Guide to Infinispan in Java](http://www.baeldung.com/infinispan)
- [Introduction to OpenCSV](http://www.baeldung.com/opencsv)
- [A Guide to Unirest](http://www.baeldung.com/unirest)
- [Introduction to Akka Actors in Java](http://www.baeldung.com/akka-actors-java)
- [A Guide to Byte Buddy](http://www.baeldung.com/byte-buddy)

View File

@ -13,9 +13,9 @@ public class GetterLazy {
private static final String DELIMETER = ",";
@Getter(lazy = true)
private final Map<String, Long> transactions = readTxnsFromFile();
private final Map<String, Long> transactions = getTransactions();
private Map<String, Long> readTxnsFromFile() {
private Map<String, Long> getTransactions() {
final Map<String, Long> cache = new HashMap<>();
List<String> txnRows = readTxnListFromFile();

View File

@ -0,0 +1,26 @@
package com.baeldung.lombok.intro;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.stream.Collectors;
import lombok.SneakyThrows;
import lombok.Synchronized;
public class Utility {
@SneakyThrows
public String resourceAsString() throws IOException {
try (InputStream is = this.getClass().getResourceAsStream("sure_in_my_jar.txt")) {
BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF-8"));
return br.lines().collect(Collectors.joining("\n"));
}
}
@Synchronized
public void putValueInCache(String key, String value) {
System.out.println("Thread safe here with key : [" + key + "] and value[" + value + "]");
}
}

View File

@ -0,0 +1 @@
Hello

View File

@ -28,8 +28,31 @@
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>${cargo-maven2-plugin.version}</version>
<configuration>
<wait>true</wait>
<container>
<containerId>jetty8x</containerId>
<type>embedded</type>
</container>
<configuration>
<properties>
<cargo.servlet.port>8082</cargo.servlet.port>
</properties>
</configuration>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<spring.version>4.3.22.RELEASE</spring.version>
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
</properties>
</project>

View File

@ -1,4 +1,4 @@
package com.baeldung.pattern.chainofresponsibility;
package com.baeldung.chainofresponsibility;
public abstract class AuthenticationProcessor {

View File

@ -1,4 +1,4 @@
package com.baeldung.pattern.chainofresponsibility;
package com.baeldung.chainofresponsibility;
public interface AuthenticationProvider {

View File

@ -1,4 +1,4 @@
package com.baeldung.pattern.chainofresponsibility;
package com.baeldung.chainofresponsibility;
public class OAuthAuthenticationProcessor extends AuthenticationProcessor {

View File

@ -1,4 +1,4 @@
package com.baeldung.pattern.chainofresponsibility;
package com.baeldung.chainofresponsibility;
public class OAuthTokenProvider implements AuthenticationProvider {

View File

@ -1,4 +1,4 @@
package com.baeldung.pattern.chainofresponsibility;
package com.baeldung.chainofresponsibility;
public class SamlAuthenticationProvider implements AuthenticationProvider {

View File

@ -1,4 +1,4 @@
package com.baeldung.pattern.chainofresponsibility;
package com.baeldung.chainofresponsibility;
public class UsernamePasswordAuthenticationProcessor extends AuthenticationProcessor {

View File

@ -1,4 +1,4 @@
package com.baeldung.pattern.chainofresponsibility;
package com.baeldung.chainofresponsibility;
public class UsernamePasswordProvider implements AuthenticationProvider {

View File

@ -1,10 +1,10 @@
package com.baeldung.pattern.command.client;
package com.baeldung.command.client;
import com.baeldung.pattern.command.command.OpenTextFileOperation;
import com.baeldung.pattern.command.command.SaveTextFileOperation;
import com.baeldung.pattern.command.command.TextFileOperation;
import com.baeldung.pattern.command.invoker.TextFileOperationExecutor;
import com.baeldung.pattern.command.receiver.TextFile;
import com.baeldung.command.command.OpenTextFileOperation;
import com.baeldung.command.command.SaveTextFileOperation;
import com.baeldung.command.command.TextFileOperation;
import com.baeldung.command.invoker.TextFileOperationExecutor;
import com.baeldung.command.receiver.TextFile;
public class TextFileApplication {

View File

@ -1,6 +1,6 @@
package com.baeldung.pattern.command.command;
package com.baeldung.command.command;
import com.baeldung.pattern.command.receiver.TextFile;
import com.baeldung.command.receiver.TextFile;
public class OpenTextFileOperation implements TextFileOperation {

View File

@ -1,6 +1,6 @@
package com.baeldung.pattern.command.command;
package com.baeldung.command.command;
import com.baeldung.pattern.command.receiver.TextFile;
import com.baeldung.command.receiver.TextFile;
public class SaveTextFileOperation implements TextFileOperation {

View File

@ -1,4 +1,4 @@
package com.baeldung.pattern.command.command;
package com.baeldung.command.command;
@FunctionalInterface
public interface TextFileOperation {

View File

@ -1,6 +1,6 @@
package com.baeldung.pattern.command.invoker;
package com.baeldung.command.invoker;
import com.baeldung.pattern.command.command.TextFileOperation;
import com.baeldung.command.command.TextFileOperation;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,4 +1,4 @@
package com.baeldung.pattern.command.receiver;
package com.baeldung.command.receiver;
public class TextFile {

View File

@ -1,11 +1,9 @@
package com.baeldung.pattern.templatemethod.application;
package com.baeldung.templatemethod.application;
import com.baeldung.pattern.templatemethod.model.Computer;
import com.baeldung.pattern.templatemethod.model.StandardComputer;
import com.baeldung.pattern.templatemethod.model.HighEndComputer;
import com.baeldung.pattern.templatemethod.model.ComputerBuilder;
import com.baeldung.pattern.templatemethod.model.HighEndComputerBuilder;
import com.baeldung.pattern.templatemethod.model.StandardComputerBuilder;
import com.baeldung.templatemethod.model.Computer;
import com.baeldung.templatemethod.model.ComputerBuilder;
import com.baeldung.templatemethod.model.HighEndComputerBuilder;
import com.baeldung.templatemethod.model.StandardComputerBuilder;
public class Application {

View File

@ -1,4 +1,4 @@
package com.baeldung.pattern.templatemethod.model;
package com.baeldung.templatemethod.model;
import java.util.HashMap;
import java.util.Map;

View File

@ -1,6 +1,5 @@
package com.baeldung.pattern.templatemethod.model;
package com.baeldung.templatemethod.model;
import com.baeldung.pattern.templatemethod.model.Computer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

View File

@ -1,6 +1,5 @@
package com.baeldung.pattern.templatemethod.model;
package com.baeldung.templatemethod.model;
import com.baeldung.pattern.templatemethod.model.Computer;
import java.util.Map;
public class HighEndComputer extends Computer {

View File

@ -1,4 +1,4 @@
package com.baeldung.pattern.templatemethod.model;
package com.baeldung.templatemethod.model;
public class HighEndComputerBuilder extends ComputerBuilder {

View File

@ -1,6 +1,5 @@
package com.baeldung.pattern.templatemethod.model;
package com.baeldung.templatemethod.model;
import com.baeldung.pattern.templatemethod.model.Computer;
import java.util.Map;
public class StandardComputer extends Computer {

View File

@ -1,4 +1,4 @@
package com.baeldung.pattern.templatemethod.model;
package com.baeldung.templatemethod.model;
public class StandardComputerBuilder extends ComputerBuilder {

View File

@ -1,14 +1,9 @@
package com.baeldung.chainofresponsibility;
import org.junit.Test;
import com.baeldung.pattern.chainofresponsibility.AuthenticationProcessor;
import com.baeldung.pattern.chainofresponsibility.OAuthAuthenticationProcessor;
import com.baeldung.pattern.chainofresponsibility.OAuthTokenProvider;
import com.baeldung.pattern.chainofresponsibility.UsernamePasswordProvider;
import com.baeldung.pattern.chainofresponsibility.SamlAuthenticationProvider;
import com.baeldung.pattern.chainofresponsibility.UsernamePasswordAuthenticationProcessor;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class ChainOfResponsibilityIntegrationTest {
private static AuthenticationProcessor getChainOfAuthProcessor() {

View File

@ -1,10 +1,12 @@
package com.baeldung.pattern.command.test;
package com.baeldung.command.test;
import static org.assertj.core.api.Assertions.assertThat;
import com.baeldung.pattern.command.command.OpenTextFileOperation;
import com.baeldung.pattern.command.command.TextFileOperation;
import com.baeldung.pattern.command.receiver.TextFile;
import org.junit.Test;
import static org.assertj.core.api.Assertions.*;
import com.baeldung.command.command.OpenTextFileOperation;
import com.baeldung.command.command.TextFileOperation;
import com.baeldung.command.receiver.TextFile;
public class OpenTextFileOperationUnitTest {

View File

@ -1,10 +1,12 @@
package com.baeldung.pattern.command.test;
package com.baeldung.command.test;
import static org.assertj.core.api.Assertions.assertThat;
import com.baeldung.pattern.command.command.SaveTextFileOperation;
import com.baeldung.pattern.command.command.TextFileOperation;
import com.baeldung.pattern.command.receiver.TextFile;
import org.junit.Test;
import static org.assertj.core.api.Assertions.*;
import com.baeldung.command.command.SaveTextFileOperation;
import com.baeldung.command.command.TextFileOperation;
import com.baeldung.command.receiver.TextFile;
public class SaveTextFileOperationUnitTest {

View File

@ -1,14 +1,17 @@
package com.baeldung.pattern.command.test;
package com.baeldung.command.test;
import static org.assertj.core.api.Assertions.assertThat;
import com.baeldung.pattern.command.command.OpenTextFileOperation;
import com.baeldung.pattern.command.command.SaveTextFileOperation;
import com.baeldung.pattern.command.command.TextFileOperation;
import com.baeldung.pattern.command.invoker.TextFileOperationExecutor;
import com.baeldung.pattern.command.receiver.TextFile;
import java.util.function.Function;
import org.junit.Test;
import static org.assertj.core.api.Assertions.*;
import org.junit.BeforeClass;
import org.junit.Test;
import com.baeldung.command.command.OpenTextFileOperation;
import com.baeldung.command.command.SaveTextFileOperation;
import com.baeldung.command.command.TextFileOperation;
import com.baeldung.command.invoker.TextFileOperationExecutor;
import com.baeldung.command.receiver.TextFile;
public class TextFileOperationExecutorUnitTest {
@ -65,4 +68,11 @@ public class TextFileOperationExecutorUnitTest {
Function<SaveTextFileOperation, String> executeMethodReference = SaveTextFileOperation::execute;
assertThat(executeMethodReference.apply(new SaveTextFileOperation(new TextFile("file1.txt")))).isEqualTo("Saving file file1.txt");
}
@Test
public void givenOpenAndSaveTextFileOperationExecutorInstance_whenCalledExecuteOperationWithLambdaExpression_thenBothAssertion() {
TextFileOperationExecutor textFileOperationExecutor = new TextFileOperationExecutor();
assertThat(textFileOperationExecutor.executeOperation(() -> "Opening file file1.txt")).isEqualTo("Opening file file1.txt");
assertThat(textFileOperationExecutor.executeOperation(() -> "Saving file file1.txt")).isEqualTo("Saving file file1.txt");
}
}

View File

@ -1,9 +1,11 @@
package com.baeldung.pattern.command.test;
package com.baeldung.command.test;
import static org.assertj.core.api.Assertions.assertThat;
import com.baeldung.pattern.command.receiver.TextFile;
import org.junit.Test;
import static org.assertj.core.api.Assertions.*;
import org.junit.BeforeClass;
import org.junit.Test;
import com.baeldung.command.receiver.TextFile;
public class TextFileUnitTest {

View File

@ -1,14 +1,16 @@
package com.baeldung.templatemethod.test;
import com.baeldung.pattern.templatemethod.model.Computer;
import com.baeldung.pattern.templatemethod.model.HighEndComputerBuilder;
import com.baeldung.pattern.templatemethod.model.StandardComputerBuilder;
import org.junit.Assert;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertThat;
import com.baeldung.templatemethod.model.Computer;
import com.baeldung.templatemethod.model.HighEndComputerBuilder;
import com.baeldung.templatemethod.model.StandardComputerBuilder;
public class TemplateMethodPatternIntegrationTest {

View File

@ -0,0 +1,19 @@
package com.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 org.springframework.test.context.web.WebAppConfiguration;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
@WebAppConfiguration
public class SpringContextTest {
@Test
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
}
}

View File

@ -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<String, Object>());
}
@Test
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
}
@After
public void dropTable() {
adminTemplate.dropTable(CqlIdentifier.cqlId(DATA_TABLE_NAME));
}
@AfterClass
public static void stopCassandraEmbedded() {
EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -7,10 +7,10 @@
<name>spring-hibernate4</name>
<parent>
<artifactId>parent-spring-4</artifactId>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../</relativePath>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../parent-spring-4</relativePath>
</parent>
<dependencies>
@ -175,7 +175,6 @@
<!-- maven plugins -->
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
<!-- <hibernate4-maven-plugin.version>1.1.0</hibernate4-maven-plugin.version> -->
</properties>

View File

@ -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() {
}
}

View File

@ -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() {
}
}

13
pom.xml
View File

@ -312,6 +312,10 @@
<configuration>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>SpringContextTest</include>
<include>**/*UnitTest</include>
</includes>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
<exclude>**/*IntTest.java</exclude>
@ -574,6 +578,10 @@
<configuration>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>SpringContextTest</include>
<include>**/*UnitTest</include>
</includes>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
<exclude>**/*IntTest.java</exclude>
@ -950,6 +958,10 @@
<configuration>
<forkCount>3</forkCount>
<reuseForks>true</reuseForks>
<includes>
<include>SpringContextTest</include>
<include>**/*UnitTest</include>
</includes>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
<exclude>**/*IntTest.java</exclude>
@ -1446,7 +1458,6 @@
<module>xml</module>
<module>xmlunit-2</module>
<module>xstream</module>
</modules>
</profile>

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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");

View File

@ -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() {
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -54,7 +54,28 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
@ -62,4 +83,4 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
</project>

View File

@ -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[] {});
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

6
spring-boot-di/README.MD Normal file
View File

@ -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)

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -34,6 +34,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.4</version>
<scope>provided</scope>
</dependency>
<!-- for Graylog demo -->
<dependency>

View File

@ -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...";
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -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 {
}

View File

@ -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 {
}

View File

@ -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() {
}
}

View File

@ -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 {

View File

@ -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<String> response = restTemplate.getForEntity(base.toString(), String.class);

View File

@ -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() {
}
}

View File

@ -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() {
}
}

View File

@ -29,7 +29,6 @@ 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)

Some files were not shown because too many files have changed in this diff Show More