View | Details | Raw Unified | Return to bug 60710
Collapse All | Expand All

(-)src/components/org/apache/jmeter/extractor/XPathExtractor.java (-1 / +1 lines)
Lines 188-194 Link Here
188
188
189
    private void addAssertionFailure(final SampleResult previousResult,
189
    private void addAssertionFailure(final SampleResult previousResult,
190
            final Throwable thrown, final boolean setFailed) {
190
            final Throwable thrown, final boolean setFailed) {
191
        AssertionResult ass = new AssertionResult(thrown.getClass().getSimpleName()); // $NON-NLS-1$
191
        AssertionResult ass = new AssertionResult(getName()); // $NON-NLS-1$
192
        ass.setFailure(true);
192
        ass.setFailure(true);
193
        ass.setFailureMessage(thrown.getLocalizedMessage()+"\nSee log file for further details.");
193
        ass.setFailureMessage(thrown.getLocalizedMessage()+"\nSee log file for further details.");
194
        previousResult.addAssertionResult(ass);
194
        previousResult.addAssertionResult(ass);
(-)test/src/org/apache/jmeter/extractor/TestXPathExtractor.java (-1 / +25 lines)
Lines 256-270 Link Here
256
        public void testInvalidXpath() throws Exception {
256
        public void testInvalidXpath() throws Exception {
257
            extractor.setXPathQuery("<");
257
            extractor.setXPathQuery("<");
258
            extractor.process();
258
            extractor.process();
259
            assertEquals(1, result.getAssertionResults().length);
260
            assertEquals(extractor.getName(), result.getAssertionResults()[0].getName());
261
            org.junit.Assert.assertTrue(result.getAssertionResults()[0].
262
                    getFailureMessage().contains("A location path was expected, but the following token was encountered"));
259
            assertEquals("Default", vars.get(VAL_NAME));
263
            assertEquals("Default", vars.get(VAL_NAME));
260
            assertEquals("0", vars.get(VAL_NAME_NR));
264
            assertEquals("0", vars.get(VAL_NAME_NR));
261
        }
265
        }
262
266
263
        @Test
267
        @Test
268
        public void testNonXmlDocument() throws Exception {
269
            result.setResponseData("Error:exception occured", null);
270
            extractor.setXPathQuery("//test");
271
            extractor.process();
272
            assertEquals(1, result.getAssertionResults().length);
273
            assertEquals(extractor.getName(), result.getAssertionResults()[0].getName());
274
            org.junit.Assert.assertTrue(result.getAssertionResults()[0].
275
                    getFailureMessage().contains("Content is not allowed in prolog"));
276
            assertEquals("Default", vars.get(VAL_NAME));
277
            assertEquals("0", vars.get(VAL_NAME_NR));
278
        }
279
        @Test
264
        public void testInvalidDocument() throws Exception {
280
        public void testInvalidDocument() throws Exception {
265
            result.setResponseData("<z>", null);
281
            result.setResponseData("<z>", null);
266
            extractor.setXPathQuery("<");
282
            extractor.setXPathQuery("//test");
267
            extractor.process();
283
            extractor.process();
284
            
285
            assertEquals(1, result.getAssertionResults().length);
286
            assertEquals(extractor.getName(), result.getAssertionResults()[0].getName());
287
            System.out.println(result.getAssertionResults()[0].
288
                    getFailureMessage());
289
            org.junit.Assert.assertTrue(result.getAssertionResults()[0].
290
                    getFailureMessage().contains("XML document structures must start and end within the same entity"));
291
268
            assertEquals("Default", vars.get(VAL_NAME));
292
            assertEquals("Default", vars.get(VAL_NAME));
269
            assertEquals("0", vars.get(VAL_NAME_NR));
293
            assertEquals("0", vars.get(VAL_NAME_NR));
270
        }
294
        }

Return to bug 60710