< prev index next >

test/javax/xml/jaxp/unittest/xpath/Bug4991857.java

Print this page




  75     }
  76 
  77     @Test
  78     public void testXPath11() throws Exception {
  79         try {
  80             Document d = null;
  81 
  82             XPathFactory xpathFactory = XPathFactory.newInstance();
  83             Assert.assertNotNull(xpathFactory);
  84 
  85             XPath xpath = xpathFactory.newXPath();
  86             Assert.assertNotNull(xpath);
  87 
  88             String quantity = (String) xpath.evaluate("/widgets/widget[@name='a']/@quantity", d, XPathConstants.STRING);
  89             Assert.fail("XPathExpressionException not thrown");
  90         } catch (XPathExpressionException e) {
  91             // Expected exception as context node is null
  92         }
  93     }
  94 }
  95 


  75     }
  76 
  77     @Test
  78     public void testXPath11() throws Exception {
  79         try {
  80             Document d = null;
  81 
  82             XPathFactory xpathFactory = XPathFactory.newInstance();
  83             Assert.assertNotNull(xpathFactory);
  84 
  85             XPath xpath = xpathFactory.newXPath();
  86             Assert.assertNotNull(xpath);
  87 
  88             String quantity = (String) xpath.evaluate("/widgets/widget[@name='a']/@quantity", d, XPathConstants.STRING);
  89             Assert.fail("XPathExpressionException not thrown");
  90         } catch (XPathExpressionException e) {
  91             // Expected exception as context node is null
  92         }
  93     }
  94 }

< prev index next >