| | | |

???()

?CSND.NET ?samlet [2003/11/24]


3.3.2 'JunitEJB
3.3.2.1?JUnitJunitEE
?junit.jarjunitee.jar?J2EE?óCLASSPATH?
h?jarl??¼µlib?¼??????¼µlh??????÷
3.3.2.2?hEJB
JunitEE??¼example?¼?h??EJB??????g???ô???build.xmllll?·?buildl??¼?ant
something
??L?õ?junitee-example.earll?out?¼?h????EJBh'EJB?ó?web?óh?J2EE?j???e?÷?
??????example?¼µcomponents/test-war?¼?????
3.3.2.3?¼?
?hWeb?ó???¼??¼
example/javasrc/org/infohazard/test/
example/components/test-war/
example/components/test-war/WEB-INF/
?org.infohazard.test????????classl?h????public??????
3.3.2.4?
??JUnitfixture'??JNDI InitialContextõEJB£
protected void setUp() throws Exception
{
Context jndiContext = new InitialContext();
Object einRef = jndiContext.lookup("java:comp/env/ejb/EinsteinEJB");
EinsteinHome home = (EinsteinHome)PortableRemoteObject.narrow(einRef, EinsteinHome.class);
this.ein = home.create();
}
??
public void testSimpleAddition() throws RemoteException
{
String result = this.ein.addTwoNumbers("7", "10");
assert(result.equals("17"));
}
?example/javasrc/org/infoazard/test/EinsteinTest.java
3.3.2.5' servlet?
hjunit.htmlui?servlet??'web?óWEB-INF/classes/´hservletservlet?junit.htmlui.TestServletBase??
protected ClassLoader getDynamicClassLoader()
{
return this.getClass().getClassLoader();
}
'servlet'ö???÷'????ÿ?i?l?web?÷
?ó???Lclasslh?û?g?ò?TestServletBase?abstract?
3.3.2.6UI
<p>
You may type in the name of a test suite:
<br/>
<form action="TestServlet" method="get" name="youTypeItForm">
<input type="text" name="suite" size=60 />
<input type="submit" value="Run" />
</form>
</p>
<hr/>
<p>
You may pick one or more of the following test suites:
<br/>
<form action="TestServlet" method="get" name="youPickItForm">
<select name="suite" size="2" multiple>
<option value="org.infohazard.test.EinsteinTest">
org.infohazard.test.EinsteinTest
</option>
<option value="some.other.Test">
some.other.Test
</option>
</select>
<input type="submit" value="Run" />
</form>
</p>
??example/components/test-war/index.htmll
3.3.2.7 web.xml
Web?óh?ejb-ref??'"java:comp/env/ejb/EinsteinEJB" JNDI lookup?and so that the TestServlet gets mapped to some sort of URI.web.xml?
<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<display-name> Einstein Unit Tester Web Application </display-name>
<servlet>
<servlet-name>JUnitEETestServlet</servlet-name>
<description>JUnitEE test framework</description>
<servlet-class>org.infohazard.servlet.TestServlet</servlet-class>
</servlet>
<ejb-ref>
<ejb-ref-name>ejb/EinsteinEJB</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>org.infohazard.ejb.einstein.EinsteinHome</home>
<remote>org.infohazard.ejb.einstein.Einstein</remote>
</ejb-ref>

<servlet-mapping>
<servlet-name>JUnitEETestServlet</servlet-name>
<url-pattern>/TestServlet</url-pattern>
</servlet-mapping>
</web-app>
?example/components/test-war/WEB-INF/web.xml
3.4 ??????????l?????????
???J2EEh?????HttpUnitJakarta CatausJ2EE?j??????k?h?????XP?Mock Object?h??HttpUnitL??h?J2EE?Weblogic?j????????h???²J2EE?j??


  <>

? | ? | | ? | ? | | | ? | ? | ??

Copyright® 2003 Test Engineer, Inc. All rights reserved.

 

| | | ? | ? | ? | ? | ? | ? | ? | ? | ? | ? | Software Quality Assuranc | Software Quality Assuranc | Software Quality Assuranc | Agenda | Agenda (cont.) | Historical Problems | Historical Problem | SQA Agenda | Quality Definition | Example - Furby | ArrayArrayArrayArrayMiami Cooking Schools - Weight Loss Surgery - International ScholarshipsArrayArrayArrayArray