Skip to content

Commit 16295e6

Browse files
Merge branch 'master' into pr/470-alexB-logging
2 parents 57ebe60 + 9257da4 commit 16295e6

81 files changed

Lines changed: 2484 additions & 587 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎assertj/pom.xml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,28 @@
99
<version>1.0.0-SNAPSHOT</version>
1010

1111
<dependencies>
12+
<dependency>
13+
<groupId>com.google.guava</groupId>
14+
<artifactId>guava</artifactId>
15+
<version>19.0</version>
16+
</dependency>
1217
<dependency>
1318
<groupId>junit</groupId>
1419
<artifactId>junit</artifactId>
1520
<version>4.12</version>
21+
<scope>test</scope>
1622
</dependency>
1723
<dependency>
1824
<groupId>org.assertj</groupId>
1925
<artifactId>assertj-core</artifactId>
2026
<version>3.4.1</version>
2127
<scope>test</scope>
2228
</dependency>
29+
<dependency>
30+
<groupId>org.assertj</groupId>
31+
<artifactId>assertj-guava</artifactId>
32+
<version>3.0.0</version>
33+
</dependency>
2334
</dependencies>
2435

2536
<build>
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
package com.baeldung.assertj.introduction;
2+
3+
import com.google.common.base.Optional;
4+
import com.google.common.collect.HashBasedTable;
5+
import com.google.common.collect.Multimap;
6+
import com.google.common.collect.Multimaps;
7+
import com.google.common.collect.Range;
8+
import com.google.common.collect.Sets;
9+
import com.google.common.collect.Table;
10+
import com.google.common.collect.TreeRangeMap;
11+
import com.google.common.io.Files;
12+
import org.assertj.guava.data.MapEntry;
13+
import org.junit.Test;
14+
15+
import java.io.File;
16+
import java.util.HashMap;
17+
18+
import static org.assertj.guava.api.Assertions.assertThat;
19+
import static org.assertj.guava.api.Assertions.entry;
20+
21+
public class AssertJGuavaTest {
22+
23+
@Test
24+
public void givenTwoEmptyFiles_whenComparingContent_thenEqual() throws Exception {
25+
final File temp = File.createTempFile("bael", "dung");
26+
final File temp2 = File.createTempFile("bael", "dung2");
27+
28+
assertThat(Files.asByteSource(temp))
29+
.hasSize(0)
30+
.hasSameContentAs(Files.asByteSource(temp2));
31+
}
32+
33+
@Test
34+
public void givenMultimap_whenVerifying_thenCorrect() throws Exception {
35+
final Multimap<Integer, String> mmap = Multimaps.newMultimap(new HashMap<>(), Sets::newHashSet);
36+
mmap.put(1, "one");
37+
mmap.put(1, "1");
38+
39+
assertThat(mmap)
40+
.hasSize(2)
41+
.containsKeys(1)
42+
.contains(entry(1, "one"))
43+
.contains(entry(1, "1"));
44+
}
45+
46+
@Test
47+
public void givenOptional_whenVerifyingContent_thenShouldBeEqual() throws Exception {
48+
final Optional<String> something = Optional.of("something");
49+
50+
assertThat(something)
51+
.isPresent()
52+
.extractingValue()
53+
.isEqualTo("something");
54+
}
55+
56+
@Test
57+
public void givenRange_whenVerifying_thenShouldBeCorrect() throws Exception {
58+
final Range<String> range = Range.openClosed("a", "g");
59+
60+
assertThat(range)
61+
.hasOpenedLowerBound()
62+
.isNotEmpty()
63+
.hasClosedUpperBound()
64+
.contains("b");
65+
}
66+
67+
@Test
68+
public void givenRangeMap_whenVerifying_thenShouldBeCorrect() throws Exception {
69+
final TreeRangeMap<Integer, String> map = TreeRangeMap.create();
70+
71+
map.put(Range.closed(0, 60), "F");
72+
map.put(Range.closed(61, 70), "D");
73+
74+
assertThat(map)
75+
.isNotEmpty()
76+
.containsKeys(0)
77+
.contains(MapEntry.entry(34, "F"));
78+
}
79+
80+
@Test
81+
public void givenTable_whenVerifying_thenShouldBeCorrect() throws Exception {
82+
final Table<Integer, String, String> table = HashBasedTable.create(2, 2);
83+
84+
table.put(1, "A", "PRESENT");
85+
table.put(1, "B", "ABSENT");
86+
87+
assertThat(table)
88+
.hasRowCount(1)
89+
.containsValues("ABSENT")
90+
.containsCell(1, "B", "ABSENT");
91+
}
92+
93+
94+
95+
96+
}

‎dependency-injection/build.gradle‎

Lines changed: 0 additions & 43 deletions
This file was deleted.
-42.7 KB
Binary file not shown.

‎dependency-injection/docs/inject-qualifier-demo-classdiagram.xml‎

Lines changed: 0 additions & 1 deletion
This file was deleted.

‎dependency-injection/pom.xml‎

Lines changed: 76 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,83 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0"
2-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44

5-
<modelVersion>4.0.0</modelVersion>
5+
<modelVersion>4.0.0</modelVersion>
66

7-
<groupId>com.baeldung</groupId>
8-
<artifactId>dependency-injection</artifactId>
9-
<version>0.0.1-SNAPSHOT</version>
10-
<packaging>war</packaging>
7+
<groupId>com.baeldung</groupId>
8+
<artifactId>dependency-injection</artifactId>
9+
<version>0.0.1-SNAPSHOT</version>
10+
<packaging>war</packaging>
1111

12-
<name>@Resource vs @Inject vs @Autowired</name>
13-
<description>Accompanying the demonstration of the use of the annotations related to injection mechanisms, namely @Resource, @Inject, and @Autowired</description>
12+
<name>Resource vs Inject vs Autowired</name>
13+
<description>Accompanying the demonstration of the use of the annotations related to injection mechanisms, namely
14+
Resource, Inject, and Autowired
15+
</description>
1416

15-
<dependencies>
16-
<dependency>
17-
<groupId>junit</groupId>
18-
<artifactId>junit</artifactId>
19-
<version>4.11</version>
20-
<scope>test</scope>
21-
</dependency>
22-
<dependency>
23-
<groupId>org.mockito</groupId>
24-
<artifactId>mockito-all</artifactId>
25-
<version>1.10.19</version>
26-
</dependency>
27-
<dependency>
28-
<groupId>org.springframework</groupId>
29-
<artifactId>spring-test</artifactId>
30-
<version>4.2.6.RELEASE</version>
31-
</dependency>
32-
<dependency>
33-
<groupId>org.springframework</groupId>
34-
<artifactId>spring-core</artifactId>
35-
<version>4.2.6.RELEASE</version>
36-
</dependency>
37-
<dependency>
38-
<groupId>org.springframework</groupId>
39-
<artifactId>spring-beans</artifactId>
40-
<version>4.2.6.RELEASE</version>
41-
</dependency>
42-
<dependency>
43-
<groupId>org.springframework</groupId>
44-
<artifactId>spring-context</artifactId>
45-
<version>4.2.6.RELEASE</version>
46-
</dependency>
47-
<dependency>
48-
<groupId>javax.inject</groupId>
49-
<artifactId>javax.inject</artifactId>
50-
<version>1</version>
51-
</dependency>
52-
</dependencies>
17+
<dependencies>
18+
<dependency>
19+
<groupId>junit</groupId>
20+
<artifactId>junit</artifactId>
21+
<version>4.11</version>
22+
<scope>test</scope>
23+
</dependency>
24+
<dependency>
25+
<groupId>org.mockito</groupId>
26+
<artifactId>mockito-all</artifactId>
27+
<version>1.10.19</version>
28+
</dependency>
29+
<dependency>
30+
<groupId>org.springframework</groupId>
31+
<artifactId>spring-test</artifactId>
32+
<version>4.2.6.RELEASE</version>
33+
</dependency>
34+
<dependency>
35+
<groupId>org.springframework</groupId>
36+
<artifactId>spring-core</artifactId>
37+
<version>4.2.6.RELEASE</version>
38+
</dependency>
39+
<dependency>
40+
<groupId>org.springframework</groupId>
41+
<artifactId>spring-beans</artifactId>
42+
<version>4.2.6.RELEASE</version>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.springframework</groupId>
46+
<artifactId>spring-context</artifactId>
47+
<version>4.2.6.RELEASE</version>
48+
</dependency>
49+
<dependency>
50+
<groupId>javax.inject</groupId>
51+
<artifactId>javax.inject</artifactId>
52+
<version>1</version>
53+
</dependency>
54+
</dependencies>
5355

54-
<build>
55-
<plugins>
56-
<plugin>
57-
<artifactId>maven-compiler-plugin</artifactId>
58-
<configuration>
59-
<source>1.6</source>
60-
<target>1.6</target>
61-
</configuration>
62-
</plugin>
63-
<plugin>
64-
<groupId>org.apache.maven.plugins</groupId>
65-
<artifactId>maven-surefire-plugin</artifactId>
66-
<configuration>
67-
<includes>
68-
<include>**/*Test.java</include>
69-
</includes>
70-
</configuration>
71-
</plugin>
72-
</plugins>
73-
</build>
56+
<build>
57+
<plugins>
58+
<plugin>
59+
<artifactId>maven-compiler-plugin</artifactId>
60+
<configuration>
61+
<source>1.8</source>
62+
<target>1.8</target>
63+
</configuration>
64+
</plugin>
65+
<plugin>
66+
<groupId>org.apache.maven.plugins</groupId>
67+
<artifactId>maven-surefire-plugin</artifactId>
68+
<configuration>
69+
<includes>
70+
<include>**/*Test.java</include>
71+
</includes>
72+
</configuration>
73+
</plugin>
74+
</plugins>
75+
</build>
7476

75-
<repositories>
76-
<repository>
77-
<id>java.net</id>
78-
<url>https://maven.java.net/content/repositories/releases/</url>
79-
</repository>
80-
</repositories>
77+
<repositories>
78+
<repository>
79+
<id>java.net</id>
80+
<url>https://maven.java.net/content/repositories/releases/</url>
81+
</repository>
82+
</repositories>
8183
</project>

dependency-injection/src/test/java/com/baeldung/configuration/ApplicationContextTestAutowiredName.java renamed to dependency-injection/src/main/java/com/baeldung/configuration/ApplicationContextTestAutowiredName.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
import org.springframework.context.annotation.Configuration;
55

66
@Configuration
7-
@ComponentScan(basePackages={"com.baeldung.dependency"})
7+
@ComponentScan(basePackages = {"com.baeldung.dependency"})
88
public class ApplicationContextTestAutowiredName {
99
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.baeldung.configuration;
2+
3+
import com.baeldung.dependency.AnotherArbitraryDependency;
4+
import com.baeldung.dependency.ArbitraryDependency;
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.context.annotation.Configuration;
7+
8+
@Configuration
9+
public class ApplicationContextTestAutowiredQualifier {
10+
11+
@Bean
12+
public ArbitraryDependency autowiredFieldDependency() {
13+
ArbitraryDependency autowiredFieldDependency = new ArbitraryDependency();
14+
15+
return autowiredFieldDependency;
16+
}
17+
18+
@Bean
19+
public ArbitraryDependency anotherAutowiredFieldDependency() {
20+
ArbitraryDependency anotherAutowiredFieldDependency = new AnotherArbitraryDependency();
21+
22+
return anotherAutowiredFieldDependency;
23+
}
24+
}

dependency-injection/src/test/java/com/baeldung/configuration/ApplicationContextTestAutowiredType.java renamed to dependency-injection/src/main/java/com/baeldung/configuration/ApplicationContextTestAutowiredType.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package com.baeldung.configuration;
22

3+
import com.baeldung.dependency.ArbitraryDependency;
34
import org.springframework.context.annotation.Bean;
45
import org.springframework.context.annotation.Configuration;
56

6-
import com.baeldung.dependency.ArbitraryDependency;
7-
87
@Configuration
98
public class ApplicationContextTestAutowiredType {
109

dependency-injection/src/test/java/com/baeldung/configuration/ApplicationContextTestInjectName.java renamed to dependency-injection/src/main/java/com/baeldung/configuration/ApplicationContextTestInjectName.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
package com.baeldung.configuration;
22

3-
import org.springframework.context.annotation.Bean;
4-
import org.springframework.context.annotation.Configuration;
5-
63
import com.baeldung.dependency.ArbitraryDependency;
74
import com.baeldung.dependency.YetAnotherArbitraryDependency;
5+
import org.springframework.context.annotation.Bean;
6+
import org.springframework.context.annotation.Configuration;
87

98
@Configuration
109
public class ApplicationContextTestInjectName {

0 commit comments

Comments
 (0)