Revert "Spring Groovy Config with fixed pom" (#1209)

This commit is contained in:
Grzegorz Piwowarek
2017-02-21 07:35:07 +01:00
committed by GitHub
parent a75ed7e70a
commit d3d11a18f3
22 changed files with 0 additions and 449 deletions

View File

@@ -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<TestFailure> 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");
}
}
}
}

View File

@@ -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;
}
}

View File

@@ -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"));
}
}

View File

@@ -1,6 +0,0 @@
package com.baeldung.java_bean_injection;
public class AutowireObject {
}

View File

@@ -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();
}
}

View File

@@ -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;
}
}