package com.project.config;

import javax.naming.NamingException;
import javax.sql.DataSource;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import org.springframework.jndi.JndiObjectFactoryBean;
import org.springframework.mock.jndi.SimpleNamingContextBuilder;

/**
 * Test configuration with dataSource overidden to use the in-memory hsqldb
 *
 * @author Jay Paulynice (jay.paulynice@gmail.com)
 */
@Configuration
@Import({ SpringConfig.class })
public class TestConfig {
    /**
     * @return the datasource
     */
    @Bean
    public DataSource dataSource() {
        return new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL)
                .addScript("classpath:data/sql/drop_all.sql").addScript(
                        "classpath:data/sql/schema.sql").addScript(
                        "classpath:data/sql/test-data.sql").build();
    }

    @Bean
    JndiObjectFactoryBean jndiDataSource() throws IllegalStateException,
            NamingException {
        final String jndiName = "java:com/env/foo";
        final SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder();
        builder.bind(jndiName, dataSource());
        builder.activate();

        final JndiObjectFactoryBean bean = new JndiObjectFactoryBean();
        bean.setJndiName(jndiName);
        bean.setResourceRef(true);

        return bean;
    }
}
@@ -799,23 +799,16 @@
 ean%0A    
-public 
 DataSour
@@ -825,16 +825,16 @@
 rce() %7B%0A
+
         
@@ -966,32 +966,17 @@
 ll.sql%22)
-.addScript(%0A    
+%0A
         
@@ -975,36 +975,43 @@
                 
-    
+.addScript(
 %22classpath:data/
@@ -1030,24 +1030,9 @@
 ql%22)
-.addScript(%0A    
+%0A
     
@@ -1043,20 +1043,27 @@
         
-    
+.addScript(
 %22classpa
@@ -1189,24 +1189,16 @@
 eption,%0A
-        
     Nami

clean up