[Webtest] Failling to check an email

Florent Blondeau Florent Blondeau <fblondeau@pingwy.com>
Wed, 21 Nov 2007 09:31:58 +0100


Thanks for paying attention to my messages and thanks for the link...
Your test scenarii are quite impressive, really, it's a great job !
I see that you manage to get the content of your mail.
My OS is :
Linux version 2.6.23 (Debian 4.2.2-3)

java : 
java version "1.6.0_02-ea"
Java(TM) SE Runtime Environment (build 1.6.0_02-ea-b02)
Java HotSpot(TM) Client VM (build 1.6.0_02-ea-b02, mixed mode, sharing)

That's not so different...

I can't explain why you don't encounter the problem anymore since I saw 
no changes on the code between the build 1539 and the build 1620 
regarding to the parts we're interested in.
I may use emailContentFilter in a wrong way, or I don't understand all 
the code. All that I see is that the content type is different, because 
my email is in multipart/alternative. I didn't try in "plain"...

I got my step working with the hack I mentioned and another one to get 
the part I want from my mail. The problem is that the getContent() 
method on multipart messages fetched from POP3 result on a 
SharedByteArrayInputStream. This can not be an instance of Multipart nor 
String as it is supposed in emailMessageContentFilter :
            final Object content = message.getContent();
            if (content instanceof Multipart) {
                extractMultiPartMessage((Multipart) content, partIndex);
                return;
            }
            extractSimpleMessage((String) content, partIndex);
            return;
This code really complains when I try to get a "part" of my multipart 
email because of the String cast. I browse sun's javamail implementation 
code, and i can't find anything that would return a Multipart instance 
nor a String for the content of a Pop3 message, because it returns an 
InputStream. So to get it working, i made a new function to treat 
MimeMessage instances with partIndex:

private void extractMimeMessagePart(MimeMessage message, final int 
partIndex) throws MessagingException {
        MimePartDataSource ds = new MimePartDataSource(message);
        MimeMultipart multi = new MimeMultipart(ds);
        BodyPart part = multi.getBodyPart(partIndex);
        byte[] datas;
        try {
            datas = ASCIIUtility.getBytes(part.getInputStream());
        } catch (IOException e) {
            throw new StepFailedException("ASCIIUtility failed to parse 
email body part.", this);
        }
        defineAsCurrentResponse(datas, getContentType());
    }
That works well actually, but is it a good way to do it ?
The fact that you encounter no problem makes me think I'm completely off 
the subject !!!
Have you ever tried with a multipart message, or just plain text ?

If someone who has contributed to this code can enlighten me on how it 
works, and why it waits for Multipart or String,
it would be a great help !!!!

My message is sent via PHP/PEAR Mime utilities, and I'm wondering if it 
is really well formed...

If you test with a multipart mail, or if you think about something 
special, please let me know

Thanks
        

Karel Soupal a écrit :
> Hello again,
>
> as I stated earlier, after switching to a build 1620 I do NOT 
> experience this issue ... you can see that is does not fail for me 
> (see example here):
> http://www.ework.cz/ework_robot_results/testrun_20112007220436-manual_immediate/File2.html 
> .. expand all and search for emailMessageContentFilter ...
>
> the only thinkg that comes to my mind is java, os versions maybe? ... 
> mine are:
> debian etch 4.0 (2.6.18-5-686 #1 SMP Fri Jun 1 00:47:00 UTC 2007 i686 
> GNU/Linux)
>
> java:
> java version "1.5.0_12"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04)
> Java HotSpot(TM) Client VM (build 1.5.0_12-b04, mixed mode, sharing)
>


-- 
Pingwy
27, rue des arènes
49100 Angers