[java] Added test for #2828