📄 testextracttimeentriesworkflow.java
字号:
package com.wiley.compBooks.EJwithUML.Clients;
import javax.naming.*;
import javax.ejb.*;
import java.rmi.*;
import javax.rmi.PortableRemoteObject;
import java.util.*;
import java.text.ParseException;
import com.wiley.compBooks.EJwithUML.TimeCardDomain.*;
import com.wiley.compBooks.EJwithUML.Dtos.*;
import com.wiley.compBooks.EJwithUML.TimeCardWorkflow.*;
import com.wiley.compBooks.EJwithUML.Base.ApplicationExceptions.*;
import com.wiley.compBooks.EJwithUML.Base.*;
import com.wiley.compBooks.EJwithUML.Base.EjbUtil.*;
import junit.framework.*;
/**
* This is JUint test class for testing ExtractTimeEntriesWorkflow EJB. This
* test assumes that the EJB is running and accessible.
*/
public class TestExtractTimeEntriesWorkflow extends TestCase
{
private static ExtractTimeEntriesWorkflow xtewf;
private static String testCaseToRun;
private ExtractCriteriaDTO criteria;
public TestExtractTimeEntriesWorkflow(String name)
{
super(name);
}
/** Executes all the test case */
public static void main(String[] args)throws CreateException, NamingException, RemoteException
{
Context initial = new InitialContext();
Object objref = initial.lookup(EjbReferenceNames.EXTRACT_TIME_ENTRY_WORKFLOW_HOME);
ExtractTimeEntriesWorkflowHome xtewhome = (ExtractTimeEntriesWorkflowHome)
PortableRemoteObject.narrow(objref,ExtractTimeEntriesWorkflowHome.class);
xtewf = xtewhome.create();
if (args.length > 0)
{
TestExtractTimeEntriesWorkflow.testCaseToRun= args[0];
}
junit.textui.TestRunner.run(suite());
}
/** groups all test cases into a test suite. */
public static Test suite()
{
TestSuite suite = null;
if (TestExtractTimeEntriesWorkflow.testCaseToRun == null)
{
// runs all test cases
suite = new TestSuite(TestExtractTimeEntriesWorkflow.class);
}
else
{
suite = new TestSuite();
suite.addTest(new TestExtractTimeEntriesWorkflow(
TestExtractTimeEntriesWorkflow.testCaseToRun));
}
return suite;
}
/**
* sets common test fixture (input test data) for all the test cases<br>
* prepares the testing environment before a testXXX() method is executed.
*/
protected void setUp()throws ParseException
{
criteria = new ExtractCriteriaDTO("Ford",
DateUtil.createDate("10/10/2002"), DateUtil.createDate("11/27/2002"));
}
/**
* tearDown method for test case<br>
* resets the testing environment after a testXXX() method is executed.
*/
protected void tearDown()
{
criteria.setClient("Ford");
}
public void testGetAllTimecardsForUser()throws Exception
{
try
{
Collection timecards = xtewf.getAllTimecardsForUser("fred");
Iterator cardIterator = timecards.iterator();
while(cardIterator.hasNext())
{
System.out.println((TimecardDTO)cardIterator.next());
}
}
catch(ApplicationException e)
{
fail("expected exception, but received none.");
}
}
public void testExtractForCriteriaWithInvalidClient()throws Exception
{
try
{
criteria.setClient("nissan");
HashMap reports = xtewf.extractForCriteria(criteria);
fail("expected exception, but received none.");
}
catch(InvalidDataException e)
{
System.out.println("received expected exception-" + e);
}
}
public void testExtractForCriteriaWithInvalidUser()throws Exception
{
try
{
ArrayList users = new ArrayList();
users.add("syed");
criteria.setUsers(users);
HashMap reports = xtewf.extractForCriteria(criteria);
fail("expected exception, but received none.");
}
catch(InvalidDataException e)
{
System.out.println("received expected exception-" + e);
}
}
public void testExtractForCriteriaWithAllUser()
{
try
{
HashMap reports = xtewf.extractForCriteria(criteria);
Iterator reportIterator = reports.entrySet().iterator();
while(reportIterator.hasNext())
{
Map.Entry entry = (Map.Entry) reportIterator.next();
System.out.println(entry.getValue());
}
}
catch(Exception e)
{
fail("received unexpected exception-" + e);
}
}
public void testExtractForCriteriaWithAUserList()
{
try
{
ArrayList users = new ArrayList();
users.add("fred");
criteria.setUsers(users);
HashMap reports = xtewf.extractForCriteria(criteria);
Iterator reportIterator = reports.entrySet().iterator();
while(reportIterator.hasNext())
{
Map.Entry entry = (Map.Entry) reportIterator.next();
System.out.println(entry.getValue());
}
}
catch(Exception e)
{
fail("received unexpected exception-" + e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -