diff --git a/spring-core/src/main/java/com/baeldung/annotationinjection/App.java b/spring-core/src/main/java/com/baeldung/annotationinjection/App.java deleted file mode 100644 index dc9560286d..0000000000 --- a/spring-core/src/main/java/com/baeldung/annotationinjection/App.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.baeldung.java_bean_injection; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -import com.baeldung.java_bean_injection.*; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - - -import junit.framework.TestResult; -import junit.framework.TestFailure; - -import java.util.Enumeration; - - -/** - * Bean Injection Test Application - * - */ -public class App -{ - public static void main( String[] args ) - { - - TestResult result = new TestResult(); - AppTest.suite().run(result); - System.out.println(String.format("Tests: %d",result.runCount())); - System.out.println(String.format("Errors: %d",result.errorCount())); - System.out.println(String.format("Failures: %d",result.failureCount())); - if(result.failureCount() > 0){ - Enumeration failures = result.failures(); - int failNum = 0; - TestFailure failure = null; - while(failures.hasMoreElements()){ - failure = failures.nextElement(); - - System.out.println(failure.exceptionMessage()); - System.out.println(String.format("Test Failure %d\n",failNum)); - System.out.println(failure.trace()); - System.out.print("\n"); - } - } - - } -} diff --git a/spring-core/src/main/java/com/baeldung/annotationinjection/AppConfig.java b/spring-core/src/main/java/com/baeldung/annotationinjection/AppConfig.java deleted file mode 100644 index 138bda6b1b..0000000000 --- a/spring-core/src/main/java/com/baeldung/annotationinjection/AppConfig.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.baeldung.java_bean_injection; - -import org.springframework.beans.factory.annotation.*; -import org.springframework.context.annotation.*; -import org.springframework.stereotype.*; - -import com.baeldung.java_bean_injection.*; - -@Configuration -@PropertySource(value="classpath:inject.properties") -@Import(ImportConfig.class) -public class AppConfig { - @Value("${contructor.arg1}") String constructorArg; - - @Bean - public InjectedClass injectedClass(){ - InjectedClass ic = new InjectedClass(constructorArg); - ic.setMyInt(10); - ic.setTestString("test"); - return ic; - } - -} diff --git a/spring-core/src/main/java/com/baeldung/annotationinjection/AppTest.java b/spring-core/src/main/java/com/baeldung/annotationinjection/AppTest.java deleted file mode 100644 index fa7b46f06b..0000000000 --- a/spring-core/src/main/java/com/baeldung/annotationinjection/AppTest.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.baeldung.java_bean_injection; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -import com.baeldung.java_bean_injection.*; - -import java.io.File; -import java.util.Scanner; - -/** - * Unit test for simple App. - */ -public class AppTest extends TestCase{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - AnnotationConfigApplicationContext context= new AnnotationConfigApplicationContext(); - context.register(AppConfig.class); - context.refresh(); - InjectedClass injectedClass = (InjectedClass) context.getBean(InjectedClass.class); - assertTrue(injectedClass.getMyInt() == 10); - assertTrue(injectedClass.getTestString().equals("test")); - assertNotNull(injectedClass.obj); - assertTrue(injectedClass.myConstructorArg.equals("test")); - } -} diff --git a/spring-core/src/main/java/com/baeldung/annotationinjection/AutowireObject.java b/spring-core/src/main/java/com/baeldung/annotationinjection/AutowireObject.java deleted file mode 100644 index df5859f0af..0000000000 --- a/spring-core/src/main/java/com/baeldung/annotationinjection/AutowireObject.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.baeldung.java_bean_injection; - - -public class AutowireObject { - -} diff --git a/spring-core/src/main/java/com/baeldung/annotationinjection/ImportConfig.java b/spring-core/src/main/java/com/baeldung/annotationinjection/ImportConfig.java deleted file mode 100644 index e37d94931b..0000000000 --- a/spring-core/src/main/java/com/baeldung/annotationinjection/ImportConfig.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baeldung.java_bean_injection; - -import org.springframework.context.annotation.*; - -import com.baeldung.java_bean_injection.*; - -@Configuration -public class ImportConfig { - - @Bean(name="autobean") - public AutowireObject autowireObject(){ - return new AutowireObject(); - } - - - @Bean(name="autobean2") - public AutowireObject autowireObject2(){ - return new AutowireObject(); - } -} diff --git a/spring-core/src/main/java/com/baeldung/annotationinjection/InjectedClass.java b/spring-core/src/main/java/com/baeldung/annotationinjection/InjectedClass.java deleted file mode 100644 index 55fe733db5..0000000000 --- a/spring-core/src/main/java/com/baeldung/annotationinjection/InjectedClass.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.baeldung.java_bean_injection; - -import org.springframework.beans.factory.annotation.*; -import org.springframework.context.annotation.*; - -import com.baeldung.java_bean_injection.*; - - -public class InjectedClass { - private int myInt; - private String testString; - String myConstructorArg; - - - @Autowired - @Qualifier("autobean") - AutowireObject obj; - - public InjectedClass(String constArg){ - this.myConstructorArg = constArg; - } - - public void setMyInt(int myInt){ - this.myInt = myInt; - } - - public void setTestString(String testString){ - this.testString = testString; - } - - public int getMyInt(){ - return this.myInt; - } - - public String getTestString(){ - return this.testString; - } - -} diff --git a/spring-groovy-config/.gitignore b/spring-groovy-config/.gitignore deleted file mode 100644 index b83d22266a..0000000000 --- a/spring-groovy-config/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target/ diff --git a/spring-groovy-config/.settings/org.eclipse.core.resources.prefs b/spring-groovy-config/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index f9fe34593f..0000000000 --- a/spring-groovy-config/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,4 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/test/java=UTF-8 -encoding/=UTF-8 diff --git a/spring-groovy-config/.settings/org.eclipse.jdt.core.prefs b/spring-groovy-config/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index abec6ca389..0000000000 --- a/spring-groovy-config/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.5 diff --git a/spring-groovy-config/.settings/org.eclipse.jdt.groovy.core.prefs b/spring-groovy-config/.settings/org.eclipse.jdt.groovy.core.prefs deleted file mode 100644 index ae98feaa79..0000000000 --- a/spring-groovy-config/.settings/org.eclipse.jdt.groovy.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -groovy.compiler.level=24 diff --git a/spring-groovy-config/.settings/org.eclipse.m2e.core.prefs b/spring-groovy-config/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f1cb..0000000000 --- a/spring-groovy-config/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/spring-groovy-config/config/groovyContextWithConstructor.groovy b/spring-groovy-config/config/groovyContextWithConstructor.groovy deleted file mode 100644 index dbde5f3822..0000000000 --- a/spring-groovy-config/config/groovyContextWithConstructor.groovy +++ /dev/null @@ -1,9 +0,0 @@ -import com.baeldung.spring_groovy_config.TestClass - -beans{ - testString String, 'Test String' - testClass(TestClass){ - beanDefinition -> - beanDefinition.constructorArgs = ["Test String",10.2] - } -} \ No newline at end of file diff --git a/spring-groovy-config/config/groovyPropConfig.groovy b/spring-groovy-config/config/groovyPropConfig.groovy deleted file mode 100644 index 08d3acf354..0000000000 --- a/spring-groovy-config/config/groovyPropConfig.groovy +++ /dev/null @@ -1,5 +0,0 @@ -import com.baeldung.spring_groovy_config.TestClassB - -beans{ - testClassB(TestClassB,testStringB:"Test String",testIntB:10.2) -} \ No newline at end of file diff --git a/spring-groovy-config/config/groovyPropConfigWithClosure.groovy b/spring-groovy-config/config/groovyPropConfigWithClosure.groovy deleted file mode 100644 index 3ca306bdd7..0000000000 --- a/spring-groovy-config/config/groovyPropConfigWithClosure.groovy +++ /dev/null @@ -1,8 +0,0 @@ -import com.baeldung.spring_groovy_config.TestClassB - -beans{ - testClassB(TestClassB){ - testStringB = "Test String" - testIntB = 10 - } -} \ No newline at end of file diff --git a/spring-groovy-config/config/groovyTestWithRefBean.groovy b/spring-groovy-config/config/groovyTestWithRefBean.groovy deleted file mode 100644 index d079480d46..0000000000 --- a/spring-groovy-config/config/groovyTestWithRefBean.groovy +++ /dev/null @@ -1,10 +0,0 @@ -import com.baeldung.spring_groovy_config.GroovyClass -import com.baeldung.spring_groovy_config.ClassWithRef - -beans{ - groovyClass(GroovyClass, groovyInt:5) - classWithRef(ClassWithRef){ - myClass = groovyClass - } - -} \ No newline at end of file diff --git a/spring-groovy-config/pom.xml b/spring-groovy-config/pom.xml deleted file mode 100644 index f6c63ae232..0000000000 --- a/spring-groovy-config/pom.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - 4.0.0 - com.baeldung - spring-groovy-config - 0.0.1-SNAPSHOT - jar - spring-groovy-config - http://maven.apache.org - - UTF-8 - - - - - maven-compiler-plugin - - 3.1 - - groovy-eclipse-compiler - - - - org.codehaus.groovy - groovy-eclipse-compiler - 2.9.1-01 - - - - org.codehaus.groovy - groovy-eclipse-batch - 2.3.7-01 - - - - - - - - org.codehaus.groovy - groovy-all - 2.4.8 - - - junit - junit - 4.12 - test - - - org.springframework - spring-context - 4.3.6.RELEASE - - - org.springframework - spring-core - 4.3.6.RELEASE - - - org.springframework - spring-test - 4.3.6.RELEASE - - - - diff --git a/spring-groovy-config/src/main/java/com/baeldung/spring_groovy_config/ClassWithRef.java b/spring-groovy-config/src/main/java/com/baeldung/spring_groovy_config/ClassWithRef.java deleted file mode 100644 index ec8987f387..0000000000 --- a/spring-groovy-config/src/main/java/com/baeldung/spring_groovy_config/ClassWithRef.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.baeldung.spring_groovy_config; - -import org.springframework.stereotype.Component; - -import com.baeldung.spring_groovy_config.GroovyClass; - -@Component -public class ClassWithRef { - private GroovyClass myClass = null; - - public void setMyClass(GroovyClass myClass){ - this.myClass = myClass; - } - - public GroovyClass getMyClass(){ - return this.myClass; - } -} diff --git a/spring-groovy-config/src/main/java/com/baeldung/spring_groovy_config/GroovyClass.groovy b/spring-groovy-config/src/main/java/com/baeldung/spring_groovy_config/GroovyClass.groovy deleted file mode 100644 index 2a1ef6a2c5..0000000000 --- a/spring-groovy-config/src/main/java/com/baeldung/spring_groovy_config/GroovyClass.groovy +++ /dev/null @@ -1,9 +0,0 @@ -package com.baeldung.spring_groovy_config - -class GroovyClass { - int groovyInt = 0 - - def getGroovyInt(){ - return groovyInt - } -} diff --git a/spring-groovy-config/src/main/java/com/baeldung/spring_groovy_config/MainApp.java b/spring-groovy-config/src/main/java/com/baeldung/spring_groovy_config/MainApp.java deleted file mode 100644 index ac85963cf7..0000000000 --- a/spring-groovy-config/src/main/java/com/baeldung/spring_groovy_config/MainApp.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.baeldung.spring_groovy_config; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.support.GenericGroovyApplicationContext; - -public class MainApp { - public static void main(String[] args){ - ApplicationContext context = new GenericGroovyApplicationContext("file:config/groovyTestWithRefBean.groovy"); - ClassWithRef test = (ClassWithRef) context.getBean("classWithRef"); - } -} diff --git a/spring-groovy-config/src/main/java/com/baeldung/spring_groovy_config/TestClass.java b/spring-groovy-config/src/main/java/com/baeldung/spring_groovy_config/TestClass.java deleted file mode 100644 index 75b6b5fc5b..0000000000 --- a/spring-groovy-config/src/main/java/com/baeldung/spring_groovy_config/TestClass.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baeldung.spring_groovy_config; - -import org.springframework.stereotype.Component; - -@Component -public class TestClass { - private String testString; - private double testDouble; - - public TestClass(String testString, double testDouble){ - this.testString = testString; - this.testDouble = testDouble; - } - - public String getTestString(){ - return this.testString; - } - - public double getTestDouble(){ - return this.testDouble; - } -} diff --git a/spring-groovy-config/src/main/java/com/baeldung/spring_groovy_config/TestClassB.java b/spring-groovy-config/src/main/java/com/baeldung/spring_groovy_config/TestClassB.java deleted file mode 100644 index d2387c87e5..0000000000 --- a/spring-groovy-config/src/main/java/com/baeldung/spring_groovy_config/TestClassB.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.baeldung.spring_groovy_config; - -import org.springframework.stereotype.Component; - -@Component -public class TestClassB { - private String testStringB; - private int testIntB; - - public void setTestStringB(String testStringB){ - this.testStringB = testStringB; - } - - public String getTestStringB(){ - return this.testStringB; - } - - - public void setTestIntB(int testIntB){ - this.testIntB = testIntB; - } - - public int getTestIntB(){ - return this.testIntB; - } -} diff --git a/spring-groovy-config/src/test/java/com/baeldung/spring_groovy_config/AppTest.java b/spring-groovy-config/src/test/java/com/baeldung/spring_groovy_config/AppTest.java deleted file mode 100644 index 93de401e0c..0000000000 --- a/spring-groovy-config/src/test/java/com/baeldung/spring_groovy_config/AppTest.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.baeldung.spring_groovy_config; - -import com.baeldung.spring_groovy_config.*; -import groovy.lang.Binding; -import junit.framework.TestCase; -import static org.junit.Assert.*; -import org.junit.Test; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.support.FileSystemXmlApplicationContext; -import org.springframework.context.support.GenericApplicationContext; -import org.springframework.context.support.GenericGroovyApplicationContext; -import org.springframework.core.env.ConfigurableEnvironment; -/** - * Spring Framework Tests for Groovy. - */ -public class AppTest{ - - @Test - public void testSimple(){ - ApplicationContext context = new GenericGroovyApplicationContext("file:config/groovyContextWithConstructor.groovy"); - TestClass test = (TestClass) context.getBean("testClass"); - assertNotNull(test.getTestString()); - assertEquals(test.getTestString(),"Test String"); - assertTrue(test.getTestDouble() == 10.2); - - String testString = context.getBean("testString",String.class); - assertEquals(testString,"Test String"); - } - - - @Test - public void testProperties(){ - ApplicationContext context = new GenericGroovyApplicationContext("file:config/groovyPropConfig.groovy"); - TestClassB test = (TestClassB) context.getBean("testClassB"); - assertNotNull(test.getTestStringB()); - assertEquals(test.getTestStringB(),"Test String"); - assertTrue(test.getTestIntB() == 10); - } - - @Test - public void testPropertiesWithClosure(){ - ApplicationContext context = new GenericGroovyApplicationContext("file:config/groovyPropConfigWithClosure.groovy"); - TestClassB test = (TestClassB) context.getBean("testClassB"); - assertNotNull(test.getTestStringB()); - assertEquals(test.getTestStringB(),"Test String"); - assertTrue(test.getTestIntB() == 10); - } - - - @Test - public void testWithRef(){ - ApplicationContext context = new GenericGroovyApplicationContext("file:config/groovyTestWithRefBean.groovy"); - ClassWithRef test = (ClassWithRef) context.getBean("classWithRef"); - assertEquals(test.getMyClass().getGroovyInt(),5); - } -}