JAVA-2422: Merge spring-groovy into spring-boot-groovy (#9970)
* JAVA-2422: Moved article to spring-boot-groovy * JAVA-2422: removed module spring-groovy * JAVA-2422: Moved spring-boot-groovy inside spring-boot-modules module * JAVA-2422: Added entry to spring-boot-module's pom * JAVA-2422: main pom changes for module movements * JAVA-2422: Renamed test as it needs the app up and running * JAVA-2422: Renamed test to live as it needs App to be running
This commit is contained in:
9
spring-boot-modules/spring-boot-groovy/README.md
Normal file
9
spring-boot-modules/spring-boot-groovy/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
## Spring Boot Groovy
|
||||
|
||||
This module contains articles about Spring with Groovy
|
||||
|
||||
|
||||
### Relevant Articles:
|
||||
|
||||
- [Building a Simple Web Application with Spring Boot and Groovy](https://www.baeldung.com/spring-boot-groovy-web-app)
|
||||
- [Groovy Bean Definitions](https://www.baeldung.com/spring-groovy-beans)
|
||||
78
spring-boot-modules/spring-boot-groovy/pom.xml
Normal file
78
spring-boot-modules/spring-boot-groovy/pom.xml
Normal file
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.baeldung.app</groupId>
|
||||
<artifactId>spring-boot-groovy</artifactId>
|
||||
<name>spring-boot-groovy</name>
|
||||
<packaging>war</packaging>
|
||||
<description>Spring Boot Todo Application with Groovy</description>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-boot-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-boot-2</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.gmavenplus</groupId>
|
||||
<artifactId>gmavenplus-plugin</artifactId>
|
||||
<version>1.9.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>addSources</goal>
|
||||
<goal>addTestSources</goal>
|
||||
<goal>generateStubs</goal>
|
||||
<goal>compile</goal>
|
||||
<goal>generateTestStubs</goal>
|
||||
<goal>compileTests</goal>
|
||||
<goal>removeStubs</goal>
|
||||
<goal>removeTestStubs</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<start-class>com.baeldung.springwithgroovy.SpringBootGroovyApplication</start-class>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.baeldung.springwithgroovy
|
||||
|
||||
import org.springframework.boot.SpringApplication
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
|
||||
import com.baeldung.springwithgroovy.SpringBootGroovyApplication
|
||||
|
||||
@SpringBootApplication
|
||||
class SpringBootGroovyApplication {
|
||||
static void main(String[] args) {
|
||||
SpringApplication.run SpringBootGroovyApplication, args
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.baeldung.springwithgroovy.controller
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.web.bind.annotation.DeleteMapping
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
import org.springframework.web.bind.annotation.PostMapping
|
||||
import org.springframework.web.bind.annotation.PutMapping
|
||||
import org.springframework.web.bind.annotation.RequestBody
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RequestMethod
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
import com.baeldung.springwithgroovy.entity.Todo
|
||||
import com.baeldung.springwithgroovy.service.TodoService
|
||||
|
||||
@RestController
|
||||
@RequestMapping('todo')
|
||||
public class TodoController {
|
||||
|
||||
@Autowired
|
||||
TodoService todoService
|
||||
|
||||
@GetMapping
|
||||
List<Todo> getAllTodoList(){
|
||||
todoService.findAll()
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
Todo saveTodo(@RequestBody Todo todo){
|
||||
todoService.saveTodo todo
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
Todo updateTodo(@RequestBody Todo todo){
|
||||
todoService.updateTodo todo
|
||||
}
|
||||
|
||||
@DeleteMapping('/{todoId}')
|
||||
deleteTodo(@PathVariable Integer todoId){
|
||||
todoService.deleteTodo todoId
|
||||
}
|
||||
|
||||
@GetMapping('/{todoId}')
|
||||
Todo getTodoById(@PathVariable Integer todoId){
|
||||
todoService.findById todoId
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.baeldung.springwithgroovy.entity
|
||||
|
||||
import javax.persistence.Column
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.GeneratedValue
|
||||
import javax.persistence.GenerationType
|
||||
import javax.persistence.Id
|
||||
import javax.persistence.Table
|
||||
|
||||
@Entity
|
||||
@Table(name = 'todo')
|
||||
class Todo {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
Integer id
|
||||
|
||||
@Column
|
||||
String task
|
||||
|
||||
@Column
|
||||
Boolean isCompleted
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.baeldung.springwithgroovy.repository
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
import com.baeldung.springwithgroovy.entity.Todo
|
||||
|
||||
@Repository
|
||||
interface TodoRepository extends JpaRepository<Todo, Integer> {}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.baeldung.springwithgroovy.service
|
||||
|
||||
import com.baeldung.springwithgroovy.entity.Todo
|
||||
|
||||
interface TodoService {
|
||||
|
||||
List<Todo> findAll()
|
||||
|
||||
Todo findById(Integer todoId)
|
||||
|
||||
Todo saveTodo(Todo todo)
|
||||
|
||||
Todo updateTodo(Todo todo)
|
||||
|
||||
Todo deleteTodo(Integer todoId)
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.baeldung.springwithgroovy.service.impl
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.stereotype.Service
|
||||
|
||||
import com.baeldung.springwithgroovy.entity.Todo
|
||||
import com.baeldung.springwithgroovy.repository.TodoRepository
|
||||
import com.baeldung.springwithgroovy.service.TodoService
|
||||
|
||||
@Service
|
||||
class TodoServiceImpl implements TodoService {
|
||||
|
||||
@Autowired
|
||||
TodoRepository todoRepository
|
||||
|
||||
@Override
|
||||
List<Todo> findAll() {
|
||||
todoRepository.findAll()
|
||||
}
|
||||
|
||||
@Override
|
||||
Todo findById(Integer todoId) {
|
||||
todoRepository.findById todoId get()
|
||||
}
|
||||
|
||||
@Override
|
||||
Todo saveTodo(Todo todo){
|
||||
todoRepository.save todo
|
||||
}
|
||||
|
||||
@Override
|
||||
Todo updateTodo(Todo todo){
|
||||
todoRepository.save todo
|
||||
}
|
||||
|
||||
@Override
|
||||
Todo deleteTodo(Integer todoId){
|
||||
todoRepository.deleteById todoId
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.groovyconfig;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BandsBean {
|
||||
|
||||
private List<String> bandsList = new ArrayList<>();
|
||||
|
||||
public List<String> getBandsList() {
|
||||
return bandsList;
|
||||
}
|
||||
|
||||
public void setBandsList(List<String> bandsList) {
|
||||
this.bandsList = bandsList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.baeldung.groovyconfig;
|
||||
|
||||
beans {
|
||||
javaPesronBean(JavaPersonBean) {
|
||||
firstName = 'John'
|
||||
lastName = 'Doe'
|
||||
age ='32'
|
||||
eyesColor = 'blue'
|
||||
hairColor='black'
|
||||
}
|
||||
|
||||
bandsBean(BandsBean) { bean->
|
||||
bean.scope = "singleton"
|
||||
bandsList=['Nirvana', 'Pearl Jam', 'Foo Fighters']
|
||||
}
|
||||
|
||||
registerAlias("bandsBean","bands")
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.baeldung.groovyconfig;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class JavaBeanConfig {
|
||||
|
||||
@Bean
|
||||
public JavaPersonBean javaPerson() {
|
||||
JavaPersonBean jPerson = new JavaPersonBean();
|
||||
jPerson.setFirstName("John");
|
||||
jPerson.setLastName("Doe");
|
||||
jPerson.setAge("31");
|
||||
jPerson.setEyesColor("green");
|
||||
jPerson.setHairColor("blond");
|
||||
|
||||
return jPerson;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.baeldung.groovyconfig;
|
||||
|
||||
public class JavaPersonBean {
|
||||
|
||||
public String jj;
|
||||
|
||||
private String firstName;
|
||||
|
||||
private String lastName;
|
||||
|
||||
private String age;
|
||||
|
||||
private String eyesColor;
|
||||
|
||||
private String hairColor;
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(String age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public String getEyesColor() {
|
||||
return eyesColor;
|
||||
}
|
||||
|
||||
public void setEyesColor(String eyesColor) {
|
||||
this.eyesColor = eyesColor;
|
||||
}
|
||||
|
||||
public String getHairColor() {
|
||||
return hairColor;
|
||||
}
|
||||
|
||||
public void setHairColor(String hairColor) {
|
||||
this.hairColor = hairColor;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.baeldung.spring_groovy;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*
|
||||
*/
|
||||
public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
System.out.println( "Hello World!" );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.baeldung.spring_groovy;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class TestConfig {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
spring.datasource.url=jdbc:h2:mem:todo
|
||||
spring.datasource.driverClassName=org.h2.Driver
|
||||
spring.datasource.username=sa
|
||||
spring.datasource.password=sa
|
||||
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
|
||||
@@ -0,0 +1,5 @@
|
||||
beans{
|
||||
testString String, 'test'
|
||||
testNum int, 100
|
||||
testObj(i:101,s:'objVal')
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
<bean id="JavaPersonBean" class="com.baeldung.groovyconfig.JavaPersonBean">
|
||||
<property name="firstName" value="John" />
|
||||
<property name="LastName" value="Doe" />
|
||||
<property name="age" value="30" />
|
||||
<property name="eyesColor" value="brown" />
|
||||
<property name="hairColor" value="brown" />
|
||||
</bean>
|
||||
</beans>
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.baeldung.springwithgroovy
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue
|
||||
|
||||
import org.junit.BeforeClass
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.http.MediaType
|
||||
import org.springframework.test.context.event.annotation.BeforeTestClass
|
||||
import org.springframework.test.context.junit4.SpringRunner
|
||||
|
||||
import com.baeldung.springwithgroovy.entity.Todo
|
||||
|
||||
import io.restassured.RestAssured
|
||||
import io.restassured.response.Response
|
||||
|
||||
// This test requires the com.baeldung.springwithgroovy.SpringBootGroovyApplication to be up
|
||||
// For that, run the maven build - spring-boot:run on the module
|
||||
|
||||
class TodoAppLiveTest {
|
||||
static API_ROOT = 'http://localhost:8080/todo'
|
||||
static readingTodoId
|
||||
static writingTodoId
|
||||
|
||||
@BeforeClass
|
||||
static void populateDummyData() {
|
||||
Todo readingTodo = new Todo(task: 'Reading', isCompleted: false)
|
||||
Todo writingTodo = new Todo(task: 'Writing', isCompleted: false)
|
||||
|
||||
final Response readingResponse =
|
||||
RestAssured.given()
|
||||
.contentType(MediaType.APPLICATION_JSON_VALUE)
|
||||
.body(readingTodo).post(API_ROOT)
|
||||
|
||||
Todo cookingTodoResponse = readingResponse.as Todo.class
|
||||
readingTodoId = cookingTodoResponse.getId()
|
||||
|
||||
final Response writingResponse =
|
||||
RestAssured.given()
|
||||
.contentType(MediaType.APPLICATION_JSON_VALUE)
|
||||
.body(writingTodo).post(API_ROOT)
|
||||
|
||||
Todo writingTodoResponse = writingResponse.as Todo.class
|
||||
writingTodoId = writingTodoResponse.getId()
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenGetAllTodoList_thenOk(){
|
||||
final Response response = RestAssured.get(API_ROOT)
|
||||
|
||||
assertEquals HttpStatus.OK.value(),response.getStatusCode()
|
||||
assertTrue response.as(List.class).size() > 0
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenGetTodoById_thenOk(){
|
||||
final Response response =
|
||||
RestAssured.get("$API_ROOT/$readingTodoId")
|
||||
|
||||
assertEquals HttpStatus.OK.value(),response.getStatusCode()
|
||||
Todo todoResponse = response.as Todo.class
|
||||
assertEquals readingTodoId,todoResponse.getId()
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenUpdateTodoById_thenOk(){
|
||||
Todo todo = new Todo(id:readingTodoId, isCompleted: true)
|
||||
final Response response =
|
||||
RestAssured.given()
|
||||
.contentType(MediaType.APPLICATION_JSON_VALUE)
|
||||
.body(todo).put(API_ROOT)
|
||||
|
||||
assertEquals HttpStatus.OK.value(),response.getStatusCode()
|
||||
Todo todoResponse = response.as Todo.class
|
||||
assertTrue todoResponse.getIsCompleted()
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenDeleteTodoById_thenOk(){
|
||||
final Response response =
|
||||
RestAssured.given()
|
||||
.delete("$API_ROOT/$writingTodoId")
|
||||
|
||||
assertEquals HttpStatus.OK.value(),response.getStatusCode()
|
||||
}
|
||||
|
||||
@Test
|
||||
void whenSaveTodo_thenOk(){
|
||||
Todo todo = new Todo(task: 'Blogging', isCompleted: false)
|
||||
final Response response =
|
||||
RestAssured.given()
|
||||
.contentType(MediaType.APPLICATION_JSON_VALUE)
|
||||
.body(todo).post(API_ROOT)
|
||||
|
||||
assertEquals HttpStatus.OK.value(),response.getStatusCode()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.baeldung.groovyconfig;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.support.GenericGroovyApplicationContext;
|
||||
|
||||
import com.baeldung.groovyconfig.BandsBean;
|
||||
import com.baeldung.groovyconfig.JavaPersonBean;
|
||||
|
||||
public class GroovyConfigurationUnitTest {
|
||||
|
||||
private static final String FILE_NAME = "GroovyBeanConfig.groovy";
|
||||
private static final String FILE_PATH = "src/main/java/com/baeldung/groovyconfig/";
|
||||
|
||||
@Test
|
||||
public void whenGroovyConfig_thenCorrectPerson() throws Exception {
|
||||
|
||||
GenericGroovyApplicationContext ctx = new GenericGroovyApplicationContext();
|
||||
ctx.load("file:" + getPathPart() + FILE_NAME);
|
||||
ctx.refresh();
|
||||
|
||||
JavaPersonBean j = ctx.getBean(JavaPersonBean.class);
|
||||
|
||||
assertEquals("32", j.getAge());
|
||||
assertEquals("blue", j.getEyesColor());
|
||||
assertEquals("black", j.getHairColor());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGroovyConfig_thenCorrectListLength() throws Exception {
|
||||
|
||||
GenericGroovyApplicationContext ctx = new GenericGroovyApplicationContext();
|
||||
ctx.load("file:" + getPathPart() + FILE_NAME);
|
||||
ctx.refresh();
|
||||
|
||||
BandsBean bb = ctx.getBean(BandsBean.class);
|
||||
|
||||
assertEquals(3, bb.getBandsList()
|
||||
.size());
|
||||
}
|
||||
|
||||
private String getPathPart() {
|
||||
String pathPart = new File(".").getAbsolutePath();
|
||||
pathPart = pathPart.replace(".", "");
|
||||
pathPart = pathPart.replace("\\", "/");
|
||||
pathPart = pathPart + FILE_PATH;
|
||||
|
||||
return pathPart;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.baeldung.groovyconfig;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
|
||||
import com.baeldung.groovyconfig.JavaBeanConfig;
|
||||
import com.baeldung.groovyconfig.JavaPersonBean;
|
||||
|
||||
public class JavaConfigurationUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenJavaConfig_thenCorrectPerson() {
|
||||
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||
ctx.register(JavaBeanConfig.class);
|
||||
ctx.refresh();
|
||||
|
||||
JavaPersonBean j = ctx.getBean(JavaPersonBean.class);
|
||||
|
||||
assertEquals("31", j.getAge());
|
||||
assertEquals("green", j.getEyesColor());
|
||||
assertEquals("blond", j.getHairColor());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.baeldung.groovyconfig;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
|
||||
import com.baeldung.groovyconfig.JavaPersonBean;
|
||||
|
||||
public class XmlConfigurationUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenXmlConfig_thenCorrectPerson() {
|
||||
final ApplicationContext applicationContext = new ClassPathXmlApplicationContext("xml-bean-config.xml");
|
||||
|
||||
JavaPersonBean j = (JavaPersonBean) applicationContext.getBean("JavaPersonBean");
|
||||
|
||||
assertEquals("30", j.getAge());
|
||||
assertEquals("brown", j.getEyesColor());
|
||||
assertEquals("brown", j.getHairColor());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.baeldung.spring_groovy;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* Unit test for simple App.
|
||||
*/
|
||||
public class AppUnitTest
|
||||
extends TestCase
|
||||
{
|
||||
/**
|
||||
* Create the test case
|
||||
*
|
||||
* @param testName name of the test case
|
||||
*/
|
||||
public AppUnitTest( String testName )
|
||||
{
|
||||
super( testName );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the suite of tests being tested
|
||||
*/
|
||||
public static Test suite()
|
||||
{
|
||||
return new TestSuite( AppUnitTest.class );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rigourous Test :-)
|
||||
*/
|
||||
public void testApp()
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user