Put code under test in own package
This commit is contained in:
-9
@@ -1,9 +0,0 @@
|
||||
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 {
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
package com.baeldung.configuration;
|
||||
|
||||
import com.baeldung.dependency.AnotherArbitraryDependency;
|
||||
import com.baeldung.dependency.ArbitraryDependency;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class ApplicationContextTestAutowiredQualifier {
|
||||
|
||||
@Bean
|
||||
public ArbitraryDependency autowiredFieldDependency() {
|
||||
ArbitraryDependency autowiredFieldDependency = new ArbitraryDependency();
|
||||
|
||||
return autowiredFieldDependency;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ArbitraryDependency anotherAutowiredFieldDependency() {
|
||||
ArbitraryDependency anotherAutowiredFieldDependency = new AnotherArbitraryDependency();
|
||||
|
||||
return anotherAutowiredFieldDependency;
|
||||
}
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package com.baeldung.configuration;
|
||||
|
||||
import com.baeldung.dependency.ArbitraryDependency;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class ApplicationContextTestAutowiredType {
|
||||
|
||||
@Bean
|
||||
public ArbitraryDependency autowiredFieldDependency() {
|
||||
ArbitraryDependency autowiredFieldDependency = new ArbitraryDependency();
|
||||
return autowiredFieldDependency;
|
||||
}
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
package com.baeldung.configuration;
|
||||
|
||||
import com.baeldung.dependency.ArbitraryDependency;
|
||||
import com.baeldung.dependency.YetAnotherArbitraryDependency;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class ApplicationContextTestInjectName {
|
||||
|
||||
@Bean
|
||||
public ArbitraryDependency yetAnotherFieldInjectDependency() {
|
||||
ArbitraryDependency yetAnotherFieldInjectDependency = new YetAnotherArbitraryDependency();
|
||||
return yetAnotherFieldInjectDependency;
|
||||
}
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
package com.baeldung.configuration;
|
||||
|
||||
import com.baeldung.dependency.AnotherArbitraryDependency;
|
||||
import com.baeldung.dependency.ArbitraryDependency;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class ApplicationContextTestInjectQualifier {
|
||||
|
||||
@Bean
|
||||
public ArbitraryDependency defaultFile() {
|
||||
ArbitraryDependency defaultFile = new ArbitraryDependency();
|
||||
return defaultFile;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ArbitraryDependency namedFile() {
|
||||
ArbitraryDependency namedFile = new AnotherArbitraryDependency();
|
||||
return namedFile;
|
||||
}
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package com.baeldung.configuration;
|
||||
|
||||
import com.baeldung.dependency.ArbitraryDependency;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class ApplicationContextTestInjectType {
|
||||
|
||||
@Bean
|
||||
public ArbitraryDependency injectDependency() {
|
||||
ArbitraryDependency injectDependency = new ArbitraryDependency();
|
||||
return injectDependency;
|
||||
}
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
package com.baeldung.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Configuration
|
||||
public class ApplicationContextTestResourceNameType {
|
||||
|
||||
@Bean(name = "namedFile")
|
||||
public File namedFile() {
|
||||
File namedFile = new File("namedFile.txt");
|
||||
return namedFile;
|
||||
}
|
||||
}
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
package com.baeldung.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Configuration
|
||||
public class ApplicationContextTestResourceQualifier {
|
||||
|
||||
@Bean(name = "defaultFile")
|
||||
public File defaultFile() {
|
||||
File defaultFile = new File("defaultFile.txt");
|
||||
return defaultFile;
|
||||
}
|
||||
|
||||
@Bean(name = "namedFile")
|
||||
public File namedFile() {
|
||||
File namedFile = new File("namedFile.txt");
|
||||
return namedFile;
|
||||
}
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package com.baeldung.dependency;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class AnotherArbitraryDependency extends ArbitraryDependency {
|
||||
|
||||
private final String label = "Another Arbitrary Dependency";
|
||||
|
||||
public String toString() {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.baeldung.dependency;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component(value = "autowiredFieldDependency")
|
||||
public class ArbitraryDependency {
|
||||
|
||||
private final String label = "Arbitrary Dependency";
|
||||
|
||||
public String toString() {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package com.baeldung.dependency;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class YetAnotherArbitraryDependency extends ArbitraryDependency {
|
||||
|
||||
private final String label = "Yet Another Arbitrary Dependency";
|
||||
|
||||
public String toString() {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user