protected void onSetUpInTransaction() throws Exception {
    super.onSetUpInTransaction();

    servletConfig = new MockServletConfig(new MockServletContext(), "simple");
    MockServletConfig complexConfig =
        new MockServletConfig(servletConfig.getServletContext(), "complex");
    complexConfig.addInitParameter("publishContext", "false");
    complexConfig.addInitParameter("class", "notWritable");
    complexConfig.addInitParameter("unknownParam", "someValue");

    simpleDispatcherServlet = new DispatcherServlet();
    simpleDispatcherServlet.setContextClass(SimpleWebApplicationContext.class);
    simpleDispatcherServlet.init(servletConfig);

    complexDispatcherServlet = new DispatcherServlet();
    complexDispatcherServlet.setContextClass(WebApplicationContext.class);
    complexDispatcherServlet.setNamespace("test");

    Constants constants = (Constants) applicationContext.getBean("constants");
    Authentication auth = constants.getAuthentication(applicationContext);
    SecurityContextHolder.getContext().setAuthentication(auth);

    parent = (Controller) applicationContext.getBean("workCodeController");
    child = (Controller) applicationContext.getBean("workCodeFormController");
    sf = (SessionFactory) applicationContext.getBean("sessionFactory");
  }
  protected void onSetUpInTransaction() throws Exception {
    super.onSetUpInTransaction();
    HoursWorked hours = null;
    HoursWorkedDaoHibernate dao = null;
    JobManager mgrJob = null;

    FulltimeAgreements fulltimeAgreement = null;
    FulltimeAgreementDao fulltimeDao = null;
    WorkCodeDao workcodeDao = null;

    PeoplePropertiesDao peopleDao = null;
    JobDao jobDao = null;
    HoursWorkedDao hoursDao = null;
    PeopleProperties people = null;

    super.onSetUpBeforeTransaction();

    mgrJob = (JobManager) applicationContext.getBean("jobManager");

    Constants constants = (Constants) applicationContext.getBean("constants");
    Authentication auth = constants.getAuthentication(applicationContext);
    SecurityContextHolder.getContext().setAuthentication(auth);

    CodeTermDao termDao = (CodeTermDao) applicationContext.getBean("termDao");
    CodeTerm term = termDao.findTerm("FA");
    if (term == null) {
      term = new CodeTerm();
      term.setTerm("FA");
      termDao.saveTerms(term);
    }

    PayPeriodDao payDao = (PayPeriodDao) applicationContext.getBean("payPeriodDao");
    PayPeriodDao payPeriodDao = (PayPeriodDao) applicationContext.getBean("payPeriodDao");
    workcodeDao = (WorkCodeDao) applicationContext.getBean("workCodeDao");

    peopleDao = (PeoplePropertiesDao) applicationContext.getBean("peoplePropertiesDao");
    people = peopleDao.getPerson("000201922");
    if (people == null) {
      // inserted = true;
      people = new PeopleProperties();
      people.setFirstName("first");
      people.setLastName("last");
      people.setMiddleName("middle");
      people.setGovernmentId("999999999");
      people.setPeopleId("000201922");
      peopleDao.save(people);
      log.debug("INSERTED PERSON");
    }
    // 133	Bus.Office	01-IS-00-133	59	000203290	01-IS-00-133

    jobDao = (JobDao) applicationContext.getBean("jobDao");
    Job jobBus = mgrJob.getJobByDepartment("133");
    if (jobBus == null) {
      log.debug("insert job ");
      // insertedJob = true;
      jobBus = new Job();
      // job.setId(1L);
      jobBus.setAccountNumber("XXX");
      jobBus.setDepartment("133");
      jobBus.setDescription("bus.off");
      jobDao.saveJob(jobBus);
    }
    Job jobIt = jobDao.getJob("071");
    if (jobIt == null) {
      log.debug("insert job ");
      jobIt = new Job();
      jobIt.setAccountNumber("XXX");
      jobIt.setDepartment("071");
      jobIt.setDescription("it");
      jobDao.saveJob(jobIt);
    }

    fulltimeDao = (FulltimeAgreementDao) applicationContext.getBean("fulltimeAgreementDao");
    Set<FulltimeAgreements> agreements = people.getFulltimeAgreements();
    fulltimeAgreement = new FulltimeAgreements();
    fulltimeAgreement.setActive(true);
    fulltimeAgreement.setJob(jobIt);
    fulltimeAgreement.setOvertime(555);
    fulltimeAgreement.setRate(555);
    fulltimeAgreement.setPeople(people);
    agreements.add(fulltimeAgreement);

    hoursDao = (HoursWorkedDao) applicationContext.getBean("hoursWorkedDao");
    List<HoursWorked> hoursList =
        hoursDao.getHoursWorked("000201922", "133", Constants.getDate("MM/dd/yyyy", "01/01/2008"));
    if (hoursList == null || hoursList.size() < 1) {
      log.debug("insert hours ");
      // insertedJob = true;
      hours = new HoursWorked();

      hours.setPeopleId("000201922");
      hours.setJob(mgrJob.getJobByDepartment("133"));
      hours.setDateIn(Constants.getDate("MM/dd/yyyy", "01/01/2008"));
      WorkCode w = workcodeDao.getWorkCode("LOGIN");
      hours.setWorkcode(w);
      hoursDao.saveHoursWorked(hours);
    }

    termDao = (CodeTermDao) applicationContext.getBean("termDao");
    term = termDao.findTerm("FA");
    if (term == null) {
      term = new CodeTerm();
      term.setTerm("FA");
      termDao.saveTerms(term);
    }

    payPeriodDao = (PayPeriodDao) applicationContext.getBean("payPeriodDao");
    java.sql.Date beginDate = Constants.getSqlDate("MM/dd/yyyy", "01/01/2008");
    PayPer pay = (PayPer) payPeriodDao.getPeriod(beginDate, false);
    if (pay == null) {
      pay = new PayPer();
      pay.setCodeTerm(term);
      pay.setBeginDate(beginDate);
      pay.setEndDate(
          Constants.addField(Calendar.DATE, -1, Constants.addField(Calendar.MONTH, 1, beginDate)));
      pay.setPpYear("" + Constants.year(beginDate));
      payPeriodDao.savePeriod(pay);
    }

    AwardedDao awardDao = (AwardedDao) applicationContext.getBean("awardedDao");
    List<Awarded> awarded = (List<Awarded>) awardDao.getAward("000201922", "2008", "FA");

    if (awarded == null || awarded.size() == 0) {
      AgreementsDao agreeDao = (AgreementsDao) applicationContext.getBean("agreementsDao");

      Awarded award1 = new Awarded();
      award1.setAmount(2000);
      award1.setAwards(awardDao.getAwards("IWX652"));
      award1.setCodeTerm(term);
      PeopleProperties p = new PeopleProperties();
      p.setPeopleId("000201922");
      award1.setPerson(p);
      award1.setYear("2008");
      awardDao.saveAward(award1);

      Agreements agree = new Agreements();
      agree.setAmount(-1);
      agree.setAwarded(award1);
      agree.setJob(jobBus);
      agree.setRate(655);
      agreeDao.saveAgreement(agree);

      Awarded award2 = new Awarded();
      award2.setAmount(444);
      award2.setAwards(awardDao.getAwards("FWN651"));
      award2.setCodeTerm(term);
      p = new PeopleProperties();
      p.setPeopleId("000198239");
      award1.setPerson(p);
      award2.setYear("2008");
      awardDao.saveAward(award2);
      Agreements agree2 = new Agreements();
      agree2.setAmount(100);
      agree2.setAwarded(award2);
      agree2.setJob(jobIt);
      agree2.setRate(655);
      agreeDao.saveAgreement(agree2);
    }
  }