@Test
public void testJvmOpts() throws Exception {

  String invalidJvmOpts = "`ping -c 3 example.com`";
  intercept(IllegalArgumentException.class,
      "Invalid character in yarn.service.am.java.opts.",
      () -> ServiceApiUtil.validateJvmOpts(invalidJvmOpts));
  String validJvmOpts = "-Dyarn.service.am.java.opts=-Xmx768m "
      + "-Djava.security.auth.login.config=/opt/hadoop/etc/jaas-zk.conf";
  try {
    ServiceApiUtil.validateJvmOpts(validJvmOpts);
  } catch (Exception ex) {
    fail("Invalid character in yarn.service.am.java.opts.");
  }
}