{"action":"created","comment":{"url":"https://api.github.com/repos/dimagi/javarosa/pulls/comments/27697730","id":27697730,"diff_hunk":"@@ -0,0 +1,175 @@\n+/*\n+ * Copyright (C) 2015 JavaRosa\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\"); you may not\n+ * use this file except in compliance with the License. You may obtain a copy of\n+ * the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the\n+ * License for the specific language governing permissions and limitations under\n+ * the License.\n+ */\n+\n+package org.javarosa.xpath.expr.test;\n+\n+import j2meunit.framework.Test;\n+import j2meunit.framework.TestCase;\n+import j2meunit.framework.TestMethod;\n+import j2meunit.framework.TestSuite;\n+\n+import java.io.BufferedReader;\n+import java.io.FileReader;\n+import java.io.FileNotFoundException;\n+import java.io.InputStream;\n+import java.io.IOException;\n+import java.util.Date;\n+import java.util.Vector;\n+\n+import org.javarosa.core.model.condition.EvaluationContext;\n+import org.javarosa.core.model.condition.IFunctionHandler;\n+import org.javarosa.core.model.data.IAnswerData;\n+import org.javarosa.core.model.data.IntegerData;\n+import org.javarosa.core.model.data.StringData;\n+import org.javarosa.core.model.instance.FormInstance;\n+import org.javarosa.core.model.instance.TreeElement;\n+import org.javarosa.core.model.instance.TreeReference;\n+import org.javarosa.core.model.utils.DateUtils;\n+import org.javarosa.model.xform.XPathReference;\n+import org.javarosa.xpath.IExprDataType;\n+import org.javarosa.xpath.XPathException;\n+import org.javarosa.xpath.XPathParseTool;\n+import org.javarosa.xpath.XPathTypeMismatchException;\n+import org.javarosa.xpath.XPathUnhandledException;\n+import org.javarosa.xpath.XPathUnsupportedException;\n+import org.javarosa.xpath.expr.XPathExpression;\n+import org.javarosa.xpath.expr.XPathFuncExpr;\n+import org.javarosa.xpath.expr.XPathNumericLiteral;\n+import org.javarosa.xpath.expr.XPathPathExpr;\n+import org.javarosa.xpath.parser.XPathSyntaxException;\n+import org.javarosa.xml.ElementParser;\n+import org.javarosa.xml.TreeElementParser;\n+import org.javarosa.xml.util.InvalidStructureException;\n+import org.kxml2.io.KXmlParser;\n+import org.xmlpull.v1.XmlPullParserException;\n+\n+/**\n+ *\n+ * @author Phillip Mates\n+ */\n+\n+public class XPathPathExprTest extends TestCase {\n+\n+    private static final String formPath = new String(\"/test_xpathpathexpr.xml\");\n+    // private static final String formPath = new String(\"/test_small_xml_example.xml\");\n+\n+    public XPathPathExprTest(String name, TestMethod rTestMethod) {\n+        super(name, rTestMethod);\n+    }\n+\n+    public XPathPathExprTest(String name) {\n+        super(name);\n+    }\n+\n+    public XPathPathExprTest() {\n+        super();\n+    }\n+\n+    public Test suite() {\n+        TestSuite aSuite = new TestSuite();\n+\n+        aSuite.addTest(new XPathPathExprTest(\"XPath Path Expression Test\", new TestMethod() {\n+            public void run(TestCase tc) {\n+                ((XPathPathExprTest) tc).doTests();\n+            }\n+        }));\n+\n+        return aSuite;\n+    }\n+\n+    public void doTests() {\n+        TreeElement root = null;\n+        EvaluationContext ec = new EvaluationContext(null);\n+\n+        TreeElementParser parser;\n+        // read in xml\n+        try {\n+            InputStream is = System.class.getResourceAsStream(formPath);\n+            parser = new TreeElementParser(ElementParser.instantiateParser(is), 0, \"instance\");\n+        } catch (IOException e) {\n+            fail(\"Contents at filepath could not be loaded into parser: \" + formPath);\n+            return;\n+        }\n+\n+        // turn parsed xml into a form instance\n+        try {\n+            root = parser.parse();\n+        } catch (Exception e) {\n+            fail(\"File couldn't be parsed into a TreeElement: \" + formPath);\n+            return;\n+        }\n+        FormInstance instance = null;\n+        try {\n+            instance = new FormInstance(root, \"\");\n+        } catch (Exception e) {\n+            fail(\"couldn't create form instance\");\n+        }\n+\n+        // Used to reproduce bug where locations can't handle heterogeneous template paths\n+        // The following test will pass when this is fixed.\n+        testEval(\"/data/places/country[1]/state[0]/name\", instance, null, \"Utah\");\n+\n+        // XXX: not sure why this test isn't passing\n+        testEval(\"/data/places/country[0]/name\", instance, null, \"Singapore\");","path":"core/test/org/javarosa/xpath/expr/test/XPathPathExprTest.java","position":126,"original_position":126,"commit_id":"caa63ea2ca65b5fc40da14210a1dc752e48c369e","original_commit_id":"caa63ea2ca65b5fc40da14210a1dc752e48c369e","user":{"login":"phillipm","id":94817,"avatar_url":"https://avatars.githubusercontent.com/u/94817?v=3","gravatar_id":"","url":"https://api.github.com/users/phillipm","html_url":"https://github.com/phillipm","followers_url":"https://api.github.com/users/phillipm/followers","following_url":"https://api.github.com/users/phillipm/following{/other_user}","gists_url":"https://api.github.com/users/phillipm/gists{/gist_id}","starred_url":"https://api.github.com/users/phillipm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phillipm/subscriptions","organizations_url":"https://api.github.com/users/phillipm/orgs","repos_url":"https://api.github.com/users/phillipm/repos","events_url":"https://api.github.com/users/phillipm/events{/privacy}","received_events_url":"https://api.github.com/users/phillipm/received_events","type":"User","site_admin":false},"body":"Why does this evaluation return \"\" instead of \"Singapore\"?","created_at":"2015-04-02T21:13:27Z","updated_at":"2015-04-02T21:13:27Z","html_url":"https://github.com/dimagi/javarosa/pull/66#discussion_r27697730","pull_request_url":"https://api.github.com/repos/dimagi/javarosa/pulls/66","_links":{"self":{"href":"https://api.github.com/repos/dimagi/javarosa/pulls/comments/27697730"},"html":{"href":"https://github.com/dimagi/javarosa/pull/66#discussion_r27697730"},"pull_request":{"href":"https://api.github.com/repos/dimagi/javarosa/pulls/66"}}},"pull_request":{"url":"https://api.github.com/repos/dimagi/javarosa/pulls/66","id":32515783,"html_url":"https://github.com/dimagi/javarosa/pull/66","diff_url":"https://github.com/dimagi/javarosa/pull/66.diff","patch_url":"https://github.com/dimagi/javarosa/pull/66.patch","issue_url":"https://api.github.com/repos/dimagi/javarosa/issues/66","number":66,"state":"open","locked":false,"title":"Simple tests for XPath Path Expressions","user":{"login":"phillipm","id":94817,"avatar_url":"https://avatars.githubusercontent.com/u/94817?v=3","gravatar_id":"","url":"https://api.github.com/users/phillipm","html_url":"https://github.com/phillipm","followers_url":"https://api.github.com/users/phillipm/followers","following_url":"https://api.github.com/users/phillipm/following{/other_user}","gists_url":"https://api.github.com/users/phillipm/gists{/gist_id}","starred_url":"https://api.github.com/users/phillipm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phillipm/subscriptions","organizations_url":"https://api.github.com/users/phillipm/orgs","repos_url":"https://api.github.com/users/phillipm/repos","events_url":"https://api.github.com/users/phillipm/events{/privacy}","received_events_url":"https://api.github.com/users/phillipm/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-02T14:24:38Z","updated_at":"2015-04-02T21:13:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"33c9d8085ba61ccdaf9883a9cc89092628cab720","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dimagi/javarosa/pulls/66/commits","review_comments_url":"https://api.github.com/repos/dimagi/javarosa/pulls/66/comments","review_comment_url":"https://api.github.com/repos/dimagi/javarosa/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dimagi/javarosa/issues/66/comments","statuses_url":"https://api.github.com/repos/dimagi/javarosa/statuses/caa63ea2ca65b5fc40da14210a1dc752e48c369e","head":{"label":"dimagi:path_expr_tests","ref":"path_expr_tests","sha":"caa63ea2ca65b5fc40da14210a1dc752e48c369e","user":{"login":"dimagi","id":94514,"avatar_url":"https://avatars.githubusercontent.com/u/94514?v=3","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"repo":{"id":20938963,"name":"javarosa","full_name":"dimagi/javarosa","owner":{"login":"dimagi","id":94514,"avatar_url":"https://avatars.githubusercontent.com/u/94514?v=3","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dimagi/javarosa","description":"","fork":false,"url":"https://api.github.com/repos/dimagi/javarosa","forks_url":"https://api.github.com/repos/dimagi/javarosa/forks","keys_url":"https://api.github.com/repos/dimagi/javarosa/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dimagi/javarosa/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dimagi/javarosa/teams","hooks_url":"https://api.github.com/repos/dimagi/javarosa/hooks","issue_events_url":"https://api.github.com/repos/dimagi/javarosa/issues/events{/number}","events_url":"https://api.github.com/repos/dimagi/javarosa/events","assignees_url":"https://api.github.com/repos/dimagi/javarosa/assignees{/user}","branches_url":"https://api.github.com/repos/dimagi/javarosa/branches{/branch}","tags_url":"https://api.github.com/repos/dimagi/javarosa/tags","blobs_url":"https://api.github.com/repos/dimagi/javarosa/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dimagi/javarosa/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dimagi/javarosa/git/refs{/sha}","trees_url":"https://api.github.com/repos/dimagi/javarosa/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dimagi/javarosa/statuses/{sha}","languages_url":"https://api.github.com/repos/dimagi/javarosa/languages","stargazers_url":"https://api.github.com/repos/dimagi/javarosa/stargazers","contributors_url":"https://api.github.com/repos/dimagi/javarosa/contributors","subscribers_url":"https://api.github.com/repos/dimagi/javarosa/subscribers","subscription_url":"https://api.github.com/repos/dimagi/javarosa/subscription","commits_url":"https://api.github.com/repos/dimagi/javarosa/commits{/sha}","git_commits_url":"https://api.github.com/repos/dimagi/javarosa/git/commits{/sha}","comments_url":"https://api.github.com/repos/dimagi/javarosa/comments{/number}","issue_comment_url":"https://api.github.com/repos/dimagi/javarosa/issues/comments{/number}","contents_url":"https://api.github.com/repos/dimagi/javarosa/contents/{+path}","compare_url":"https://api.github.com/repos/dimagi/javarosa/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dimagi/javarosa/merges","archive_url":"https://api.github.com/repos/dimagi/javarosa/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dimagi/javarosa/downloads","issues_url":"https://api.github.com/repos/dimagi/javarosa/issues{/number}","pulls_url":"https://api.github.com/repos/dimagi/javarosa/pulls{/number}","milestones_url":"https://api.github.com/repos/dimagi/javarosa/milestones{/number}","notifications_url":"https://api.github.com/repos/dimagi/javarosa/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dimagi/javarosa/labels{/name}","releases_url":"https://api.github.com/repos/dimagi/javarosa/releases{/id}","created_at":"2014-06-17T20:46:39Z","updated_at":"2015-04-01T18:56:26Z","pushed_at":"2015-04-02T21:12:32Z","git_url":"git://github.com/dimagi/javarosa.git","ssh_url":"git@github.com:dimagi/javarosa.git","clone_url":"https://github.com/dimagi/javarosa.git","svn_url":"https://github.com/dimagi/javarosa","homepage":null,"size":29965,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":5,"forks":1,"open_issues":5,"watchers":0,"default_branch":"master"}},"base":{"label":"dimagi:master","ref":"master","sha":"63b3d034cbdb07c022825fd465fd2a09b3341736","user":{"login":"dimagi","id":94514,"avatar_url":"https://avatars.githubusercontent.com/u/94514?v=3","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"repo":{"id":20938963,"name":"javarosa","full_name":"dimagi/javarosa","owner":{"login":"dimagi","id":94514,"avatar_url":"https://avatars.githubusercontent.com/u/94514?v=3","gravatar_id":"","url":"https://api.github.com/users/dimagi","html_url":"https://github.com/dimagi","followers_url":"https://api.github.com/users/dimagi/followers","following_url":"https://api.github.com/users/dimagi/following{/other_user}","gists_url":"https://api.github.com/users/dimagi/gists{/gist_id}","starred_url":"https://api.github.com/users/dimagi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimagi/subscriptions","organizations_url":"https://api.github.com/users/dimagi/orgs","repos_url":"https://api.github.com/users/dimagi/repos","events_url":"https://api.github.com/users/dimagi/events{/privacy}","received_events_url":"https://api.github.com/users/dimagi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dimagi/javarosa","description":"","fork":false,"url":"https://api.github.com/repos/dimagi/javarosa","forks_url":"https://api.github.com/repos/dimagi/javarosa/forks","keys_url":"https://api.github.com/repos/dimagi/javarosa/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dimagi/javarosa/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dimagi/javarosa/teams","hooks_url":"https://api.github.com/repos/dimagi/javarosa/hooks","issue_events_url":"https://api.github.com/repos/dimagi/javarosa/issues/events{/number}","events_url":"https://api.github.com/repos/dimagi/javarosa/events","assignees_url":"https://api.github.com/repos/dimagi/javarosa/assignees{/user}","branches_url":"https://api.github.com/repos/dimagi/javarosa/branches{/branch}","tags_url":"https://api.github.com/repos/dimagi/javarosa/tags","blobs_url":"https://api.github.com/repos/dimagi/javarosa/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dimagi/javarosa/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dimagi/javarosa/git/refs{/sha}","trees_url":"https://api.github.com/repos/dimagi/javarosa/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dimagi/javarosa/statuses/{sha}","languages_url":"https://api.github.com/repos/dimagi/javarosa/languages","stargazers_url":"https://api.github.com/repos/dimagi/javarosa/stargazers","contributors_url":"https://api.github.com/repos/dimagi/javarosa/contributors","subscribers_url":"https://api.github.com/repos/dimagi/javarosa/subscribers","subscription_url":"https://api.github.com/repos/dimagi/javarosa/subscription","commits_url":"https://api.github.com/repos/dimagi/javarosa/commits{/sha}","git_commits_url":"https://api.github.com/repos/dimagi/javarosa/git/commits{/sha}","comments_url":"https://api.github.com/repos/dimagi/javarosa/comments{/number}","issue_comment_url":"https://api.github.com/repos/dimagi/javarosa/issues/comments{/number}","contents_url":"https://api.github.com/repos/dimagi/javarosa/contents/{+path}","compare_url":"https://api.github.com/repos/dimagi/javarosa/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dimagi/javarosa/merges","archive_url":"https://api.github.com/repos/dimagi/javarosa/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dimagi/javarosa/downloads","issues_url":"https://api.github.com/repos/dimagi/javarosa/issues{/number}","pulls_url":"https://api.github.com/repos/dimagi/javarosa/pulls{/number}","milestones_url":"https://api.github.com/repos/dimagi/javarosa/milestones{/number}","notifications_url":"https://api.github.com/repos/dimagi/javarosa/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dimagi/javarosa/labels{/name}","releases_url":"https://api.github.com/repos/dimagi/javarosa/releases{/id}","created_at":"2014-06-17T20:46:39Z","updated_at":"2015-04-01T18:56:26Z","pushed_at":"2015-04-02T21:12:32Z","git_url":"git://github.com/dimagi/javarosa.git","ssh_url":"git@github.com:dimagi/javarosa.git","clone_url":"https://github.com/dimagi/javarosa.git","svn_url":"https://github.com/dimagi/javarosa","homepage":null,"size":29965,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":5,"forks":1,"open_issues":5,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dimagi/javarosa/pulls/66"},"html":{"href":"https://github.com/dimagi/javarosa/pull/66"},"issue":{"href":"https://api.github.com/repos/dimagi/javarosa/issues/66"},"comments":{"href":"https://api.github.com/repos/dimagi/javarosa/issues/66/comments"},"review_comments":{"href":"https://api.github.com/repos/dimagi/javarosa/pulls/66/comments"},"review_comment":{"href":"https://api.github.com/repos/dimagi/javarosa/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dimagi/javarosa/pulls/66/commits"},"statuses":{"href":"https://api.github.com/repos/dimagi/javarosa/statuses/caa63ea2ca65b5fc40da14210a1dc752e48c369e"}}}}