Merge master into BAEL-2797
This commit is contained in:
commit
bc38dde66c
@ -1,42 +1,42 @@
|
|||||||
package com.baeldung.algorithms.reversingtree;
|
package com.baeldung.algorithms.reversingtree;
|
||||||
|
|
||||||
public class TreeNode {
|
public class TreeNode {
|
||||||
|
|
||||||
private int value;
|
private int value;
|
||||||
private TreeNode rightChild;
|
private TreeNode rightChild;
|
||||||
private TreeNode leftChild;
|
private TreeNode leftChild;
|
||||||
|
|
||||||
public int getValue() {
|
public int getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(int value) {
|
public void setValue(int value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TreeNode getRightChild() {
|
public TreeNode getRightChild() {
|
||||||
return rightChild;
|
return rightChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRightChild(TreeNode rightChild) {
|
public void setRightChild(TreeNode rightChild) {
|
||||||
this.rightChild = rightChild;
|
this.rightChild = rightChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TreeNode getLeftChild() {
|
public TreeNode getLeftChild() {
|
||||||
return leftChild;
|
return leftChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLeftChild(TreeNode leftChild) {
|
public void setLeftChild(TreeNode leftChild) {
|
||||||
this.leftChild = leftChild;
|
this.leftChild = leftChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TreeNode(int value, TreeNode rightChild, TreeNode leftChild) {
|
public TreeNode(int value, TreeNode leftChild, TreeNode rightChild) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.rightChild = rightChild;
|
this.rightChild = rightChild;
|
||||||
this.leftChild = leftChild;
|
this.leftChild = leftChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TreeNode(int value) {
|
public TreeNode(int value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,68 +1,53 @@
|
|||||||
package com.baeldung.algorithms.reversingtree;
|
package com.baeldung.algorithms.reversingtree;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
public class TreeReverser {
|
public class TreeReverser {
|
||||||
|
|
||||||
public TreeNode createBinaryTree() {
|
public void reverseRecursive(TreeNode treeNode) {
|
||||||
|
if (treeNode == null) {
|
||||||
TreeNode leaf1 = new TreeNode(3);
|
return;
|
||||||
TreeNode leaf2 = new TreeNode(1);
|
}
|
||||||
TreeNode leaf3 = new TreeNode(9);
|
|
||||||
TreeNode leaf4 = new TreeNode(6);
|
TreeNode temp = treeNode.getLeftChild();
|
||||||
|
treeNode.setLeftChild(treeNode.getRightChild());
|
||||||
TreeNode nodeLeft = new TreeNode(2, leaf1, leaf2);
|
treeNode.setRightChild(temp);
|
||||||
TreeNode nodeRight = new TreeNode(7, leaf3, leaf4);
|
|
||||||
|
reverseRecursive(treeNode.getLeftChild());
|
||||||
TreeNode root = new TreeNode(4, nodeRight, nodeLeft);
|
reverseRecursive(treeNode.getRightChild());
|
||||||
|
}
|
||||||
return root;
|
|
||||||
}
|
public void reverseIterative(TreeNode treeNode) {
|
||||||
|
LinkedList<TreeNode> queue = new LinkedList<TreeNode>();
|
||||||
public void reverseRecursive(TreeNode treeNode) {
|
|
||||||
if (treeNode == null) {
|
if (treeNode != null) {
|
||||||
return;
|
queue.add(treeNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeNode temp = treeNode.getLeftChild();
|
while (!queue.isEmpty()) {
|
||||||
treeNode.setLeftChild(treeNode.getRightChild());
|
|
||||||
treeNode.setRightChild(temp);
|
TreeNode node = queue.poll();
|
||||||
|
if (node.getLeftChild() != null)
|
||||||
reverseRecursive(treeNode.getLeftChild());
|
queue.add(node.getLeftChild());
|
||||||
reverseRecursive(treeNode.getRightChild());
|
if (node.getRightChild() != null)
|
||||||
}
|
queue.add(node.getRightChild());
|
||||||
|
|
||||||
public void reverseIterative(TreeNode treeNode) {
|
TreeNode temp = node.getLeftChild();
|
||||||
LinkedList<TreeNode> queue = new LinkedList<TreeNode>();
|
node.setLeftChild(node.getRightChild());
|
||||||
|
node.setRightChild(temp);
|
||||||
if (treeNode != null) {
|
}
|
||||||
queue.add(treeNode);
|
}
|
||||||
}
|
|
||||||
|
public String toString(TreeNode root) {
|
||||||
while (!queue.isEmpty()) {
|
if (root == null) {
|
||||||
|
return "";
|
||||||
TreeNode node = queue.poll();
|
}
|
||||||
if (node.getLeftChild() != null)
|
|
||||||
queue.add(node.getLeftChild());
|
StringBuffer buffer = new StringBuffer(String.valueOf(root.getValue())).append(" ");
|
||||||
if (node.getRightChild() != null)
|
|
||||||
queue.add(node.getRightChild());
|
buffer.append(toString(root.getLeftChild()));
|
||||||
|
buffer.append(toString(root.getRightChild()));
|
||||||
TreeNode temp = node.getLeftChild();
|
|
||||||
node.setLeftChild(node.getRightChild());
|
return buffer.toString();
|
||||||
node.setRightChild(temp);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public String toString(TreeNode root) {
|
|
||||||
if (root == null) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuffer buffer = new StringBuffer(String.valueOf(root.getValue())).append(" ");
|
|
||||||
|
|
||||||
buffer.append(toString(root.getLeftChild()));
|
|
||||||
buffer.append(toString(root.getRightChild()));
|
|
||||||
|
|
||||||
return buffer.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,33 +1,47 @@
|
|||||||
package com.baeldung.algorithms.reversingtree;
|
package com.baeldung.algorithms.reversingtree;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
public class TreeReverserUnitTest {
|
public class TreeReverserUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenTreeWhenReversingRecursivelyThenReversed() {
|
public void givenTreeWhenReversingRecursivelyThenReversed() {
|
||||||
TreeReverser reverser = new TreeReverser();
|
TreeReverser reverser = new TreeReverser();
|
||||||
|
|
||||||
TreeNode treeNode = reverser.createBinaryTree();
|
TreeNode treeNode = createBinaryTree();
|
||||||
|
|
||||||
reverser.reverseRecursive(treeNode);
|
reverser.reverseRecursive(treeNode);
|
||||||
|
|
||||||
assertEquals("4 7 9 6 2 3 1", reverser.toString(treeNode)
|
assertEquals("4 7 9 6 2 3 1", reverser.toString(treeNode)
|
||||||
.trim());
|
.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenTreeWhenReversingIterativelyThenReversed() {
|
public void givenTreeWhenReversingIterativelyThenReversed() {
|
||||||
TreeReverser reverser = new TreeReverser();
|
TreeReverser reverser = new TreeReverser();
|
||||||
|
|
||||||
TreeNode treeNode = reverser.createBinaryTree();
|
TreeNode treeNode = createBinaryTree();
|
||||||
|
|
||||||
reverser.reverseIterative(treeNode);
|
reverser.reverseIterative(treeNode);
|
||||||
|
|
||||||
assertEquals("4 7 9 6 2 3 1", reverser.toString(treeNode)
|
assertEquals("4 7 9 6 2 3 1", reverser.toString(treeNode)
|
||||||
.trim());
|
.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
private TreeNode createBinaryTree() {
|
||||||
|
|
||||||
|
TreeNode leaf1 = new TreeNode(1);
|
||||||
|
TreeNode leaf2 = new TreeNode(3);
|
||||||
|
TreeNode leaf3 = new TreeNode(6);
|
||||||
|
TreeNode leaf4 = new TreeNode(9);
|
||||||
|
|
||||||
|
TreeNode nodeRight = new TreeNode(7, leaf3, leaf4);
|
||||||
|
TreeNode nodeLeft = new TreeNode(2, leaf1, leaf2);
|
||||||
|
|
||||||
|
TreeNode root = new TreeNode(4, nodeLeft, nodeRight);
|
||||||
|
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<source>${maven.compiler.source.version}</source>
|
<source>${maven.compiler.source.version}</source>
|
||||||
<target>${maven.compiler.target.version}</target>
|
<target>${maven.compiler.target.version}</target>
|
||||||
|
<compilerArgs>--enable-preview</compilerArgs>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.baeldung.switchExpression;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class SwitchUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void switchJava12(){
|
||||||
|
|
||||||
|
var month = Month.AUG;
|
||||||
|
|
||||||
|
var value = switch(month){
|
||||||
|
case JAN,JUN, JUL -> 3;
|
||||||
|
case FEB,SEP, OCT, NOV, DEC -> 1;
|
||||||
|
case MAR,MAY, APR, AUG -> 2;
|
||||||
|
};
|
||||||
|
|
||||||
|
Assert.assertEquals(value, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void switchLocalVariable(){
|
||||||
|
var month = Month.AUG;
|
||||||
|
int i = switch (month){
|
||||||
|
case JAN,JUN, JUL -> 3;
|
||||||
|
case FEB,SEP, OCT, NOV, DEC -> 1;
|
||||||
|
case MAR,MAY, APR, AUG -> {
|
||||||
|
int j = month.toString().length() * 4;
|
||||||
|
break j;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Assert.assertEquals(12, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.baeldung.customer;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Customer {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
private long id;
|
||||||
|
private String name;
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
public Customer(String name, String email) {
|
||||||
|
this.name = name;
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEmail(String email) {
|
||||||
|
this.email = email;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.baeldung.customer;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface CustomerRepository extends JpaRepository<Customer, Long> {
|
||||||
|
|
||||||
|
List<Customer> findByName(String name);
|
||||||
|
|
||||||
|
List<Customer> findByNameAndEmail(String name, String email);
|
||||||
|
|
||||||
|
@Query("SELECT c FROM Customer c WHERE (:name is null or c.name = :name) and (:email is null or c.email = :email)")
|
||||||
|
List<Customer> findCustomerByNameAndEmail(@Param("name") String name, @Param("email") String email);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package com.baeldung.customer;
|
||||||
|
|
||||||
|
import com.baeldung.config.PersistenceConfiguration;
|
||||||
|
import com.baeldung.config.PersistenceProductConfiguration;
|
||||||
|
import com.baeldung.config.PersistenceUserConfiguration;
|
||||||
|
import org.junit.After;
|
||||||
|
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.autoconfigure.orm.jpa.DataJpaTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.PersistenceContext;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
@DataJpaTest(excludeAutoConfiguration = { PersistenceConfiguration.class, PersistenceUserConfiguration.class, PersistenceProductConfiguration.class })
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
public class CustomerRepositoryIntegrationTest {
|
||||||
|
|
||||||
|
@PersistenceContext
|
||||||
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CustomerRepository repository;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void before() {
|
||||||
|
entityManager.persist(new Customer("A", "A@example.com"));
|
||||||
|
entityManager.persist(new Customer("D", null));
|
||||||
|
entityManager.persist(new Customer("D", "D@example.com"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenQueryMethod_whenEmailIsNull_thenFoundByNullEmail() {
|
||||||
|
List<Customer> customers = repository.findByNameAndEmail("D", null);
|
||||||
|
|
||||||
|
assertEquals(1, customers.size());
|
||||||
|
Customer actual = customers.get(0);
|
||||||
|
|
||||||
|
assertEquals(null, actual.getEmail());
|
||||||
|
assertEquals("D", actual.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenQueryMethod_whenEmailIsAbsent_thenIgnoreEmail() {
|
||||||
|
List<Customer> customers = repository.findByName("D");
|
||||||
|
|
||||||
|
assertEquals(2, customers.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenQueryAnnotation_whenEmailIsNull_thenIgnoreEmail() {
|
||||||
|
List<Customer> customers = repository.findCustomerByNameAndEmail("D", null);
|
||||||
|
|
||||||
|
assertEquals(2, customers.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void cleanUp() {
|
||||||
|
repository.deleteAll();
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,12 @@
|
|||||||
package com.baeldung.spring.cloud.archaius.additionalsources.config;
|
package com.baeldung.spring.cloud.archaius.additionalsources.config;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
import org.apache.commons.configuration.AbstractConfiguration;
|
import org.apache.commons.configuration.AbstractConfiguration;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
|
||||||
import com.netflix.config.DynamicConfiguration;
|
import com.netflix.config.DynamicConfiguration;
|
||||||
import com.netflix.config.FixedDelayPollingScheduler;
|
import com.netflix.config.FixedDelayPollingScheduler;
|
||||||
@ -13,8 +17,9 @@ import com.netflix.config.sources.URLConfigurationSource;
|
|||||||
public class ApplicationPropertiesConfigurations {
|
public class ApplicationPropertiesConfigurations {
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public AbstractConfiguration addApplicationPropertiesSource() {
|
public AbstractConfiguration addApplicationPropertiesSource() throws IOException {
|
||||||
PolledConfigurationSource source = new URLConfigurationSource("classpath:other-config.properties");
|
URL configPropertyURL = (new ClassPathResource("other-config.properties")).getURL();
|
||||||
|
PolledConfigurationSource source = new URLConfigurationSource(configPropertyURL);
|
||||||
return new DynamicConfiguration(source, new FixedDelayPollingScheduler());
|
return new DynamicConfiguration(source, new FixedDelayPollingScheduler());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package org.baeldung;
|
package com.baeldung.spring.cloud.archaius.additionalsources;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import com.baeldung.spring.cloud.archaius.additionalsources.AdditionalSourcesSimpleApplication;
|
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(classes = AdditionalSourcesSimpleApplication.class)
|
@SpringBootTest(classes = AdditionalSourcesSimpleApplication.class)
|
||||||
public class SpringContextIntegrationTest {
|
public class SpringContextIntegrationTest {
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.baeldung.spring.cloud.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 = SpringCloudAwsApplication.class)
|
||||||
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
}
|
@ -1,18 +1,22 @@
|
|||||||
package com.baeldung.spring.cloud.config.server;
|
package com.baeldung.spring.cloud.config.server;
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
import org.springframework.test.context.web.WebAppConfiguration;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* The context will load successfully with some properties provided by docker
|
||||||
|
*
|
||||||
|
*/
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@SpringBootTest(classes = ConfigServer.class)
|
@SpringBootTest(classes = ConfigServer.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
@Ignore
|
public class SpringContextLiveTest {
|
||||||
public class ConfigServerListIntegrationTest {
|
|
||||||
@Test
|
@Test
|
||||||
public void contextLoads() {
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,6 +21,15 @@
|
|||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
<relativePath>..</relativePath>
|
<relativePath>..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<version>${spring-boot.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<spring-boot.version>2.0.1.RELEASE</spring-boot.version>
|
<spring-boot.version>2.0.1.RELEASE</spring-boot.version>
|
||||||
|
@ -26,12 +26,6 @@
|
|||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
<version>${spring-boot.version}</version>
|
<version>${spring-boot.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
|
||||||
<version>${spring-boot.version}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
@ -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 SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,17 +1,16 @@
|
|||||||
package org.baeldung;
|
package com.baeldung.spring.cloud.feign.client;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.test.context.junit4.SpringRunner;
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
import com.baeldung.spring.cloud.aws.InstanceProfileAwsApplication;
|
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(classes = InstanceProfileAwsApplication.class)
|
@SpringBootTest
|
||||||
public class SpringContextIntegrationTest {
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -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 SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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 SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -40,6 +40,13 @@
|
|||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
<version>${spring-boot-starter-web.version}</version>
|
<version>${spring-boot-starter-web.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
<version>${spring-boot-starter-web.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
@ -53,5 +60,10 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<!-- we need the Mockito version provided by Spring Boot -->
|
||||||
|
<mockito.version>1.10.19</mockito.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
package org.baeldung;
|
package com.baeldung.spring.cloud.hystrix.rest.consumer;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
import org.springframework.test.context.web.WebAppConfiguration;
|
||||||
|
|
||||||
import com.baeldung.spring.cloud.config.server.ConfigServer;
|
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@SpringBootTest(classes = ConfigServer.class)
|
@ContextConfiguration(classes = RestConsumerApplication.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
public class SpringContextIntegrationTest {
|
public class SpringContextIntegrationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void contextLoads() {
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -20,6 +20,18 @@
|
|||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
<version>${spring-boot-starter-web.version}</version>
|
<version>${spring-boot-starter-web.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<version>${spring-boot-starter-web.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<!-- we need the Mockito version provided by Spring Boot -->
|
||||||
|
<mockito.version>1.10.19</mockito.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -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 SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -25,6 +25,13 @@
|
|||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
<version>${spring-boot-starter-web.version}</version>
|
<version>${spring-boot-starter-web.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<version>${spring-boot-starter-web.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
@ -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 SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -25,7 +25,13 @@
|
|||||||
<artifactId>commons-configuration</artifactId>
|
<artifactId>commons-configuration</artifactId>
|
||||||
<version>${commons-config.version}</version>
|
<version>${commons-config.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<version>${spring-boot-starter-web.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
@ -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 SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -33,6 +33,13 @@
|
|||||||
<artifactId>rxjava</artifactId>
|
<artifactId>rxjava</artifactId>
|
||||||
<version>${rxjava.version}</version>
|
<version>${rxjava.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<version>${spring-boot-starter-web.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
@ -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 SpringContextIntegrationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,2 +1,3 @@
|
|||||||
###Relevant Articles:
|
###Relevant Articles:
|
||||||
- [A Guide to REST-assured](http://www.baeldung.com/rest-assured-tutorial)
|
- [A Guide to REST-assured](http://www.baeldung.com/rest-assured-tutorial)
|
||||||
|
- [REST-assured Support for Spring MockMvc](https://www.baeldung.com/spring-mock-mvc-rest-assured)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user