[Webtest] Failling to check an email
Florent Blondeau
Florent Blondeau <fblondeau@pingwy.com>
Tue, 13 Nov 2007 17:50:39 +0100
This is a multi-part message in MIME format.
--------------000107050005060001040704
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Thank you,
After hours spent on trying to configure a debug workbench with Eclipse,
i'm closer to the
answer that i've ever been. But now, i lack some webtest's internal
stuff knowledge to get rid of
my issue.
Everything seems to be OK since i reach the filterContent method in the
EmailMessageContentFilter class.
I run into the defineAsCurrentResponse and reach the ContextHelper
class. There, I arrive in this method :
public static void defineAsCurrentResponse(final Context context, final
byte[] responseBytes,
final String contentType, final String urlStr) {
final WebClient webClient = context.getWebClient();
final WebConnection originalConnection =
webClient.getWebConnection();
try {
final MockWebConnection mockConnection = new
MockWebConnection(webClient);
webClient.setWebConnection(mockConnection);
mockConnection.setDefaultResponse(responseBytes, 200, "ok",
contentType);
// htmlUnit does't currently follow the "current window"
// check that our faked content will be loaded in what
WebTest considers as the "current window"
// cf WT-293
final WebWindow currentTopWindow =
context.getCurrentResponse().getEnclosingWindow().getTopWindow();
// with the <previousResponse/> it may happen that the
window is not registerd anymore
if (webClient.getWebWindows().contains(currentTopWindow))
{
webClient.setCurrentWindow(currentTopWindow);
}
final URL url = UrlBoundary.tryCreateUrl(urlStr);
HtmlUnitBoundary.tryGetPage(url, webClient);
}
finally {
// remove special connection
webClient.setWebConnection(originalConnection);
}
}
The webClient variable seems to be OK, and the mockConnection works well
(they reference each other). The default response
of the mockConnection is well set and responseBytes contains my email's
text (that is the most important things to me).
The only thing that seems to behave badly is that the
currentWebClientContext of the context variable has fPreviousResponse
and fCurrentResponse set both to null.
When the I reach the line final WebWindow currentTopWindow =
context.getCurrentResponse().getEnclosingWindow().getTopWindow();,
getCurrentResponse() returns null and that leads to
an exception when "context.null" is called.
So i see what happens during the execution, but I don't know the
"normal" behaviour of this classes and especially when the responses
(previous and current) are set and defined. I suppose it could be done
when connection and webClient register themselves, but I am a webtest
newcomer (newbie?) and I can't be sure of that
If someone knows what happens and could help me, it would be awesome
Thanks
Florent Blondeau
Paul King a écrit :
>
> I'll see if I can have a look shortly.
>
> Paul.
>
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
--
Pingwy
27, rue des arènes
49100 Angers
--------------000107050005060001040704
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Thank you,<br>
<br>
After hours spent on trying to configure a debug workbench with
Eclipse, i'm closer to the <br>
answer that i've ever been. But now, i lack some webtest's internal
stuff knowledge to get rid of <br>
my issue.<br>
<br>
Everything seems to be OK since i reach the filterContent method in the
EmailMessageContentFilter class.<br>
I run into the defineAsCurrentResponse and reach the ContextHelper
class. There, I arrive in this method :<br>
<br>
<small><small><font face="serif">public static void
defineAsCurrentResponse(final Context context, final byte[]
responseBytes,<br>
final String contentType, final String urlStr) {<br>
final WebClient webClient = context.getWebClient();<br>
final WebConnection originalConnection =
webClient.getWebConnection();<br>
try {<br>
final MockWebConnection mockConnection = new
MockWebConnection(webClient);<br>
webClient.setWebConnection(mockConnection);<br>
mockConnection.setDefaultResponse(responseBytes, 200, "ok",
contentType);<br>
<br>
// htmlUnit does't currently follow the "current window"<br>
// check that our faked content will be loaded in what
WebTest considers as the "current window"<br>
// cf WT-293<br>
final WebWindow currentTopWindow =
context.getCurrentResponse().getEnclosingWindow().getTopWindow();<br>
// with the <previousResponse/> it may happen that
the window is not registerd anymore<br>
if (webClient.getWebWindows().contains(currentTopWindow)) <br>
{<br>
webClient.setCurrentWindow(currentTopWindow);<br>
}<br>
<br>
final URL url = UrlBoundary.tryCreateUrl(urlStr);<br>
HtmlUnitBoundary.tryGetPage(url, webClient);<br>
}<br>
finally {<br>
// remove special connection<br>
webClient.setWebConnection(originalConnection);<br>
}<br>
}<br>
<br>
</font></small></small><small><small><font face="Arial"></font></small></small>
<p>The webClient variable seems to be OK, and the mockConnection works
well (they reference each other). The default response <br>
of the mockConnection is well set and responseBytes contains my email's
text (that is the most important things to me).<br>
The only thing that seems to behave badly is that the
currentWebClientContext of the context variable has fPreviousResponse
and fCurrentResponse set both to null.<br>
</p>
<p>When the I reach the line <small><small><font face="serif">final
WebWindow currentTopWindow =
context.getCurrentResponse().getEnclosingWindow().getTopWindow();,</font>
<big><big>getCurrentResponse() returns null</big></big><big><big> and
that leads to <br>
an exception when "context.null" is called.<br>
</big></big></small></small></p>
<p><small><small><big><big>So i see what happens during the execution,
but I don't know the "normal" behaviour of this classes and especially
when the responses (previous and current) are set and defined. I
suppose it could be done when connection and webClient register
themselves, but I am a webtest newcomer (newbie?) and I can't be sure
of that<br>
</big></big></small></small></p>
<p><small><small><big><big>If someone knows what happens and could help
me, it would be awesome<br>
</big></big></small></small></p>
<p><small><small><big><big>Thanks</big></big></small></small></p>
<p><small><small><big><big>Florent Blondeau<br>
</big></big></small></small></p>
<br>
Paul King a écrit :
<blockquote cite="mid:4738AC6F.8060506@asert.com.au" type="cite"><br>
I'll see if I can have a look shortly.
<br>
<br>
Paul.
<br>
<br>
_______________________________________________
<br>
WebTest mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:WebTest@lists.canoo.com">WebTest@lists.canoo.com</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.canoo.com/mailman/listinfo/webtest">http://lists.canoo.com/mailman/listinfo/webtest</a>
<br>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Pingwy
27, rue des arènes
49100 Angers
</pre>
</body>
</html>
--------------000107050005060001040704--