@Test public void invalidTokenThrows() { when(UserGroupInformation.isSecurityEnabled()).thenReturn(true); when(mockProtocolData.getToken()).thenReturn("This is odd"); try { SecuredHDFS.verifyToken(mockProtocolData, mockContext); fail("invalid X-GP-TOKEN should throw"); } catch (SecurityException e) { assertEquals("Failed to verify delegation token java.io.EOFException", e.getMessage()); } }