commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephan Mikaty <mik...@ecircle-ag.com>
Subject AW: [jxpath] querying a javamail Message
Date Mon, 16 Jun 2003 08:51:21 GMT
Hi there,

Thanks for the reply. I tried to use 1 instead of 0,
to no avail. The exception is identical to the one
i submitted previously. Here is a test case that
exhibits the problem:

    public void testJXPath() throws Exception {
        BodyPart textPart = new MimeBodyPart();
        textPart.setContent("plain", "text/plain");
        MimeMultipart mp = new MimeMultipart("alternative");
        mp.addBodyPart(textPart);
        assertEquals(1, mp.getCount());
        assertEquals("text/plain", mp.getBodyPart(0).getContentType());
        
        JXPathContext ctx = JXPathContext.newContext(mp);
        assertEquals(new Integer(1), ctx.getValue("count"));
!!!!    assertEquals("text/plain", ctx.getValue("bodyPart[1]/contentType"));
// Failure here
    }

I have to stress that i didn't write any special (X)BeanInfo for
any of the classes in the standard javax.mail package. When stepping
through the code, "bodyPart" is correctly discovered as an indexed
property, so i'm at a loss as to what causes the problem.

The version i tested this on was commons-jxpath-1.1.

Stephane

> -----Ursprungliche Nachricht-----
> Von: Dmitri Plotnikov [mailto:dplotnik@yahoo.com]
> Gesendet: Freitag, 13. Juni 2003 23:07
> An: Jakarta Commons Users List
> Betreff: Re: [jxpath] querying a javamail Message
> 
> 
> Stephan,
> 
> Sorry about the horrible error message.  I'll change it to print
> something more comprehensible.
> 
> The obvious problem is that you are using 0 instead of 1 to access the
> first element of the collection (I know, I know... I hate 
> that too. But
> it's XPath standard - what are you gonna do?)
> 
> I hope this helps.
> 
> - Dmitri
> 
> 
> --- Stephan Mikaty <mikaty@ecircle-ag.com> wrote:
> > Hi everyone, 
> > 
> > I've been trying to use xpath expressions against
> > a javax.mail.internet.MimeMessage with attachments.
> > Thi allows me to shorten my junit test cases:
> > 
> > JXPathContext ctx = JXPathContext.newContext(message);
> > assertEquals("text/plain",
> > ctx.getValue("content/bodyPart[0]/contentType"));
> > 
> > I get the following trace:
> > 
> > java.lang.NullPointerException
> > 	at
> >
> org.apache.commons.jxpath.util.ValueUtils.getCollectionHint(Va
> lueUtils.java:
> > 112)
> > 	at
> >
> org.apache.commons.jxpath.ri.model.beans.BeanPropertyPointer.i
> sCollection(Be
> > anPropertyPointer.java:201)
> > 	at
> >
> org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.isColl
> ectionElement(
> > SimplePathInterpreter.java:770)
> > 	at
> >
> org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.doPred
> icateIndex(Sim
> > plePathInterpreter.java:674)
> > 	at
> >
> org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.doPred
> icate(SimplePa
> > thInterpreter.java:487)
> > 	at
> >
> org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.doStep
> PredicatesProp
> > ertyOwner(SimplePathInterpreter.java:353)
> > 	at
> >
> org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.doStep
> (SimplePathInt
> > erpreter.java:194)
> > 	at
> >
> org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.doStep
> NoPredicatesPr
> > opertyOwner(SimplePathInterpreter.java:276)
> > 	at
> >
> org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.doStep
> (SimplePathInt
> > erpreter.java:187)
> > 	at
> >
> org.apache.commons.jxpath.ri.axes.SimplePathInterpreter.interp
> retSimpleLocat
> > ionPath(SimplePathInterpreter.java:122)
> > 	at
> >
> org.apache.commons.jxpath.ri.compiler.Path.getSingleNodePointe
> rForSteps(Path
> > .java:186)
> > 	at
> >
> org.apache.commons.jxpath.ri.compiler.LocationPath.computeValu
> e(LocationPath
> > .java:128)
> > 	at
> >
> org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getVal
> ue(JXPathConte
> > xtReferenceImpl.java:287)
> > 	at
> >
> org.apache.commons.jxpath.ri.JXPathContextReferenceImpl.getVal
> ue(JXPathConte
> > xtReferenceImpl.java:283)
> > 
> > 
> > Am i doing something wrong? I looked a the code and tried a few
> > changes,
> > but couldn't come up with any obvious fix.
> > 
> > Any help appreciated,
> > 
> > Stephane
> > 
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: 
> commons-user-help@jakarta.apache.org
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
> http://calendar.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 

Mime
View raw message