0734w-月下竹音

0734是来自家乡的声音

常用链接

统计

最新评论

多对多测试

package com.dsii.eservice.creationservice.dao.test;

import junit.framework.TestCase;
import net.sf.hibernate.HibernateException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.dsii.eservice.creationservice.dao.ArtDAO;
import com.dsii.eservice.creationservice.po.ArtPO;
import com.dsii.eservice.creatorservice.po.CreatorPO;

public class ArtDAOTests extends TestCase {


 private Log log = LogFactory.getLog(ArtDAOTests.class);

 private static Integer pInsertKey1;
 private static Integer pInsertKey2;
 private static Integer pInsertKey3;
 private static Integer pInsertKey4;
 private static Integer pInsertKey5;
 private static Integer pInsertKey6;

 public ArtDAOTests(String arg0) {
  super(arg0);
 }

 /*
  * @see TestCase#setUp()
  */
 protected void setUp() throws Exception {
  super.setUp();
 }

 /*
  * @see TestCase#tearDown()
  */
 protected void tearDown() throws Exception {
  super.tearDown();
 }

 /**
  *
  * <p><code>testInsertObject</code></p>
  *
  * @authorspark 2005-8-3
  * @since1.0
  */
 public void testInsertObject() throws HibernateException {

  log.debug("----------testInsertObject start-------------");
  ArtPO artPO1 = new ArtPO();
  artPO1.setArtId(new Integer(1));
  artPO1.setArtTypeId(new Integer(6));
  artPO1.setArtName("spark");
  
  ArtPO artPO2 = new ArtPO();
  artPO2.setArtId(new Integer(2));
  artPO2.setArtTypeId(new Integer(7));
  artPO2.setArtName("spark2");
  
  ArtPO artPO3 = new ArtPO();
  artPO3.setArtId(new Integer(3));
  artPO3.setArtTypeId(new Integer(8));
  artPO3.setArtName("spark3");

  CreatorPO creatorPO1 = new CreatorPO();
  creatorPO1.setArtCreatorId(new Integer(31));
  CreatorPO creatorPO2 = new CreatorPO();
  creatorPO2.setArtCreatorId(new Integer(32));
  CreatorPO creatorPO3 = new CreatorPO();
  creatorPO3.setArtCreatorId(new Integer(37));
  //artPO1
  artPO1.getCreatorSet().add(creatorPO1);
  artPO1.getCreatorSet().add(creatorPO2);
  artPO2.getCreatorSet().add(creatorPO2);
  artPO2.getCreatorSet().add(creatorPO3);
  artPO3.getCreatorSet().add(creatorPO1);
  artPO3.getCreatorSet().add(creatorPO3);
  //creatorPO1
  creatorPO1.getArtSet().add(artPO1);
  creatorPO1.getArtSet().add(artPO2);
  creatorPO2.getArtSet().add(artPO2);
  creatorPO2.getArtSet().add(artPO3);
  creatorPO3.getArtSet().add(artPO1);
  creatorPO3.getArtSet().add(artPO3);

  //  artPO.setArtsize("big");
  //  artPO.setArtCreatedYear("CreatedYear1");
  //  artPO.setArtDrawedBird("DrawedBird1");
  //  artPO.setOriginal("original1");
  //  artPO.setDepostion("top");
  //  artPO.setIntroduction("china1");
  //  artPO.setArtFileURL("www.dsii.net");
  //  artPO.setCreator("sparkwu");
  //  artPO.setCreateDate(TimeUtils.getCurrentTimestamp());
  //  artPO.setModifier("inModify");
  //  artPO.setModifyDate(TimeUtils.getCurrentTimestamp());
    try {
     log.info("----------pInsertKey1 insertObject(artPO1) start-------------");
     pInsertKey1 = (Integer) ArtDAO.getInstance().insertObject(artPO1);
     pInsertKey2 = (Integer) ArtDAO.getInstance().insertObject(artPO2);
     pInsertKey3 = (Integer) ArtDAO.getInstance().insertObject(artPO3);
     pInsertKey4 = (Integer) ArtDAO.getInstance().insertObject(creatorPO1);
     pInsertKey5 = (Integer) ArtDAO.getInstance().insertObject(creatorPO2);
     pInsertKey6 = (Integer) ArtDAO.getInstance().insertObject(creatorPO3);
     log.debug("--------pInsertKey ==---------------" + pInsertKey1);
    } catch (Exception e) {
     e.printStackTrace();
    }
 }

 /**
  * <p><code>testFindByPrimeryKey</code></p>
  */
 // public void testFindByPrimeryKey() {
 //  log.debug("--------testFindByPrimeryKey start---------------");
 //
 //  Integer pk = pInsertKey;
 //  try {
 //   ArtPO po = (ArtPO) ArtDAO.getInstance()
 //     .findByPrimeryKey(new Integer(1));
 //   assertEquals("1", po.getArtId());
 //   assertEquals("inCreator", po.getCreator());
 //   log.debug("--------BirdsPO==---------------" + po);
 //  } catch (Exception e) {
 //   e.printStackTrace();
 //  }
 //  log.debug("--------testFindByPrimeryKey end---------------");
 // }

}

posted on 2005-10-21 09:45 sparkwu 阅读(359) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: