JavaBean
Overwiew of using Jice for javabean classes. Further docs at Jice site.
Jice Element For Creating a Bean Instance
<method name="testGetBean">
<test-case="standard">
<params>
<param name="bean" type="" use-jice="yes">
<jice>
<bean xmlns="http://www.jicengine.org/jic/2.0"
class="org.jtestcase.CustomBean" >
<name>mybeanname</name>
<count class="int">1</count>
</bean>
</jice>
</param>
</params>
</method>
The Example Bean Instance : CostumBean
package org.jtestcase;
public class CustomBean {
private String name = "";
private int count = 0;
public CustomBean() {
super();
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
|
Example JTestCase Test
/*
* This program is licensed under Common Public License Version 0.5.
*
* For License Information and conditions of use, see "LICENSE" in packaged
*/
package org.jtestcase;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Locale;
import java.util.Vector;
import junit.framework.TestCase;
/**
* Tests getting jice elements as javabeans
*
* @throws Exception
*/
public void testGetBean() throws Exception {
Vector testCases = null;
HashMap params = null;
_jtestcase = new JTestCase(dataFile, getName());
testCases = _jtestcase
.getTestCasesInstancesInMethod("testGetBean");
// for each test case
for (int i = 0; i < testCases.size(); i++) {
TestCaseInstance testCase = ((TestCaseInstance) testCases
.elementAt(i));
params = testCase.getTestCaseParams();
CustomBean customBean = (CustomBean) params.get("bean");
assertTrue("bean property name not correct", customBean.getName().equals("mybeanname"));
assertTrue("bean property count not correct ", customBean.getCount()==1);
}
}
}
|