Do not log legacy warnings in JUnit tests (#11963)

Change-Id: I5549a524d7fae32b1ef201073ab48cadcc4e8212