[jboss-cvs] JBossAS SVN: r66727 - projects/microcontainer/trunk/docs/examples/User_Guide/cmdLineClient/src/test/java/org/jboss/example/client.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Nov 5 07:36:19 EST 2007
Author: newtonm
Date: 2007-11-05 07:36:19 -0500 (Mon, 05 Nov 2007)
New Revision: 66727
Added:
projects/microcontainer/trunk/docs/examples/User_Guide/cmdLineClient/src/test/java/org/jboss/example/client/MockUserInterface.java
Modified:
projects/microcontainer/trunk/docs/examples/User_Guide/cmdLineClient/src/test/java/org/jboss/example/client/ClientTestCase.java
Log:
Added test case for Client.
Modified: projects/microcontainer/trunk/docs/examples/User_Guide/cmdLineClient/src/test/java/org/jboss/example/client/ClientTestCase.java
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/cmdLineClient/src/test/java/org/jboss/example/client/ClientTestCase.java 2007-11-05 11:53:49 UTC (rev 66726)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/cmdLineClient/src/test/java/org/jboss/example/client/ClientTestCase.java 2007-11-05 12:36:19 UTC (rev 66727)
@@ -3,13 +3,43 @@
import junit.framework.TestCase;
public class ClientTestCase extends TestCase
-{
- public ClientTestCase(String name) {
- super(name);
- }
+{
+ public ClientTestCase(String name) {
+ super(name);
+ }
- public void testClient() throws Exception {
- Client client = new Client(false);
- assertNotNull(client);
- }
+ public void testClientWithoutBus() throws Exception {
+ Client client = new Client(false);
+ assertNotNull(client);
+ runTests(client);
+ }
+
+ public void testClientWithBus() throws Exception {
+ Client client = new Client(true);
+ assertNotNull(client);
+ runTests(client);
+ }
+
+ private void runTests(Client client) throws Exception {
+ client.setUserInterface(new MockUserInterface());
+
+ client.deploy();
+
+ assertEquals(true, client.toggleHiringFreeze());
+ assertEquals(false, client.addEmployee());
+ assertEquals(0, client.listEmployees().size());
+
+ assertEquals(false, client.toggleHiringFreeze());
+ assertEquals(true, client.addEmployee());
+ assertEquals(1, client.listEmployees().size());
+ assertEquals((Integer) 10000, client.getSalary());
+
+ client.setSalary();
+ assertEquals((Integer) 50000, client.getSalary());
+
+ client.removeEmployee();
+ assertEquals(0, client.listEmployees().size());
+
+ client.undeploy();
+ }
}
Added: projects/microcontainer/trunk/docs/examples/User_Guide/cmdLineClient/src/test/java/org/jboss/example/client/MockUserInterface.java
===================================================================
--- projects/microcontainer/trunk/docs/examples/User_Guide/cmdLineClient/src/test/java/org/jboss/example/client/MockUserInterface.java (rev 0)
+++ projects/microcontainer/trunk/docs/examples/User_Guide/cmdLineClient/src/test/java/org/jboss/example/client/MockUserInterface.java 2007-11-05 12:36:19 UTC (rev 66727)
@@ -0,0 +1,34 @@
+package org.jboss.example.client;
+
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.Calendar;
+import java.util.Date;
+
+import org.jboss.example.service.Address;
+import org.jboss.example.service.Employee;
+
+public class MockUserInterface implements UserInterface {
+
+ public Address getAddress() throws IOException {
+ return new Address(5, "Oxford St", "London");
+ }
+
+ public Date getDateOfBirth() throws ParseException, IOException {
+ Calendar age = Calendar.getInstance();
+ int year = age.get(Calendar.YEAR);
+ int month = age.get(Calendar.MONTH);
+ int day = age.get(Calendar.DAY_OF_MONTH);
+
+ age.set(year - 43, month, day);
+ return age.getTime();
+ }
+
+ public Employee getEmployee() throws IOException {
+ return new Employee("David", "Hasselhof");
+ }
+
+ public Integer getSalary() throws IOException {
+ return new Integer("50000");
+ }
+}
More information about the jboss-cvs-commits
mailing list