com.pureinfo.srmcenter.datasync.client.domain.impl.SyncConfigInfoMgrImplTest.java Source code

Java tutorial

Introduction

Here is the source code for com.pureinfo.srmcenter.datasync.client.domain.impl.SyncConfigInfoMgrImplTest.java

Source

/**
 * PureInfo Quake
 * @(#)SyncConfigInfoMgrImplTest.java   1.0 Jan 24, 2006
 * 
 * Copyright(c) 2004-2005, PureInfo Information Technology Corp. Ltd. 
 * All rights reserved, see the license file.
 * 
 * www.pureinfo.com.cn
 */

package com.pureinfo.srmcenter.datasync.client.domain.impl;

import junit.framework.TestCase;

import org.apache.commons.lang.time.DateUtils;

import com.pureinfo.ark.content.ArkContentHelper;
import com.pureinfo.dolphin.model.IObjects;
import com.pureinfo.force.exception.PureException;
import com.pureinfo.srmcenter.datasync.client.model.SyncConfigInfo;

/**
 * 
 * <P>
 * Created on Jan 24, 2006 4:04:30 PM<BR>
 * Last modified on Jan 24, 2006
 * </P>
 * 
 * 
 * @author Freeman.Hu
 * @version 1.0, Jan 24, 2006
 * @since Quake 1.0
 */
public class SyncConfigInfoMgrImplTest extends TestCase {

    private SyncConfigInfoMgrImpl m_mgr;

    public void setUp() throws PureException {
        m_mgr = (SyncConfigInfoMgrImpl) ArkContentHelper.getContentMgrOf(SyncConfigInfo.class);
        clear();
    }

    public void tearDown() throws PureException {
        clear();
    }

    private void clear() throws PureException {
        IObjects objects = m_mgr.findAll(null);
        m_mgr.delete(objects);
        objects.clear();
    }

    public void testLookupBySchoolCodeFromNull() throws PureException {
        String sSchoolCode = "8888";

        SyncConfigInfo expected = new SyncConfigInfo();
        expected.setSchoolCode(sSchoolCode);
        expected.setActiveInterval(DateUtils.MILLIS_PER_HOUR);
        expected.setSyncInterval(DateUtils.MILLIS_PER_DAY);

        SyncConfigInfo actual = m_mgr.lookupBySchoolCode(sSchoolCode);

        assertEquals(expected, actual);

        SyncConfigInfo actual2 = m_mgr.lookupBySchoolCode(sSchoolCode);
        assertEquals(actual.getId(), actual2.getId());
    }

    public void testLookupSchoolCode() throws PureException {
        String sSchoolCode = "8888";

        SyncConfigInfo expected = new SyncConfigInfo();
        expected.setSchoolCode(sSchoolCode);
        expected.setActiveInterval(DateUtils.MILLIS_PER_HOUR);
        expected.setSyncInterval(DateUtils.MILLIS_PER_DAY);
        m_mgr.save(expected);

        SyncConfigInfo actual = m_mgr.lookupBySchoolCode(sSchoolCode);

        assertEquals(expected, actual);
    }
}