Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ target/

spring-openid/src/main/resources/application.properties
.recommenders/

Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<mxfile userAgent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36" version="5.5.1.6" editor="www.draw.io" type="device"><diagram>7Vptb+I4EP41le4+bEUIUPZjeenenrqn3tLT3X6qTGIS7zox5zil7K/fcTLTvHbhFOAkBEKAx87EM88zL7G4cqfRywfN1uEn5XN51e/5L1fu7KrfH/dd+LSCbS4Y9VAQaOHnIqcQLMR3jsIeSlPh86Sy0CgljVhXhZ6KY+6ZioxprTbVZSslq3dds4DuWAgWHpNN6d/CNyGZNSrkv3ERhHRnZ/Q+n1ky71ugVRrj/a767ip75dMRI11oaBIyX21KIncObtVKgWb7K3qZcmldS27Lr7t7Y/Z135rHuLcdF9A+zJZs5z64AodKm1AFKmZyXkgnmX3caujBKDSRhJ8O/ISb6u0/KM8GX+zgepgN/VuLjNW65vFjKOJceidgR/klX7kxW2QDS40CUbGDe6XWeJ+mlWh4olLtoR0wznjDdMBx1U0ushaWLkPPfOAq4rBlWKC5ZEY8V8nAkFPB67rCr/ADXdvuZtzLM5MpKr0TXPp/pkyKleD6Y/wVaDzjkWrAkWxEJFls/V7y9ErFhkCyY9ATgD9nHniEaxA8c20EEPoWJ4x13sQLhfTv2Val1iOJAbbSaBIqLb6DWkb3gGltE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0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36" version="5.5.2.3" editor="www.draw.io" type="device"><diagram>7VptbyI3EP41SO2Hi1iWl+RjAuSuUpqml6jX+xQZ1uz6zrumXhPC/fqb8Y7ZV0IaXqpGICTWw3hsz/N4Zmxo+cP4+aNm8+h3FXDZ6rSD55Y/anU6XrvvwwdKVpmk3yZBqEVASrngXvzgridJFyLgaUnRKCWNmJeFU5UkfGpKMqa1WpbVZkqWR52z0I2YC+6nTNalX0Rgokx63unn8k9chJEb2etfZN9M2PR7qNUiofFaHX9mX9nXMXO2aKFpxAK1LIj8MfhVKwWW8Sl+HnKJvnVuy/pdb/h2PW/NE5rblg5uHmbl1s4DcAU1lTaRClXC5DiXXtn1cbTQhlZkYgmPHjzCoHr1N8lt4ys2znq2GVwiMmh1zpOHSCSZ9FrAjLIu37gxK2IDWxgFonwGN0rNaZz6KmnhqVroKa0D2pY3TIectAaZCFdY6Eae+chVzGHKoKC5ZEY8lcnAiFPhWi/3KzyQa5vdTHN5YnJBRq8Fl8GfCybFTHD9W/INaDzisarBkS5FLFmCfi94eqYS40DCNtgJwZ+jKXiEaxA8cW0EEPqSvjDovKtpJGRww1ZqgR5JDbDVta4ipcUPMMvcGPC1NoQGML+ocY89CTTNU9C5c2Bgz0x0w1IUoM5UScnmqZisJxwDLCK5UsaomJTcSpEQQyUVLAMc4PbPC6jjWrmLPc2IUhwaEAOW+abuuq0YFTd0h+LVLqCTiQLoH1qdPosRiGSS4ge0Jfo+nbMEnkN8Bj7IYMRhjwQ8ma5gQZkODFdUa/mXYPxST4TRTK/yDk4/EE9O9y3jwtQ3j1u29sIkoHNhHjVyA2yWejmxU6PVd+7gT5Ql/qzACBI5wks+QwvNdId5T0US3lidUTeXfCaoUbSMhOH3IMc5LSGfYdQBezNpg1UkAliRjXqGGZYxGOk6VyIxlh69K3gDi4YY6XqwriG0ATfXhjeqazNUCayPQT/oxmF7LDlukQZmu4Dxama71LSN2d3u7sQmEwVi14CVohqxMmBdNrUx7F+jGgMWNgMRjA82I3yw5ktQ+3WoUVSFULIJl3cqFUYotK8z3Qq0R0BvQEhtQ+98d/B6DeA1xoMQEmByCVl4KTTPU9UfiU1djw+fxrePo/Hd+HY0vh1+9R7/AoVgU9BosP/Lry9GtieVWyuFkD1MtvOmyQJjqhPb0PMU9Y4U9Qa0IbZGvT2kc48i7P+rVObPwthhzroX1MSBvLP2gJp3XAtwBlaN1vKrimuKIsXi2iP09lddU9c7pByoOEacE8Au8/nUdiayeVKvHF9wKcPhnRoxeeM4nXZlnHY21fVRaot+t505KadXNoOcbGufvIp/RL9C4G6su07HhwMcH+jbfq8MsTs9F8KP128IPxcVhr4l/NDJpXyaaNsKJstL90ZDjD8lm9cmG7efdimxG9F2erugTXntVGLvDb0eeXAbensosekusFpiwxVmtkehmDzt2GNg7vA9xo71qCTad3l4NvBwX61LRKjc/HMnqNZuhcpxIhXm2EPesHruar5QBRL3j3/F6iZTrI8SZSKuT2XSscskVxfRNvT79cy5rpZL165OuBMR6pftp0ppp7i73lq7lEqNgO8l8Nbv2U+10o74NRRLjfjtoVjymm6TT9XSf7FrG8qlw+3a+nn2M/9nAbe39kpmC8Q29W10JPoKixtMj5XM/RqsaRsjsHtIht3KdZVf31qNJek+MmH9FPlOfVy5l/HPj+jk+mnPlcrvxLveBR1tXkoOh3Gus/F+ndt3t9euciI6HcO59RPTO3Nu/Qq/KcMdyLv1Y8g7827PXWu7qDs4GHehmf8nLvvtJP/joT/+CQ==</diagram></mxfile>
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

2 changes: 1 addition & 1 deletion dependency-injection/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xs
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>**/*Demo.java</include>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,24 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;

import com.baeldung.configuration.ApplicationContextTestAutowiredName;
import com.baeldung.dependency.ArbitraryDependency;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={
"/applicationContextTest-@Autowired-Name.xml"})
public class FieldAutowiredNameDemo {
@ContextConfiguration(
loader=AnnotationConfigContextLoader.class,
classes=ApplicationContextTestAutowiredName.class)
public class FieldAutowiredNameTest {

@Autowired
private ArbitraryDependency autowiredFieldDependency;

@Test
public void autowiredFieldDependency_MUST_BE_AUTOWIRED_Correctly() {
public void givenAutowiredAnnotation_WhenOnField_ThenDependencyValid(){
assertNotNull(autowiredFieldDependency);
assertEquals("Arbitrary Dependency", autowiredFieldDependency.toString());
assertEquals("Arbitrary Dependency",
autowiredFieldDependency.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;

import com.baeldung.configuration.ApplicationContextTestAutowiredType;
import com.baeldung.dependency.ArbitraryDependency;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={
"/applicationContextTest-@Autowired-Type.xml"})
public class FieldAutowiredDemo {
@ContextConfiguration(
loader=AnnotationConfigContextLoader.class,
classes=ApplicationContextTestAutowiredType.class)
public class FieldAutowiredTest {

@Autowired
private ArbitraryDependency fieldDependency;

@Test
public void fieldDependency_MUST_BE_AUTOWIRED_Correctly() {
public void givenAutowired_WhenSetOnField_ThenDependencyResolved() {
assertNotNull(fieldDependency);
assertEquals("Arbitrary Dependency", fieldDependency.toString());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;

import com.baeldung.configuration.ApplicationContextTestAutowiredQualifier;
import com.baeldung.dependency.ArbitraryDependency;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={
"/applicationContextTest-@Autowired-Qualifier.xml"})
public class FieldQualifierAutowiredDemo {
@ContextConfiguration(
loader=AnnotationConfigContextLoader.class,
classes=ApplicationContextTestAutowiredQualifier.class)
public class FieldQualifierAutowiredTest {

@Autowired
@Qualifier("autowiredFieldDependency")
Expand All @@ -26,14 +29,15 @@ public class FieldQualifierAutowiredDemo {
private ArbitraryDependency fieldDependency2;

@Test
public void fieldDependency1_MUST_BE_AUTOWIRED_Correctly() {
public void givenAutowiredQualifier_WhenOnField_ThenDep1Valid(){
assertNotNull(fieldDependency1);
assertEquals("Arbitrary Dependency", fieldDependency1.toString());
}

@Test
public void fieldDependency2_MUST_BE_AUTOWIRED_Correctly() {
public void givenAutowiredQualifier_WhenOnField_ThenDep2Valid(){
assertNotNull(fieldDependency2);
assertEquals("Another Arbitrary Dependency", fieldDependency2.toString());
assertEquals("Another Arbitrary Dependency",
fieldDependency2.toString());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.baeldung.configuration;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan(basePackages={"com.baeldung.dependency"})
public class ApplicationContextTestAutowiredName {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.baeldung.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.baeldung.dependency.AnotherArbitraryDependency;
import com.baeldung.dependency.ArbitraryDependency;

@Configuration
public class ApplicationContextTestAutowiredQualifier {

@Bean
public ArbitraryDependency autowiredFieldDependency() {
ArbitraryDependency autowiredFieldDependency = new ArbitraryDependency();

return autowiredFieldDependency;
}

@Bean
public ArbitraryDependency anotherAutowiredFieldDependency() {
ArbitraryDependency anotherAutowiredFieldDependency = new AnotherArbitraryDependency();

return anotherAutowiredFieldDependency;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.baeldung.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.baeldung.dependency.ArbitraryDependency;

@Configuration
public class ApplicationContextTestAutowiredType {

@Bean
public ArbitraryDependency autowiredFieldDependency() {
ArbitraryDependency autowiredFieldDependency = new ArbitraryDependency();
return autowiredFieldDependency;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.baeldung.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.baeldung.dependency.ArbitraryDependency;
import com.baeldung.dependency.YetAnotherArbitraryDependency;

@Configuration
public class ApplicationContextTestInjectName {

@Bean
public ArbitraryDependency yetAnotherFieldInjectDependency() {
ArbitraryDependency yetAnotherFieldInjectDependency = new YetAnotherArbitraryDependency();
return yetAnotherFieldInjectDependency;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.baeldung.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.baeldung.dependency.AnotherArbitraryDependency;
import com.baeldung.dependency.ArbitraryDependency;

@Configuration
public class ApplicationContextTestInjectQualifier {

@Bean
public ArbitraryDependency defaultFile() {
ArbitraryDependency defaultFile = new ArbitraryDependency();
return defaultFile;
}

@Bean
public ArbitraryDependency namedFile() {
ArbitraryDependency namedFile = new AnotherArbitraryDependency();
return namedFile;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.baeldung.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.baeldung.dependency.ArbitraryDependency;

@Configuration
public class ApplicationContextTestInjectType {

@Bean
public ArbitraryDependency injectDependency() {
ArbitraryDependency injectDependency = new ArbitraryDependency();
return injectDependency;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.baeldung.configuration;

import java.io.File;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ApplicationContextTestResourceNameType {

@Bean(name="namedFile")
public File namedFile() {
File namedFile = new File("namedFile.txt");
return namedFile;
}
}
Loading