[
https://issues.apache.org/jira/browse/JXPATH-205?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Samuel Zihlmann updated JXPATH-205:
-----------------------------------
Summary: JXPath size() of an uninitialized array return 1 instead of 0
(was: JXPath size() of a uninitialized array return 1 instead of 0)
> JXPath size() of an uninitialized array return 1 instead of 0
> -------------------------------------------------------------
>
> Key: JXPATH-205
> URL: https://issues.apache.org/jira/browse/JXPATH-205
> Project: Commons JXPath
> Issue Type: Bug
> Affects Versions: 1.4.0
> Reporter: Samuel Zihlmann
> Priority: Major
>
> Since version 1.4.0 JXPath size() of an uninitialized array return 1 instead
> of 0
> In version 1.3 following unittest did work:
> {code:java}
> @Test
> public void testSize() {
> Foo foo = new Foo();
> foo.setTitle("title");
> Bar bar = new Bar();
> //bar.setWords(List.of("Bla", "Bli", "Blub"));
> //bar.setWords(List.of("Bla"));
> foo.setBar(bar);
> JXPathContext fallCtx = JXPathContext.newContext(foo);
> String query = "size(bar/words)";
> Object result = fallCtx.getValue(query);
> Assert.assertEquals(0, result);
> }
> public static class Foo {
> private Bar bar;
> private String title;
> public Bar getBar() {
> return bar;
> }
> public void setBar(Bar bar) {
> this.bar = bar;
> }
> public String getTitle() {
> return title;
> }
> public void setTitle(String title) {
> this.title = title;
> }
> }
> public static class Bar {
> private List<String> words;
> public List<String> getWords() {
> return words;
> }
> public void setWords(List<String> words) {
> this.words = words;
> }
> }{code}
> Result Version 1.4.0:
> {code:bash}
> java.lang.AssertionError:
> Expected :0
> Actual :1
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)