📄 testrecordtimeworkflow.java
字号:
package com.wiley.compBooks.EJwithUML.Clients;
import javax.naming.*;
import javax.ejb.*;
import java.rmi.*;
import javax.rmi.PortableRemoteObject;
import java.util.*;
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.EjbUtil.*;
import com.wiley.compBooks.EJwithUML.Base.DateUtil;
import junit.framework.*;
/**
* This is JUint test class for testing RecordTimeWorkflow EJB. This
* test assumes that the EJB is running and accessible.
*/
public class TestRecordTimeWorkflow extends TestCase
{
private static LoginWorkflow lwf;
private static RecordTimeWorkflow rtwf;
private static String testCaseToRun;
public TestRecordTimeWorkflow(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.RECORD_TIME_WORKFLOW_HOME);
RecordTimeWorkflowHome rtwhome = (RecordTimeWorkflowHome )
PortableRemoteObject.narrow(objref,
RecordTimeWorkflowHome.class);
rtwf = rtwhome.create("fred");
if (args.length > 0)
{
TestRecordTimeWorkflow.testCaseToRun= args[0];
}
junit.textui.TestRunner.run(suite());
}
/** groups all test cases into a test suite. */
public static Test suite()
{
TestSuite suite = null;
if (TestRecordTimeWorkflow.testCaseToRun == null)
{
// runs all test cases
suite = new TestSuite(TestRecordTimeWorkflow.class);
}
else
{
suite = new TestSuite();
suite.addTest(new TestRecordTimeWorkflow(
TestRecordTimeWorkflow.testCaseToRun));
}
return suite;
}
public void testGetCurrentTimecard()
{
try
{
TimecardDTO card = rtwf.getCurrentTimecard();
System.out.println(card);
}
catch(Exception e)
{
fail("received unexpected exception-" + e);
}
}
public void testUpdateTimecardWithNewEntry()
{
try
{
TimecardDTO card = rtwf.getCurrentTimecard();
TimeEntryDTO newEntry = new TimeEntryDTO("Ford", "Paint", "Mustang", 4,
card.getStartDate());
card.addEntry(newEntry);
newEntry = new TimeEntryDTO("Ford", "UpgradeEngine","Mustang", 4,
card.getStartDate());
card.addEntry(newEntry);
rtwf.updateTimecard(card);
}
catch(Exception e)
{
fail("received unexpected exception-" + e);
}
}
public void testUpdateTimecardWithExistingEntry()
{
try
{
TimecardDTO card = rtwf.getCurrentTimecard();
Iterator entryItr = card.getEntries();
while(entryItr.hasNext())
{
TimeEntryDTO existingEntry = (TimeEntryDTO)entryItr.next();
existingEntry.setHours(5);
System.out.println("updated one entry- " + existingEntry);
break;
}
rtwf.updateTimecard(card);
}
catch(Exception e)
{
fail("received unexpected exception-" + e);
}
}
public void testGetClient()
{
try
{
ClientDTO client = rtwf.getClient("GM");
System.out.println(client);
}
catch(Exception e)
{
fail("received unexpected exception-" + e);
}
}
public void testGetAllClients()
{
try
{
Collection clients = rtwf.getAllClients();
Iterator clientIterator = clients.iterator();
while(clientIterator.hasNext())
{
System.out.println((ClientDTO)clientIterator.next());
}
}
catch(Exception e)
{
fail("received unexpected exception-" + e);
}
}
public void testSubmitTimecard()
{
try
{
rtwf.submitTimecard();
}
catch(Exception e)
{
fail("received unexpected exception-" + e);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -