$ bazel test //java/org/bar/service:test-foo
TEST FAILED
Right, and the "resources" attribute works as I would expect. What I don't fully grep yet is how the "data" attribute is intended to work and I have not found any java_test examples online that demonstrate it's use. I guess the lesson is that bazel does not "move" files around, just links them up according to the same namespace of the dependency graph. I can see how this could avoid different data resources stepping on each other, but I'm not sure that is the rationale.
... oh wait, I just found https://github.com/bazelbuild/bazel/blob/master/examples/java-skylark/src/main/java/com/example/myproject/Greeter.java#L32-L33. I hadn't looked in the java-skylark examples.Looks like the way it to get a data dependency is to lookup the runfiles directory from System.getenv("JAVA_RUNFILES") or System.getenv("TEST_SRCDIR") and then append the full path of the file as it appears within the workspace. If the workspace name has not been defined by the workspace rule, e.g. (workspace(name = "io_bazel"), the default is __main__.