Hi Henry,
Here I am attaching the .jsp file which I am trying to test.Please find some
time for this.
And the test class I written,
package com.test;
import junit.framework.TestSuite;
import net.sourceforge.jwebunit.WebTestCase;
public class ExampleWebTestApp extends WebTestCase {
public static void main(String[] args) {
junit.textui.TestRunner.run(new TestSuite(ExampleWebTestApp.class));
}
public void setUp() {
getTestContext().setBaseUrl(Messages.getString("ExampleWebTestApp.0"));
//$NON-NLS-1$
}
public void testAllBusinessServices() {
beginAt("/wsee_its_edit.jsp");
assertKeyPresent("test_message");
assertFormPresent("myform"); //$NON-NLS-1$
assertSubmitButtonPresent(Messages.getString("ExampleWebTestApp.4"));
assertTablePresent("webTest");
}
}
Actually my module name bse_refresh, and that is a Dynamic Web
Peoject.Ihave created a new Project in IDE (Eclipse) for testing .Is
it the way or
otherwise I have to write the tests in the same project.Please let me know.
Thanks in Advance,
Viswa Bharat.
On 2/26/07, Julien HENRY <[EMAIL PROTECTED]> wrote:
Can you show me the whole test source, and the HTML code you are trying
to test?
----- Message d'origine ----
De : vbreddy k <[EMAIL PROTECTED]>
À : Usage problems for JWebUnit <[email protected]>
Envoyé le : Lundi, 26 Février 2007, 2h27mn 39s
Objet : Re: [JWebUnit-users] Re : New to JWebUnit
Hi Julien Henry,
Thanks for your reply..As I said I am new to JWebUnit .I am trying to
execute some test .But the result is always Fail , where it has to be
Success. When I tried to execute the test,
beginAt("/login.jsp");
The output is ok(1 test) ;
In the same test , I am trying to test a form and table in my application
,The result is Failure .
Can you please help me out to solve the problem.
Thanks in Advance,
Viswa Bharat.
On 2/25/07, Julien HENRY <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> With latest releases, it is:
>
> *net.sourceforge.jwebunit.util.TestingEngineRegistry
>
> *
>
> Don't forget to consult Javadoc:
> http://jwebunit.sourceforge.net/apidocs/
>
> ++
> Julien
>
> ----- Message d'origine ----
> De : vbreddy k < [EMAIL PROTECTED]>
> À : [email protected]
> Envoyé le : Samedi, 24 Février 2007, 4h42mn 26s
> Objet : [JWebUnit-users] New to JWebUnit
>
>
> Hi Friends,
>
> I am new to JWebUnit .I have to use that in my current application.Itried to
execute a
> Test.But I am facing compilation error while I am importing * *
>
> *import** net.sourceforge.jwebunit.TestingEngineRegistry*;
>
> Can anybody help me with the solution .And if possible please tell me
> cleaaarly how to add plugin with Eclipse IDE.
> *
>
> package
> *com.test;
>
> *
>
> import
> *junit.framework.TestSuite;*
>
> import
> *net.sourceforge.jwebunit.WebTestCase;
>
> *
>
> import
> *net.sourceforge.jwebunit.*TestingEngineRegistry*;
>
> //import net.sourceforge.jwebunit.util.TestContext;
>
> *
>
> public
> **class* ExampleWebTestApp *extends* WebTestCase {
>
> *public* *static* *void *main(String[] args) {
>
> junit.textui.TestRunner.*run*(
> *new* TestSuite(ExampleWebTestApp.*class* ));
>
> }
>
> *public* *void* setUp() {
>
> getTestContext().setBaseUrl(Messages.*getString*(
> "ExampleWebTestApp.0")); //$NON-NLS-1$
>
> setTestingEngineKey(TestingEngineRegistry.
> *TESTING_ENGINE_HTMLUNIT*);
>
> System.
> *out*.println("Cookies" + getTestContext().getCookies()); //$NON-NLS-1$
>
> }
>
> *public* *void* testAllBusinessServices() {
>
> *try* {
>
> beginAt(
> "/wsee_its_edit.jsp");
>
> assertTitleEquals(
> "Edit WS Intermediary Service");
>
> }
> *catch* (Exception ex) {
>
> ex.printStackTrace();
>
> }
> *finally* {
>
> //assertKeyPresent("test_message");
>
> assertFormPresent(
> "myform"); //$NON-NLS-1$
>
> assertSubmitButtonPresent(Messages.*getString*(
> "ExampleWebTestApp.4")); //$NON-NLS-1$
>
> assertTablePresent(
> "webTest"); //$NON-NLS-1$
>
> }
>
> }
>
> }
>
> --
> Thanks in Advance,
> Viswa Bharat Reddy
>
>
> --
> Regards
> Viswa Bharat Reddy
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> opinions on IT & business topics through brief surveys-and earn cash
>
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> JWebUnit-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jwebunit-users
>
>
>
> ------------------------------
> Découvrez une nouvelle façon d'obtenir des réponses à toutes vos
> questions ! Profitez des connaissances, des opinions et des expériences des
> internautes sur Yahoo!
Questions/Réponses<http://fr.rd.yahoo.com/evt=42054/*http://fr.answers.yahoo.com>
> .
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your
> opinions on IT & business topics through brief surveys-and earn cash
>
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> JWebUnit-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jwebunit-users
>
>
--
Regards
Viswa Bharat Reddy
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
JWebUnit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users
------------------------------
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions
! Profitez des connaissances, des opinions et des expériences des
internautes sur Yahoo!
Questions/Réponses<http://fr.rd.yahoo.com/evt=42054/*http://fr.answers.yahoo.com>
.
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
JWebUnit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users
--
Regards
Viswa Bharat Reddy
<%@ page contentType="text/html; charset=utf-8"%>
<%@ page
import="com.hp.mip.model.framework.MipObjectId,
com.hp.wsm.bse.utils.RequestHelper,
com.hp.mip.model.virtualwsee.VirtualWsee,
com.hp.mip.model.usecase.ListVirtualWseesUseCase,
com.hp.mip.model.usecase.VirtualWseeFactoryHelper,
com.hp.mip.model.contacts.ContactRelationship,
com.hp.mip.model.contacts.ItServiceContactRelationshipFactory,
com.hp.mip.model.contacts.ContactRelationshipDesc,
java.util.Set,
java.util.HashSet"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jstl/fmt"%>
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml"%>
<jsp:useBean id="bse" scope="session" type="com.hp.wsm.bse.model.Bse" />
<%
/*
** Usage: virtualWseeId=MipObjectId, or no params for create.
**
**
*/
RequestHelper helper = new RequestHelper(request);
int type = helper.getInt("type", -1);
boolean create = helper.getString("virtualWseeId", null) == null;
if (helper.isPost()) {
boolean wasCreated = false;
String id = helper.getString("virtualWseeId", null);
try {
VirtualWsee virtualWsee;
if (id != null) {
MipObjectId virtualWseeId = new
MipObjectId(request.getParameter("virtualWseeId"));
ListVirtualWseesUseCase useCase = new
ListVirtualWseesUseCase(bse.getMip());
virtualWsee = useCase.getVirtualWsee(virtualWseeId);
} else {
String name = helper.getString("name", "");
if ((name == null) || (name.trim().length() == 0)) {
%>
<c:set var="errorMsg" scope="session">
<f:message key="message.error.Name_is_a_required_field" />
</c:set>
<%
response.sendRedirect(request.getRequestURI() + "?" +
request.getQueryString());
return;
}
String desc = helper.getString("description", "");
if ((desc == null) || (desc.trim().length() == 0)) {
%>
<c:set var="errorMsg" scope="session">
<f:message key="message.error.Description_is_a_required_field" />
</c:set>
<%
response.sendRedirect(request.getRequestURI() + "?" +
request.getQueryString());
return;
}
try {
virtualWsee =
bse.getMip().getUseCases().getWseeUseCases().getCreateVirtualWseeUseCase().createVirtualWsee(name,
type);
} catch (Exception e) {
%>
<c:set var="errorMsg" scope="session">
<f:message key="message.additservice.DuplicateItService" /> :
<%=e.getMessage()%>
</c:set>
<%
response.sendRedirect(request.getRequestURI() + "?" +
request.getQueryString());
return;
}
wasCreated = true;
}
type = VirtualWseeFactoryHelper.getVirtualWseeType(virtualWsee);
// String[] urls = request.getParameterValues("add");
// virtualWsee.setWsees(urls);
if (create) {
virtualWsee.setName(request.getParameter("name"));
}
virtualWsee.setDescription(request.getParameter("description"));
String isMonitored = helper.getString("slo.availability.enabled");
virtualWsee.getMonitorSettings().setMonitored(isMonitored != null);
String categoryError = helper.getString("errorCategory");
String categoryWarn = helper.getString("warnCategory");
virtualWsee.getMonitorSettings().setBreachAlertCategory(categoryError);
virtualWsee.getMonitorSettings().setWarningAlertCategory(categoryWarn);
virtualWsee.save();
Set updatedRelationships = new HashSet();
String owner = request.getParameter("ownerId");
if (owner != null && owner.length() > 0) {
updatedRelationships.add(new ContactRelationshipDesc(owner,
ContactRelationship.ROLE_OWNS));
}
String support = request.getParameter("supportId");
if (support != null && support.length() > 0) {
updatedRelationships.add(new ContactRelationshipDesc(support,
ContactRelationship.ROLE_SUPPORTS));
}
ItServiceContactRelationshipFactory factory =
(ItServiceContactRelationshipFactory)
bse.getMip().getRegistry().getFactory(ItServiceContactRelationshipFactory.class);
factory.updateRelationships(virtualWsee, updatedRelationships);
if (wasCreated) {
%>
<c:url var="viewLink" value="wsee_its_view.jsp">
<c:param name="id">
<%=virtualWsee.getId().toString()%>
</c:param>
</c:url>
<c:redirect url="${viewLink}" />
<%
return;
}
}
catch (Exception e) {
e.printStackTrace(); //To change body of catch statement use File |
Settings | File Templates.
}
%>
<c:redirect url="done.jsp" />
<%
return;
}
%>
<c:catch var="error">
<c:import url="VirtualWseeView.xml.jsp" var="xmlText" />
<x:parse xml="${xmlText}" var="xml" />
</c:catch>
<c:catch var="error">
<c:import url="ContactList.xml.jsp?sort=name" var="xmlContactList" />
<x:parse xml="${xmlContactList}" var="contactList" />
</c:catch>
<c:set scope="request" var="crumbs_id" value="default" />
<c:set scope="request" var="page_title">
<f:message key="heading.Edit_WSEE_IT_Service" />
</c:set>
<c:import url="Global_Header.jsp" />
<br>
<c:choose>
<c:when test="${error != null}">
<div><f:message
key="message.error.Unable_to_view_WSEE_IT_Service" />:
<c:out
value="${error.message}" /></div>
</c:when>
<c:otherwise>
<form id="myform" method="POST" accept-charset="utf-8"
onsubmit="return validate(this);"><c:choose>
<c:when test="${param.type != null && param.type !=
''}">
<input name="type" type="hidden"
value="<c:out value="${param.type}"/>"
/>
</c:when>
</c:choose> <input name="_p" type="hidden" value="<c:out
value='${param._p}'/>" />
<input type="hidden" name="virtualWseeId"
value="<c:out value="${param.virtualWseeId}" />" />
<div class="handler"
style="border: 3px solid red; margin-top: .5cm;
padding: 4px;"
for="myform.invalid">
<div><f:message key="message.error.Form_has_errors" /></div>
<div class="handler" for="name.invalid"><f:message
key="message.error.Name_is_a_required_field" /></div>
<div class="handler" for="description.invalid"><f:message
key="message.error.Description_is_a_required_field"
/></div>
</div>
<%
session.removeAttribute("errorMsg");
%>
<div
class="txtBold"><f:message>action.<%=create?"Create":"Edit"%>
</f:message> <f:message
key="heading.WSEE_IT_Service_Type_${param.type}" /></div>
<div class="formbox">
<table border="0" cellpadding="6" cellspacing="0" width="100%"
id="webTest">
<tr>
<%if (create) {%>
<td class="label2"><b><f:message
key="label.Name" />:*</b></td>
<td width="100%"><input size="50" type="text"
id="initalFocusInput" name="name"
validate="required"
value="<x:out
select="$xml/virtualWsee/@name" />" /></td>
<%} else {%>
<td class="label2"><b><f:message
key="label.Name" />:</b></td>
<td width="100%"><x:out
select="$xml/virtualWsee/@name" /></td>
<%}%>
</tr>
<tr>
<td class="label2"><b><f:message
key="label.Description" />:*</b></td>
<td><input size="50" type="text"
name="description"
validate="required"
<%=!create?"id=\"initalFocusInput\"":""%>
value="<x:out
select="$xml/virtualWsee/@desc" />" /></td>
</tr>
<tr>
<td class="label2"><b><f:message
key="label.Owner" />:</b></td>
<td><select name="ownerId">
<x:if select="$xml/virtualWsee/[EMAIL
PROTECTED]'owns']">
<x:forEach
select="$xml/virtualWsee/[EMAIL PROTECTED]'owns']">
<option value="<x:out
select="@id"/>" SELECTED><x:out
select="@name"
/></option>
</x:forEach>
</x:if>
<option value="">[<f:message
key="option.not_specified" />]</option>
<x:forEach
select="$contactList/contactList/contact">
<option value="<x:out
select="@id"/>"><x:out
select="@name"
/></option>
</x:forEach>
</select></td>
</tr>
<tr>
<td class="label2"><b><f:message
key="label.Support" />:</b></td>
<td><select name="supportId">
<x:if select="$xml/virtualWsee/[EMAIL
PROTECTED]'supports']">
<x:forEach
select="$xml/virtualWsee/[EMAIL PROTECTED]'supports']">
<option value="<x:out
select="@id"/>" SELECTED><x:out
select="@name"
/></option>
</x:forEach>
</x:if>
<option value="">[<f:message
key="option.not_specified" />]</option>
<x:forEach
select="$contactList/contactList/contact">
<option value="<x:out
select="@id"/>"><x:out
select="@name"
/></option>
</x:forEach>
</select></td>
</tr>
<tr>
<td class="label2">
<div><b><f:message key="label.Availability"
/>:</b></div>
</td>
<td><input type="checkbox"
name="slo.availability.enabled"
value="true"
<x:if
select="boolean($xml/virtualWsee/@isMonitored='true')">CHECKED</x:if> />
<f:message
key="label.Alert_when_not_operational" /></td>
</tr>
<tr>
<td class="label2" valign="top" nowrap="true">
<div><b><f:message key="label.Alert_Recipients"
/>:</b></div>
</td>
<td valign="top">
<table cellpadding="0" cellspacing="0"
border="0" width="100%" class="treeTable">
<thead>
<tr class="captionRow">
<th><f:message
key="label.Availability" />
</th>
<th><f:message
key="label.Alert_Recipient" /> <span class="normaltext">[
<a href="<c:url
value="AlertConfig.jsp" backtrack="true" />"><f:message
key="action.Edit" /></a> ]</span>
</th>
</tr>
</thead>
<tbody>
<tr>
<td class="sorted"
nowrap="true"><img
src="images/i_liteYellow.png"> <f:message
key="label.Degraded" />:</td>
<td class="sorted"
width="100%"><select name="warnCategory">
<x:forEach
select="$xml/virtualWsee/category">
<option
value="<x:out select="@name" />"
<x:if
select="@name=string($xml/virtualWsee/@SloWarningCategory)">SELECTED</x:if>>
<f:message key="option.x">
<f:param>
<x:out select="@desc" />
</f:param>
</f:message></option>
</x:forEach>
</select></td>
</tr>
<tr>
<td class="sorted"
nowrap="true"><img
src="images/alert_critical_sm.gif"> <f:message
key="label.Unavailable" />:</td>
<td
class="sorted"><select name="errorCategory">
<x:forEach
select="$xml/virtualWsee/category">
<option
value="<x:out select="@name" />"
<x:if select="@name=string($xml/virtualWsee/@SloErrorCategory)">SELECTED</x:if>>
<f:message key="option.x">
<f:param>
<x:out select="@desc" />
</f:param>
</f:message></option>
</x:forEach>
</select></td>
</tr>
</tbody>
</table>
</td>
</tr>
<%-- <tr>--%>
<%-- <td colspan="2">--%>
<%-- <table class="datatable">--%>
<%-- <thead>--%>
<%-- <tr>--%>
<%-- <td class="labelColumn"
align="center">Contains</td>--%>
<%-- <td
class="labelColumn">WSEE</td>--%>
<%-- <td
class="labelColumn">Management Interface (WSDL)</td>--%>
<%-- </tr>--%>
<%-- </thead>--%>
<%-- <tbody>--%>
<%-- <x:forEach
select="$xml/virtualWsee/wsee">--%>
<%-- <tr>--%>
<%-- <td class="data"
align="center">--%>
<%-- <input type="checkbox"--%>
<%-- name="add"--%>
<%-- value="<x:out
select="@url" />"--%>
<%-- <x:if
select="@contained='true'">CHECKED</x:if>--%>
<%-- />--%>
<%-- </td>--%>
<%-- <td class="data"><x:out
select="@name"></x:out>--%>
<%-- <td class="data"><x:out
select="@url"></x:out>--%>
<%-- </tr>--%>
<%-- </x:forEach>--%>
<%-- </tbody>--%>
<%-- </table>--%>
<%-- <small>--%>
<%-- Check any WSEEs you wish to use in
this IT Service--%>
<%-- </small>--%>
<%-- </td>--%>
<%-- </tr>--%>
<tfoot>
<tr>
<td align="center" colspan="2"><br />
<div class="buttonSet">
<div class="bWrapperUp">
<div>
<div><input class="hpButton"
type="button"
value="<f:message
key="action.Cancel" />"
onclick="window.location='<c:out value="${donePage.url}" />'" />
</div>
</div>
</div>
<div class="bWrapperUp bEmphasized">
<div>
<div><input class="hpButton"
type=submit name="submit"
value="<f:message
key="action.Save" />" /></div>
</div>
</div>
</div>
</div>
<br />
</td>
</tr>
</tfoot>
</table>
</div>
</form>
<script>
document.getElementById("initalFocusInput").focus();
</script>
<br />
<br />
</c:otherwise>
</c:choose>
<c:import url="Global_Footer.jsp" />
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
JWebUnit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users