Merge branch 'eugenp:master' into master
This commit is contained in:
commit
6bf1b3500b
@ -33,7 +33,9 @@ Next, they are segregated further on the basis of the tests that we want to exec
|
||||
|
||||
Additionally, there are 2 profiles dedicated for JDK9 and above builds.
|
||||
|
||||
Therefore, we have a total of 8 profiles:
|
||||
We also have a parents profile to build only parent modules.
|
||||
|
||||
Therefore, we have a total of 9 profiles:
|
||||
|
||||
| Profile | Includes | Type of test enabled |
|
||||
| -------------------------- | --------------------------- | -------------------- |
|
||||
@ -45,6 +47,7 @@ Therefore, we have a total of 8 profiles:
|
||||
| integration-heavy | Heavy/long running projects | *IntegrationTest |
|
||||
| default-jdk9-and-above | JDK9 and above projects | *UnitTest |
|
||||
| integration-jdk9-and-above | JDK9 and above projects | *IntegrationTest |
|
||||
| parents | Set of parent modules | None |
|
||||
|
||||
Building the project
|
||||
====================
|
||||
|
@ -36,6 +36,7 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<properties>
|
||||
<akka.http.version>10.0.11</akka.http.version>
|
||||
<akka.stream.version>2.5.11</akka.stream.version>
|
||||
|
@ -21,6 +21,7 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<properties>
|
||||
<auto-service.version>1.0-rc2</auto-service.version>
|
||||
</properties>
|
||||
|
@ -54,6 +54,42 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.core5</groupId>
|
||||
<artifactId>httpcore5</artifactId>
|
||||
<version>${httpcore5.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
<artifactId>httpclient5-fluent</artifactId>
|
||||
<version>${httpclient5-fluent.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
||||
<artifactId>httpclient5</artifactId>
|
||||
<version>${httpclient5.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<groupId>commons-logging</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.tomakehurst</groupId>
|
||||
<artifactId>wiremock</artifactId>
|
||||
@ -78,6 +114,10 @@
|
||||
<!-- testing -->
|
||||
<wiremock.version>2.5.1</wiremock.version>
|
||||
<httpclient.version>4.5.8</httpclient.version> <!-- 4.3.6 --> <!-- 4.4-beta1 -->
|
||||
<!-- http client & core 5 -->
|
||||
<httpcore5.version>5.2</httpcore5.version>
|
||||
<httpclient5.version>5.2</httpclient5.version>
|
||||
<httpclient5-fluent.version>5.2</httpclient5-fluent.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -1,19 +1,24 @@
|
||||
package com.baeldung.httpclient;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.mime.HttpMultipartMode;
|
||||
import org.apache.http.entity.mime.MultipartEntityBuilder;
|
||||
import org.apache.http.entity.mime.content.FileBody;
|
||||
import org.apache.http.entity.mime.content.StringBody;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.apache.hc.client5.http.classic.methods.HttpPost;
|
||||
import org.apache.hc.client5.http.entity.mime.FileBody;
|
||||
import org.apache.hc.client5.http.entity.mime.HttpMultipartMode;
|
||||
import org.apache.hc.client5.http.entity.mime.MultipartEntityBuilder;
|
||||
import org.apache.hc.client5.http.entity.mime.StringBody;
|
||||
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
|
||||
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
|
||||
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder;
|
||||
|
||||
import org.apache.hc.core5.http.ContentType;
|
||||
import org.apache.hc.core5.http.HttpEntity;
|
||||
import org.apache.hc.core5.http.HttpStatus;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@ -22,14 +27,10 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import com.baeldung.httpclient.handler.CustomHttpClientResponseHandler;
|
||||
|
||||
public class HttpClientMultipartLiveTest {
|
||||
class HttpClientMultipartLiveTest {
|
||||
|
||||
// No longer available
|
||||
// private static final String SERVER = "http://echo.200please.com";
|
||||
@ -38,41 +39,16 @@ public class HttpClientMultipartLiveTest {
|
||||
private static final String TEXTFILENAME = "temp.txt";
|
||||
private static final String IMAGEFILENAME = "image.jpg";
|
||||
private static final String ZIPFILENAME = "zipFile.zip";
|
||||
private static final Logger LOGGER = Logger.getLogger("com.baeldung.httpclient.HttpClientMultipartLiveTest");
|
||||
private CloseableHttpClient client;
|
||||
private HttpPost post;
|
||||
private BufferedReader rd;
|
||||
private CloseableHttpResponse response;
|
||||
|
||||
@Before
|
||||
public final void before() {
|
||||
client = HttpClientBuilder.create()
|
||||
.build();
|
||||
@BeforeEach
|
||||
public void before() {
|
||||
post = new HttpPost(SERVER);
|
||||
}
|
||||
|
||||
@After
|
||||
public final void after() throws IllegalStateException, IOException {
|
||||
post.completed();
|
||||
try {
|
||||
client.close();
|
||||
} catch (final IOException e1) {
|
||||
LOGGER.log(Level.SEVERE, e1.getMessage(), e1);
|
||||
throw e1;
|
||||
}
|
||||
try {
|
||||
rd.close();
|
||||
} catch (final IOException e) {
|
||||
LOGGER.log(Level.SEVERE, e.getMessage(), e);
|
||||
throw e;
|
||||
}
|
||||
ResponseUtil.closeResponse(response);
|
||||
}
|
||||
|
||||
// tests
|
||||
|
||||
@Test
|
||||
public final void givenFileandMultipleTextParts_whenUploadwithAddPart_thenNoExceptions() throws IOException {
|
||||
void givenFileandMultipleTextParts_whenUploadwithAddPart_thenNoExceptions() throws IOException {
|
||||
final URL url = Thread.currentThread()
|
||||
.getContextClassLoader()
|
||||
.getResource("uploads/" + TEXTFILENAME);
|
||||
@ -83,53 +59,61 @@ public class HttpClientMultipartLiveTest {
|
||||
final StringBody stringBody2 = new StringBody("This is message 2", ContentType.MULTIPART_FORM_DATA);
|
||||
//
|
||||
final MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
|
||||
builder.setMode(HttpMultipartMode.LEGACY);
|
||||
builder.addPart("file", fileBody);
|
||||
builder.addPart("text1", stringBody1);
|
||||
builder.addPart("text2", stringBody2);
|
||||
final HttpEntity entity = builder.build();
|
||||
//
|
||||
post.setEntity(entity);
|
||||
response = client.execute(post);
|
||||
|
||||
final int statusCode = response.getStatusLine()
|
||||
.getStatusCode();
|
||||
final String responseString = getContent();
|
||||
final String contentTypeInHeader = getContentTypeHeader();
|
||||
assertThat(statusCode, equalTo(HttpStatus.SC_OK));
|
||||
// assertTrue(responseString.contains("Content-Type: multipart/form-data;"));
|
||||
assertTrue(contentTypeInHeader.contains("Content-Type: multipart/form-data;"));
|
||||
System.out.println(responseString);
|
||||
System.out.println("POST Content Type: " + contentTypeInHeader);
|
||||
post.setEntity(entity);
|
||||
try(CloseableHttpClient client = HttpClientBuilder.create()
|
||||
.build();
|
||||
|
||||
CloseableHttpResponse response = (CloseableHttpResponse) client
|
||||
.execute(post, new CustomHttpClientResponseHandler())){
|
||||
final int statusCode = response.getCode();
|
||||
final String responseString = getContent(response.getEntity());
|
||||
final String contentTypeInHeader = getContentTypeHeader();
|
||||
|
||||
assertThat(statusCode, equalTo(HttpStatus.SC_OK));
|
||||
assertTrue(contentTypeInHeader.contains("Content-Type: multipart/form-data;"));
|
||||
System.out.println(responseString);
|
||||
System.out.println("POST Content Type: " + contentTypeInHeader);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public final void givenFileandTextPart_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoExeption() throws IOException {
|
||||
void givenFileandTextPart_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoExeption() throws IOException {
|
||||
final URL url = Thread.currentThread()
|
||||
.getContextClassLoader()
|
||||
.getResource("uploads/" + TEXTFILENAME);
|
||||
final File file = new File(url.getPath());
|
||||
final String message = "This is a multipart post";
|
||||
final MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
|
||||
builder.setMode(HttpMultipartMode.LEGACY);
|
||||
builder.addBinaryBody("file", file, ContentType.DEFAULT_BINARY, TEXTFILENAME);
|
||||
builder.addTextBody("text", message, ContentType.DEFAULT_BINARY);
|
||||
final HttpEntity entity = builder.build();
|
||||
post.setEntity(entity);
|
||||
response = client.execute(post);
|
||||
final int statusCode = response.getStatusLine()
|
||||
.getStatusCode();
|
||||
final String responseString = getContent();
|
||||
final String contentTypeInHeader = getContentTypeHeader();
|
||||
assertThat(statusCode, equalTo(HttpStatus.SC_OK));
|
||||
// assertTrue(responseString.contains("Content-Type: multipart/form-data;"));
|
||||
assertTrue(contentTypeInHeader.contains("Content-Type: multipart/form-data;"));
|
||||
System.out.println(responseString);
|
||||
System.out.println("POST Content Type: " + contentTypeInHeader);
|
||||
|
||||
try(CloseableHttpClient client = HttpClientBuilder.create()
|
||||
.build();
|
||||
|
||||
CloseableHttpResponse response = (CloseableHttpResponse) client
|
||||
.execute(post, new CustomHttpClientResponseHandler())){
|
||||
|
||||
final int statusCode = response.getCode();
|
||||
final String responseString = getContent(response.getEntity());
|
||||
final String contentTypeInHeader = getContentTypeHeader();
|
||||
assertThat(statusCode, equalTo(HttpStatus.SC_OK));
|
||||
assertTrue(contentTypeInHeader.contains("Content-Type: multipart/form-data;"));
|
||||
System.out.println(responseString);
|
||||
System.out.println("POST Content Type: " + contentTypeInHeader);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public final void givenFileAndInputStreamandText_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoException() throws IOException {
|
||||
void givenFileAndInputStreamandText_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoException() throws IOException {
|
||||
final URL url = Thread.currentThread()
|
||||
.getContextClassLoader()
|
||||
.getResource("uploads/" + ZIPFILENAME);
|
||||
@ -140,64 +124,75 @@ public class HttpClientMultipartLiveTest {
|
||||
final File file = new File(url2.getPath());
|
||||
final String message = "This is a multipart post";
|
||||
final MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
|
||||
builder.setMode(HttpMultipartMode.STRICT);
|
||||
builder.addBinaryBody("file", file, ContentType.DEFAULT_BINARY, IMAGEFILENAME);
|
||||
builder.addBinaryBody("upstream", inputStream, ContentType.create("application/zip"), ZIPFILENAME);
|
||||
builder.addTextBody("text", message, ContentType.TEXT_PLAIN);
|
||||
final HttpEntity entity = builder.build();
|
||||
post.setEntity(entity);
|
||||
response = client.execute(post);
|
||||
final int statusCode = response.getStatusLine()
|
||||
.getStatusCode();
|
||||
final String responseString = getContent();
|
||||
final String contentTypeInHeader = getContentTypeHeader();
|
||||
assertThat(statusCode, equalTo(HttpStatus.SC_OK));
|
||||
// assertTrue(responseString.contains("Content-Type: multipart/form-data;"));
|
||||
assertTrue(contentTypeInHeader.contains("Content-Type: multipart/form-data;"));
|
||||
System.out.println(responseString);
|
||||
System.out.println("POST Content Type: " + contentTypeInHeader);
|
||||
inputStream.close();
|
||||
|
||||
try(CloseableHttpClient client = HttpClientBuilder.create()
|
||||
.build();
|
||||
|
||||
CloseableHttpResponse response = (CloseableHttpResponse) client
|
||||
.execute(post, new CustomHttpClientResponseHandler())){
|
||||
|
||||
final int statusCode = response.getCode();
|
||||
final String responseString = getContent(response.getEntity());
|
||||
final String contentTypeInHeader = getContentTypeHeader();
|
||||
assertThat(statusCode, equalTo(HttpStatus.SC_OK));
|
||||
assertTrue(contentTypeInHeader.contains("Content-Type: multipart/form-data;"));
|
||||
System.out.println(responseString);
|
||||
System.out.println("POST Content Type: " + contentTypeInHeader);
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public final void givenCharArrayandText_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoException() throws IOException {
|
||||
void givenCharArrayandText_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoException() throws IOException {
|
||||
final String message = "This is a multipart post";
|
||||
final byte[] bytes = "binary code".getBytes();
|
||||
final MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
|
||||
builder.setMode(HttpMultipartMode.STRICT);
|
||||
builder.addBinaryBody("file", bytes, ContentType.DEFAULT_BINARY, TEXTFILENAME);
|
||||
builder.addTextBody("text", message, ContentType.TEXT_PLAIN);
|
||||
final HttpEntity entity = builder.build();
|
||||
post.setEntity(entity);
|
||||
response = client.execute(post);
|
||||
final int statusCode = response.getStatusLine()
|
||||
.getStatusCode();
|
||||
final String responseString = getContent();
|
||||
final String contentTypeInHeader = getContentTypeHeader();
|
||||
assertThat(statusCode, equalTo(HttpStatus.SC_OK));
|
||||
// assertTrue(responseString.contains("Content-Type: multipart/form-data;"));
|
||||
assertTrue(contentTypeInHeader.contains("Content-Type: multipart/form-data;"));
|
||||
System.out.println(responseString);
|
||||
System.out.println("POST Content Type: " + contentTypeInHeader);
|
||||
|
||||
try(CloseableHttpClient client = HttpClientBuilder.create()
|
||||
.build();
|
||||
|
||||
CloseableHttpResponse response = (CloseableHttpResponse) client
|
||||
.execute(post, new CustomHttpClientResponseHandler())){
|
||||
|
||||
final int statusCode = response.getCode();
|
||||
final String responseString = getContent(response.getEntity());
|
||||
final String contentTypeInHeader = getContentTypeHeader();
|
||||
assertThat(statusCode, equalTo(HttpStatus.SC_OK));
|
||||
assertTrue(contentTypeInHeader.contains("Content-Type: multipart/form-data;"));
|
||||
System.out.println(responseString);
|
||||
System.out.println("POST Content Type: " + contentTypeInHeader);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// UTIL
|
||||
|
||||
private String getContent() throws IOException {
|
||||
rd = new BufferedReader(new InputStreamReader(response.getEntity()
|
||||
.getContent()));
|
||||
private String getContent(HttpEntity httpEntity) throws IOException {
|
||||
rd = new BufferedReader(new InputStreamReader(httpEntity.getContent()));
|
||||
String body = "";
|
||||
StringBuilder content = new StringBuilder();
|
||||
while ((body = rd.readLine()) != null) {
|
||||
content.append(body).append("\n");
|
||||
content.append(body)
|
||||
.append("\n");
|
||||
}
|
||||
return content.toString().trim();
|
||||
return content.toString()
|
||||
.trim();
|
||||
}
|
||||
|
||||
private String getContentTypeHeader() throws IOException {
|
||||
private String getContentTypeHeader() {
|
||||
return post.getEntity()
|
||||
.getContentType()
|
||||
.toString();
|
||||
.getContentType();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package com.baeldung.httpclient.handler;
|
||||
|
||||
import org.apache.hc.core5.http.ClassicHttpResponse;
|
||||
import org.apache.hc.core5.http.io.HttpClientResponseHandler;
|
||||
|
||||
public class CustomHttpClientResponseHandler implements HttpClientResponseHandler<ClassicHttpResponse> {
|
||||
@Override
|
||||
public ClassicHttpResponse handleResponse(ClassicHttpResponse response) {
|
||||
return response;
|
||||
}
|
||||
}
|
@ -27,7 +27,8 @@ import java.util.concurrent.TimeUnit;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@SpringBootTest(classes = OrderApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
class OrderRestEndpointIntegrationTest {
|
||||
//marked as manual as the test is unstable on Jenkins due to low resources
|
||||
class OrderRestEndpointManualTest {
|
||||
|
||||
@LocalServerPort
|
||||
private int port;
|
@ -5,3 +5,4 @@ This module contains articles about Java 11 core features
|
||||
### Relevant articles
|
||||
- [Adding Parameters to Java HttpClient Requests](https://www.baeldung.com/java-httpclient-request-parameters)
|
||||
- [Writing a List of Strings Into a Text File](https://www.baeldung.com/java-list-to-text-file)
|
||||
- [Java HttpClient – Map JSON Response to Java Class](https://www.baeldung.com/java-httpclient-map-json-response)
|
||||
|
@ -1,2 +1,3 @@
|
||||
## Relevant Articles
|
||||
- [Record Patterns in Java 19](https://www.baeldung.com/java-19-record-patterns)
|
||||
- [Structured Concurrency in Java 19](https://www.baeldung.com/java-structured-concurrency)
|
||||
|
@ -0,0 +1,63 @@
|
||||
package com.baeldung.array.conversions;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
|
||||
|
||||
public class StringArrayToIntArrayUnitTest {
|
||||
private final String[] stringArray = new String[] { "1", "2", "3", "4", "5", "6", "42" };
|
||||
private final int[] expected = new int[] { 1, 2, 3, 4, 5, 6, 42 };
|
||||
|
||||
private final String[] stringArrayWithInvalidNum = new String[] { "1", "2", "hello", "4", "world", "6", "42" };
|
||||
private final int[] expectedWithInvalidInput = new int[] { 1, 2, Integer.MIN_VALUE, 4, Integer.MIN_VALUE, 6, 42 };
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Test
|
||||
void givenStringArray_whenUseStreamApi_shouldGetExpectedIntArray() {
|
||||
int[] result = Arrays.stream(stringArray).mapToInt(Integer::parseInt).toArray();
|
||||
assertArrayEquals(expected, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenStringArrayWithInvalidNum_whenUseStreamApi_shouldGetExpectedIntArray() {
|
||||
int[] result = Arrays.stream(stringArrayWithInvalidNum).mapToInt(s -> {
|
||||
try {
|
||||
return Integer.parseInt(s);
|
||||
} catch (NumberFormatException ex) {
|
||||
logger.warn("Invalid number format detected: {}, use Int.MinValue as the fallback", s);
|
||||
return Integer.MIN_VALUE;
|
||||
}
|
||||
}).toArray();
|
||||
assertArrayEquals(expectedWithInvalidInput, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenStringArray_whenConvertInLoop_shouldGetExpectedIntArray() {
|
||||
int[] result = new int[stringArray.length];
|
||||
for (int i = 0; i < stringArray.length; i++) {
|
||||
result[i] = Integer.parseInt(stringArray[i]);
|
||||
}
|
||||
assertArrayEquals(expected, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenStringArrayWithInvalidNum_whenConvertInLoop_shouldGetExpectedIntArray() {
|
||||
int[] result = new int[stringArrayWithInvalidNum.length];
|
||||
for (int i = 0; i < stringArrayWithInvalidNum.length; i++) {
|
||||
try {
|
||||
result[i] = Integer.parseInt(stringArrayWithInvalidNum[i]);
|
||||
} catch (NumberFormatException exception) {
|
||||
logger.warn("Invalid number format detected: [{}], use Int.MinValue as the fallback", stringArrayWithInvalidNum[i]);
|
||||
result[i] = Integer.MIN_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
assertArrayEquals(expectedWithInvalidInput, result);
|
||||
}
|
||||
}
|
@ -6,8 +6,7 @@ import com.baeldung.callbackfunctions.EventListener;
|
||||
import com.baeldung.callbackfunctions.asynchronous.AsynchronousEventConsumer;
|
||||
import com.baeldung.callbackfunctions.asynchronous.AsynchronousEventListenerImpl;
|
||||
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class AsynchronousCallbackUnitTest {
|
||||
|
||||
@ -17,6 +16,6 @@ public class AsynchronousCallbackUnitTest {
|
||||
AsynchronousEventConsumer asynchronousEventListenerConsumer = new AsynchronousEventConsumer(listener);
|
||||
asynchronousEventListenerConsumer.doAsynchronousOperation();
|
||||
|
||||
verify(listener, times(1)).onTrigger();
|
||||
verify(listener, timeout(1000).times(1)).onTrigger();
|
||||
}
|
||||
}
|
||||
|
@ -3,18 +3,25 @@ package com.baeldung.callbackfunctions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import com.baeldung.callbackfunctions.ConsumerCallback;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class ConsumerCallbackUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenIncreasingInitialAgeByGivenValueThroughCallback_shouldIncreaseAge(){
|
||||
void whenIncreasingInitialAgeByGivenValueThroughCallback_shouldIncreaseAge(){
|
||||
ConsumerCallback consumerCallback = new ConsumerCallback();
|
||||
consumerCallback.getAge(20, (initialAge) -> {
|
||||
int ageDifference = 10;
|
||||
int ageDifference = 10;
|
||||
AtomicInteger newAge1 = new AtomicInteger();
|
||||
int initialAge = 20;
|
||||
consumerCallback.getAge(initialAge, (initialAge1) -> {
|
||||
consumerCallback.increaseAge(initialAge, ageDifference, (newAge) -> {
|
||||
assertEquals(initialAge + ageDifference, newAge);
|
||||
System.out.printf("New age ==> %s", newAge);
|
||||
newAge1.set(newAge);
|
||||
|
||||
});
|
||||
});
|
||||
assertEquals(initialAge + ageDifference, newAge1.get());
|
||||
}
|
||||
}
|
||||
|
@ -14,3 +14,4 @@ This module contains articles about core features in the Java language
|
||||
- [Convert Between int and char in Java](https://www.baeldung.com/java-convert-int-char)
|
||||
- [Converting a Number from One Base to Another in Java](https://www.baeldung.com/java-converting-a-number-from-one-base-to-another)
|
||||
- [Check if Command-Line Arguments Are Null in Java](https://www.baeldung.com/java-check-command-line-args)
|
||||
- [Determine if a Class Implements an Interface in Java](https://www.baeldung.com/java-check-class-implements-interface)
|
||||
|
@ -13,6 +13,12 @@
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<commons-lang3.version>3.12.0</commons-lang3.version>
|
||||
<reflections.version>0.10.2</reflections.version>
|
||||
</properties>
|
||||
|
||||
|
||||
<build>
|
||||
<finalName>core-java-lang-5</finalName>
|
||||
@ -24,4 +30,18 @@
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.reflections</groupId>
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>${reflections.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,5 @@
|
||||
package com.baeldung.checkinterface;
|
||||
|
||||
public class ChildClass1 implements ChildInterface1 {
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.baeldung.checkinterface;
|
||||
|
||||
public class ChildClass2 implements ChildInterface2 {
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.baeldung.checkinterface;
|
||||
|
||||
public interface ChildInterface1 extends MasterInterface {
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.baeldung.checkinterface;
|
||||
|
||||
public interface ChildInterface2 extends MasterInterface {
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.baeldung.checkinterface;
|
||||
|
||||
public class MasterClass implements MasterInterface {
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.baeldung.checkinterface;
|
||||
|
||||
public interface MasterInterface {
|
||||
|
||||
}
|
@ -0,0 +1,154 @@
|
||||
package com.baeldung.checkinterface;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.ClassUtils;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.reflections.ReflectionUtils;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
public class CheckInterfaceUnitTest {
|
||||
|
||||
protected static Reflections reflections;
|
||||
|
||||
@BeforeAll
|
||||
public static void initializeReflectionsLibrary() {
|
||||
|
||||
reflections = new Reflections("com.baeldung.checkinterface");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingReflectionGetInterfaces_thenDirectlyImplementedInterfaceIsFound() {
|
||||
|
||||
ChildClass2 childClass2 = new ChildClass2();
|
||||
List<Class<?>> interfaces = Arrays.asList(childClass2.getClass().getInterfaces());
|
||||
|
||||
assertEquals(1, interfaces.size());
|
||||
assertTrue(interfaces.contains(ChildInterface2.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingReflectionGetInterfaces_thenParentInterfaceIsNotFound() {
|
||||
|
||||
ChildClass2 childClass2 = new ChildClass2();
|
||||
List<Class<?>> interfaces = Arrays.asList(childClass2.getClass().getInterfaces());
|
||||
|
||||
assertFalse(interfaces.contains(MasterInterface.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingReflectionGetInterfacesRecursively_thenParentInterfaceIsFound() {
|
||||
|
||||
Set<Class<?>> interfaces = getAllExtendedOrImplementedInterfacesRecursively(ChildClass2.class);
|
||||
|
||||
assertTrue(interfaces.contains(ChildInterface2.class));
|
||||
assertTrue(interfaces.contains(MasterInterface.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingReflectionIsAssignableFrom_thenDirectlyImplementedInterfaceIsFound() {
|
||||
|
||||
ChildClass2 childClass2 = new ChildClass2();
|
||||
|
||||
assertTrue(ChildInterface2.class.isAssignableFrom(childClass2.getClass()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingReflectionIsAssignableFrom_thenParentInterfaceIsFound() {
|
||||
|
||||
ChildClass2 childClass2 = new ChildClass2();
|
||||
|
||||
assertTrue(MasterInterface.class.isAssignableFrom(childClass2.getClass()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingReflectionIsInstance_thenDirectlyImplementedInterfaceIsFound() {
|
||||
|
||||
ChildClass2 childClass2 = new ChildClass2();
|
||||
|
||||
assertTrue(ChildInterface2.class.isInstance(childClass2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingReflectionIsInstance_thenParentInterfaceIsFound() {
|
||||
|
||||
ChildClass2 childClass2 = new ChildClass2();
|
||||
|
||||
assertTrue(MasterInterface.class.isInstance(childClass2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingReflectionInstanceOf_thenDirectlyImplementedInterfaceIsFound() {
|
||||
|
||||
ChildClass2 childClass2 = new ChildClass2();
|
||||
|
||||
assertTrue(childClass2 instanceof ChildInterface2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingReflectionInstanceOf_thenParentInterfaceIsFound() {
|
||||
|
||||
ChildClass2 childClass2 = new ChildClass2();
|
||||
|
||||
assertTrue(childClass2 instanceof MasterInterface);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingCommons_thenDirectlyImplementedInterfaceIsFound() {
|
||||
|
||||
ChildClass2 childClass2 = new ChildClass2();
|
||||
List<Class<?>> interfaces = ClassUtils.getAllInterfaces(childClass2.getClass());
|
||||
|
||||
assertTrue(interfaces.contains(ChildInterface2.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingCommons_thenParentInterfaceIsFound() {
|
||||
|
||||
ChildClass2 childClass2 = new ChildClass2();
|
||||
List<Class<?>> interfaces = ClassUtils.getAllInterfaces(childClass2.getClass());
|
||||
|
||||
assertTrue(interfaces.contains(MasterInterface.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingReflections_thenDirectlyImplementedInterfaceIsFound() {
|
||||
|
||||
ChildClass2 childClass2 = new ChildClass2();
|
||||
Set<Class<?>> interfaces = reflections.get(ReflectionUtils.Interfaces.of(childClass2.getClass()));
|
||||
|
||||
assertTrue(interfaces.contains(ChildInterface2.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingReflections_thenParentInterfaceIsFound() {
|
||||
|
||||
ChildClass2 childClass2 = new ChildClass2();
|
||||
Set<Class<?>> interfaces = reflections.get(ReflectionUtils.Interfaces.of(childClass2.getClass()));
|
||||
|
||||
assertTrue(interfaces.contains(MasterInterface.class));
|
||||
}
|
||||
|
||||
static Set<Class<?>> getAllExtendedOrImplementedInterfacesRecursively(Class<?> clazz) {
|
||||
|
||||
Set<Class<?>> res = new HashSet<Class<?>>();
|
||||
Class<?>[] interfaces = clazz.getInterfaces();
|
||||
|
||||
if (interfaces.length > 0) {
|
||||
res.addAll(Arrays.asList(interfaces));
|
||||
for (Class<?> interfaze : interfaces) {
|
||||
res.addAll(getAllExtendedOrImplementedInterfacesRecursively(interfaze));
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
@ -8,3 +8,4 @@ This module contains articles about types in Java
|
||||
- [Check if an Enum Value Exists in Java](https://www.baeldung.com/java-search-enum-values)
|
||||
- [Generate a Random Value From an Enum](https://www.baeldung.com/java-enum-random-value)
|
||||
- [Filling a List With All Enum Values in Java](https://www.baeldung.com/java-enum-values-to-list)
|
||||
- [Comparing a String to an Enum Value in Java](https://www.baeldung.com/java-comparing-string-to-enum)
|
||||
|
@ -1,55 +1,67 @@
|
||||
package com.baeldung.keyword;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.baeldung.keyword.Circle;
|
||||
import com.baeldung.keyword.Ring;
|
||||
import com.baeldung.keyword.Round;
|
||||
import com.baeldung.keyword.Shape;
|
||||
import com.baeldung.keyword.Triangle;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class InstanceOfUnitTest {
|
||||
|
||||
@Test
|
||||
public void giveWhenInstanceIsCorrect_thenReturnTrue() {
|
||||
void giveWhenInstanceIsCorrect_thenReturnTrue() {
|
||||
Ring ring = new Ring();
|
||||
Assert.assertTrue("ring is instance of Round ", ring instanceof Round);
|
||||
assertTrue(ring instanceof Round);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void giveWhenObjectIsInstanceOfType_thenReturnTrue() {
|
||||
void giveWhenObjectIsInstanceOfType_thenReturnTrue() {
|
||||
Circle circle = new Circle();
|
||||
Assert.assertTrue("circle is instance of Circle ", circle instanceof Circle);
|
||||
assertTrue(circle instanceof Circle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void giveWhenInstanceIsOfSubtype_thenReturnTrue() {
|
||||
void giveWhenInstanceIsOfSubtype_thenReturnTrue() {
|
||||
Circle circle = new Circle();
|
||||
Assert.assertTrue("circle is instance of Round", circle instanceof Round);
|
||||
assertTrue(circle instanceof Round);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void giveWhenTypeIsInterface_thenReturnTrue() {
|
||||
void giveWhenTypeIsInterface_thenReturnTrue() {
|
||||
Circle circle = new Circle();
|
||||
Assert.assertTrue("circle is instance of Shape", circle instanceof Shape);
|
||||
assertTrue(circle instanceof Shape);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void giveWhenTypeIsOfObjectType_thenReturnTrue() {
|
||||
void giveWhenTypeIsOfObjectType_thenReturnTrue() {
|
||||
Thread thread = new Thread();
|
||||
Assert.assertTrue("thread is instance of Object", thread instanceof Object);
|
||||
assertTrue(thread instanceof Object);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void giveWhenInstanceValueIsNull_thenReturnFalse() {
|
||||
void giveWhenInstanceValueIsNull_thenReturnFalse() {
|
||||
Circle circle = null;
|
||||
Assert.assertFalse("circle is instance of Round", circle instanceof Round);
|
||||
assertFalse(circle instanceof Round);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void giveWhenComparingClassInDiffHierarchy_thenCompilationError() {
|
||||
// Assert.assertFalse("circle is instance of Triangle", circle instanceof Triangle);
|
||||
void giveWhenComparingClassInDiffHierarchy_thenCompilationError() {
|
||||
//assertFalse( circle instanceof Triangle);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void giveWhenStream_whenCastWithoutInstanceOfChk_thenGetException() {
|
||||
Stream<Round> roundStream = Stream.of(new Ring(), new Ring(), new Circle());
|
||||
assertThrows(ClassCastException.class, () -> roundStream.map(it -> (Ring) it).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void giveWhenStream_whenCastAfterInstanceOfChk_thenGetExpectedResult() {
|
||||
Stream<Round> roundStream = Stream.of(new Ring(), new Ring(), new Circle());
|
||||
List<Ring> ringList = roundStream.filter(it -> it instanceof Ring).map(it -> (Ring) it).collect(Collectors.toList());
|
||||
assertEquals(2, ringList.size());
|
||||
}
|
||||
}
|
@ -25,15 +25,20 @@
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
<version>${javax.mail.version}</version>
|
||||
<groupId>org.eclipse.angus</groupId>
|
||||
<artifactId>angus-mail</artifactId>
|
||||
<version>${angus.mail.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.asynchttpclient</groupId>
|
||||
<artifactId>async-http-client</artifactId>
|
||||
<version>${async-http-client.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.xml.bind</groupId>
|
||||
<artifactId>jakarta.xml.bind-api</artifactId>
|
||||
<version>${jakarta.bind.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.icegreen</groupId>
|
||||
<artifactId>greenmail</artifactId>
|
||||
@ -48,9 +53,10 @@
|
||||
|
||||
<properties>
|
||||
<httpclient.version>4.5.9</httpclient.version>
|
||||
<javax.mail.version>1.5.0-b01</javax.mail.version>
|
||||
<angus.mail.version>2.0.1</angus.mail.version>
|
||||
<async-http-client.version>2.4.5</async-http-client.version>
|
||||
<greenmail.version>1.5.8</greenmail.version>
|
||||
<jakarta.bind.version>2.3.3</jakarta.bind.version>
|
||||
<greenmail.version>2.0.0-alpha-3</greenmail.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -1,19 +1,20 @@
|
||||
package com.baeldung.mail;
|
||||
|
||||
import javax.mail.Authenticator;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.Multipart;
|
||||
import javax.mail.PasswordAuthentication;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.Transport;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeBodyPart;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import jakarta.mail.Authenticator;
|
||||
import jakarta.mail.Message;
|
||||
import jakarta.mail.Multipart;
|
||||
import jakarta.mail.PasswordAuthentication;
|
||||
import jakarta.mail.Session;
|
||||
import jakarta.mail.Transport;
|
||||
import jakarta.mail.internet.InternetAddress;
|
||||
import jakarta.mail.internet.MimeBodyPart;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import jakarta.mail.internet.MimeMultipart;
|
||||
|
||||
public class EmailService {
|
||||
|
||||
private String username;
|
||||
|
@ -1,21 +1,23 @@
|
||||
package com.baeldung.mail.mailwithattachment;
|
||||
|
||||
import javax.mail.BodyPart;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.Multipart;
|
||||
import javax.mail.PasswordAuthentication;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.Transport;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeBodyPart;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import jakarta.mail.Authenticator;
|
||||
import jakarta.mail.BodyPart;
|
||||
import jakarta.mail.Message;
|
||||
import jakarta.mail.MessagingException;
|
||||
import jakarta.mail.Multipart;
|
||||
import jakarta.mail.PasswordAuthentication;
|
||||
import jakarta.mail.Session;
|
||||
import jakarta.mail.Transport;
|
||||
import jakarta.mail.internet.InternetAddress;
|
||||
import jakarta.mail.internet.MimeBodyPart;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import jakarta.mail.internet.MimeMultipart;
|
||||
|
||||
public class MailWithAttachmentService {
|
||||
|
||||
private final String username;
|
||||
@ -37,7 +39,7 @@ public class MailWithAttachmentService {
|
||||
props.put("mail.smtp.host", this.host);
|
||||
props.put("mail.smtp.port", this.port);
|
||||
|
||||
return Session.getInstance(props, new javax.mail.Authenticator() {
|
||||
return Session.getInstance(props, new Authenticator() {
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(username, password);
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
package com.baeldung.download;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Files;
|
||||
@ -13,7 +10,11 @@ import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class FileDownloadIntegrationTest {
|
||||
|
||||
|
@ -1,17 +1,19 @@
|
||||
package com.baeldung.mail;
|
||||
|
||||
import com.icegreen.greenmail.junit.GreenMailRule;
|
||||
import com.icegreen.greenmail.util.ServerSetupTest;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
import java.io.IOException;
|
||||
import com.icegreen.greenmail.junit.GreenMailRule;
|
||||
import com.icegreen.greenmail.util.ServerSetupTest;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import jakarta.mail.MessagingException;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import jakarta.mail.internet.MimeMultipart;
|
||||
|
||||
public class EmailServiceLiveTest {
|
||||
|
||||
|
@ -1,20 +1,20 @@
|
||||
package com.baeldung.mail.mailwithattachment;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.icegreen.greenmail.configuration.GreenMailConfiguration;
|
||||
import com.icegreen.greenmail.junit.GreenMailRule;
|
||||
import com.icegreen.greenmail.util.GreenMailUtil;
|
||||
import com.icegreen.greenmail.util.ServerSetupTest;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import jakarta.mail.MessagingException;
|
||||
import jakarta.mail.Session;
|
||||
import jakarta.mail.internet.MimeMessage;
|
||||
import jakarta.mail.internet.MimeMultipart;
|
||||
|
||||
public class MailWithAttachmentServiceLiveTest {
|
||||
|
||||
@ -29,7 +29,6 @@ public class MailWithAttachmentServiceLiveTest {
|
||||
.withUser(USERNAME, PASSWORD)
|
||||
);
|
||||
|
||||
@Resource
|
||||
private MailWithAttachmentService emailService;
|
||||
|
||||
@Before
|
||||
@ -73,5 +72,4 @@ public class MailWithAttachmentServiceLiveTest {
|
||||
return GreenMailUtil.getBody(((MimeMultipart) receivedMessage.getContent())
|
||||
.getBodyPart(2));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,9 +30,9 @@
|
||||
<version>${tomcat.embeded.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<version>${javax.mail.version}</version>
|
||||
<groupId>org.eclipse.angus</groupId>
|
||||
<artifactId>angus-mail</artifactId>
|
||||
<version>${angus.mail.version}</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.github.seancfoley/ipaddress -->
|
||||
<dependency>
|
||||
@ -95,7 +95,7 @@
|
||||
<seancfoley.ipaddress.version>5.3.3</seancfoley.ipaddress.version>
|
||||
<jgonian.commons-ip-math.version>1.32</jgonian.commons-ip-math.version>
|
||||
<googlecode.ipv6.version>0.17</googlecode.ipv6.version>
|
||||
<javax.mail.version>1.6.2</javax.mail.version>
|
||||
<angus.mail.version>2.0.1</angus.mail.version>
|
||||
<apache.commons-validator.version>1.7</apache.commons-validator.version>
|
||||
</properties>
|
||||
|
||||
|
@ -6,16 +6,16 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.mail.Address;
|
||||
import javax.mail.Folder;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.Multipart;
|
||||
import javax.mail.NoSuchProviderException;
|
||||
import javax.mail.Part;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.Store;
|
||||
import javax.mail.internet.MimeBodyPart;
|
||||
import jakarta.mail.Address;
|
||||
import jakarta.mail.Folder;
|
||||
import jakarta.mail.Message;
|
||||
import jakarta.mail.MessagingException;
|
||||
import jakarta.mail.Multipart;
|
||||
import jakarta.mail.NoSuchProviderException;
|
||||
import jakarta.mail.Part;
|
||||
import jakarta.mail.Session;
|
||||
import jakarta.mail.Store;
|
||||
import jakarta.mail.internet.MimeBodyPart;
|
||||
|
||||
public class DownloadEmailAttachments {
|
||||
private String downloadDirectory;
|
||||
@ -24,7 +24,7 @@ public class DownloadEmailAttachments {
|
||||
this.downloadDirectory = dir;
|
||||
}
|
||||
|
||||
public void downloadEmailAttachments(String host, String port, String userName, String password) throws NoSuchProviderException, MessagingException, IOException {
|
||||
public void downloadEmailAttachments(String host, String port, String userName, String password) throws MessagingException, IOException {
|
||||
Properties properties = setMailServerProperties(host, port);
|
||||
Store store = setSessionStoreProperties(userName, password, properties);
|
||||
Folder inbox = store.getFolder("INBOX");
|
||||
@ -67,7 +67,7 @@ public class DownloadEmailAttachments {
|
||||
return downloadedAttachments;
|
||||
}
|
||||
|
||||
public Store setSessionStoreProperties(String userName, String password, Properties properties) throws NoSuchProviderException, MessagingException {
|
||||
public Store setSessionStoreProperties(String userName, String password, Properties properties) throws MessagingException {
|
||||
Session session = Session.getDefaultInstance(properties);
|
||||
|
||||
Store store = session.getStore("pop3");
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.baeldung.urlvalidation;
|
||||
|
||||
import com.google.common.net.InetAddresses;
|
||||
import org.apache.commons.validator.routines.InetAddressValidator;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class IPv4Validation {
|
||||
|
||||
public static boolean validateWithApacheCommons(String ip) {
|
||||
InetAddressValidator validator = InetAddressValidator.getInstance();
|
||||
return validator.isValid(ip);
|
||||
}
|
||||
|
||||
public static boolean validateWithGuava(String ip) {
|
||||
return InetAddresses.isInetAddress(ip);
|
||||
}
|
||||
|
||||
public static boolean validateWithRegex(String ip) {
|
||||
String regex = "^((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)\\.?\\b){4}$";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(ip);
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
package com.baeldung.ipv4validation;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.baeldung.urlvalidation.IPv4Validation.*;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class IPv4ValidationUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenValidIPv4_whenValidate_thenReturnsTrue() {
|
||||
String ip = "192.168.0.1";
|
||||
assertTrue(validateWithApacheCommons(ip));
|
||||
assertTrue(validateWithGuava(ip));
|
||||
assertTrue(validateWithRegex(ip));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenIPv4WithThreeOctets_whenValidate_thenReturnsFalse() {
|
||||
String ip = "192.168.0";
|
||||
assertFalse(validateWithApacheCommons(ip));
|
||||
assertFalse(validateWithGuava(ip));
|
||||
assertFalse(validateWithRegex(ip));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenIPv4WithLeadingZero_whenValidate_thenReturnsFalse() {
|
||||
String ip = "192.168.0.01";
|
||||
assertFalse(validateWithApacheCommons(ip));
|
||||
assertFalse(validateWithGuava(ip));
|
||||
assertFalse(validateWithRegex(ip));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenIPv4WithInvalidCharacter_whenValidate_thenReturnsFalse() {
|
||||
String ip = "a.168.0.01";
|
||||
assertFalse(validateWithApacheCommons(ip));
|
||||
assertFalse(validateWithGuava(ip));
|
||||
assertFalse(validateWithRegex(ip));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenIPv4HaveValueAbove255_whenValidate_thenReturnsFalse() {
|
||||
String ip = "192.168.256.1";
|
||||
assertFalse(validateWithApacheCommons(ip));
|
||||
assertFalse(validateWithGuava(ip));
|
||||
assertFalse(validateWithRegex(ip));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenValidIPv4WithTwoDigitOctet_whenValidate_thenReturnsTrue() {
|
||||
String ip = "192.168.42.1";
|
||||
assertTrue(validateWithApacheCommons(ip));
|
||||
assertTrue(validateWithGuava(ip));
|
||||
assertTrue(validateWithRegex(ip));
|
||||
}
|
||||
@Test
|
||||
public void givenValidIPv4WithNumberInRange200And249_whenValidate_thenReturnsTrue() {
|
||||
String ip = "192.168.42.222";
|
||||
assertTrue(validateWithApacheCommons(ip));
|
||||
assertTrue(validateWithGuava(ip));
|
||||
assertTrue(validateWithRegex(ip));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenIPv4WithFourDigitOctet_whenValidate_thenReturnsFalse() {
|
||||
String ip = "1921.168.42.222";
|
||||
assertFalse(validateWithApacheCommons(ip));
|
||||
assertFalse(validateWithGuava(ip));
|
||||
assertFalse(validateWithRegex(ip));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenIPv4WithFiveOctets_whenValidate_thenReturnsFalse() {
|
||||
String ip = "192.168.42.222.10";
|
||||
assertFalse(validateWithApacheCommons(ip));
|
||||
assertFalse(validateWithGuava(ip));
|
||||
assertFalse(validateWithRegex(ip));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenIPv4WithTwoConsecutiveDots_whenValidate_thenReturnsFalse() {
|
||||
String ip = "192.168..1";
|
||||
assertFalse(validateWithApacheCommons(ip));
|
||||
assertFalse(validateWithGuava(ip));
|
||||
assertFalse(validateWithRegex(ip));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenOnlyDots_whenValidate_thenReturnsFalse() {
|
||||
String ip = "...";
|
||||
assertFalse(validateWithApacheCommons(ip));
|
||||
assertFalse(validateWithGuava(ip));
|
||||
assertFalse(validateWithRegex(ip));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenBlankString_whenValidate_thenReturnsFalse() {
|
||||
String ip = " ";
|
||||
assertFalse(validateWithApacheCommons(ip));
|
||||
assertFalse(validateWithGuava(ip));
|
||||
assertFalse(validateWithRegex(ip));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenIPv4StartWithDot_whenValidate_thenReturnsFalse() {
|
||||
String ip = ".192.168.0.1";
|
||||
assertFalse(validateWithApacheCommons(ip));
|
||||
assertFalse(validateWithGuava(ip));
|
||||
assertFalse(validateWithRegex(ip));
|
||||
}
|
||||
@Test
|
||||
public void givenIPv4EndWithDot_whenValidate_thenReturnsFalse() {
|
||||
String ip = "192.168.0.1.";
|
||||
assertFalse(validateWithApacheCommons(ip));
|
||||
assertFalse(validateWithGuava(ip));
|
||||
assertFalse(validateWithRegex(ip));
|
||||
}
|
||||
|
||||
}
|
@ -7,3 +7,4 @@
|
||||
- [Make Division of Two Integers Result in a Float](https://www.baeldung.com/java-integer-division-float-result)
|
||||
- [Creating Random Numbers With No Duplicates in Java](https://www.baeldung.com/java-unique-random-numbers)
|
||||
- [Multiply a BigDecimal by an Integer in Java](https://www.baeldung.com/java-bigdecimal-multiply-integer)
|
||||
- [Check if an Integer Value is null or Zero in Java](https://www.baeldung.com/java-check-integer-null-or-zero)
|
||||
|
@ -0,0 +1,58 @@
|
||||
package com.baeldung.absintdiff;
|
||||
|
||||
import static com.baeldung.absintdiff.IntDiffUtil.absDiff;
|
||||
import static com.baeldung.absintdiff.IntDiffUtil.absDiff2;
|
||||
import static com.baeldung.absintdiff.IntDiffUtil.absDiffAsLong;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class IntDiffUtil {
|
||||
static int absDiff(int num1, int num2) {
|
||||
int result = Math.abs(num1 - num2);
|
||||
System.out.println("Absolute diff: " + result);
|
||||
return result;
|
||||
}
|
||||
|
||||
static int absDiff2(int num1, int num2) {
|
||||
return Math.abs(Math.subtractExact(num1, num2));
|
||||
}
|
||||
|
||||
static long absDiffAsLong(int num1, int num2) {
|
||||
return Math.abs((long) num1 - num2);
|
||||
}
|
||||
}
|
||||
|
||||
public class AbsoluteDifferenceOfTwoIntUnitTest {
|
||||
|
||||
@Test
|
||||
void givenTwoIntegers_whenCallingAbsDiff_shouldGetExpectedResult() {
|
||||
int diff1 = absDiff(100, -200);
|
||||
assertEquals(300, diff1);
|
||||
|
||||
int diff2 = absDiff(100, 200);
|
||||
assertEquals(100, diff2);
|
||||
|
||||
//integer overflow! output: Absolute diff: 2147483449
|
||||
//absDiff(Integer.MAX_VALUE, -200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoIntegers_whenCallingAbsDiff2_shouldThrowException() {
|
||||
int diff1 = absDiff2(100, -200);
|
||||
assertEquals(300, diff1);
|
||||
|
||||
int diff2 = absDiff2(100, 200);
|
||||
assertEquals(100, diff2);
|
||||
|
||||
//overflow -> exception
|
||||
assertThrows(ArithmeticException.class, () -> absDiff2(Integer.MAX_VALUE, -200));
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoIntegers_whenCallingAbsDiffAsLong_shouldThrowException() {
|
||||
long diff = absDiffAsLong(Integer.MAX_VALUE, -200);
|
||||
assertEquals(Integer.MAX_VALUE + 200L, diff);
|
||||
}
|
||||
}
|
@ -6,3 +6,4 @@
|
||||
- [Java 8 Streams: Multiple Filters vs. Complex Condition](https://www.baeldung.com/java-streams-multiple-filters-vs-condition)
|
||||
- [Finding Max Date in List Using Streams](https://www.baeldung.com/java-max-date-list-streams)
|
||||
- [Batch Processing of Stream Data in Java](https://www.baeldung.com/java-stream-batch-processing)
|
||||
- [Stream to Iterable in Java](https://www.baeldung.com/java-stream-to-iterable)
|
||||
|
@ -14,20 +14,20 @@ public class CustomBatchIterator<T> implements Iterator<List<T>> {
|
||||
private List<T> currentBatch;
|
||||
private final Iterator<T> iterator;
|
||||
|
||||
public CustomBatchIterator(Iterator<T> sourceIterator, int batchSize) {
|
||||
private CustomBatchIterator(Iterator<T> sourceIterator, int batchSize) {
|
||||
this.batchSize = batchSize;
|
||||
this.iterator = sourceIterator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<T> next() {
|
||||
prepareNextBatch();
|
||||
return currentBatch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
prepareNextBatch();
|
||||
return currentBatch != null && !currentBatch.isEmpty();
|
||||
return iterator.hasNext();
|
||||
}
|
||||
|
||||
public static <T> Stream<List<T>> batchStreamOf(Stream<T> stream, int batchSize) {
|
||||
|
@ -0,0 +1,42 @@
|
||||
package com.baeldung.streams.streamtoiterable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import joptsimple.internal.Strings;
|
||||
|
||||
public class StreamToIterable {
|
||||
public String streamToIterableLambda(List<String> listOfStrings) {
|
||||
Stream<String> stringStream = listOfStrings.stream();
|
||||
StringBuilder sentence = new StringBuilder();
|
||||
for (String eachString : (Iterable<String>) () -> stringStream.iterator()) {
|
||||
doSomethingOnString(eachString, sentence);
|
||||
}
|
||||
return sentence.toString();
|
||||
}
|
||||
|
||||
public String streamToIterableMethodReference(List<String> listOfStrings) {
|
||||
Stream<String> stringStream = listOfStrings.stream();
|
||||
StringBuilder sentence = new StringBuilder();
|
||||
for (String eachString : (Iterable<String>) stringStream::iterator) {
|
||||
doSomethingOnString(eachString, sentence);
|
||||
}
|
||||
return sentence.toString();
|
||||
}
|
||||
|
||||
public String streamToList(List<String> listOfStrings) {
|
||||
Stream<String> stringStream = listOfStrings.stream();
|
||||
StringBuilder sentence = new StringBuilder();
|
||||
for (String eachString : stringStream.collect(Collectors.toList())) {
|
||||
doSomethingOnString(eachString, sentence);
|
||||
}
|
||||
return sentence.toString();
|
||||
}
|
||||
|
||||
private void doSomethingOnString(String s, StringBuilder sentence) {
|
||||
if (!Strings.isNullOrEmpty(s)) {
|
||||
sentence.append(s);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.baeldung.streams.streamtoiterable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class StreamToIterableUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenList_whenLambdaIsUsed_ThenStreamAsIterable(){
|
||||
StreamToIterable streamToIterable = new StreamToIterable();
|
||||
String actualString = streamToIterable.streamToIterableLambda(getListOfStrings());
|
||||
String expectedString = "Thisisasentencewithnospaces";
|
||||
Assert.assertEquals(expectedString, actualString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenList_whenMethodReferenceIsUsed_ThenStreamAsIterable(){
|
||||
StreamToIterable streamToIterable = new StreamToIterable();
|
||||
String actualString = streamToIterable.streamToIterableMethodReference(getListOfStrings());
|
||||
String expectedString = "Thisisasentencewithnospaces";
|
||||
Assert.assertEquals(expectedString, actualString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenList_whenCollectedToList_ThenStreamAsIterable(){
|
||||
StreamToIterable streamToIterable = new StreamToIterable();
|
||||
String actualString = streamToIterable.streamToList(getListOfStrings());
|
||||
String expectedString = "Thisisasentencewithnospaces";
|
||||
Assert.assertEquals(expectedString, actualString);
|
||||
}
|
||||
|
||||
private List<String> getListOfStrings(){
|
||||
List<String> listOfStrings = new ArrayList<>();
|
||||
listOfStrings.add("This");
|
||||
listOfStrings.add("is");
|
||||
listOfStrings.add("a");
|
||||
listOfStrings.add(null);
|
||||
listOfStrings.add("sentence");
|
||||
listOfStrings.add("with");
|
||||
listOfStrings.add("no");
|
||||
listOfStrings.add(null);
|
||||
listOfStrings.add("spaces");
|
||||
return listOfStrings;
|
||||
}
|
||||
}
|
@ -9,5 +9,6 @@ public class AnonymousClassExample{
|
||||
System.out.println("Thread: "+Thread.currentThread().getName()+" started");
|
||||
}
|
||||
});
|
||||
t1.start();
|
||||
}
|
||||
}
|
@ -53,19 +53,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<discord4j-core.version>3.1.1</discord4j-core.version>
|
||||
</properties>
|
||||
|
||||
|
@ -1 +1,2 @@
|
||||
## Relevant Articles:
|
||||
- [Communicating With Docker Containers on the Same Machine](https://www.baeldung.com/ops/docker-communicating-with-containers-on-same-machine)
|
||||
|
@ -116,7 +116,6 @@
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<feign.version>11.8</feign.version>
|
||||
<wsdl4j.version>1.6.3</wsdl4j.version>
|
||||
</properties>
|
||||
|
@ -1,2 +1,2 @@
|
||||
# Service account location. Can be a filesystem path or a classpath resource
|
||||
gcp.firebase.service-account=file:firebase-service-account.json
|
||||
# Service account location. Can be a filesystem path or a classpath resource. NB: Generate and use your own firebase-service-account.json file.
|
||||
gcp.firebase.service-account=classpath:firebase-service-account.json
|
@ -0,0 +1,12 @@
|
||||
{
|
||||
"type": "service_account",
|
||||
"project_id": "tutorials-2cdfb",
|
||||
"private_key_id": "d9f6a684d6814f85ed2d0490585eb7bf590f983a",
|
||||
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDdJWTeGT2eBFo+\nXxzT9xFJYPtyawTAj0K1rVUNlWNUwj3zszK6P2sAsrpI2Rz1klwQ9aDz9i3+Opxv\n7UZ3pOzur6S58JnoswtNs6BZ9P7oeggLJJC6MPjioxwh8jLLIGMgdVtC2/iPYW3r\nGzurWlwkM8M8DyCgNq7KKJcx44pGcyy16ZGCYiijuTEmK6R+WHJTTyICzRFu3Org\nuHGlZUs/G4E76p10HanoFX2AIS/fDEEMP2DXBB73yoCal5GuvMY9yZWxnvV65Y5z\nGveY3NDB9EESbO2AAhDvHekWT17uWhymtO5N3gM8da48J9d51tVzi0D/NIPZnF0u\nTS64uxK3AgMBAAECggEAYuEQa7oPcfLyQscWRbRH1250n2E4e7zSkBcTW4J7Km+7\ncZajTOGEP4iqgF4Lc8XgQnkBYXOmdvDP97+47VAh3EtOtRDeUEyV9kUlonNH8rx1\nkj3kNEwnTHav4oG/slEl4WJ3zro6NinTEvdXQ7OgVVOLrPP6m4g3uQ5TJCxgLEUI\nTd3Hs3cg3P71mzEqfBF4NmGVmC1ea5lXFELd6giJJMvL7g+O2w22/fquGWOrreAM\ncj/G2Xv9/vmzeb9yzbgGxqCJyY6vspmd90fQLUu7bxkEY5/PPc6Zk8qay4AdEn47\nkL6hnJiR8H1wMCzV2RTUKE7ospriNVdBilXgxm9IMQKBgQD1TmF0Bg85zvXmEKBa\nLBhbc3xTtM7DOgKs+pI12sYDKwgL/QKEI/TKkYXua0aVGiQWc2Bk2/0sYhO6aB2f\n6AN1ZUrf4PRM8c53jebChc7beVLSjWI8Tx+kE+0t8864OwvELYZUzP35oSx3RdJD\nE/CvqBM7NQfJwx2Mw2VJK/YRGQKBgQDmyWLm/IWitehkITw6xMQpkkFs2m4Joq3A\nJvAyri58TRkw/7rqWaIxb5Wcy/7BOvjDN8PZNTHh4ZvhQiHpn7NGUks2/ULnWxUB\nWAA9YbeO9PNHJfZ6PjD2FSvwOXHj+vVkWt2GCXT8pDGYM2ImqXon85Oe3OH/h+N5\nktO9taesTwKBgQCSdPGKK/P7N61oZpTWQW1pbFHWSCUKOiBO1mtk6/E9AvwS7EQM\nUMteBfRInJPPgYP6Q3hRv2YwkX3l1TOavRMTjB5f/BbfuZ7jkj0r9mfCcXUZcIAu\nMa9abus0fFP3eolT3zpMdvdLiwbZTz5x/f29YkPZHZhAxdVmrWJThYOsQQKBgBDu\nZVsc25D8V3hBF/IXzWxfVn1t6PS8ApM+SBDvxmlIHrkBiez3dna6APfn32C9utJX\nnP6qcGZp7s2v1F0XYkeecfYuzmG6xOe8VQgryxOp1M87ccG2HlFvbDHLhRd8qdQa\n9nWG7BY81Yac/m5nsJaNwB6/hbUBeybIJtCcKxjxAoGBAJ3y+QSFb4AYmxLFtmMA\nklOvlT+r70w4RV/z4SEO1gjWEh9IozNSXknl5Q/8Zh9IVm3+/qYap//IzEv9JUc3\nv4+HlpZu0trxTpvRWWjPqVr3ssxRdiFLC0LCLEk4rzqWLBVyzJm8uHVIF9Inv8PE\naudInvdbnfAWi60+1Wi8u0Co\n-----END PRIVATE KEY-----\n",
|
||||
"client_email": "firebase-adminsdk-2afzd@tutorials-2cdfb.iam.gserviceaccount.com",
|
||||
"client_id": "111111112074248894669",
|
||||
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||
"token_uri": "https://oauth2.googleapis.com/token",
|
||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-2afzd%40tutorials-2cdfb.iam.gserviceaccount.com"
|
||||
}
|
@ -24,22 +24,6 @@
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -28,6 +28,15 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<javax.websocket-api.version>1.1</javax.websocket-api.version>
|
||||
<gson.version>2.8.0</gson.version>
|
||||
|
@ -60,9 +60,6 @@
|
||||
<properties>
|
||||
<hibernate-validator.version>6.2.3.Final</hibernate-validator.version>
|
||||
<hibernate-validator.ap.version>6.2.0.Final</hibernate-validator.ap.version>
|
||||
<maven.compiler.version>3.6.1</maven.compiler.version>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<javax.el.version>3.0.0</javax.el.version>
|
||||
<org.springframework.version>5.3.21</org.springframework.version>
|
||||
<spring.boot.version>2.7.1</spring.boot.version>
|
||||
|
@ -60,9 +60,6 @@
|
||||
<properties>
|
||||
<hibernate-validator.version>6.2.3.Final</hibernate-validator.version>
|
||||
<hibernate-validator.ap.version>6.2.0.Final</hibernate-validator.ap.version>
|
||||
<maven.compiler.version>3.6.1</maven.compiler.version>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<javax.el.version>3.0.0</javax.el.version>
|
||||
<org.springframework.version>5.3.21</org.springframework.version>
|
||||
<spring.boot.version>2.7.1</spring.boot.version>
|
||||
|
@ -9,10 +9,14 @@ import org.glassfish.grizzly.http.server.HttpServer;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
|
||||
import com.baeldung.jersey.server.http.EmbeddedHttpServer;
|
||||
|
||||
@Disabled
|
||||
@Ignore
|
||||
public class ItemsUnitTest {
|
||||
|
||||
private HttpServer server;
|
||||
|
@ -36,6 +36,7 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<properties>
|
||||
<org.eclipse.jgit.version>4.5.0.201609210915-r</org.eclipse.jgit.version>
|
||||
</properties>
|
||||
|
@ -68,5 +68,91 @@
|
||||
<properties>
|
||||
<jmeter.version>2.6.0</jmeter.version>
|
||||
</properties>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>dashboard</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env</name>
|
||||
<value>dash</value>
|
||||
</property>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>launch-web-app</id>
|
||||
<goals>
|
||||
<goal>start</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<mainClass>com.baeldung.dashboard.DashboardApplication</mainClass>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.lazerycode.jmeter</groupId>
|
||||
<artifactId>jmeter-maven-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<executions>
|
||||
<!-- Generate JMeter configuration -->
|
||||
<execution>
|
||||
<id>configuration</id>
|
||||
<goals>
|
||||
<goal>configure</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<!-- Run JMeter tests -->
|
||||
<execution>
|
||||
<id>jmeter-tests</id>
|
||||
<goals>
|
||||
<goal>jmeter</goal>
|
||||
<goal>results</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<testFilesDirectory>${project.basedir}/src/main/resources/dashboard</testFilesDirectory>
|
||||
<resultsDirectory>${project.basedir}/src/main/resources/dashboard</resultsDirectory>
|
||||
<generateReports>true</generateReports>
|
||||
<ignoreResultFailures>true</ignoreResultFailures>
|
||||
<testResultsTimestamp>false</testResultsTimestamp>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>stop-web-app</id>
|
||||
<goals>
|
||||
<goal>stop</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<jmeter.version>5.5</jmeter.version>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
@ -0,0 +1,15 @@
|
||||
package com.baeldung.dashboard;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
|
||||
|
||||
@SpringBootApplication(exclude = { SecurityAutoConfiguration.class, MongoAutoConfiguration.class, MongoRepositoriesAutoConfiguration.class, MongoDataAutoConfiguration.class })
|
||||
public class DashboardApplication {
|
||||
public static void main(String[] args) throws Exception {
|
||||
SpringApplication.run(DashboardApplication.class, args);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.baeldung.dashboard.controllers;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Random;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import com.baeldung.dashboard.models.Quotes;
|
||||
|
||||
@Controller
|
||||
public class Dashboard {
|
||||
|
||||
@GetMapping("/greeting")
|
||||
public String getGreeting(Model model) {
|
||||
model.addAttribute("host", System.getProperty("os.name"));
|
||||
return "greeting";
|
||||
}
|
||||
|
||||
@GetMapping("/quote")
|
||||
public String getQuote(Model model) throws InterruptedException {
|
||||
Random r = new Random();
|
||||
int day = r.nextInt(7);
|
||||
String quote = Quotes.list.get(day);
|
||||
|
||||
int wait = r.nextInt(6);
|
||||
Thread.currentThread().sleep(wait);
|
||||
model.addAttribute("quote", quote);
|
||||
|
||||
return "quote";
|
||||
}
|
||||
|
||||
@GetMapping("/time")
|
||||
public String getTime(Model model) {
|
||||
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("hh:mm:ss a");
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
model.addAttribute("time", fmt.format(now));
|
||||
return "time";
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.baeldung.dashboard.models;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Quotes {
|
||||
public static final List<String> list = Arrays.asList("The greatest glory in living lies not in never falling, but in rising every time we fall. -Nelson Mandela\r\n",
|
||||
"The way to get started is to quit talking and begin doing. -Walt Disney\r\n",
|
||||
"Your time is limited, so don't waste it living someone else's life. Don't be trapped by dogma – which is living with the results of other people's thinking. -Steve Jobs\r\n",
|
||||
"If life were predictable it would cease to be life, and be without flavor. -Eleanor Roosevelt\r\n",
|
||||
"If you look at what you have in life, you'll always have more. If you look at what you don't have in life, you'll never have enough. -Oprah Winfrey\r\n",
|
||||
"If you set your goals ridiculously high and it's a failure, you will fail above everyone else's success. -James Cameron\r\n", "Life is what happens when you're busy making other plans. -John Lennon");
|
||||
}
|
16
jmeter/src/main/resources/dashboard/ReportsDashboard.csv
Normal file
16
jmeter/src/main/resources/dashboard/ReportsDashboard.csv
Normal file
@ -0,0 +1,16 @@
|
||||
timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect
|
||||
1674622105952,714,HTTP Request (/greeting),200,,Thread Group 1-4,text,true,,430,126,5,5,http://localhost:8080/greeting,705,0,7
|
||||
1674622105450,1216,HTTP Request (/greeting),200,,Thread Group 1-1,text,true,,430,126,5,5,http://localhost:8080/greeting,1207,0,54
|
||||
1674622105468,1198,HTTP Request (/greeting),200,,Thread Group 1-2,text,true,,430,126,5,5,http://localhost:8080/greeting,1189,0,36
|
||||
1674622106064,602,HTTP Request (/greeting),200,,Thread Group 1-5,text,true,,430,126,5,5,http://localhost:8080/greeting,593,0,2
|
||||
1674622105800,866,HTTP Request (/greeting),200,,Thread Group 1-3,text,true,,430,126,5,5,http://localhost:8080/greeting,857,0,1
|
||||
1674622106669,13,HTTP Request (/quote),200,,Thread Group 1-4,text,true,,515,123,5,5,http://localhost:8080/quote,12,0,0
|
||||
1674622106669,16,HTTP Request (/quote),200,,Thread Group 1-2,text,true,,548,123,5,5,http://localhost:8080/quote,16,0,0
|
||||
1674622106671,18,HTTP Request (/quote),200,,Thread Group 1-1,text,true,,629,123,5,5,http://localhost:8080/quote,18,0,0
|
||||
1674622106669,24,HTTP Request (/quote),200,,Thread Group 1-5,text,true,,602,123,5,5,http://localhost:8080/quote,24,0,0
|
||||
1674622106669,29,HTTP Request (/quote),200,,Thread Group 1-3,text,true,,515,123,5,5,http://localhost:8080/quote,29,0,0
|
||||
1674622106690,18,HTTP Request (/time),200,,Thread Group 1-1,text,true,,432,122,5,5,http://localhost:8080/time,18,0,0
|
||||
1674622106699,9,HTTP Request (/time),200,,Thread Group 1-3,text,true,,432,122,5,5,http://localhost:8080/time,9,0,0
|
||||
1674622106683,26,HTTP Request (/time),200,,Thread Group 1-4,text,true,,432,122,5,5,http://localhost:8080/time,25,0,0
|
||||
1674622106688,25,HTTP Request (/time),200,,Thread Group 1-2,text,true,,432,122,2,2,http://localhost:8080/time,25,0,0
|
||||
1674622106695,18,HTTP Request (/time),200,,Thread Group 1-5,text,true,,432,122,2,2,http://localhost:8080/time,17,0,0
|
|
127
jmeter/src/main/resources/dashboard/ReportsDashboard.jmx
Normal file
127
jmeter/src/main/resources/dashboard/ReportsDashboard.jmx
Normal file
@ -0,0 +1,127 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.5">
|
||||
<hashTree>
|
||||
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="ReportsDashboard" enabled="true">
|
||||
<stringProp name="TestPlan.comments"></stringProp>
|
||||
<boolProp name="TestPlan.functional_mode">false</boolProp>
|
||||
<boolProp name="TestPlan.tearDown_on_shutdown">true</boolProp>
|
||||
<boolProp name="TestPlan.serialize_threadgroups">false</boolProp>
|
||||
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
|
||||
<collectionProp name="Arguments.arguments"/>
|
||||
</elementProp>
|
||||
<stringProp name="TestPlan.user_define_classpath"></stringProp>
|
||||
</TestPlan>
|
||||
<hashTree>
|
||||
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
|
||||
<stringProp name="TestPlan.comments">Test Greetings Page</stringProp>
|
||||
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
|
||||
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
|
||||
<boolProp name="LoopController.continue_forever">false</boolProp>
|
||||
<stringProp name="LoopController.loops">1</stringProp>
|
||||
</elementProp>
|
||||
<stringProp name="ThreadGroup.num_threads">5</stringProp>
|
||||
<stringProp name="ThreadGroup.ramp_time">1</stringProp>
|
||||
<boolProp name="ThreadGroup.scheduler">false</boolProp>
|
||||
<stringProp name="ThreadGroup.duration"></stringProp>
|
||||
<stringProp name="ThreadGroup.delay"></stringProp>
|
||||
<boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
|
||||
</ThreadGroup>
|
||||
<hashTree>
|
||||
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Request (/greeting)" enabled="true">
|
||||
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
|
||||
<collectionProp name="Arguments.arguments"/>
|
||||
</elementProp>
|
||||
<stringProp name="HTTPSampler.domain">localhost</stringProp>
|
||||
<stringProp name="HTTPSampler.port">8080</stringProp>
|
||||
<stringProp name="HTTPSampler.protocol"></stringProp>
|
||||
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
|
||||
<stringProp name="HTTPSampler.path">/greeting</stringProp>
|
||||
<stringProp name="HTTPSampler.method">GET</stringProp>
|
||||
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
|
||||
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
|
||||
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
|
||||
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
|
||||
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
|
||||
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
|
||||
<stringProp name="HTTPSampler.response_timeout"></stringProp>
|
||||
</HTTPSamplerProxy>
|
||||
<hashTree/>
|
||||
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Request (/quote)" enabled="true">
|
||||
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
|
||||
<collectionProp name="Arguments.arguments"/>
|
||||
</elementProp>
|
||||
<stringProp name="HTTPSampler.domain">localhost</stringProp>
|
||||
<stringProp name="HTTPSampler.port">8080</stringProp>
|
||||
<stringProp name="HTTPSampler.protocol"></stringProp>
|
||||
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
|
||||
<stringProp name="HTTPSampler.path">/quote</stringProp>
|
||||
<stringProp name="HTTPSampler.method">GET</stringProp>
|
||||
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
|
||||
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
|
||||
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
|
||||
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
|
||||
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
|
||||
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
|
||||
<stringProp name="HTTPSampler.response_timeout"></stringProp>
|
||||
</HTTPSamplerProxy>
|
||||
<hashTree/>
|
||||
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Request (/time)" enabled="true">
|
||||
<elementProp name="HTTPsampler.Arguments" elementType="Arguments" guiclass="HTTPArgumentsPanel" testclass="Arguments" testname="User Defined Variables" enabled="true">
|
||||
<collectionProp name="Arguments.arguments"/>
|
||||
</elementProp>
|
||||
<stringProp name="HTTPSampler.domain">localhost</stringProp>
|
||||
<stringProp name="HTTPSampler.port">8080</stringProp>
|
||||
<stringProp name="HTTPSampler.protocol"></stringProp>
|
||||
<stringProp name="HTTPSampler.contentEncoding"></stringProp>
|
||||
<stringProp name="HTTPSampler.path">/time</stringProp>
|
||||
<stringProp name="HTTPSampler.method">GET</stringProp>
|
||||
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
|
||||
<boolProp name="HTTPSampler.auto_redirects">false</boolProp>
|
||||
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
|
||||
<boolProp name="HTTPSampler.DO_MULTIPART_POST">false</boolProp>
|
||||
<stringProp name="HTTPSampler.embedded_url_re"></stringProp>
|
||||
<stringProp name="HTTPSampler.connect_timeout"></stringProp>
|
||||
<stringProp name="HTTPSampler.response_timeout"></stringProp>
|
||||
</HTTPSamplerProxy>
|
||||
<hashTree/>
|
||||
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree" enabled="true">
|
||||
<boolProp name="ResultCollector.error_logging">false</boolProp>
|
||||
<objProp>
|
||||
<name>saveConfig</name>
|
||||
<value class="SampleSaveConfiguration">
|
||||
<time>true</time>
|
||||
<latency>true</latency>
|
||||
<timestamp>true</timestamp>
|
||||
<success>true</success>
|
||||
<label>true</label>
|
||||
<code>true</code>
|
||||
<message>true</message>
|
||||
<threadName>true</threadName>
|
||||
<dataType>true</dataType>
|
||||
<encoding>false</encoding>
|
||||
<assertions>true</assertions>
|
||||
<subresults>true</subresults>
|
||||
<responseData>false</responseData>
|
||||
<samplerData>false</samplerData>
|
||||
<xml>false</xml>
|
||||
<fieldNames>true</fieldNames>
|
||||
<responseHeaders>false</responseHeaders>
|
||||
<requestHeaders>false</requestHeaders>
|
||||
<responseDataOnError>false</responseDataOnError>
|
||||
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
|
||||
<assertionsResultsToSave>0</assertionsResultsToSave>
|
||||
<bytes>true</bytes>
|
||||
<sentBytes>true</sentBytes>
|
||||
<url>true</url>
|
||||
<threadCounts>true</threadCounts>
|
||||
<idleTime>true</idleTime>
|
||||
<connectTime>true</connectTime>
|
||||
</value>
|
||||
</objProp>
|
||||
<stringProp name="filename">dashapp</stringProp>
|
||||
</ResultCollector>
|
||||
<hashTree/>
|
||||
</hashTree>
|
||||
</hashTree>
|
||||
</hashTree>
|
||||
</jmeterTestPlan>
|
15
jmeter/src/main/resources/static/index.html
Normal file
15
jmeter/src/main/resources/static/index.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Jmeter Dashboard Test APP</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p>Get your Quote <a href="/quote">here</a></p>
|
||||
<p>Get your Time <a href="/time">here</a></p>
|
||||
<p>Get your greeting <a href="/greeting">here</a></p>
|
||||
</body>
|
||||
|
||||
</html>
|
10
jmeter/src/main/resources/templates/greeting.html
Normal file
10
jmeter/src/main/resources/templates/greeting.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>Jmeter Dashboard Test APP</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
</head>
|
||||
<body>
|
||||
<p th:text="'Hello from, ' + ${host} + '!'" />
|
||||
</body>
|
||||
</html>
|
11
jmeter/src/main/resources/templates/quote.html
Normal file
11
jmeter/src/main/resources/templates/quote.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>Jmeter Dashboard Test APP</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
</head>
|
||||
<body>
|
||||
<h1 th:text="'Quote of the day:'" />
|
||||
<p th:text="${quote}" />
|
||||
</body>
|
||||
</html>
|
10
jmeter/src/main/resources/templates/time.html
Normal file
10
jmeter/src/main/resources/templates/time.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head>
|
||||
<title>Jmeter Dashboard Test APP</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
</head>
|
||||
<body>
|
||||
<p th:text="'Current Time: ' + ${time}" />
|
||||
</body>
|
||||
</html>
|
@ -3,11 +3,10 @@
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.example</groupId>
|
||||
<artifactId>demo</artifactId>
|
||||
<artifactId>kubernetes-spring</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>demo</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
<name>kubernetes-spring</name>
|
||||
<description>Intro to Kubernetes with Spring boot</description>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
|
@ -34,6 +34,10 @@
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
|
@ -65,14 +65,14 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.mail</groupId>
|
||||
<artifactId>javax.mail</artifactId>
|
||||
<version>${javax.mail.version}</version>
|
||||
<groupId>org.eclipse.angus</groupId>
|
||||
<artifactId>angus-mail</artifactId>
|
||||
<version>${angus.mail.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>javax.activation-api</artifactId>
|
||||
<version>${javax.activation.version}</version>
|
||||
<groupId>org.eclipse.angus</groupId>
|
||||
<artifactId>angus-activation</artifactId>
|
||||
<version>${angus.activation.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@ -116,8 +116,8 @@
|
||||
<json.version>20180130</json.version>
|
||||
<logback.contrib.version>0.1.5</logback.contrib.version>
|
||||
<docx4j.version>3.3.5</docx4j.version>
|
||||
<javax.mail.version>1.6.2</javax.mail.version>
|
||||
<javax.activation.version>1.2.0</javax.activation.version>
|
||||
<angus.mail.version>2.0.1</angus.mail.version>
|
||||
<angus.activation.version>2.0.0</angus.activation.version>
|
||||
<logback.version>1.3.5</logback.version>
|
||||
<slf4j.version>2.0.4</slf4j.version>
|
||||
</properties>
|
||||
|
@ -49,10 +49,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
@ -78,8 +75,6 @@
|
||||
<properties>
|
||||
<org.mapstruct.version>1.5.3.Final</org.mapstruct.version>
|
||||
<springframework.version>4.3.4.RELEASE</springframework.version>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<lombok.mapstruct.binding.version>0.2.0</lombok.mapstruct.binding.version>
|
||||
</properties>
|
||||
|
||||
|
BIN
pdf/sample.pdf
Normal file
BIN
pdf/sample.pdf
Normal file
Binary file not shown.
@ -0,0 +1,52 @@
|
||||
package com.baeldung.pdfreadertest;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.pdfbox.pdmodel.PDDocument;
|
||||
import org.apache.pdfbox.text.PDFTextStripper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.itextpdf.text.pdf.PdfReader;
|
||||
import com.itextpdf.text.pdf.parser.PdfTextExtractor;
|
||||
|
||||
class ReadPdfFileUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenSamplePdf_whenUsingApachePdfBox_thenCompareOutput() throws IOException {
|
||||
String expectedText = "Hello World!\n";
|
||||
|
||||
File file = new File("sample.pdf");
|
||||
PDDocument document = PDDocument.load(file);
|
||||
|
||||
PDFTextStripper stripper = new PDFTextStripper();
|
||||
|
||||
String text = stripper.getText(document);
|
||||
|
||||
document.close();
|
||||
|
||||
assertEquals(expectedText, text);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenSamplePdf_whenUsingiTextPdf_thenCompareOutput() throws IOException {
|
||||
String expectedText = "Hello World!";
|
||||
|
||||
PdfReader reader = new PdfReader("sample.pdf");
|
||||
int pages = reader.getNumberOfPages();
|
||||
StringBuilder text = new StringBuilder();
|
||||
|
||||
for (int i = 1; i <= pages; i++) {
|
||||
|
||||
text.append(PdfTextExtractor.getTextFromPage(reader, i));
|
||||
|
||||
}
|
||||
reader.close();
|
||||
assertEquals(expectedText, text.toString());
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -42,11 +42,6 @@
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.platform</groupId>
|
||||
<artifactId>junit-platform-runner</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cglib</groupId>
|
||||
<artifactId>cglib-nodep</artifactId>
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.baeldung;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.annotation.DirtiesContext;
|
||||
import org.springframework.test.annotation.DirtiesContext.ClassMode;
|
||||
@ -13,17 +13,17 @@ import redis.embedded.RedisServerBuilder;
|
||||
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = SpringRedisApplication.class)
|
||||
@DirtiesContext(classMode = ClassMode.BEFORE_CLASS)
|
||||
public class SpringContextTest {
|
||||
public class SpringContextLiveTest {
|
||||
|
||||
private static redis.embedded.RedisServer redisServer;
|
||||
|
||||
@BeforeClass
|
||||
@BeforeAll
|
||||
public static void startRedisServer() {
|
||||
redisServer = new RedisServerBuilder().port(6379).setting("maxmemory 256M").build();
|
||||
redisServer.start();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
@AfterAll
|
||||
public static void stopRedisServer() {
|
||||
redisServer.stop();
|
||||
}
|
640
pom.xml
640
pom.xml
@ -330,161 +330,104 @@
|
||||
<module>parent-spring-5</module>
|
||||
<module>parent-java</module>
|
||||
|
||||
<module>akka-modules</module>
|
||||
|
||||
<module>algorithms-modules</module>
|
||||
<module>annotations</module>
|
||||
<module>antlr</module>
|
||||
|
||||
<module>apache-cxf-modules</module>
|
||||
<module>apache-kafka</module>
|
||||
<module>apache-kafka-2</module>
|
||||
<module>apache-libraries</module>
|
||||
<module>apache-olingo</module>
|
||||
<module>apache-poi</module>
|
||||
<module>apache-poi-2</module>
|
||||
<module>apache-rocketmq</module>
|
||||
<module>apache-thrift</module>
|
||||
<module>apache-tika</module>
|
||||
<module>apache-velocity</module>
|
||||
|
||||
<module>di-modules</module>
|
||||
<module>asciidoctor</module>
|
||||
<module>asm</module>
|
||||
|
||||
<module>atomix</module>
|
||||
|
||||
<module>aws-modules</module>
|
||||
|
||||
<module>axon</module>
|
||||
|
||||
<module>azure</module>
|
||||
|
||||
<module>bazel</module>
|
||||
<module>checker-plugin</module>
|
||||
<!-- <module>clojure</module> --> <!-- Not a maven project -->
|
||||
<module>code-generation</module>
|
||||
|
||||
<module>core-groovy-modules</module>
|
||||
|
||||
<module>core-java-modules</module>
|
||||
|
||||
<module>couchbase</module>
|
||||
<module>custom-pmd</module>
|
||||
|
||||
<module>data-structures</module>
|
||||
<module>ddd</module>
|
||||
<module>deeplearning4j</module>
|
||||
<module>di-modules</module>
|
||||
<module>discord4j</module>
|
||||
<module>disruptor</module>
|
||||
<module>dozer</module>
|
||||
<module>drools</module>
|
||||
<module>dubbo</module>
|
||||
|
||||
|
||||
<!-- <module>ethereum</module> --> <!-- JAVA-6001 -->
|
||||
|
||||
<module>feign</module>
|
||||
<!-- <module>gcp-firebase</module> --> <!-- JAVA-16938 -->
|
||||
|
||||
<module>geotools</module>
|
||||
<module>google-cloud</module>
|
||||
|
||||
<!-- <module>gradle-modules</module> --> <!-- Not a maven project -->
|
||||
<module>gradle-modules/gradle/maven-to-gradle</module>
|
||||
<!-- <module>grails</module> --> <!-- Not a maven project -->
|
||||
<module>graphql-modules</module>
|
||||
<module>grpc</module>
|
||||
|
||||
<module>guava-modules</module>
|
||||
<!-- <module>guest</module> --> <!-- not to be built as its for guest articles -->
|
||||
|
||||
<module>hazelcast</module>
|
||||
<module>apache-httpclient</module>
|
||||
<module>httpclient-simple</module>
|
||||
<module>hystrix</module>
|
||||
|
||||
|
||||
<module>jackson-modules</module>
|
||||
<module>jackson-simple</module>
|
||||
<module>java-blockchain</module>
|
||||
|
||||
<module>javafx</module>
|
||||
<module>java-jdi</module>
|
||||
<module>java-rmi</module>
|
||||
<module>java-spi</module>
|
||||
<module>java-websocket</module>
|
||||
<module>javax-sound</module>
|
||||
<module>javaxval</module>
|
||||
<module>javaxval-2</module>
|
||||
<module>javax-validation-advanced</module>
|
||||
|
||||
<module>jaxb</module>
|
||||
<module>jersey</module>
|
||||
<module>jgit</module>
|
||||
<module>jhipster-5</module>
|
||||
<module>jib</module>
|
||||
<module>jmeter</module>
|
||||
<module>jmh</module>
|
||||
<module>java-native</module>
|
||||
|
||||
<module>jsf</module>
|
||||
<module>json-modules</module>
|
||||
<module>jsoup</module>
|
||||
|
||||
<module>kubernetes-modules</module>
|
||||
<module>ksqldb</module>
|
||||
|
||||
<!-- <module>lagom</module> --> <!-- Not a maven project -->
|
||||
<module>language-interop</module>
|
||||
<module>libraries-2</module>
|
||||
<module>libraries-3</module>
|
||||
<module>libraries-7</module>
|
||||
|
||||
<module>libraries-apache-commons</module>
|
||||
<module>libraries-apache-commons-collections</module>
|
||||
<module>libraries-apache-commons-io</module>
|
||||
<module>libraries-data</module>
|
||||
<module>libraries-data-2</module>
|
||||
|
||||
|
||||
<module>libraries-data-db</module>
|
||||
<module>libraries-data-io</module>
|
||||
<module>libraries-files</module>
|
||||
<module>libraries-http</module>
|
||||
<module>libraries-http-2</module>
|
||||
<module>libraries-io</module>
|
||||
<module>libraries-primitive</module>
|
||||
<module>libraries-rpc</module>
|
||||
<module>libraries-security</module>
|
||||
<module>libraries-server</module>
|
||||
<module>libraries-server-2</module>
|
||||
<module>libraries-testing</module>
|
||||
<module>logging-modules</module>
|
||||
<module>lombok-modules</module>
|
||||
<module>lucene</module>
|
||||
<module>mapstruct</module>
|
||||
|
||||
<module>maven-modules</module>
|
||||
|
||||
<module>mesos-marathon</module>
|
||||
<module>messaging-modules</module>
|
||||
<module>metrics</module>
|
||||
|
||||
<module>microservices-modules</module>
|
||||
<module>muleesb</module>
|
||||
<module>mustache</module>
|
||||
<module>mybatis</module>
|
||||
|
||||
|
||||
<module>netflix-modules</module>
|
||||
|
||||
<module>orika</module>
|
||||
<module>osgi</module>
|
||||
<module>orika</module>
|
||||
|
||||
<module>patterns-modules</module>
|
||||
<module>pdf</module>
|
||||
<module>pdf-2</module>
|
||||
|
||||
<module>performance-tests</module>
|
||||
<module>persistence-modules</module>
|
||||
<module>protobuffer</module>
|
||||
|
||||
|
||||
<module>quarkus-modules</module>
|
||||
|
||||
<module>reactor-core</module>
|
||||
<module>rsocket</module>
|
||||
<module>rule-engines-modules</module>
|
||||
<module>rxjava-modules</module>
|
||||
<module>atomikos</module>
|
||||
|
||||
<module>reactive-systems</module>
|
||||
<module>security-modules</module>
|
||||
<module>slack</module>
|
||||
|
||||
<module>vavr-modules</module>
|
||||
<module>web-modules</module>
|
||||
</modules>
|
||||
@ -533,93 +476,51 @@
|
||||
|
||||
<module>saas-modules</module>
|
||||
<module>server-modules</module>
|
||||
|
||||
<module>spf4j</module>
|
||||
|
||||
<module>spring-4</module>
|
||||
|
||||
<module>spring-5</module>
|
||||
<module>spring-reactive-modules</module>
|
||||
<module>spring-5-webflux</module>
|
||||
<module>spring-5-webflux-2</module>
|
||||
|
||||
<module>spring-activiti</module>
|
||||
<module>spring-aop</module>
|
||||
<module>spring-aop-2</module>
|
||||
|
||||
<module>spring-batch</module>
|
||||
<module>spring-batch-2</module>
|
||||
<module>spring-bom</module>
|
||||
<module>spring-boot-modules</module>
|
||||
<module>spring-boot-rest</module>
|
||||
|
||||
<module>spring-caching</module>
|
||||
<module>spring-caching-2</module>
|
||||
|
||||
<module>spring-cloud-modules</module>
|
||||
<!-- <module>spring-cloud-cli</module> --> <!-- Not a maven project -->
|
||||
|
||||
<module>spring-core</module>
|
||||
<module>spring-core-2</module>
|
||||
<module>spring-core-3</module>
|
||||
<module>spring-core-4</module>
|
||||
<module>spring-core-5</module>
|
||||
<module>spring-credhub</module>
|
||||
<module>spring-cucumber</module>
|
||||
|
||||
<module>spring-di</module>
|
||||
<module>spring-di-2</module>
|
||||
<module>spring-di-3</module>
|
||||
<module>spring-drools</module>
|
||||
|
||||
<module>spring-ejb-modules</module>
|
||||
|
||||
<module>spring-exceptions</module>
|
||||
|
||||
<module>spring-integration</module>
|
||||
|
||||
<module>spring-jenkins-pipeline</module>
|
||||
<module>spring-jersey</module>
|
||||
<module>spring-jinq</module>
|
||||
|
||||
<module>spring-kafka</module>
|
||||
<module>spring-katharsis</module>
|
||||
|
||||
<module>spring-mobile</module>
|
||||
<module>spring-native</module>
|
||||
<module>spring-protobuf</module>
|
||||
<module>spring-quartz</module>
|
||||
|
||||
<module>spring-remoting-modules</module>
|
||||
|
||||
<!-- <module>spring-roo</module> --> <!-- JAVA-17327 -->
|
||||
|
||||
<module>spring-scheduling</module>
|
||||
<module>spring-security-modules</module>
|
||||
<module>spring-shell</module>
|
||||
<module>spring-soap</module>
|
||||
<module>spring-spel</module>
|
||||
<module>spring-state-machine</module>
|
||||
<module>spring-static-resources</module>
|
||||
<module>spring-swagger-codegen</module>
|
||||
|
||||
<module>spring-threads</module>
|
||||
|
||||
<module>spring-vault</module>
|
||||
|
||||
<module>spring-web-modules</module>
|
||||
<module>spring-websockets</module>
|
||||
|
||||
<module>static-analysis</module>
|
||||
|
||||
<module>tensorflow-java</module>
|
||||
<module>testing-modules</module>
|
||||
|
||||
<module>vertx-modules</module>
|
||||
<module>video-tutorials</module>
|
||||
|
||||
<module>webrtc</module>
|
||||
<module>xml</module>
|
||||
<module>xml-2</module>
|
||||
<module>xstream</module>
|
||||
</modules>
|
||||
|
||||
</profile>
|
||||
@ -674,7 +575,6 @@
|
||||
<module>libraries-4</module>
|
||||
<module>libraries-5</module>
|
||||
<module>libraries-6</module>
|
||||
|
||||
<module>spring-boot-modules/spring-boot-react</module>
|
||||
<module>spring-ejb-modules/ejb-beans</module>
|
||||
|
||||
@ -715,161 +615,104 @@
|
||||
<module>parent-spring-5</module>
|
||||
<module>parent-java</module>
|
||||
|
||||
<module>akka-modules</module>
|
||||
|
||||
<module>algorithms-modules</module>
|
||||
<module>annotations</module>
|
||||
<module>antlr</module>
|
||||
|
||||
<module>apache-cxf-modules</module>
|
||||
<module>apache-kafka</module>
|
||||
<module>apache-kafka-2</module>
|
||||
<module>apache-libraries</module>
|
||||
<module>apache-olingo</module>
|
||||
<module>apache-poi</module>
|
||||
<module>apache-poi-2</module>
|
||||
<module>apache-rocketmq</module>
|
||||
<module>apache-thrift</module>
|
||||
<module>apache-tika</module>
|
||||
<module>apache-velocity</module>
|
||||
|
||||
<module>di-modules</module>
|
||||
<module>asciidoctor</module>
|
||||
<module>asm</module>
|
||||
|
||||
<module>atomix</module>
|
||||
|
||||
<module>aws-modules</module>
|
||||
|
||||
<module>axon</module>
|
||||
|
||||
<module>azure</module>
|
||||
|
||||
<module>bazel</module>
|
||||
<module>checker-plugin</module>
|
||||
<!-- <module>clojure</module> --> <!-- Not a maven project -->
|
||||
<module>code-generation</module>
|
||||
|
||||
<module>core-groovy-modules</module>
|
||||
|
||||
<module>core-java-modules</module>
|
||||
|
||||
<module>couchbase</module>
|
||||
<module>custom-pmd</module>
|
||||
|
||||
<module>data-structures</module>
|
||||
<module>ddd</module>
|
||||
<module>deeplearning4j</module>
|
||||
<module>di-modules</module>
|
||||
<module>discord4j</module>
|
||||
<module>disruptor</module>
|
||||
<module>dozer</module>
|
||||
<module>drools</module>
|
||||
<module>dubbo</module>
|
||||
|
||||
|
||||
<!-- <module>ethereum</module> --> <!-- JAVA-6001 -->
|
||||
|
||||
<module>feign</module>
|
||||
<!-- <module>gcp-firebase</module> --> <!-- JAVA-16938 -->
|
||||
|
||||
<module>geotools</module>
|
||||
<module>google-cloud</module>
|
||||
|
||||
<!-- <module>gradle-modules</module> --> <!-- Not a maven project -->
|
||||
<module>gradle-modules/gradle/maven-to-gradle</module>
|
||||
<!-- <module>grails</module> --> <!-- Not a maven project -->
|
||||
<module>graphql-modules</module>
|
||||
<module>grpc</module>
|
||||
|
||||
<module>guava-modules</module>
|
||||
<!-- <module>guest</module> --> <!-- not to be built as its for guest articles -->
|
||||
|
||||
<module>hazelcast</module>
|
||||
<module>apache-httpclient</module>
|
||||
<module>httpclient-simple</module>
|
||||
<module>hystrix</module>
|
||||
|
||||
|
||||
<module>jackson-modules</module>
|
||||
<module>jackson-simple</module>
|
||||
<module>java-blockchain</module>
|
||||
|
||||
<module>javafx</module>
|
||||
<module>java-jdi</module>
|
||||
<module>java-rmi</module>
|
||||
<module>java-spi</module>
|
||||
<module>java-websocket</module>
|
||||
<module>javax-sound</module>
|
||||
<module>javaxval</module>
|
||||
<module>javaxval-2</module>
|
||||
<module>javax-validation-advanced</module>
|
||||
|
||||
<module>jaxb</module>
|
||||
<module>jersey</module>
|
||||
<module>jgit</module>
|
||||
<module>jhipster-5</module>
|
||||
<module>jib</module>
|
||||
<module>jmeter</module>
|
||||
<module>jmh</module>
|
||||
<module>java-native</module>
|
||||
|
||||
<module>jsf</module>
|
||||
<module>json-modules</module>
|
||||
<module>jsoup</module>
|
||||
|
||||
<module>kubernetes-modules</module>
|
||||
<module>ksqldb</module>
|
||||
|
||||
<!-- <module>lagom</module> --> <!-- Not a maven project -->
|
||||
<module>language-interop</module>
|
||||
<module>libraries-2</module>
|
||||
<module>libraries-3</module>
|
||||
<module>libraries-7</module>
|
||||
|
||||
<module>libraries-apache-commons</module>
|
||||
<module>libraries-apache-commons-collections</module>
|
||||
<module>libraries-apache-commons-io</module>
|
||||
<module>libraries-data</module>
|
||||
<module>libraries-data-2</module>
|
||||
|
||||
|
||||
<module>libraries-data-db</module>
|
||||
<module>libraries-data-io</module>
|
||||
<module>libraries-files</module>
|
||||
<module>libraries-http</module>
|
||||
<module>libraries-http-2</module>
|
||||
<module>libraries-io</module>
|
||||
<module>libraries-primitive</module>
|
||||
<module>libraries-rpc</module>
|
||||
<module>libraries-security</module>
|
||||
<module>libraries-server</module>
|
||||
<module>libraries-server-2</module>
|
||||
<module>libraries-testing</module>
|
||||
<module>logging-modules</module>
|
||||
<module>lombok-modules</module>
|
||||
<module>lucene</module>
|
||||
<module>mapstruct</module>
|
||||
|
||||
<module>maven-modules</module>
|
||||
|
||||
<module>mesos-marathon</module>
|
||||
<module>messaging-modules</module>
|
||||
<module>metrics</module>
|
||||
|
||||
<module>microservices-modules</module>
|
||||
<module>muleesb</module>
|
||||
<module>mustache</module>
|
||||
<module>mybatis</module>
|
||||
|
||||
|
||||
<module>netflix-modules</module>
|
||||
|
||||
<module>orika</module>
|
||||
<module>osgi</module>
|
||||
<module>orika</module>
|
||||
|
||||
<module>patterns-modules</module>
|
||||
<module>pdf</module>
|
||||
<module>pdf-2</module>
|
||||
|
||||
<module>performance-tests</module>
|
||||
<module>persistence-modules</module>
|
||||
<module>protobuffer</module>
|
||||
|
||||
|
||||
<module>quarkus-modules</module>
|
||||
|
||||
<module>reactor-core</module>
|
||||
<module>rsocket</module>
|
||||
<module>rule-engines-modules</module>
|
||||
<module>rxjava-modules</module>
|
||||
<module>atomikos</module>
|
||||
|
||||
<module>reactive-systems</module>
|
||||
<module>security-modules</module>
|
||||
<module>slack</module>
|
||||
|
||||
<module>vavr-modules</module>
|
||||
<module>web-modules</module>
|
||||
</modules>
|
||||
@ -910,94 +753,50 @@
|
||||
|
||||
<module>saas-modules</module>
|
||||
<module>server-modules</module>
|
||||
|
||||
<module>spf4j</module>
|
||||
|
||||
<module>spring-4</module>
|
||||
|
||||
<module>spring-5</module>
|
||||
<module>spring-reactive-modules</module>
|
||||
<module>spring-5-webflux</module>
|
||||
<module>spring-5-webflux-2</module>
|
||||
|
||||
|
||||
<module>spring-activiti</module>
|
||||
<module>spring-aop</module>
|
||||
<module>spring-aop-2</module>
|
||||
|
||||
<module>spring-batch</module>
|
||||
<module>spring-batch-2</module>
|
||||
<module>spring-bom</module>
|
||||
<module>spring-boot-modules</module>
|
||||
<module>spring-boot-rest</module>
|
||||
|
||||
<module>spring-caching</module>
|
||||
<module>spring-caching-2</module>
|
||||
|
||||
<module>spring-cloud-modules</module>
|
||||
<!-- <module>spring-cloud-cli</module> --> <!-- Not a maven project -->
|
||||
|
||||
<module>spring-core</module>
|
||||
<module>spring-core-2</module>
|
||||
<module>spring-core-3</module>
|
||||
<module>spring-core-4</module>
|
||||
<module>spring-core-5</module>
|
||||
<module>spring-credhub</module>
|
||||
<module>spring-cucumber</module>
|
||||
|
||||
<module>spring-di</module>
|
||||
<module>spring-di-2</module>
|
||||
<module>spring-di-3</module>
|
||||
<module>spring-drools</module>
|
||||
|
||||
<module>spring-ejb-modules</module>
|
||||
<module>spring-exceptions</module>
|
||||
|
||||
<module>spring-integration</module>
|
||||
|
||||
<module>spring-jenkins-pipeline</module>
|
||||
<module>spring-jersey</module>
|
||||
<module>spring-jinq</module>
|
||||
|
||||
<module>spring-kafka</module>
|
||||
<module>spring-katharsis</module>
|
||||
|
||||
<module>spring-mobile</module>
|
||||
<module>spring-native</module>
|
||||
<module>spring-protobuf</module>
|
||||
<module>spring-quartz</module>
|
||||
|
||||
<module>spring-remoting-modules</module>
|
||||
|
||||
<!-- <module>spring-roo</module> --> <!-- JAVA-17327 -->
|
||||
|
||||
<module>spring-scheduling</module>
|
||||
<module>spring-security-modules</module>
|
||||
<module>spring-shell</module>
|
||||
<module>spring-soap</module>
|
||||
<module>spring-spel</module>
|
||||
<module>spring-state-machine</module>
|
||||
<module>spring-static-resources</module>
|
||||
<module>spring-swagger-codegen</module>
|
||||
|
||||
<module>spring-threads</module>
|
||||
|
||||
<module>spring-vault</module>
|
||||
|
||||
<module>spring-web-modules</module>
|
||||
<module>spring-websockets</module>
|
||||
|
||||
<module>static-analysis</module>
|
||||
|
||||
<module>tensorflow-java</module>
|
||||
<module>testing-modules</module>
|
||||
|
||||
<module>vertx-modules</module>
|
||||
<module>video-tutorials</module>
|
||||
|
||||
<module>webrtc</module>
|
||||
<module>xml</module>
|
||||
<module>xml-2</module>
|
||||
<module>xstream</module>
|
||||
</modules>
|
||||
|
||||
</profile>
|
||||
@ -1044,12 +843,10 @@
|
||||
<module>libraries-4</module>
|
||||
<module>libraries-5</module>
|
||||
<module>libraries-6</module>
|
||||
|
||||
<module>spring-boot-modules/spring-boot-react</module>
|
||||
<module>spring-ejb-modules/ejb-beans</module>
|
||||
|
||||
<module>vaadin</module>
|
||||
<module>vavr-modules</module>
|
||||
<module>vavr-modules</module>
|
||||
</modules>
|
||||
|
||||
</profile>
|
||||
@ -1119,64 +916,173 @@
|
||||
<module>core-java-modules/core-java-9-improvements</module>
|
||||
<module>core-java-modules/core-java-9-jigsaw</module>
|
||||
<!-- <module>core-java-modules/core-java-9-new-features</module> --> <!-- uses preview features, to be decided how to handle -->
|
||||
<module>core-java-modules/core-java-9-streams</module>
|
||||
<module>core-java-modules/core-java-10</module>
|
||||
<module>core-java-modules/core-java-11</module>
|
||||
<module>core-java-modules/core-java-11-2</module>
|
||||
<module>core-java-modules/core-java-11-3</module>
|
||||
<!-- <module>core-java-modules/core-java-12</module> --> <!-- uses preview features, to be decided how to handle -->
|
||||
<!-- <module>core-java-modules/core-java-13</module> --> <!-- uses preview features, to be decided how to handle -->
|
||||
<!-- <module>core-java-modules/core-java-14</module> --> <!-- uses preview features, to be decided how to handle -->
|
||||
<!-- <module>core-java-modules/core-java-15</module> --> <!-- uses preview features, to be decided how to handle -->
|
||||
<!-- <module>core-java-modules/core-java-16</module> --> <!-- uses preview features, to be decided how to handle -->
|
||||
<!-- <module>core-java-modules/core-java-17</module> --> <!-- uses preview features, to be decided how to handle -->
|
||||
<!-- <module>core-java-modules/core-java-19</module> --> <!-- uses preview features, to be decided how to handle -->
|
||||
<module>core-java-modules/core-java-collections-set</module>
|
||||
<module>core-java-modules/core-java-collections-list-4</module>
|
||||
<module>core-java-modules/core-java-collections-array-list</module>
|
||||
<module>core-java-modules/core-java-collections-maps-4</module>
|
||||
<module>core-java-modules/core-java-collections-maps-5</module>
|
||||
<module>core-java-modules/core-java-concurrency-simple</module>
|
||||
<module>core-java-modules/core-java-date-operations-1</module>
|
||||
<module>core-java-modules/core-java-datetime-conversion</module>
|
||||
<module>core-java-modules/core-java-datetime-string</module>
|
||||
<module>core-java-modules/core-java-io-conversions-2</module>
|
||||
<module>core-java-modules/core-java-jpms</module>
|
||||
<module>core-java-modules/core-java-os</module>
|
||||
<module>core-java-modules/core-java-streams-4</module>
|
||||
<module>core-java-modules/core-java-string-algorithms-3</module>
|
||||
<module>core-java-modules/core-java-string-operations-3</module>
|
||||
<module>core-java-modules/core-java-string-operations-4</module>
|
||||
<module>core-java-modules/core-java-string-operations-5</module>
|
||||
<module>core-java-modules/core-java-time-measurements</module>
|
||||
<module>core-java-modules/core-java-networking-3</module>
|
||||
<module>core-java-modules/core-java-strings</module>
|
||||
<module>core-java-modules/core-java-httpclient</module>
|
||||
<module>spring-core-6</module>
|
||||
<module>ddd-contexts</module>
|
||||
<module>docker-modules</module>
|
||||
<module>apache-httpclient-2</module>
|
||||
<module>kubernetes-modules/kubernetes-spring</module>
|
||||
<module>libraries-concurrency</module>
|
||||
<module>maven-modules/compiler-plugin-java-9</module>
|
||||
<module>maven-modules/maven-generate-war</module>
|
||||
<module>maven-modules/multimodulemavenproject</module>
|
||||
<module>optaplanner</module>
|
||||
<module>persistence-modules/sirix</module>
|
||||
<module>persistence-modules/spring-data-cassandra-2</module>
|
||||
<module>quarkus-modules/quarkus-vs-springboot</module>
|
||||
<module>quarkus-modules/quarkus-jandex</module>
|
||||
<module>spring-boot-modules/spring-boot-cassandre</module>
|
||||
<module>spring-boot-modules/spring-boot-camel</module>
|
||||
<module>spring-boot-modules/spring-boot-3</module>
|
||||
<module>spring-boot-modules/spring-boot-3-native</module>
|
||||
<module>core-java-modules/core-java-9-streams</module>
|
||||
<module>core-java-modules/core-java-10</module>
|
||||
<module>core-java-modules/core-java-11</module>
|
||||
<module>core-java-modules/core-java-11-2</module>
|
||||
<module>core-java-modules/core-java-11-3</module>
|
||||
<!-- <module>core-java-modules/core-java-12</module> --> <!-- uses preview features, to be decided how to handle -->
|
||||
<!-- <module>core-java-modules/core-java-13</module> --> <!-- uses preview features, to be decided how to handle -->
|
||||
<!-- <module>core-java-modules/core-java-14</module> --> <!-- uses preview features, to be decided how to handle -->
|
||||
<!-- <module>core-java-modules/core-java-15</module> --> <!-- uses preview features, to be decided how to handle -->
|
||||
<!-- <module>core-java-modules/core-java-16</module> --> <!-- uses preview features, to be decided how to handle -->
|
||||
<!-- <module>core-java-modules/core-java-17</module> --> <!-- uses preview features, to be decided how to handle -->
|
||||
<!-- <module>core-java-modules/core-java-19</module> --> <!-- uses preview features, to be decided how to handle -->
|
||||
<module>core-java-modules/core-java-collections-set</module>
|
||||
<module>core-java-modules/core-java-collections-list-4</module>
|
||||
<module>core-java-modules/core-java-collections-array-list</module>
|
||||
<module>core-java-modules/core-java-collections-maps-4</module>
|
||||
<module>core-java-modules/core-java-collections-maps-5</module>
|
||||
<module>core-java-modules/core-java-concurrency-simple</module>
|
||||
<module>core-java-modules/core-java-date-operations-1</module>
|
||||
<module>core-java-modules/core-java-datetime-conversion</module>
|
||||
<module>core-java-modules/core-java-datetime-string</module>
|
||||
<module>core-java-modules/core-java-io-conversions-2</module>
|
||||
<module>core-java-modules/core-java-jpms</module>
|
||||
<module>core-java-modules/core-java-os</module>
|
||||
<module>core-java-modules/core-java-streams-4</module>
|
||||
<module>core-java-modules/core-java-string-algorithms-3</module>
|
||||
<module>core-java-modules/core-java-string-operations-3</module>
|
||||
<module>core-java-modules/core-java-string-operations-4</module>
|
||||
<module>core-java-modules/core-java-string-operations-5</module>
|
||||
<module>core-java-modules/core-java-time-measurements</module>
|
||||
<module>core-java-modules/core-java-networking-3</module>
|
||||
<module>core-java-modules/core-java-strings</module>
|
||||
<module>core-java-modules/core-java-httpclient</module>
|
||||
<module>spring-core-6</module>
|
||||
<module>ddd-contexts</module>
|
||||
<module>docker-modules</module>
|
||||
<module>apache-httpclient-2</module>
|
||||
<module>kubernetes-modules/kubernetes-spring</module>
|
||||
<module>libraries-concurrency</module>
|
||||
<module>maven-modules/compiler-plugin-java-9</module>
|
||||
<module>maven-modules/maven-generate-war</module>
|
||||
<module>maven-modules/multimodulemavenproject</module>
|
||||
<module>optaplanner</module>
|
||||
<module>persistence-modules/sirix</module>
|
||||
<module>persistence-modules/spring-data-cassandra-2</module>
|
||||
<module>quarkus-modules/quarkus-vs-springboot</module>
|
||||
<module>quarkus-modules/quarkus-jandex</module>
|
||||
<module>spring-boot-modules/spring-boot-cassandre</module>
|
||||
<module>spring-boot-modules/spring-boot-camel</module>
|
||||
<module>spring-boot-modules/spring-boot-3</module>
|
||||
<module>spring-boot-modules/spring-boot-3-native</module>
|
||||
<module>spring-boot-modules/spring-boot-3-observation</module>
|
||||
<module>spring-swagger-codegen/custom-validations-opeanpi-codegen</module>
|
||||
<module>testing-modules/testing-assertions</module>
|
||||
<module>persistence-modules/fauna</module>
|
||||
<module>lightrun</module>
|
||||
<module>tablesaw</module>
|
||||
<module>spring-swagger-codegen/custom-validations-opeanpi-codegen</module>
|
||||
<module>testing-modules/testing-assertions</module>
|
||||
<module>persistence-modules/fauna</module>
|
||||
<module>lightrun</module>
|
||||
<module>tablesaw</module>
|
||||
|
||||
<!-- Modules from default-first -->
|
||||
|
||||
<module>akka-modules</module>
|
||||
<module>annotations</module>
|
||||
<module>apache-httpclient</module>
|
||||
<module>antlr</module>
|
||||
<module>apache-kafka</module>
|
||||
<module>apache-kafka-2</module>
|
||||
<module>apache-olingo</module>
|
||||
|
||||
<module>apache-poi-2</module>
|
||||
<module>apache-rocketmq</module>
|
||||
<module>apache-thrift</module>
|
||||
<module>apache-tika</module>
|
||||
|
||||
<module>asm</module>
|
||||
<module>atomikos</module>
|
||||
<module>atomix</module>
|
||||
<module>axon</module>
|
||||
|
||||
<module>bazel</module>
|
||||
<module>code-generation</module>
|
||||
<module>ddd</module>
|
||||
<module>discord4j</module>
|
||||
<module>disruptor</module>
|
||||
<module>dozer</module>
|
||||
<module>dubbo</module>
|
||||
<module>feign</module>
|
||||
<module>google-cloud</module>
|
||||
<module>graphql-modules</module>
|
||||
<module>grpc</module>
|
||||
<module>hazelcast</module>
|
||||
<module>hystrix</module>
|
||||
<module>jackson-simple</module>
|
||||
<module>java-blockchain</module>
|
||||
|
||||
<module>java-rmi</module>
|
||||
<module>java-spi</module>
|
||||
<module>javax-sound</module>
|
||||
<module>javaxval</module>
|
||||
<module>javaxval-2</module>
|
||||
<module>javax-validation-advanced</module>
|
||||
<module>jgit</module>
|
||||
<module>jib</module>
|
||||
|
||||
<module>java-native</module>
|
||||
<module>jsoup</module>
|
||||
<module>ksqldb</module>
|
||||
<module>libraries-7</module>
|
||||
<module>libraries-apache-commons</module>
|
||||
<module>libraries-apache-commons-collections</module>
|
||||
<module>libraries-apache-commons-io</module>
|
||||
<module>libraries-data-2</module>
|
||||
<module>libraries-data-io</module>
|
||||
<module>libraries-files</module>
|
||||
<module>libraries-http</module>
|
||||
<module>libraries-http-2</module>
|
||||
<module>libraries-io</module>
|
||||
<module>libraries-primitive</module>
|
||||
<module>libraries-rpc</module>
|
||||
<module>libraries-server</module>
|
||||
|
||||
<module>lucene</module>
|
||||
<module>mapstruct</module>
|
||||
<module>mesos-marathon</module>
|
||||
<module>metrics</module>
|
||||
<module>mustache</module>
|
||||
<module>mybatis</module>
|
||||
<module>pdf</module>
|
||||
<module>pdf-2</module>
|
||||
<module>protobuffer</module>
|
||||
<module>reactor-core</module>
|
||||
<module>rsocket</module>
|
||||
<module>slack</module>
|
||||
|
||||
|
||||
<!-- Modules from default second-->
|
||||
<module>spring-5</module>
|
||||
<module>spring-5-webflux</module>
|
||||
<module>spring-5-webflux-2</module>
|
||||
<module>spring-activiti</module>
|
||||
<module>spring-batch-2</module>
|
||||
<module>spring-caching-2</module>
|
||||
<module>spring-core-2</module>
|
||||
<module>spring-core-3</module>
|
||||
<module>spring-core-5</module>
|
||||
<module>spring-di-3</module>
|
||||
<module>spring-cucumber</module>
|
||||
|
||||
<module>spring-kafka</module>
|
||||
|
||||
<module>spring-native</module>
|
||||
<module>spring-protobuf</module>
|
||||
<module>spring-quartz</module>
|
||||
|
||||
<module>spring-scheduling</module>
|
||||
|
||||
<module>spring-state-machine</module>
|
||||
<module>spring-threads</module>
|
||||
<module>tensorflow-java</module>
|
||||
<module>xstream</module>
|
||||
<module>webrtc</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>11</java.version>
|
||||
<java.version>11</java.version>
|
||||
</properties>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
@ -1217,8 +1123,10 @@
|
||||
<!-- <module>core-java-modules/core-java-15</module> --> <!-- uses preview features, to be decided how to handle -->
|
||||
<!-- <module>core-java-modules/core-java-16</module> --> <!-- uses preview features, to be decided how to handle -->
|
||||
<!-- <module>core-java-modules/core-java-17</module> --> <!-- uses preview features, to be decided how to handle -->
|
||||
<!-- <module>core-java-modules/core-java-19</module> --> <!-- uses preview features, to be decided how to handle -->
|
||||
<module>core-java-modules/core-java-collections-set</module>
|
||||
<module>core-java-modules/core-java-collections-list-4</module>
|
||||
<module>core-java-modules/core-java-collections-array-list</module>
|
||||
<module>core-java-modules/core-java-collections-maps-4</module>
|
||||
<module>core-java-modules/core-java-collections-maps-5</module>
|
||||
<module>core-java-modules/core-java-concurrency-simple</module>
|
||||
@ -1237,6 +1145,7 @@
|
||||
<module>core-java-modules/core-java-networking-3</module>
|
||||
<module>core-java-modules/core-java-strings</module>
|
||||
<module>core-java-modules/core-java-httpclient</module>
|
||||
<module>spring-core-6</module>
|
||||
<module>ddd-contexts</module>
|
||||
<module>docker-modules</module>
|
||||
<module>apache-httpclient-2</module>
|
||||
@ -1259,9 +1168,132 @@
|
||||
<module>testing-modules/testing-assertions</module>
|
||||
<module>persistence-modules/fauna</module>
|
||||
<module>lightrun</module>
|
||||
<module>spring-core-6</module>
|
||||
<module>tablesaw</module>
|
||||
|
||||
<!-- Modules from default-first -->
|
||||
|
||||
<module>akka-modules</module>
|
||||
<module>annotations</module>
|
||||
<module>apache-httpclient</module>
|
||||
<module>antlr</module>
|
||||
<module>apache-kafka</module>
|
||||
<module>apache-kafka-2</module>
|
||||
<module>apache-olingo</module>
|
||||
|
||||
<module>apache-poi-2</module>
|
||||
<module>apache-rocketmq</module>
|
||||
<module>apache-thrift</module>
|
||||
<module>apache-tika</module>
|
||||
|
||||
<module>asm</module>
|
||||
<module>atomikos</module>
|
||||
<module>atomix</module>
|
||||
<module>axon</module>
|
||||
|
||||
<module>bazel</module>
|
||||
<module>code-generation</module>
|
||||
<module>ddd</module>
|
||||
<module>discord4j</module>
|
||||
<module>disruptor</module>
|
||||
<module>dozer</module>
|
||||
|
||||
<module>dubbo</module>
|
||||
<module>feign</module>
|
||||
<module>google-cloud</module>
|
||||
<module>graphql-modules</module>
|
||||
<module>grpc</module>
|
||||
<module>hazelcast</module>
|
||||
<module>hystrix</module>
|
||||
<module>jackson-simple</module>
|
||||
<module>java-blockchain</module>
|
||||
|
||||
<module>java-rmi</module>
|
||||
<module>java-spi</module>
|
||||
<module>javax-sound</module>
|
||||
<module>javaxval</module>
|
||||
<module>javaxval-2</module>
|
||||
<module>javax-validation-advanced</module>
|
||||
<module>jgit</module>
|
||||
<module>jib</module>
|
||||
|
||||
<module>java-native</module>
|
||||
<module>jsoup</module>
|
||||
<module>ksqldb</module>
|
||||
|
||||
<module>libraries-7</module>
|
||||
<module>libraries-apache-commons</module>
|
||||
<module>libraries-apache-commons-collections</module>
|
||||
<module>libraries-apache-commons-io</module>
|
||||
<module>libraries-data-2</module>
|
||||
<module>libraries-data-io</module>
|
||||
<module>libraries-files</module>
|
||||
<module>libraries-http</module>
|
||||
<module>libraries-http-2</module>
|
||||
<module>libraries-io</module>
|
||||
<module>libraries-primitive</module>
|
||||
<module>libraries-rpc</module>
|
||||
<module>libraries-server</module>
|
||||
|
||||
<module>lucene</module>
|
||||
<module>mapstruct</module>
|
||||
<module>mesos-marathon</module>
|
||||
<module>metrics</module>
|
||||
<module>mustache</module>
|
||||
<module>mybatis</module>
|
||||
<module>pdf</module>
|
||||
<module>pdf-2</module>
|
||||
<module>protobuffer</module>
|
||||
<module>reactor-core</module>
|
||||
<module>rsocket</module>
|
||||
<module>slack</module>
|
||||
|
||||
|
||||
<!-- Modules from default second-->
|
||||
|
||||
<module>spring-5</module>
|
||||
<module>spring-5-webflux</module>
|
||||
<module>spring-5-webflux-2</module>
|
||||
<module>spring-activiti</module>
|
||||
<module>spring-batch-2</module>
|
||||
<module>spring-caching-2</module>
|
||||
<module>spring-core-2</module>
|
||||
<module>spring-core-3</module>
|
||||
<module>spring-core-5</module>
|
||||
<module>spring-di-3</module>
|
||||
<module>spring-cucumber</module>
|
||||
|
||||
<module>spring-kafka</module>
|
||||
|
||||
<module>spring-native</module>
|
||||
<module>spring-protobuf</module>
|
||||
<module>spring-quartz</module>
|
||||
|
||||
<module>spring-scheduling</module>
|
||||
|
||||
<module>spring-state-machine</module>
|
||||
<module>spring-threads</module>
|
||||
<module>tensorflow-java</module>
|
||||
<module>xstream</module>
|
||||
<module>webrtc</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>11</java.version>
|
||||
<java.version>11</java.version>
|
||||
</properties>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>parents</id>
|
||||
<modules>
|
||||
<module>parent-boot-1</module>
|
||||
<module>parent-boot-2</module>
|
||||
<module>parent-spring-4</module>
|
||||
<module>parent-spring-5</module>
|
||||
<module>parent-java</module>
|
||||
</modules>
|
||||
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
|
@ -1,22 +1,22 @@
|
||||
package com.baeldung.webflux.caching;
|
||||
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import reactor.cache.CacheMono;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Service
|
||||
public class ItemService {
|
||||
|
||||
private final ItemRepository repository;
|
||||
private final LoadingCache<String, Object> cache;
|
||||
private final LoadingCache<String, Mono<Item>> cache;
|
||||
|
||||
public ItemService(ItemRepository repository) {
|
||||
this.repository = repository;
|
||||
this.cache = Caffeine.newBuilder()
|
||||
.build(this::getItem_withAddons);
|
||||
this.cache = Caffeine.newBuilder().build(this::getItem_withCaffeine);
|
||||
}
|
||||
|
||||
@Cacheable("items")
|
||||
@ -34,9 +34,7 @@ public class ItemService {
|
||||
}
|
||||
|
||||
@Cacheable("items")
|
||||
public Mono<Item> getItem_withAddons(String id) {
|
||||
return CacheMono.lookup(cache.asMap(), id)
|
||||
.onCacheMissResume(() -> repository.findById(id).cast(Object.class)).cast(Item.class);
|
||||
public Mono<Item> getItem_withCaffeine(String id) {
|
||||
return cache.asMap().computeIfAbsent(id, k -> repository.findById(id).cast(Item.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -73,19 +73,19 @@ public void givenItem_whenGetItemIsCalled_thenMonoIsCached() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenItem_whenGetItemWithAddonsIsCalled_thenMonoResultIsCached() {
|
||||
public void givenItem_whenGetItemWithCaffeineIsCalled_thenMonoResultIsCached() {
|
||||
Mono<Item> glass = itemService.save(new Item("glass", 1.00));
|
||||
|
||||
String id = glass.block().get_id();
|
||||
|
||||
Mono<Item> mono = itemService.getItem_withAddons(id);
|
||||
Mono<Item> mono = itemService.getItem_withCaffeine(id);
|
||||
Item item = mono.block();
|
||||
|
||||
assertThat(item).isNotNull();
|
||||
assertThat(item.getName()).isEqualTo("glass");
|
||||
assertThat(item.getPrice()).isEqualTo(1.00);
|
||||
|
||||
Mono<Item> mono2 = itemService.getItem_withAddons(id);
|
||||
Mono<Item> mono2 = itemService.getItem_withCaffeine(id);
|
||||
Item item2 = mono2.block();
|
||||
|
||||
assertThat(item2).isNotNull();
|
||||
|
@ -1,2 +1,3 @@
|
||||
## Relevant Articles
|
||||
- [Native Images with Spring Boot and GraalVM](https://www.baeldung.com/spring-native-intro)
|
||||
- [Ahead of Time Optimizations in Spring 6](https://www.baeldung.com/spring-6-ahead-of-time-optimizations)
|
||||
|
@ -2,5 +2,5 @@ package com.baeldung.boot.readonlyrepository;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
public interface BookRepository extends BookReadOnlyRepository, CrudRepository<Book, Long> {
|
||||
public interface BookRepository extends CrudRepository<Book, Long> {
|
||||
}
|
||||
|
@ -18,10 +18,6 @@
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
|
||||
@ -93,12 +89,16 @@
|
||||
<configuration>
|
||||
<packageName>com.baeldung</packageName>
|
||||
<sources>
|
||||
<source>src/main/resources/products.xsd</source>
|
||||
<source>/${project.basedir}/src/main/resources/products.xsd</source>
|
||||
</sources>
|
||||
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<start-class>com.baeldung.keycloak.SpringBoot</start-class>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -30,7 +30,7 @@ class SecurityConfig {
|
||||
@Bean
|
||||
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
|
||||
http.authorizeRequests()
|
||||
.antMatchers("/customers*", "/users*")
|
||||
.antMatchers("/customers*")
|
||||
.hasRole("USER")
|
||||
.anyRequest()
|
||||
.permitAll();
|
||||
|
@ -7,3 +7,4 @@ This module contains articles about logging in Spring Boot projects with Log4j 2
|
||||
- [Logging to Graylog with Spring Boot](https://www.baeldung.com/graylog-with-spring-boot)
|
||||
- [Log Groups in Spring Boot 2.1](https://www.baeldung.com/spring-boot-log-groups)
|
||||
- [Writing Log Data to Syslog Using Log4j2](https://www.baeldung.com/log4j-to-syslog)
|
||||
- [Spring Boot Logback and Log4j2 Extensions](https://www.baeldung.com/spring-boot-logback-log4j2)
|
||||
|
@ -9,13 +9,11 @@
|
||||
<packaging>jar</packaging>
|
||||
<description>Module For Spring Boot Integration with BIRT</description>
|
||||
|
||||
<!-- this module should use the Boot parent directly to avoid inherit -->
|
||||
<!-- the logback dependency from our other parents -->
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.1.RELEASE</version>
|
||||
<relativePath /> <!-- lookup parent from repository -->
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@ -1,19 +1,18 @@
|
||||
package com.baeldung.web.log.app;
|
||||
|
||||
import javax.servlet.ServletRegistration;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
import com.baeldung.web.log.config.CustomeRequestLoggingFilter;
|
||||
|
||||
@EnableAutoConfiguration
|
||||
@ComponentScan("com.baeldung.web.log")
|
||||
@PropertySource("application-log.properties")
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(exclude = {
|
||||
SecurityAutoConfiguration.class,
|
||||
ManagementWebSecurityAutoConfiguration.class
|
||||
})
|
||||
public class Application {
|
||||
|
||||
public static void main(final String[] args) {
|
||||
|
@ -0,0 +1,30 @@
|
||||
package com.baeldung.web.log.app;
|
||||
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
import java.io.*;
|
||||
|
||||
public class CachedHttpServletRequest extends HttpServletRequestWrapper {
|
||||
|
||||
private byte[] cachedPayload;
|
||||
|
||||
public CachedHttpServletRequest(HttpServletRequest request) throws IOException {
|
||||
super(request);
|
||||
InputStream requestInputStream = request.getInputStream();
|
||||
this.cachedPayload = StreamUtils.copyToByteArray(requestInputStream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServletInputStream getInputStream() {
|
||||
return new CachedServletInputStream(this.cachedPayload);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BufferedReader getReader() {
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(this.cachedPayload);
|
||||
return new BufferedReader(new InputStreamReader(byteArrayInputStream));
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.baeldung.web.log.app;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.servlet.ReadListener;
|
||||
import javax.servlet.ServletInputStream;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class CachedServletInputStream extends ServletInputStream {
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(CachedServletInputStream.class);
|
||||
private InputStream cachedInputStream;
|
||||
|
||||
public CachedServletInputStream(byte[] cachedBody) {
|
||||
this.cachedInputStream = new ByteArrayInputStream(cachedBody);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
try {
|
||||
return cachedInputStream.available() == 0;
|
||||
} catch (IOException exp) {
|
||||
LOGGER.error(exp.getMessage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReadListener(ReadListener readListener) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
return cachedInputStream.read();
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.baeldung.web.log.app;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebFilter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@Order(value = Ordered.HIGHEST_PRECEDENCE)
|
||||
@Component
|
||||
@WebFilter(filterName = "RequestCachingFilter", urlPatterns = "/*")
|
||||
public class RequestCachingFilter extends OncePerRequestFilter {
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(RequestCachingFilter.class);
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
|
||||
FilterChain filterChain) throws ServletException, IOException {
|
||||
CachedHttpServletRequest cachedHttpServletRequest = new CachedHttpServletRequest(request);
|
||||
LOGGER.info("REQUEST DATA: " + IOUtils.toString(cachedHttpServletRequest.getInputStream(), StandardCharsets.UTF_8));
|
||||
filterChain.doFilter(cachedHttpServletRequest, response);
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package com.baeldung.web.log.app;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
import org.springframework.web.util.ContentCachingRequestWrapper;
|
||||
|
||||
import com.baeldung.web.log.util.RequestLoggingUtil;
|
||||
|
||||
@Component
|
||||
public class TaxiFareRequestInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
private final static Logger LOGGER = LoggerFactory.getLogger(TaxiFareRequestInterceptor.class);
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
String postData;
|
||||
HttpServletRequest requestCacheWrapperObject = null;
|
||||
try {
|
||||
// Uncomment to produce the stream closed issue
|
||||
// postData = RequestLoggingUtil.getStringFromInputStream(request.getInputStream());
|
||||
|
||||
// To overcome request stream closed issue
|
||||
requestCacheWrapperObject = new ContentCachingRequestWrapper(request);
|
||||
requestCacheWrapperObject.getParameterMap();
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
} finally {
|
||||
postData = RequestLoggingUtil.readPayload(requestCacheWrapperObject);
|
||||
LOGGER.info("REQUEST DATA: " + postData);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
|
||||
LOGGER.info("RESPONSE: " + response.getStatus());
|
||||
}
|
||||
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package com.baeldung.web.log.config;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRegistration;
|
||||
|
||||
import org.springframework.web.context.ContextLoaderListener;
|
||||
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
|
||||
import org.springframework.web.servlet.DispatcherServlet;
|
||||
import org.springframework.web.WebApplicationInitializer;
|
||||
|
||||
public class CustomWebAppInitializer implements WebApplicationInitializer {
|
||||
|
||||
@Override
|
||||
public void onStartup(ServletContext container) throws ServletException {
|
||||
|
||||
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
|
||||
context.setConfigLocation("com.baeldung.web.log");
|
||||
container.addListener(new ContextLoaderListener(context));
|
||||
|
||||
ServletRegistration.Dynamic dispatcher = container.addServlet("dispatcher", new DispatcherServlet(context));
|
||||
dispatcher.setLoadOnStartup(1);
|
||||
dispatcher.addMapping("/");
|
||||
|
||||
container.addFilter("customRequestLoggingFilter", CustomeRequestLoggingFilter.class).addMappingForServletNames(null, false, "dispatcher");
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package com.baeldung.web.log.config;
|
||||
|
||||
import org.springframework.web.filter.CommonsRequestLoggingFilter;
|
||||
|
||||
public class CustomeRequestLoggingFilter extends CommonsRequestLoggingFilter {
|
||||
|
||||
public CustomeRequestLoggingFilter() {
|
||||
super.setIncludeQueryString(true);
|
||||
super.setIncludePayload(true);
|
||||
super.setMaxPayloadLength(10000);
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@ public class RequestLoggingFilterConfig {
|
||||
filter.setIncludePayload(true);
|
||||
filter.setMaxPayloadLength(10000);
|
||||
filter.setIncludeHeaders(false);
|
||||
filter.setAfterMessagePrefix("REQUEST DATA : ");
|
||||
filter.setAfterMessagePrefix("REQUEST DATA: ");
|
||||
return filter;
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
package com.baeldung.web.log.config;
|
||||
|
||||
import com.baeldung.web.log.app.TaxiFareRequestInterceptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class TaxiFareMVCConfig implements WebMvcConfigurer {
|
||||
|
||||
@Autowired
|
||||
private TaxiFareRequestInterceptor taxiFareRequestInterceptor;
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(taxiFareRequestInterceptor).addPathPatterns("/taxifare/*/");
|
||||
}
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package com.baeldung.web.log.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.web.util.ContentCachingRequestWrapper;
|
||||
import org.springframework.web.util.WebUtils;
|
||||
|
||||
public class RequestLoggingUtil {
|
||||
|
||||
public static String getStringFromInputStream(InputStream is) {
|
||||
StringWriter writer = new StringWriter();
|
||||
String encoding = "UTF-8";
|
||||
try {
|
||||
IOUtils.copy(is, writer, encoding);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
public static String readPayload(final HttpServletRequest request) throws IOException {
|
||||
String payloadData = null;
|
||||
ContentCachingRequestWrapper contentCachingRequestWrapper = WebUtils.getNativeRequest(request, ContentCachingRequestWrapper.class);
|
||||
if (null != contentCachingRequestWrapper) {
|
||||
byte[] buf = contentCachingRequestWrapper.getContentAsByteArray();
|
||||
if (buf.length > 0) {
|
||||
payloadData = new String(buf, 0, buf.length, contentCachingRequestWrapper.getCharacterEncoding());
|
||||
}
|
||||
}
|
||||
return payloadData;
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,10 @@
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<logger name="org.springframework.web.filter.CommonsRequestLoggingFilter">
|
||||
<level value="DEBUG" />
|
||||
</logger>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
|
@ -1,23 +1,19 @@
|
||||
package com.baeldung.web.controller;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
import com.baeldung.web.log.app.Application;
|
||||
import com.baeldung.web.log.data.TaxiRide;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.boot.test.web.server.LocalServerPort;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
|
||||
import com.baeldung.web.log.app.Application;
|
||||
import com.baeldung.web.log.data.TaxiRide;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = { Application.class, TaxiFareControllerIntegrationTest.SecurityConfig.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
@SpringBootTest(classes = { Application.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||
public class TaxiFareControllerIntegrationTest {
|
||||
|
||||
@LocalServerPort
|
||||
@ -25,8 +21,6 @@ public class TaxiFareControllerIntegrationTest {
|
||||
|
||||
@Test
|
||||
public void givenRequest_whenFetchTaxiFareRateCard_thanOK() {
|
||||
|
||||
System.out.println(port);
|
||||
String URL = "http://localhost:" + port + "/spring-rest";
|
||||
TestRestTemplate testRestTemplate = new TestRestTemplate();
|
||||
TaxiRide taxiRide = new TaxiRide(true, 10l);
|
||||
@ -37,16 +31,4 @@ public class TaxiFareControllerIntegrationTest {
|
||||
assertThat(fare, equalTo("200"));
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
System.out.println("security being set");
|
||||
http
|
||||
.authorizeRequests()
|
||||
.anyRequest().permitAll()
|
||||
.and()
|
||||
.csrf().disable();
|
||||
}
|
||||
}
|
||||
}
|
@ -55,6 +55,7 @@
|
||||
<module>spring-cloud-data-flow</module>
|
||||
<module>spring-cloud-sleuth</module>
|
||||
<module>spring-cloud-openfeign-2</module>
|
||||
<module>spring-cloud-open-telemetry</module>
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
|
@ -3,7 +3,7 @@
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>spring-cloud-archaius-additional-sources-simple</artifactId>
|
||||
<artifactId>spring-cloud-archaius-additionalsources</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>spring-cloud-archaius-additionalsources</name>
|
||||
<packaging>jar</packaging>
|
||||
|
@ -0,0 +1,30 @@
|
||||
version: "4.0"
|
||||
|
||||
services:
|
||||
product-service:
|
||||
platform: linux/x86_64
|
||||
build: spring-cloud-open-telemetry1/
|
||||
ports:
|
||||
- "8080:8080"
|
||||
|
||||
price-service:
|
||||
platform: linux/x86_64
|
||||
build: spring-cloud-open-telemetry2/
|
||||
ports:
|
||||
- "8081"
|
||||
|
||||
jaeger-service:
|
||||
image: jaegertracing/all-in-one:latest
|
||||
ports:
|
||||
- "16686:16686"
|
||||
- "14250"
|
||||
|
||||
collector:
|
||||
image: otel/opentelemetry-collector:0.47.0
|
||||
command: [ "--config=/etc/otel-collector-config.yml" ]
|
||||
volumes:
|
||||
- ./otel-config.yml:/etc/otel-collector-config.yml
|
||||
ports:
|
||||
- "4317:4317"
|
||||
depends_on:
|
||||
- jaeger-service
|
@ -0,0 +1,23 @@
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
grpc:
|
||||
http:
|
||||
|
||||
processors:
|
||||
batch:
|
||||
|
||||
exporters:
|
||||
logging:
|
||||
logLevel: debug
|
||||
jaeger:
|
||||
endpoint: jaeger-service:14250
|
||||
tls:
|
||||
insecure: true
|
||||
|
||||
service:
|
||||
pipelines:
|
||||
traces:
|
||||
receivers: [ otlp ]
|
||||
processors: [ batch ]
|
||||
exporters: [ logging, jaeger ]
|
22
spring-cloud-modules/spring-cloud-open-telemetry/pom.xml
Normal file
22
spring-cloud-modules/spring-cloud-open-telemetry/pom.xml
Normal file
@ -0,0 +1,22 @@
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung.spring.cloud</groupId>
|
||||
<artifactId>spring-cloud-open-telemetry</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>spring-cloud-open-telemetry</name>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.spring.cloud</groupId>
|
||||
<artifactId>spring-cloud-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>spring-cloud-open-telemetry1</module>
|
||||
<module>spring-cloud-open-telemetry2</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
@ -0,0 +1,7 @@
|
||||
FROM adoptopenjdk/openjdk11:alpine
|
||||
|
||||
COPY target/spring-cloud-open-telemetry1-1.0.0-SNAPSHOT.jar spring-cloud-open-telemetry.jar
|
||||
|
||||
EXPOSE 8081
|
||||
|
||||
ENTRYPOINT ["java","-jar","/spring-cloud-open-telemetry.jar"]
|
@ -0,0 +1,116 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>spring-cloud-open-telemetry1</artifactId>
|
||||
<groupId>com.baeldung.spring.cloud</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<name>spring-cloud-open-telemetry1</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.spring.cloud</groupId>
|
||||
<artifactId>spring-cloud-open-telemetry</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot-dependencies.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>${release.train.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-sleuth-otel-dependencies</artifactId>
|
||||
<version>${spring-cloud-sleuth-otel.version}</version>
|
||||
<scope>import</scope>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-sleuth</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-sleuth-brave</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-sleuth-otel-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.opentelemetry</groupId>
|
||||
<artifactId>opentelemetry-exporter-otlp-trace</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.grpc</groupId>
|
||||
<artifactId>grpc-okhttp</artifactId>
|
||||
<version>${grpc-okhttp.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit-jupiter.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<properties>
|
||||
<spring-boot-dependencies.version>2.5.7</spring-boot-dependencies.version>
|
||||
<release.train.version>2020.0.4</release.train.version>
|
||||
<spring-cloud-sleuth-otel.version>1.0.0-M12</spring-cloud-sleuth-otel.version>
|
||||
<grpc-okhttp.version>1.42.1</grpc-okhttp.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -0,0 +1,12 @@
|
||||
package com.baeldung.opentelemetry;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ProductApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ProductApplication.class, args);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.baeldung.opentelemetry.api.client;
|
||||
|
||||
import com.baeldung.opentelemetry.model.Price;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Component
|
||||
public class PriceClient {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PriceClient.class);
|
||||
|
||||
private final RestTemplate restTemplate;
|
||||
|
||||
@Autowired
|
||||
public PriceClient(RestTemplate restTemplate) {
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
@Value("${priceClient.baseUrl}")
|
||||
private String baseUrl;
|
||||
|
||||
public Price getPrice(@PathVariable("id") long productId){
|
||||
LOGGER.info("Fetching Price Details With Product Id {}", productId);
|
||||
String url = String.format("%s/price/%d", baseUrl, productId);
|
||||
ResponseEntity<Price> price = restTemplate.getForEntity(url, Price.class);
|
||||
return price.getBody();
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.baeldung.opentelemetry.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Configuration
|
||||
public class RestConfiguration {
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate() {
|
||||
return new RestTemplate();
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user