Quando rodo o JUNIT, recebo o erro "Failed to load ApplicationContext ".
A classe de teste está da seguinte forma:
package br.com.spedroza.bookstore.dao;
import java.math.BigDecimal;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
import br.com.spedroza.bookstore.builder.ProductBuilder;
import br.com.spedroza.bookstore.conf.JPAConfiguration;
import br.com.spedroza.bookstore.model.PriceType;
import br.com.spedroza.bookstore.model.Product;
/*
* This class tests ProductDAO class using JUNIT
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes= {JPAConfiguration.class, ProductDAO.class})
public class ProductDAOTest {
@Autowired
ProductDAO productDAO;
@Test
@Transactional
public void sumPriceByPriceType() {
ProductBuilder productBuilder = new ProductBuilder();
// create product lists
List<Product> ebookList = productBuilder.createList(PriceType.EBOOK, BigDecimal.ONE, 3);
List<Product> printedList = productBuilder.createList(PriceType.PRINTED, BigDecimal.TEN, 3);
// insert into the db
ebookList.stream().forEach(p -> productDAO.insert(p));
printedList.stream().forEach(p -> productDAO.insert(p));
// query the sum and compare
BigDecimal ebookSum = productDAO.getTotalByPriceType(PriceType.EBOOK);
Assert.assertEquals(new BigDecimal(3).setScale(2), ebookSum);
}
}
Podem me ajudar?