Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
f053451
Spring rest logging
half-wit4u Jul 16, 2017
600d610
add libs repo (#2288)
lor6 Jul 19, 2017
b558ade
Changes for BAEL-1050: Added new field (#2282)
khatwaniNikhil Jul 20, 2017
7d36972
changed thread for ScheduledExecutorService (#2297)
jboadas Jul 20, 2017
318d079
BAEL-281: Static Analysis tools with Eclipse (#2298)
amilabanuka Jul 20, 2017
eab110d
BAEL-787 (updated) - AWS S3 with Java (#2296)
ramansahasi Jul 20, 2017
c910f25
review changes (#2299)
baljeet20 Jul 20, 2017
292d9f8
PR for BAEL-798 - Apache Camel with Spring Boot (#2280)
dcassiani Jul 20, 2017
6421286
BAEL-1029 - deep20jain@gmail.com - Addressing review comment (#2294)
deep20jain Jul 20, 2017
4e95722
BAEL-422 Examples for tutorial on Vavr Collection API (#2293)
NareshBabuPB Jul 20, 2017
f8bf403
Optimize and refactor (#2302)
pivovarit Jul 21, 2017
75ac7de
Updated custom logging implementation
Jul 21, 2017
e96690e
BAEL-964 - Changing assertions within invert test
slavisa-baeldung Jul 22, 2017
ee6656a
Merge pull request #2303 from eugenp/bael-964-commons-maputil
slavisa-baeldung Jul 22, 2017
226acd5
Bael-422 Vavr Collections (#2304)
NareshBabuPB Jul 22, 2017
101f6fd
Comment incorporation
Jul 23, 2017
879bedf
Comment incorporation
Jul 23, 2017
6c10596
Merge branch 'master' of https://github.com/half-wit4u/tutorials.git
Jul 23, 2017
ef5013c
Delete Vaadin from libraries (#2309)
jboadas Jul 23, 2017
9c4042e
Add missing "volatile"s (#2307)
pivovarit Jul 24, 2017
f58c41d
cucumber java8 (#2306)
Doha2012 Jul 24, 2017
1be49eb
introducing lambda (#2305)
AbhinabKanrar Jul 24, 2017
29b0da9
Web Logging code included in exisitng module namely "spring-rest"
Jul 24, 2017
553c26c
deleted the new module
Jul 24, 2017
34dc899
Custom Efficient hashCode() Implementations - Alejandro Gervasio - al…
Jul 24, 2017
34dc48c
Merge branch 'master' of https://github.com/half-wit4u/tutorials into…
slavisa-baeldung Jul 25, 2017
7fdab0e
BAEL-554 - Logging Spring Web Request
slavisa-baeldung Jul 25, 2017
a89462e
Merge pull request #2312 from eugenp/bael-544-logging-web-request
slavisa-baeldung Jul 25, 2017
d4f245a
BAEL-771 (#2286)
Thoughtscript Jul 25, 2017
a3c47ec
@GetMapping and @PostMapping instead of @RequestMappings change
Jul 26, 2017
7ffd8ec
Cleverson Zanon | cleverson.ssantos1008@gmail.com (#2315)
Jul 27, 2017
0a631ac
Example Code for BAEL-1048 (#2316)
SeunMatt Jul 27, 2017
9e19339
BAEL-1026 (#2322)
aietcn Jul 28, 2017
17d7f8f
Merge pull request #2317 from half-wit4u/master
slavisa-baeldung Jul 28, 2017
828e514
BAEL-907: Code example and tests (#2295)
dimitarsazdovski Jul 28, 2017
d71f330
Enable GitHub Incremental Builder (#2323)
pivovarit Jul 28, 2017
9b143b8
Refactor core-java (#2324)
pivovarit Jul 28, 2017
7f22e3d
Destructuring Declarations in Kotlin - Cleverson Zanon | cleverson.ss…
Jul 28, 2017
e8df7f8
Taxi fare refactor (#2328)
pivovarit Jul 29, 2017
c5f029b
- added custom theme for asciidoc book (#2327)
ante003 Jul 29, 2017
ae33aa6
Refactored tests for PCollections (#2331)
SeunMatt Jul 29, 2017
5c1bf55
minor cleanup work
Jul 29, 2017
244a678
jooby project (#2330)
AbhinabKanrar Jul 29, 2017
fd6e7c5
reducing employee bean content (#2332)
AbhinabKanrar Jul 29, 2017
9f45d70
BAEL-1024 introduction to mock server (#2333)
baljeet20 Jul 29, 2017
f445a4d
BAEL-373: Improve/Upgrade existing Mockito articles to Mockito 2 (#2311)
Sgitario Jul 29, 2017
34a793a
Manual money tests (#2338)
pivovarit Jul 30, 2017
4441d96
BAEL-1023 Introduction to Kryo (#2336)
juarezjaramillo Jul 30, 2017
610bb05
minor fix (#2334)
Doha2012 Jul 30, 2017
dc037a4
System outs for tests (#2321)
Thoughtscript Jul 30, 2017
36608b7
BAEL-1033 Introduction to StreamUtils (#2337)
Jul 30, 2017
6bfd4d3
BAEL-907: README updated (#2340)
KevinGilmore Jul 30, 2017
deb79bb
BAEL-887 How to collect a Java Stream to an immutable collection? (#2…
yasin3061 Jul 30, 2017
752086e
Initial Commit (#2349)
Jul 31, 2017
585597f
New libraries-data module (#2343)
juarezjaramillo Jul 31, 2017
4b53c00
BAEL-1033 Introduction to StreamUtils (#2341)
Jul 31, 2017
b4f7806
Matchers is now deprecated in Mockito 2, it's now replaced by Argumen…
Sgitario Jul 31, 2017
7f5ca78
Fix title formatting (#2314)
romach Aug 1, 2017
0c60af8
Make projects executable (#2278)
roman-seleznov Aug 1, 2017
ed92182
Build optimization 1.08.2017 (#2351)
pivovarit Aug 1, 2017
a3ed5a5
BAEL-1051: Introduction to Hoverfly Java (#2320)
aliraza995 Aug 1, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions asciidoctor/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@
<configuration>
<sourceDirectory>src/docs/asciidoc</sourceDirectory>
<outputDirectory>target/docs/asciidoc</outputDirectory>
<attributes>
<pdf-stylesdir>${project.basedir}/src/themes</pdf-stylesdir>
<pdf-style>custom</pdf-style>
</attributes>
<backend>pdf</backend>
<doctype>book</doctype>
</configuration>
</plugin>
</plugins>
Expand Down
14 changes: 12 additions & 2 deletions asciidoctor/src/docs/asciidoc/test.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
== Introduction Section
:icons: font

Hi. I'm a simple test to see if this Maven build is working. If you see me in a nice PDF, then it means everything is [red]#working#.

= Generating book with AsciiDoctorj
Baeldung

[abstract]
This is the actual content.

== First Section

This is first section of the book where you can include some nice icons like icon:comment[].
You can also create http://www.baeldung.com[links]
29 changes: 29 additions & 0 deletions asciidoctor/src/themes/custom-theme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
title_page:
align: left

page:
layout: portrait
margin: [0.75in, 1in, 0.75in, 1in]
size: A4
base:
font_color: #333333
line_height_length: 17
line_height: $base_line_height_length / $base_font_size
link:
font_color: #009900

header:
height: 0.5in
line_height: 1
recto_content:
center: '{document-title}'
verso_content:
center: '{document-title}'

footer:
height: 0.5in
line_height: 1
recto_content:
right: '{chapter-title} | *{page-number}*'
verso_content:
left: '*{page-number}* | {chapter-title}'
15 changes: 4 additions & 11 deletions aws/src/main/java/com/baeldung/s3/S3Application.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.baeldung.s3;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
Expand All @@ -28,7 +29,7 @@ public class S3Application {
"<AWS accesskey>",
"<AWS secretkey>"
);
}
}

public static void main(String[] args) throws IOException {
//set-up the client
Expand Down Expand Up @@ -74,15 +75,7 @@ public static void main(String[] args) throws IOException {
//downloading an object
S3Object s3object = awsService.getObject(bucketName, "Document/hello.txt");
S3ObjectInputStream inputStream = s3object.getObjectContent();
FileOutputStream fos = new FileOutputStream(new File("/Users/user/Desktop/hello.txt"));

int read = 0;
byte[] bytes = new byte[1024];
while ((read = inputStream.read(bytes)) != -1) {
fos.write(bytes, 0, read);
}
inputStream.close();
fos.close();
FileUtils.copyInputStreamToFile(inputStream, new File("/Users/user/Desktop/hello.txt"));

//copying an object
awsService.copyObject(
Expand Down
13 changes: 7 additions & 6 deletions camel-api/src/main/java/com/baeldung/camel/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

@SpringBootApplication
@ComponentScan(basePackages="com.baeldung.camel")
public class Application extends SpringBootServletInitializer {
public class Application{

@Value("${server.port}")
String serverPort;
Expand Down Expand Up @@ -62,10 +61,12 @@ public void configure() {
.bindingMode(RestBindingMode.json)
.dataFormatProperty("prettyPrint", "true");
/**
The Rest DSL supports automatic binding json/xml contents to/from POJOs using Camels Data Format.
By default the binding mode is off, meaning there is no automatic binding happening for incoming and outgoing messages.
You may want to use binding if you develop POJOs that maps to your REST services request and response types.
This allows you, as a developer, to work with the POJOs in Java code.
The Rest DSL supports automatic binding json/xml contents to/from
POJOs using Camels Data Format.
By default the binding mode is off, meaning there is no automatic
binding happening for incoming and outgoing messages.
You may want to use binding if you develop POJOs that maps to
your REST services request and response types.
*/

rest("/api/").description("Teste REST Service")
Expand Down
39 changes: 39 additions & 0 deletions core-java/hashcode/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?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>
<groupId>com.baeldung.hashcode</groupId>
<artifactId>hashcode</artifactId>
<version>1.0</version>
<build>
<plugins>
<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>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.baeldung.application;

import com.baeldung.entities.User;
import java.util.HashMap;
import java.util.Map;

public class Application {

public static void main(String[] args) {
Map<User, User> users = new HashMap<>();
User user1 = new User(1L, "John", "john@domain.com");
User user2 = new User(2L, "Jennifer", "jennifer@domain.com");
User user3 = new User(3L, "Mary", "mary@domain.com");

users.put(user1, user1);
users.put(user2, user2);
users.put(user3, user3);

if (users.containsKey(user1)) {
System.out.print("User found in the collection");
}
}
}
38 changes: 38 additions & 0 deletions core-java/hashcode/src/main/java/com/baeldung/entities/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.baeldung.entities;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class User {

private final Logger logger = LoggerFactory.getLogger(User.class);
private long id;
private String name;
private String email;

public User(long id, String name, String email) {
this.id = id;
this.name = name;
this.email = email;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null) return false;
if (this.getClass() != o.getClass()) return false;
User user = (User) o;
return id != user.id && (!name.equals(user.name) && !email.equals(user.email));
}

@Override
public int hashCode() {
int hash = 7;
hash = 31 * hash + (int) id;
hash = 31 * hash + (name == null ? 0 : name.hashCode());
hash = 31 * hash + (email == null ? 0 : email.hashCode());
logger.info("hashCode() method called - Computed hash: " + hash);
return hash;
}
// getters and setters here
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.baeldung.application;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import static org.junit.Assert.assertEquals;

public class ApplicationTest {

private ByteArrayOutputStream outContent;

@Before
public void setUpPrintStreamInstance() throws Exception {
this.outContent = new ByteArrayOutputStream();
System.setOut(new PrintStream(outContent));
}

@After
public void tearDownByteArrayOutputStream() throws Exception {
outContent = null;
}

@Test
public void main_NoInputState_TextPrintedToConsole() throws Exception {
Application.main(new String[]{});
assertEquals("User found in the collection", outContent.toString());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.baeldung.entities;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class UserTest {

private User user;
private User comparisonUser;

@Before
public void setUpUserInstances() {
this.user = new User(1L, "test", "test@domain.com");
this.comparisonUser = this.user;
}

@After
public void tearDownUserInstances() {
user = null;
comparisonUser = null;
}

@Test
public void equals_EqualUserInstance_TrueAssertion(){
Assert.assertTrue(user.equals(comparisonUser));
}

@Test
public void hashCode_UserHash_TrueAssertion() {
Assert.assertEquals(1792276941, user.hashCode());
}
}
6 changes: 3 additions & 3 deletions core-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@
</profile>
</profiles>

<properties>
<properties>
<!-- marshalling -->
<jackson.version>2.8.5</jackson.version>

Expand All @@ -391,7 +391,7 @@
<logback.version>1.1.7</logback.version>

<!-- util -->
<guava.version>21.0</guava.version>
<guava.version>22.0</guava.version>
<commons-lang3.version>3.5</commons-lang3.version>
<bouncycastle.version>1.55</bouncycastle.version>
<commons-codec.version>1.10</commons-codec.version>
Expand All @@ -408,7 +408,7 @@
<!-- testing -->
<org.hamcrest.version>1.3</org.hamcrest.version>
<junit.version>4.12</junit.version>
<mockito.version>1.10.19</mockito.version>
<mockito.version>2.8.9</mockito.version>
<assertj.version>3.6.1</assertj.version>
<avaitility.version>1.7.0</avaitility.version>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.baeldung.concurrent.Scheduledexecutorservice;

import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
Expand All @@ -12,32 +11,21 @@ public class ScheduledExecutorServiceDemo {
public void execute() {
ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor();

ScheduledFuture<?> scheduledFuture = executorService.schedule(new Runnable() {
@Override
public void run() {
// task details
}
ScheduledFuture<?> scheduledFuture = executorService.schedule(() -> {
// Task
}, 1, TimeUnit.SECONDS);

executorService.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
// task details
}
executorService.scheduleAtFixedRate(() -> {
// Task
}, 1, 10, TimeUnit.SECONDS);

executorService.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
// task details
}
executorService.scheduleWithFixedDelay(() -> {
// Task
}, 1, 10, TimeUnit.SECONDS);

Future<String> future = executorService.schedule(new Callable<String>() {
@Override
public String call() throws Exception {
return "Hello World";
}
Future<String> future = executorService.schedule(() -> {
// Task
return "Hellow world";
}, 1, TimeUnit.SECONDS);

executorService.shutdown();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.baeldung.concurrent.atomic;

public class SafeCounterWithLock {
int counter;
private volatile int counter;

public int getValue() {
return counter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.concurrent.atomic.AtomicInteger;

public class SafeCounterWithoutLock {
AtomicInteger counter = new AtomicInteger(0);
private final AtomicInteger counter = new AtomicInteger(0);

public int getValue() {
return counter.get();
Expand Down
Loading