学习配置ssm
package com.imooc.o2o.dao;
import static org.junit.Assert.assertEquals;
import java.util.Date;
import org.junit.FixMethodOrder;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.springframework.beans.factory.annotation.Autowired;
import com.imooc.o2o.BaseTest;
import com.imooc.o2o.entity.Area;
import com.imooc.o2o.entity.Shop;
import com.imooc.o2o.entity.ShopCategory;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ShopDaoTest extends BaseTest {
@Autowired
private ShopDao shopDao;
@Test
@Ignore
public void testInsertShop() throws Exception {
Shop shop = new Shop();
shop.setOwnerId(1L);
Area area = new Area();
area.setAreaId(1L);
ShopCategory sc = new ShopCategory();
sc.setShopCategoryId(1L);
shop.setShopName("刘泽宇");
shop.setShopDesc("刘泽宇");
shop.setShopAddr("刘泽宇");
shop.setPhone("17612474620");
shop.setShopImg("没有图");
shop.setLongitude(1D);
shop.setLatitude(1D);
shop.setCreateTime(new Date());
shop.setLastEditTime(new Date());
shop.setEnableStatus(0);
shop.setAdvice("通过");
shop.setArea(area);
shop.setShopCategory(sc);
int effectedNum = shopDao.insertShop(shop);
assertEquals(1, effectedNum);
}
@Test
public void testUpdate(){
Shop shop = new Shop();
shop.setShopId(1L);
shop.setShopDesc("刘泽宇1");
shop.setShopAddr("刘泽宇1");
shop.setLastEditTime(new Date());
int effectedNum = shopDao.updateShop(shop);
assertEquals(1, effectedNum);
}
}