Merge branch 'master' into thymeleaf-sec-upgrade
This commit is contained in:
commit
24eb6961e0
|
@ -39,6 +39,3 @@ This tutorials project is being built **[>> HERE](https://rest-security.ci.cloud
|
|||
|
||||
- [Apache Maven Standard Directory Layout](http://www.baeldung.com/maven-directory-structure)
|
||||
- [Apache Maven Tutorial](http://www.baeldung.com/maven)
|
||||
- [Designing a User Friendly Java Library](http://www.baeldung.com/design-a-user-friendly-java-library)
|
||||
- [Java Service Provider Interface](http://www.baeldung.com/java-spi)
|
||||
- [Java Streams vs Vavr Streams](http://www.baeldung.com/vavr-java-streams)
|
||||
|
|
|
@ -148,7 +148,7 @@ public class Board {
|
|||
System.out.println("Game Draw");
|
||||
break;
|
||||
case IN_PROGRESS:
|
||||
System.out.println("Game In rogress");
|
||||
System.out.println("Game In Progress");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<artifactId>animal-sniffer-mvn-plugin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>example-animal-sniffer-mvn-plugin</name>
|
||||
<name>animal-sniffer-mvn-plugin</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<parent>
|
||||
|
|
|
@ -19,7 +19,7 @@ import java.util.List;
|
|||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class CayenneAdvancedOperationIntegrationTest {
|
||||
public class CayenneAdvancedOperationLiveTest {
|
||||
private static ObjectContext context = null;
|
||||
|
||||
@BeforeClass
|
|
@ -16,7 +16,7 @@ import static junit.framework.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertNull;
|
||||
|
||||
|
||||
public class CayenneOperationIntegrationTest {
|
||||
public class CayenneOperationLiveTest {
|
||||
private static ObjectContext context = null;
|
||||
|
||||
@BeforeClass
|
|
@ -7,7 +7,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class AzureApplicationTests {
|
||||
public class AzureApplicationIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
|
@ -5,7 +5,6 @@
|
|||
<groupId>com.example</groupId>
|
||||
<artifactId>spring-boot-camel</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>Spring-Boot - Camel API</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
|
|
|
@ -195,6 +195,16 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<compilerArgument>-parameters</compilerArgument>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package com.baeldung.reflect;
|
||||
|
||||
public class Person {
|
||||
|
||||
private String fullName;
|
||||
|
||||
public Person(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public void setFullName(String fullName) {
|
||||
this.fullName = fullName;
|
||||
}
|
||||
|
||||
public String getFullName() {
|
||||
return fullName;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.baeldung.reflect;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class MethodParamNameUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenGetConstructorParams_thenOk()
|
||||
throws NoSuchMethodException, SecurityException {
|
||||
List<Parameter> parameters
|
||||
= Arrays.asList(Person.class.getConstructor(String.class).getParameters());
|
||||
Optional<Parameter> parameter
|
||||
= parameters.stream().filter(Parameter::isNamePresent).findFirst();
|
||||
assertThat(parameter.get().getName()).isEqualTo("fullName");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetMethodParams_thenOk()
|
||||
throws NoSuchMethodException, SecurityException {
|
||||
List<Parameter> parameters
|
||||
= Arrays.asList(
|
||||
Person.class.getMethod("setFullName", String.class).getParameters());
|
||||
Optional<Parameter> parameter
|
||||
= parameters.stream().filter(Parameter::isNamePresent).findFirst();
|
||||
assertThat(parameter.get().getName()).isEqualTo("fullName");
|
||||
}
|
||||
}
|
|
@ -77,6 +77,6 @@ public class FilesManualTest {
|
|||
bw.newLine();
|
||||
bw.close();
|
||||
|
||||
assertThat(StreamUtils.getStringFromInputStream(new FileInputStream(fileName))).isEqualTo("UK\r\n" + "US\r\n" + "Germany\r\n" + "Spain\n");
|
||||
assertThat(StreamUtils.getStringFromInputStream(new FileInputStream(fileName))).isEqualTo("UK\r\n" + "US\r\n" + "Germany\r\n" + "Spain\r\n");
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package org.baeldung.java.io;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -105,8 +106,9 @@ public class JavaReadFromFileUnitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore // TODO
|
||||
public void whenReadUTFEncodedFile_thenCorrect() throws IOException {
|
||||
final String expected_value = "é<EFBFBD>’空";
|
||||
final String expected_value = "青空";
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("src/test/resources/test_read7.in"), "UTF-8"));
|
||||
final String currentLine = reader.readLine();
|
||||
reader.close();
|
||||
|
|
|
@ -141,6 +141,7 @@
|
|||
- [Java KeyStore API](http://www.baeldung.com/java-keystore)
|
||||
- [Double-Checked Locking with Singleton](http://www.baeldung.com/java-singleton-double-checked-locking)
|
||||
- [Guide to Java Clock Class](http://www.baeldung.com/java-clock)
|
||||
- [Infinite Loops in Java](http://www.baeldung.com/infinite-loops-java)
|
||||
- [Using Java Assertions](http://www.baeldung.com/java-assert)
|
||||
- [Pass-By-Value as a Parameter Passing Mechanism in Java](http://www.baeldung.com/java-pass-by-value-or-pass-by-reference)
|
||||
- [Check If a String Is Numeric in Java](http://www.baeldung.com/java-check-string-number)
|
||||
|
@ -149,5 +150,3 @@
|
|||
- [NaN in Java](http://www.baeldung.com/java-not-a-number)
|
||||
- [Infinite Loops in Java](http://www.baeldung.com/infinite-loops-java)
|
||||
- [Why Use char[] Array Over a String for Storing Passwords in Java?](http://www.baeldung.com/java-storing-passwords)
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package com.baeldung.array;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class JaggedArray {
|
||||
|
||||
int[][] shortHandFormInitialization() {
|
||||
int[][] jaggedArr = { { 1, 2 }, { 3, 4, 5 }, { 6, 7, 8, 9 } };
|
||||
return jaggedArr;
|
||||
}
|
||||
|
||||
int[][] declarationAndThenInitialization() {
|
||||
int[][] jaggedArr = new int[3][];
|
||||
jaggedArr[0] = new int[] { 1, 2 };
|
||||
jaggedArr[1] = new int[] { 3, 4, 5 };
|
||||
jaggedArr[2] = new int[] { 6, 7, 8, 9 };
|
||||
return jaggedArr;
|
||||
}
|
||||
|
||||
int[][] declarationAndThenInitializationUsingUserInputs() {
|
||||
int[][] jaggedArr = new int[3][];
|
||||
jaggedArr[0] = new int[2];
|
||||
jaggedArr[1] = new int[3];
|
||||
jaggedArr[2] = new int[4];
|
||||
initializeElements(jaggedArr);
|
||||
return jaggedArr;
|
||||
}
|
||||
|
||||
void initializeElements(int[][] jaggedArr) {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
for (int outer = 0; outer < jaggedArr.length; outer++) {
|
||||
for (int inner = 0; inner < jaggedArr[outer].length; inner++) {
|
||||
jaggedArr[outer][inner] = sc.nextInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void printElements(int[][] jaggedArr) {
|
||||
for (int index = 0; index < jaggedArr.length; index++) {
|
||||
System.out.println(Arrays.toString(jaggedArr[index]));
|
||||
}
|
||||
}
|
||||
|
||||
int[] getElementAtGivenIndex(int[][] jaggedArr, int index) {
|
||||
return jaggedArr[index];
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,20 @@
|
|||
package com.baeldung.linkedlist;
|
||||
|
||||
import com.baeldung.linkedlist.LinkedList.Node;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import com.baeldung.linkedlist.Node;
|
||||
|
||||
public class MiddleElementLookup {
|
||||
|
||||
public static String findMiddleElement(Node head) {
|
||||
public static String findMiddleElementLinkedList(LinkedList<String> linkedList) {
|
||||
if (linkedList == null || linkedList.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return linkedList.get((linkedList.size() - 1) / 2);
|
||||
}
|
||||
|
||||
public static String findMiddleElementFromHead(Node head) {
|
||||
if (head == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -26,7 +36,7 @@ public class MiddleElementLookup {
|
|||
return current.data();
|
||||
}
|
||||
|
||||
public static String findMiddleElement1PassRecursively(Node head) {
|
||||
public static String findMiddleElementFromHead1PassRecursively(Node head) {
|
||||
if (head == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -53,7 +63,7 @@ public class MiddleElementLookup {
|
|||
middleAux.length--;
|
||||
}
|
||||
|
||||
public static String findMiddleElement1PassIteratively(Node head) {
|
||||
public static String findMiddleElementFromHead1PassIteratively(Node head) {
|
||||
if (head == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package com.baeldung.linkedlist;
|
||||
|
||||
public class Node {
|
||||
private Node next;
|
||||
private String data;
|
||||
|
||||
public Node(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String data() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public boolean hasNext() {
|
||||
return next != null;
|
||||
}
|
||||
|
||||
public Node next() {
|
||||
return next;
|
||||
}
|
||||
|
||||
public void setNext(Node next) {
|
||||
this.next = next;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.data;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.baeldung.array;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class JaggedArrayUnitTest {
|
||||
|
||||
private JaggedArray obj = new JaggedArray();
|
||||
|
||||
@Test
|
||||
public void whenInitializedUsingShortHandForm_thenCorrect() {
|
||||
assertArrayEquals(new int[][] { { 1, 2 }, { 3, 4, 5 }, { 6, 7, 8, 9 } }, obj.shortHandFormInitialization());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInitializedWithDeclarationAndThenInitalization_thenCorrect() {
|
||||
assertArrayEquals(new int[][] { { 1, 2 }, { 3, 4, 5 }, { 6, 7, 8, 9 } }, obj.declarationAndThenInitialization());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInitializedWithDeclarationAndThenInitalizationUsingUserInputs_thenCorrect() {
|
||||
InputStream is = new ByteArrayInputStream("1 2 3 4 5 6 7 8 9".getBytes());
|
||||
System.setIn(is);
|
||||
assertArrayEquals(new int[][] { { 1, 2 }, { 3, 4, 5 }, { 6, 7, 8, 9 } }, obj.declarationAndThenInitializationUsingUserInputs());
|
||||
System.setIn(System.in);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenJaggedArrayAndAnIndex_thenReturnArrayAtGivenIndex() {
|
||||
int[][] jaggedArr = { { 1, 2 }, { 3, 4, 5 }, { 6, 7, 8, 9 } };
|
||||
assertArrayEquals(new int[] { 1, 2 }, obj.getElementAtGivenIndex(jaggedArr, 0));
|
||||
assertArrayEquals(new int[] { 3, 4, 5 }, obj.getElementAtGivenIndex(jaggedArr, 1));
|
||||
assertArrayEquals(new int[] { 6, 7, 8, 9 }, obj.getElementAtGivenIndex(jaggedArr, 2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenJaggedArray_whenUsingArraysAPI_thenVerifyPrintedElements() {
|
||||
int[][] jaggedArr = { { 1, 2 }, { 3, 4, 5 }, { 6, 7, 8, 9 } };
|
||||
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
|
||||
System.setOut(new PrintStream(outContent));
|
||||
obj.printElements(jaggedArr);
|
||||
assertEquals("[1, 2]\n[3, 4, 5]\n[6, 7, 8, 9]\n", outContent.toString());
|
||||
System.setOut(System.out);
|
||||
}
|
||||
|
||||
}
|
|
@ -2,51 +2,46 @@ package com.baeldung.linkedlist;
|
|||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class MiddleElementLookupUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenFindingMiddle_thenMiddleFound() {
|
||||
String middle = MiddleElementLookup.findMiddleElement(createList(5).head());
|
||||
assertEquals("3", middle);
|
||||
|
||||
middle = MiddleElementLookup.findMiddleElement(createList(4).head());
|
||||
assertEquals("2", middle);
|
||||
public void whenFindingMiddleLinkedList_thenMiddleFound() {
|
||||
assertEquals("3", MiddleElementLookup.findMiddleElementLinkedList(createLinkedList(5)));
|
||||
assertEquals("2", MiddleElementLookup.findMiddleElementLinkedList(createLinkedList(4)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenFindingMiddle1PassRecursively_thenMiddleFound() {
|
||||
String middle = MiddleElementLookup.findMiddleElement1PassRecursively(createList(5).head());
|
||||
assertEquals("3", middle);
|
||||
|
||||
middle = MiddleElementLookup.findMiddleElement1PassRecursively(createList(4).head());
|
||||
assertEquals("2", middle);
|
||||
public void whenFindingMiddleFromHead_thenMiddleFound() {
|
||||
assertEquals("3", MiddleElementLookup.findMiddleElementFromHead(createNodesList(5)));
|
||||
assertEquals("2", MiddleElementLookup.findMiddleElementFromHead(createNodesList(4)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenFindingMiddle1PassIteratively_thenMiddleFound() {
|
||||
String middle = MiddleElementLookup.findMiddleElement1PassIteratively(createList(5).head());
|
||||
assertEquals("3", middle);
|
||||
public void whenFindingMiddleFromHead1PassRecursively_thenMiddleFound() {
|
||||
assertEquals("3", MiddleElementLookup.findMiddleElementFromHead1PassRecursively(createNodesList(5)));
|
||||
assertEquals("2", MiddleElementLookup.findMiddleElementFromHead1PassRecursively(createNodesList(4)));
|
||||
}
|
||||
|
||||
middle = MiddleElementLookup.findMiddleElement1PassIteratively(createList(4).head());
|
||||
assertEquals("2", middle);
|
||||
@Test
|
||||
public void whenFindingMiddleFromHead1PassIteratively_thenMiddleFound() {
|
||||
assertEquals("3", MiddleElementLookup.findMiddleElementFromHead1PassIteratively(createNodesList(5)));
|
||||
assertEquals("2", MiddleElementLookup.findMiddleElementFromHead1PassIteratively(createNodesList(4)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenListEmptyOrNull_thenMiddleNull() {
|
||||
String middle = MiddleElementLookup.findMiddleElement(null);
|
||||
assertEquals(null, middle);
|
||||
|
||||
middle = MiddleElementLookup.findMiddleElement1PassIteratively(null);
|
||||
assertEquals(null, middle);
|
||||
|
||||
middle = MiddleElementLookup.findMiddleElement1PassRecursively(null);
|
||||
assertEquals(null, middle);
|
||||
assertEquals(null, MiddleElementLookup.findMiddleElementLinkedList(null));
|
||||
assertEquals(null, MiddleElementLookup.findMiddleElementFromHead(null));
|
||||
assertEquals(null, MiddleElementLookup.findMiddleElementFromHead1PassIteratively(null));
|
||||
assertEquals(null, MiddleElementLookup.findMiddleElementFromHead1PassRecursively(null));
|
||||
}
|
||||
|
||||
private static LinkedList createList(int n) {
|
||||
LinkedList list = new LinkedList();
|
||||
private static LinkedList<String> createLinkedList(int n) {
|
||||
LinkedList<String> list = new LinkedList<>();
|
||||
|
||||
for (int i = 1; i <= n; i++) {
|
||||
list.add(String.valueOf(i));
|
||||
|
@ -55,4 +50,17 @@ public class MiddleElementLookupUnitTest {
|
|||
return list;
|
||||
}
|
||||
|
||||
private static Node createNodesList(int n) {
|
||||
Node head = new Node("1");
|
||||
Node current = head;
|
||||
|
||||
for (int i = 2; i <= n; i++) {
|
||||
Node newNode = new Node(String.valueOf(i));
|
||||
current.setNext(newNode);
|
||||
current = newNode;
|
||||
}
|
||||
|
||||
return head;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package com.baeldung.enums
|
||||
|
||||
enum class CardType(val color: String) : ICardLimit {
|
||||
SILVER("gray") {
|
||||
override fun getCreditLimit(): Int {
|
||||
return 100000
|
||||
}
|
||||
|
||||
override fun calculateCashbackPercent(): Float {
|
||||
return 0.25f
|
||||
}
|
||||
},
|
||||
GOLD("yellow") {
|
||||
override fun getCreditLimit(): Int {
|
||||
return 200000
|
||||
}
|
||||
|
||||
override fun calculateCashbackPercent(): Float {
|
||||
return 0.5f
|
||||
}
|
||||
},
|
||||
PLATINUM("black") {
|
||||
override fun getCreditLimit(): Int {
|
||||
return 300000
|
||||
}
|
||||
|
||||
override fun calculateCashbackPercent(): Float {
|
||||
return 0.75f
|
||||
}
|
||||
};
|
||||
|
||||
companion object {
|
||||
fun getCardTypeByColor(color: String): CardType? {
|
||||
for (cardType in CardType.values()) {
|
||||
if (cardType.color.equals(color)) {
|
||||
return cardType;
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun getCardTypeByName(name: String): CardType {
|
||||
return CardType.valueOf(name.toUpperCase())
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun calculateCashbackPercent(): Float
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package com.baeldung.enums
|
||||
|
||||
interface ICardLimit {
|
||||
fun getCreditLimit(): Int
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package com.baeldung.enums
|
||||
|
||||
import org.junit.jupiter.api.Assertions
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
internal class CardTypeUnitTest {
|
||||
|
||||
@Test
|
||||
fun givenSilverCardType_whenCalculateCashbackPercent_thenReturnCashbackValue() {
|
||||
assertEquals(0.25f, CardType.SILVER.calculateCashbackPercent())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenGoldCardType_whenCalculateCashbackPercent_thenReturnCashbackValue() {
|
||||
assertEquals(0.5f, CardType.GOLD.calculateCashbackPercent())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenPlatinumCardType_whenCalculateCashbackPercent_thenReturnCashbackValue() {
|
||||
assertEquals(0.75f, CardType.PLATINUM.calculateCashbackPercent())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenSilverCardType_whenGetCreditLimit_thenReturnCreditLimit() {
|
||||
assertEquals(100000, CardType.SILVER.getCreditLimit())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenGoldCardType_whenGetCreditLimit_thenReturnCreditLimit() {
|
||||
assertEquals(200000, CardType.GOLD.getCreditLimit())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenPlatinumCardType_whenGetCreditLimit_thenReturnCreditLimit() {
|
||||
assertEquals(300000, CardType.PLATINUM.getCreditLimit())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenSilverCardType_whenCheckColor_thenReturnColor() {
|
||||
assertEquals("gray", CardType.SILVER.color)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenGoldCardType_whenCheckColor_thenReturnColor() {
|
||||
assertEquals("yellow", CardType.GOLD.color)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun givenPlatinumCardType_whenCheckColor_thenReturnColor() {
|
||||
assertEquals("black", CardType.PLATINUM.color)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenGetCardTypeByColor_thenSilverCardType() {
|
||||
Assertions.assertEquals(CardType.SILVER, CardType.getCardTypeByColor("gray"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenGetCardTypeByColor_thenGoldCardType() {
|
||||
Assertions.assertEquals(CardType.GOLD, CardType.getCardTypeByColor("yellow"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenGetCardTypeByColor_thenPlatinumCardType() {
|
||||
Assertions.assertEquals(CardType.PLATINUM, CardType.getCardTypeByColor("black"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenGetCardTypeByName_thenSilverCardType() {
|
||||
Assertions.assertEquals(CardType.SILVER, CardType.getCardTypeByName("silver"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenGetCardTypeByName_thenGoldCardType() {
|
||||
Assertions.assertEquals(CardType.GOLD, CardType.getCardTypeByName("gold"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun whenGetCardTypeByName_thenPlatinumCardType() {
|
||||
Assertions.assertEquals(CardType.PLATINUM, CardType.getCardTypeByName("platinum"))
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
|
@ -14,17 +14,16 @@ public class UnitTestNamingConventionRule extends AbstractJavaRule {
|
|||
"ManualTest",
|
||||
"JdbcTest",
|
||||
"LiveTest",
|
||||
"UnitTest");
|
||||
"UnitTest",
|
||||
"jmhTest");
|
||||
|
||||
public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
|
||||
String className = node.getImage();
|
||||
Objects.requireNonNull(className);
|
||||
|
||||
if (className.endsWith("Test") || className.endsWith("Tests")) {
|
||||
if (allowedEndings.stream()
|
||||
.noneMatch(className::endsWith)) {
|
||||
addViolation(data, node);
|
||||
}
|
||||
if (className.endsWith("Tests")
|
||||
|| (className.endsWith("Test") && allowedEndings.stream().noneMatch(className::endsWith))) {
|
||||
addViolation(data, node);
|
||||
}
|
||||
|
||||
return data;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>ejb-client</artifactId>
|
||||
<name>EJB3 Client Maven</name>
|
||||
<description>EJB3 Client Maven</description>
|
||||
|
||||
<parent>
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
<name>ethereumj</name>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-boot-5</relativePath>
|
||||
<relativePath>../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<repositories>
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
<name>flips</name>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-boot-5</relativePath>
|
||||
<relativePath>../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
|||
}, webEnvironment = SpringBootTest.WebEnvironment.MOCK)
|
||||
@AutoConfigureMockMvc
|
||||
@ActiveProfiles("dev")
|
||||
public class FlipControllerTest {
|
||||
public class FlipControllerIntegrationTest {
|
||||
|
||||
@Autowired private MockMvc mvc;
|
||||
|
|
@ -8,10 +8,10 @@
|
|||
<description>Flyway Callbacks Demo</description>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-boot-5</relativePath>
|
||||
<relativePath>../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
<artifactId>grpc-demo</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>grpc-demo</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
|
|
|
@ -27,28 +27,6 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
|
|
@ -45,28 +45,6 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
<name>hystrix</name>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-boot-5</relativePath>
|
||||
<relativePath>../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
<artifactId>java-websocket</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>java-websocket Maven Webapp</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../../parent-boot-5</relativePath>
|
||||
<relativePath>../../../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>com.car.app</groupId>
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../../parent-boot-5</relativePath>
|
||||
<relativePath>../../../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>com.dealer.app</groupId>
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../../parent-boot-5</relativePath>
|
||||
<relativePath>../../../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>com.gateway</groupId>
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-5</relativePath>
|
||||
<relativePath>../../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>com.baeldung</groupId>
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
<description>Exercising the JJWT</description>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-boot-5</relativePath>
|
||||
<relativePath>../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
<description>Intro to Performance testing using JMeter</description>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-boot-5</relativePath>
|
||||
<relativePath>../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
### Relevant articles
|
||||
|
||||
- [Kotlin and Javascript](http://www.baeldung.com/kotlin-javascript)
|
|
@ -10,8 +10,13 @@ import java.util.*;
|
|||
|
||||
public class Histogram {
|
||||
|
||||
private Map distributionMap;
|
||||
private int classWidth;
|
||||
|
||||
public Histogram() {
|
||||
|
||||
distributionMap = new TreeMap();
|
||||
classWidth = 10;
|
||||
Map distributionMap = processRawData();
|
||||
List yData = new ArrayList();
|
||||
yData.addAll(distributionMap.values());
|
||||
|
@ -42,47 +47,49 @@ public class Histogram {
|
|||
|
||||
private Map processRawData() {
|
||||
|
||||
List<Integer> datasetList = Arrays.asList(36, 25, 38, 46, 55, 68, 72, 55, 36, 38, 67, 45, 22, 48, 91, 46, 52, 61, 58, 55);
|
||||
List<Integer> datasetList = Arrays.asList(
|
||||
36, 25, 38, 46, 55, 68, 72,
|
||||
55, 36, 38, 67, 45, 22, 48,
|
||||
91, 46, 52, 61, 58, 55);
|
||||
Frequency frequency = new Frequency();
|
||||
datasetList.forEach(d -> frequency.addValue(Double.parseDouble(d.toString())));
|
||||
|
||||
int classWidth = 10;
|
||||
datasetList.stream()
|
||||
.map(d -> Double.parseDouble(d.toString()))
|
||||
.distinct()
|
||||
.forEach(observation -> {
|
||||
long observationFrequency = frequency.getCount(observation);
|
||||
int upperBoundary = (observation > classWidth)
|
||||
? Math.multiplyExact( (int) Math.ceil(observation / classWidth), classWidth)
|
||||
: classWidth;
|
||||
int lowerBoundary = (upperBoundary > classWidth)
|
||||
? Math.subtractExact(upperBoundary, classWidth)
|
||||
: 0;
|
||||
String bin = lowerBoundary + "-" + upperBoundary;
|
||||
|
||||
Map distributionMap = new TreeMap();
|
||||
List processed = new ArrayList();
|
||||
datasetList.forEach(d -> {
|
||||
updateDistributionMap(lowerBoundary, bin, observationFrequency);
|
||||
|
||||
double observation = Double.parseDouble(d.toString());
|
||||
|
||||
if(processed.contains(observation))
|
||||
return;
|
||||
|
||||
long observationFrequency = frequency.getCount(observation);
|
||||
int upperBoundary = (observation > classWidth) ? Math.multiplyExact( (int) Math.ceil(observation / classWidth), classWidth) : classWidth;
|
||||
int lowerBoundary = (upperBoundary > classWidth) ? Math.subtractExact(upperBoundary, classWidth) : 0;
|
||||
String bin = lowerBoundary + "-" + upperBoundary;
|
||||
|
||||
int prevUpperBoundary = lowerBoundary;
|
||||
int prevLowerBoundary = (lowerBoundary > classWidth) ? lowerBoundary - classWidth : 0;
|
||||
String prevBin = prevLowerBoundary + "-" + prevUpperBoundary;
|
||||
if(!distributionMap.containsKey(prevBin))
|
||||
distributionMap.put(prevBin, 0);
|
||||
|
||||
if(!distributionMap.containsKey(bin)) {
|
||||
distributionMap.put(bin, observationFrequency);
|
||||
}
|
||||
else {
|
||||
long oldFrequency = Long.parseLong(distributionMap.get(bin).toString());
|
||||
distributionMap.replace(bin, oldFrequency + observationFrequency);
|
||||
}
|
||||
|
||||
processed.add(observation);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
return distributionMap;
|
||||
}
|
||||
|
||||
private void updateDistributionMap(int lowerBoundary, String bin, long observationFrequency) {
|
||||
|
||||
int prevLowerBoundary = (lowerBoundary > classWidth) ? lowerBoundary - classWidth : 0;
|
||||
String prevBin = prevLowerBoundary + "-" + lowerBoundary;
|
||||
if(!distributionMap.containsKey(prevBin))
|
||||
distributionMap.put(prevBin, 0);
|
||||
|
||||
if(!distributionMap.containsKey(bin)) {
|
||||
distributionMap.put(bin, observationFrequency);
|
||||
}
|
||||
else {
|
||||
long oldFrequency = Long.parseLong(distributionMap.get(bin).toString());
|
||||
distributionMap.replace(bin, oldFrequency + observationFrequency);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new Histogram();
|
||||
}
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
<version>0.0.1-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-boot-5</relativePath>
|
||||
<relativePath>../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.wso2.msf4j</groupId>
|
||||
<artifactId>msf4j-service</artifactId>
|
||||
<version>2.6.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.baeldung.msf4j</groupId>
|
||||
<artifactId>msf4j</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>WSO2 MSF4J Microservice</name>
|
||||
|
||||
<properties>
|
||||
<microservice.mainClass>com.baeldung.msf4j.msf4jintro.Application</microservice.mainClass>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.wso2.msf4j</groupId>
|
||||
<artifactId>msf4j-spring</artifactId>
|
||||
<version>2.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.msf4j</groupId>
|
||||
<artifactId>msf4j-mustache-template</artifactId>
|
||||
<version>2.6.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,11 @@
|
|||
package com.baeldung.msf4j.msf4japi;
|
||||
|
||||
import org.wso2.msf4j.MicroservicesRunner;
|
||||
|
||||
public class Application {
|
||||
public static void main(String[] args) {
|
||||
new MicroservicesRunner()
|
||||
.deploy(new MenuService())
|
||||
.start();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.baeldung.msf4j.msf4japi;
|
||||
|
||||
public class Meal {
|
||||
private String name;
|
||||
private Float price;
|
||||
|
||||
public Meal(String name, Float price) {
|
||||
this.name = name;
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Float getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package com.baeldung.msf4j.msf4japi;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
@Path("/menu")
|
||||
public class MenuService {
|
||||
|
||||
private List<Meal> meals = new ArrayList<Meal>();
|
||||
|
||||
public MenuService() {
|
||||
meals.add(new Meal("Java beans",42.0f));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/")
|
||||
@Produces({ "application/json" })
|
||||
public Response index() {
|
||||
return Response.ok()
|
||||
.entity(meals)
|
||||
.build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
@Produces({ "application/json" })
|
||||
public Response meal(@PathParam("id") int id) {
|
||||
return Response.ok()
|
||||
.entity(meals.get(id))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@POST
|
||||
@Path("/")
|
||||
@Consumes("application/json")
|
||||
@Produces({ "application/json" })
|
||||
public Response create(Meal meal) {
|
||||
meals.add(meal);
|
||||
return Response.ok()
|
||||
.entity(meal)
|
||||
.build();
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("/{id}")
|
||||
@Consumes("application/json")
|
||||
@Produces({ "application/json" })
|
||||
public Response update(@PathParam("id") int id, Meal meal) {
|
||||
meals.set(id, meal);
|
||||
return Response.ok()
|
||||
.entity(meal)
|
||||
.build();
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/{id}")
|
||||
@Produces({ "application/json" })
|
||||
public Response delete(@PathParam("id") int id) {
|
||||
Meal meal = meals.get(id);
|
||||
meals.remove(id);
|
||||
return Response.ok()
|
||||
.entity(meal)
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.baeldung.msf4j.msf4jintro;
|
||||
|
||||
import org.wso2.msf4j.MicroservicesRunner;
|
||||
|
||||
public class Application {
|
||||
public static void main(String[] args) {
|
||||
new MicroservicesRunner()
|
||||
.deploy(new SimpleService())
|
||||
.start();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.baeldung.msf4j.msf4jintro;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
|
||||
@Path("/")
|
||||
public class SimpleService {
|
||||
|
||||
@GET
|
||||
public String index() {
|
||||
return "Default content";
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/say/{name}")
|
||||
public String say(@PathParam("name") String name) {
|
||||
return "Hello " + name;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.baeldung.msf4j.msf4jspring;
|
||||
|
||||
import org.wso2.msf4j.spring.MSF4JSpringApplication;
|
||||
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
MSF4JSpringApplication.run(Application.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.baeldung.msf4j.msf4jspring.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.wso2.msf4j.spring.transport.HTTPTransportConfig;
|
||||
|
||||
@Configuration
|
||||
public class PortConfiguration {
|
||||
|
||||
@Bean
|
||||
public HTTPTransportConfig http() {
|
||||
return new HTTPTransportConfig(9090);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.baeldung.msf4j.msf4jspring.domain;
|
||||
|
||||
public class Meal {
|
||||
private String name;
|
||||
private Float price;
|
||||
|
||||
public Meal(String name, Float price) {
|
||||
this.name = name;
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Float getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.baeldung.msf4j.msf4jspring.repositories;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.baeldung.msf4j.msf4jspring.domain.Meal;
|
||||
|
||||
@Component
|
||||
public class MealRepository {
|
||||
|
||||
private List<Meal> meals = new ArrayList<Meal>();
|
||||
|
||||
public MealRepository() {
|
||||
meals.add(new Meal("Salad", 4.2f));
|
||||
meals.add(new Meal("Litre of cola", 2.99f));
|
||||
}
|
||||
|
||||
public void create(Meal meal) {
|
||||
meals.add(meal);
|
||||
}
|
||||
|
||||
public void remove(Meal meal) {
|
||||
meals.remove(meal);
|
||||
}
|
||||
|
||||
public Meal find(int id) {
|
||||
return meals.get(id);
|
||||
}
|
||||
|
||||
public List<Meal> findAll() {
|
||||
return meals;
|
||||
}
|
||||
|
||||
public void update(int id, Meal meal) {
|
||||
meals.set(id, meal);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.baeldung.msf4j.msf4jspring.resources;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.wso2.msf4j.template.MustacheTemplateEngine;
|
||||
|
||||
import com.baeldung.msf4j.msf4jspring.services.MealService;
|
||||
|
||||
@Component
|
||||
@Path("/meal")
|
||||
public class MealResource {
|
||||
|
||||
@Autowired
|
||||
private MealService mealService;
|
||||
|
||||
@GET
|
||||
@Path("/")
|
||||
public Response all() {
|
||||
Map map = Collections.singletonMap("meals", mealService.findAll());
|
||||
String html = MustacheTemplateEngine.instance()
|
||||
.render("meals.mustache", map);
|
||||
return Response.ok()
|
||||
.type(MediaType.TEXT_HTML)
|
||||
.entity(html)
|
||||
.build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/{id}")
|
||||
@Produces({ "text/xml" })
|
||||
public Response meal(@PathParam("id") int id) {
|
||||
return Response.ok()
|
||||
.entity(mealService.find(id))
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.baeldung.msf4j.msf4jspring.services;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baeldung.msf4j.msf4jspring.domain.Meal;
|
||||
import com.baeldung.msf4j.msf4jspring.repositories.MealRepository;
|
||||
|
||||
@Service
|
||||
public class MealService {
|
||||
@Autowired
|
||||
private MealRepository mealRepository;
|
||||
|
||||
public Meal find(int id) {
|
||||
return mealRepository.find(id);
|
||||
}
|
||||
|
||||
public List<Meal> findAll() {
|
||||
return mealRepository.findAll();
|
||||
}
|
||||
|
||||
public void create(Meal meal) {
|
||||
mealRepository.create(meal);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<head>
|
||||
<title>Meals</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<h1>Today's Meals</h1>
|
||||
{{#meals}}
|
||||
<div>{{name}}: {{price}}$ </div>
|
||||
{{/meals}}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -15,7 +15,7 @@ import java.util.Map;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class TodoMustacheServiceTest {
|
||||
public class TodoMustacheServiceUnitTest {
|
||||
|
||||
private String executeTemplate(Mustache m, Map<String, Object> context) throws IOException {
|
||||
StringWriter writer = new StringWriter();
|
|
@ -9,10 +9,10 @@
|
|||
<description>Setting up the Maven Wrapper</description>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-boot-5</relativePath>
|
||||
<relativePath>../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -2,16 +2,15 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Parent Boot 5</name>
|
||||
<description>Parent for all spring boot 1.5 modules</description>
|
||||
<description>Parent for all Spring Boot 1.x modules</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.5.10.RELEASE</version>
|
||||
<version>1.5.13.RELEASE</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
|
@ -105,6 +105,25 @@
|
|||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>thin-jar</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<dependencies>
|
||||
<!-- The following enables the "thin jar" deployment option. -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot.experimental</groupId>
|
||||
<artifactId>spring-boot-thin-layout</artifactId>
|
||||
<version>${thin.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<properties>
|
||||
|
@ -115,6 +134,7 @@
|
|||
<!-- plugins -->
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<thin.version>1.0.11.RELEASE</thin.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -15,7 +15,7 @@ import org.junit.Test;
|
|||
* @author Donato Rimenti
|
||||
*
|
||||
*/
|
||||
public class SingletonSynchronizationUnitTest {
|
||||
public class SingletonSynchronizationIntegrationTest {
|
||||
|
||||
/**
|
||||
* Size of the thread pools used.
|
||||
|
@ -33,7 +33,7 @@ public class SingletonSynchronizationUnitTest {
|
|||
@Test
|
||||
public void givenDraconianSingleton_whenMultithreadInstancesEquals_thenTrue() {
|
||||
ExecutorService executor = Executors.newFixedThreadPool(POOL_SIZE);
|
||||
Set<DraconianSingleton> resultSet = Collections.synchronizedSet(new HashSet<DraconianSingleton>());
|
||||
Set<DraconianSingleton> resultSet = Collections.synchronizedSet(new HashSet<>());
|
||||
|
||||
// Submits the instantiation tasks.
|
||||
for (int i = 0; i < TASKS_TO_SUBMIT; i++) {
|
||||
|
@ -51,7 +51,7 @@ public class SingletonSynchronizationUnitTest {
|
|||
@Test
|
||||
public void givenDclSingleton_whenMultithreadInstancesEquals_thenTrue() {
|
||||
ExecutorService executor = Executors.newFixedThreadPool(POOL_SIZE);
|
||||
Set<DclSingleton> resultSet = Collections.synchronizedSet(new HashSet<DclSingleton>());
|
||||
Set<DclSingleton> resultSet = Collections.synchronizedSet(new HashSet<>());
|
||||
|
||||
// Submits the instantiation tasks.
|
||||
for (int i = 0; i < TASKS_TO_SUBMIT; i++) {
|
||||
|
@ -69,7 +69,7 @@ public class SingletonSynchronizationUnitTest {
|
|||
@Test
|
||||
public void givenEarlyInitSingleton_whenMultithreadInstancesEquals_thenTrue() {
|
||||
ExecutorService executor = Executors.newFixedThreadPool(POOL_SIZE);
|
||||
Set<EarlyInitSingleton> resultSet = Collections.synchronizedSet(new HashSet<EarlyInitSingleton>());
|
||||
Set<EarlyInitSingleton> resultSet = Collections.synchronizedSet(new HashSet<>());
|
||||
|
||||
// Submits the instantiation tasks.
|
||||
for (int i = 0; i < TASKS_TO_SUBMIT; i++) {
|
||||
|
@ -87,7 +87,7 @@ public class SingletonSynchronizationUnitTest {
|
|||
@Test
|
||||
public void givenInitOnDemandSingleton_whenMultithreadInstancesEquals_thenTrue() {
|
||||
ExecutorService executor = Executors.newFixedThreadPool(POOL_SIZE);
|
||||
Set<InitOnDemandSingleton> resultSet = Collections.synchronizedSet(new HashSet<InitOnDemandSingleton>());
|
||||
Set<InitOnDemandSingleton> resultSet = Collections.synchronizedSet(new HashSet<>());
|
||||
|
||||
// Submits the instantiation tasks.
|
||||
for (int i = 0; i < TASKS_TO_SUBMIT; i++) {
|
||||
|
@ -105,7 +105,7 @@ public class SingletonSynchronizationUnitTest {
|
|||
@Test
|
||||
public void givenEnumSingleton_whenMultithreadInstancesEquals_thenTrue() {
|
||||
ExecutorService executor = Executors.newFixedThreadPool(POOL_SIZE);
|
||||
Set<EnumSingleton> resultSet = Collections.synchronizedSet(new HashSet<EnumSingleton>());
|
||||
Set<EnumSingleton> resultSet = Collections.synchronizedSet(new HashSet<>());
|
||||
|
||||
// Submits the instantiation tasks.
|
||||
for (int i = 0; i < TASKS_TO_SUBMIT; i++) {
|
|
@ -9,10 +9,10 @@
|
|||
<description>This is simple boot application for Spring boot actuator test</description>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-5</relativePath>
|
||||
<relativePath>../../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencyManagement>
|
||||
|
|
8
pom.xml
8
pom.xml
|
@ -9,7 +9,7 @@
|
|||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>parent-boot-5</module>
|
||||
<module>parent-boot-1</module>
|
||||
<module>parent-boot-2</module>
|
||||
<module>parent-spring-4</module>
|
||||
<module>parent-spring-5</module>
|
||||
|
@ -102,6 +102,7 @@
|
|||
<module>metrics</module>
|
||||
<module>maven</module>
|
||||
<module>mesos-marathon</module>
|
||||
<module>msf4j</module>
|
||||
<module>testing-modules/mockito</module>
|
||||
<module>testing-modules/mockito-2</module>
|
||||
<module>testing-modules/mocks</module>
|
||||
|
@ -373,8 +374,8 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
<configuration>
|
||||
<failurePriority>5</failurePriority> <!-- TODO change to 0 after fixing the project -->
|
||||
<aggregate>true</aggregate>
|
||||
<failurePriority>5</failurePriority>
|
||||
<aggregate>false</aggregate>
|
||||
<failOnViolation>true</failOnViolation>
|
||||
<verbose>true</verbose>
|
||||
<linkXRef>true</linkXRef>
|
||||
|
@ -533,5 +534,4 @@
|
|||
<commons-fileupload.version>1.3</commons-fileupload.version>
|
||||
<junit.jupiter.version>5.0.2</junit.jupiter.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
|
|||
}, webEnvironment = SpringBootTest.WebEnvironment.MOCK)
|
||||
@AutoConfigureMockMvc
|
||||
@ActiveProfiles("dev")
|
||||
public class FlipControllerTest {
|
||||
public class FlipControllerIntegrationTest {
|
||||
|
||||
@Autowired private MockMvc mvc;
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
package com.baeldung.persistence;
|
||||
|
||||
import com.baeldung.web.Foo;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
import com.baeldung.web.Foo;
|
||||
|
||||
public interface FooRepository extends JpaRepository<Foo, Long>, JpaSpecificationExecutor<Foo> {
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.springframework.http.HttpStatus;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import java.util.List;
|
||||
|
@ -14,6 +15,11 @@ import java.util.List;
|
|||
@RestController("/foos")
|
||||
public class FooController {
|
||||
|
||||
@PostConstruct
|
||||
public void init(){
|
||||
System.out.println("test");
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private FooRepository repo;
|
||||
|
||||
|
|
|
@ -3,10 +3,12 @@ package com.baeldung;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@EnableJpaRepositories("com.baeldung.persistence")
|
||||
public class Example1IntegrationTest {
|
||||
|
||||
@Test
|
||||
|
|
|
@ -3,10 +3,12 @@ package com.baeldung;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@EnableJpaRepositories("com.baeldung.persistence")
|
||||
public class Example2IntegrationTest {
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.baeldung;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
@ -7,6 +8,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
@Ignore
|
||||
public class Spring5ApplicationIntegrationTest {
|
||||
|
||||
@Test
|
||||
|
|
|
@ -6,6 +6,7 @@ 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.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.context.support.GenericWebApplicationContext;
|
||||
|
||||
|
@ -13,6 +14,7 @@ import com.baeldung.Spring5Application;
|
|||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = Spring5Application.class)
|
||||
@EnableJpaRepositories("com.baeldung.persistence")
|
||||
public class BeanRegistrationIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.baeldung.jdbc.autogenkey;
|
|||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -15,6 +16,7 @@ import com.baeldung.jdbc.autogenkey.repository.MessageRepositoryJDBCTemplate;
|
|||
import com.baeldung.jdbc.autogenkey.repository.MessageRepositorySimpleJDBCInsert;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@Ignore
|
||||
public class GetAutoGenKeyByJDBC {
|
||||
|
||||
@Configuration
|
||||
|
|
|
@ -5,6 +5,7 @@ import static org.junit.Assert.assertTrue;
|
|||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -16,18 +17,15 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = Spring5Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@Ignore
|
||||
public class JsonbIntegrationTest {
|
||||
@Value("${security.user.name}")
|
||||
private String username;
|
||||
@Value("${security.user.password}")
|
||||
private String password;
|
||||
|
||||
@Autowired
|
||||
private TestRestTemplate template;
|
||||
|
||||
@Test
|
||||
public void givenId_whenUriIsPerson_thenGetPerson() {
|
||||
ResponseEntity<Person> response = template.withBasicAuth(username, password)
|
||||
ResponseEntity<Person> response = template
|
||||
.getForEntity("/person/1", Person.class);
|
||||
Person person = response.getBody();
|
||||
assertTrue(person.equals(new Person(2, "Jhon", "jhon1@test.com", 0, LocalDate.of(2019, 9, 9), BigDecimal.valueOf(1500.0))));
|
||||
|
@ -35,8 +33,8 @@ public class JsonbIntegrationTest {
|
|||
|
||||
@Test
|
||||
public void whenSendPostAPerson_thenGetOkStatus() {
|
||||
ResponseEntity<Boolean> response = template.withBasicAuth(username, password)
|
||||
.postForEntity("/person", "{\"birthDate\":\"07-09-2017\",\"email\":\"jhon1@test.com\",\"person-name\":\"Jhon\",\"id\":10}", Boolean.class);
|
||||
ResponseEntity<Boolean> response = template.withBasicAuth("user","password").
|
||||
postForEntity("/person", "{\"birthDate\":\"07-09-2017\",\"email\":\"jhon1@test.com\",\"person-name\":\"Jhon\",\"id\":10}", Boolean.class);
|
||||
assertTrue(response.getBody());
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.baeldung.security;
|
|||
|
||||
import com.baeldung.SpringSecurity5Application;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -31,6 +32,7 @@ public class SecurityIntegrationTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
@WithMockUser
|
||||
public void whenHasCredentials_thenSeesGreeting() {
|
||||
this.rest.get().uri("/").exchange().expectStatus().isOk().expectBody(String.class).isEqualTo("Hello, user");
|
||||
|
|
|
@ -5,6 +5,7 @@ import org.junit.Test;
|
|||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
import org.springframework.web.reactive.function.server.RequestPredicates;
|
||||
|
@ -16,6 +17,7 @@ import reactor.core.publisher.Mono;
|
|||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = Spring5Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@EnableJpaRepositories("com.baeldung.persistence")
|
||||
public class WebTestClientIntegrationTest {
|
||||
|
||||
@LocalServerPort
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
<packaging>war</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-boot-5</relativePath>
|
||||
<relativePath>../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.springframework.web.servlet.ModelAndView;
|
|||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@WebAppConfiguration
|
||||
@ContextConfiguration({"classpath:test-mvc.xml"})
|
||||
public class PassParametersControllerTest {
|
||||
public class PassParametersControllerIntegrationTest {
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@Autowired
|
|
@ -5,9 +5,9 @@ import org.slf4j.LoggerFactory;
|
|||
import org.springframework.test.context.transaction.AfterTransaction;
|
||||
import org.springframework.test.context.transaction.BeforeTransaction;
|
||||
|
||||
public interface ITransactionalTest {
|
||||
public interface ITransactionalUnitTest {
|
||||
|
||||
Logger log = LoggerFactory.getLogger(ITransactionalTest.class);
|
||||
Logger log = LoggerFactory.getLogger(ITransactionalUnitTest.class);
|
||||
|
||||
@BeforeTransaction
|
||||
default void beforeTransaction() {
|
|
@ -5,7 +5,7 @@ import org.springframework.test.context.ContextConfiguration;
|
|||
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
|
||||
|
||||
@ContextConfiguration(classes = TransactionalTestConfiguration.class)
|
||||
public class TransactionalIntegrationTest extends AbstractTransactionalJUnit4SpringContextTests implements ITransactionalTest {
|
||||
public class TransactionalIntegrationTest extends AbstractTransactionalJUnit4SpringContextTests implements ITransactionalUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenDefaultMethodAnnotatedWithBeforeTransaction_thenDefaultMethodIsExecuted() {
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
<name>Spring AMQP Simple App</name>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-boot-5</relativePath>
|
||||
<relativePath>../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
<name>spring-aop</name>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-boot-5</relativePath>
|
||||
<relativePath>../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -88,6 +88,28 @@
|
|||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>thin-jar</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot.experimental</groupId>
|
||||
<artifactId>spring-boot-thin-maven-plugin</artifactId>
|
||||
<version>${thin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<!-- Download the dependencies at build time -->
|
||||
<id>resolve</id>
|
||||
<goals>
|
||||
<goal>resolve</goal>
|
||||
</goals>
|
||||
<inherited>false</inherited>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
<artifactId>greeter-spring-boot-autoconfigure</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-5</relativePath>
|
||||
<relativePath>../../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
<version>0.0.1-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-5</relativePath>
|
||||
<relativePath>../../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
<artifactId>greeter-spring-boot-starter</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-5</relativePath>
|
||||
<relativePath>../../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
<artifactId>greeter</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-5</relativePath>
|
||||
<relativePath>../../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
</project>
|
|
@ -0,0 +1,2 @@
|
|||
.gradle/
|
||||
build/
|
|
@ -1,12 +1,16 @@
|
|||
buildscript {
|
||||
ext {
|
||||
springBootVersion = '2.0.0.RELEASE'
|
||||
springBootPlugin = 'org.springframework.boot:spring-boot-gradle-plugin'
|
||||
springBootVersion = '2.0.2.RELEASE'
|
||||
thinPlugin = 'org.springframework.boot.experimental:spring-boot-thin-gradle-plugin'
|
||||
thinVersion = '1.0.11.RELEASE'
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
|
||||
classpath("${springBootPlugin}:${springBootVersion}")
|
||||
classpath("${thinPlugin}:${thinVersion}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +18,8 @@ apply plugin: 'java'
|
|||
apply plugin: 'eclipse'
|
||||
apply plugin: 'org.springframework.boot'
|
||||
apply plugin: 'io.spring.dependency-management'
|
||||
//add tasks thinJar and thinResolve for thin JAR deployments
|
||||
apply plugin: 'org.springframework.boot.experimental.thin-launcher'
|
||||
|
||||
group = 'org.baeldung'
|
||||
version = '0.0.1-SNAPSHOT'
|
||||
|
@ -23,7 +29,6 @@ repositories {
|
|||
mavenCentral()
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
compile('org.springframework.boot:spring-boot-starter')
|
||||
testCompile('org.springframework.boot:spring-boot-starter-test')
|
||||
|
@ -42,3 +47,21 @@ bootJar {
|
|||
// attributes 'Start-Class': 'org.baeldung.DemoApplication'
|
||||
// }
|
||||
}
|
||||
|
||||
//Enable this to generate and use a pom.xml file
|
||||
apply plugin: 'maven'
|
||||
|
||||
//If you want to customize the generated pom.xml you can edit this task and add it as a dependency to the bootJar task
|
||||
task createPom {
|
||||
def basePath = 'build/resources/main/META-INF/maven'
|
||||
doLast {
|
||||
pom {
|
||||
withXml(dependencyManagement.pomConfigurer)
|
||||
}.writeTo("${basePath}/${project.group}/${project.name}/pom.xml")
|
||||
}
|
||||
}
|
||||
//Uncomment the following to use your custom generated pom.xml
|
||||
bootJar.dependsOn = [createPom]
|
||||
|
||||
//Enable this to generate and use a thin.properties file
|
||||
//bootJar.dependsOn = [thinProperties]
|
|
@ -1,6 +1,6 @@
|
|||
#Tue Feb 06 12:27:20 CET 2018
|
||||
#Fri Jun 01 20:39:48 CEST 2018
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.5.1-all.zip
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../parent-boot-5</relativePath>
|
||||
<relativePath>../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
### The Course
|
||||
The "REST With Spring" Classes: http://bit.ly/restwithspring
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Intro to Spring Boot Starters](http://www.baeldung.com/spring-boot-starters)
|
||||
- [A Custom Data Binder in Spring MVC](http://www.baeldung.com/spring-mvc-custom-data-binder)
|
||||
- [Introduction to WebJars](http://www.baeldung.com/maven-webjars)
|
||||
- [A Quick Guide to Maven Wrapper](http://www.baeldung.com/maven-wrapper)
|
||||
- [Shutdown a Spring Boot Application](http://www.baeldung.com/spring-boot-shutdown)
|
||||
- [Create a Fat Jar App with Spring Boot](http://www.baeldung.com/deployable-fat-jar-spring-boot)
|
||||
- [Spring Boot Dependency Management with a Custom Parent](http://www.baeldung.com/spring-boot-dependency-management-custom-parent)
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
### The Course
|
||||
The "REST With Spring" Classes: http://bit.ly/restwithspring
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Intro to Spring Boot Starters](http://www.baeldung.com/spring-boot-starters)
|
||||
- [A Custom Data Binder in Spring MVC](http://www.baeldung.com/spring-mvc-custom-data-binder)
|
||||
- [Introduction to WebJars](http://www.baeldung.com/maven-webjars)
|
||||
- [A Quick Guide to Maven Wrapper](http://www.baeldung.com/maven-wrapper)
|
||||
- [Shutdown a Spring Boot Application](http://www.baeldung.com/spring-boot-shutdown)
|
||||
- [Create a Fat Jar App with Spring Boot](http://www.baeldung.com/deployable-fat-jar-spring-boot)
|
||||
- [Spring Boot Dependency Management with a Custom Parent](http://www.baeldung.com/spring-boot-dependency-management-custom-parent)
|
|
@ -8,10 +8,10 @@
|
|||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-5</relativePath>
|
||||
<relativePath>../../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-5</relativePath>
|
||||
<relativePath>../../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-5</relativePath>
|
||||
<relativePath>../../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-5</relativePath>
|
||||
<relativePath>../../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-5</relativePath>
|
||||
<relativePath>../../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-5</relativePath>
|
||||
<relativePath>../../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-5</relativePath>
|
||||
<relativePath>../../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent-boot-5</artifactId>
|
||||
<artifactId>parent-boot-1</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../../parent-boot-5</relativePath>
|
||||
<relativePath>../../../parent-boot-1</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue