Java 类com.google.common.util.concurrent.testing.TestingExecutors 实例源码

项目:guava-mock    文件:AbstractScheduledServiceTest.java   
public void testTimeout() {
  // Create a service whose executor will never run its commands
  Service service = new AbstractScheduledService() {
    @Override protected Scheduler scheduler() {
      return Scheduler.newFixedDelaySchedule(0, 1, TimeUnit.NANOSECONDS);
    }

    @Override protected ScheduledExecutorService executor() {
      return TestingExecutors.noOpScheduledExecutor();
    }

    @Override protected void runOneIteration() throws Exception {}

    @Override protected String serviceName() {
      return "Foo";
    }
  };
  try {
    service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS);
    fail("Expected timeout");
  } catch (TimeoutException e) {
    assertThat(e).hasMessage("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
  }
}
项目:guava-mock    文件:AbstractExecutionThreadServiceTest.java   
public void testTimeout() {
  // Create a service whose executor will never run its commands
  Service service = new AbstractExecutionThreadService() {
    @Override protected void run() throws Exception {}

    @Override protected ScheduledExecutorService executor() {
      return TestingExecutors.noOpScheduledExecutor();
    }

    @Override protected String serviceName() {
      return "Foo";
    }
  };
  try {
    service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS);
    fail("Expected timeout");
  } catch (TimeoutException e) {
    assertThat(e).hasMessage("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
  }
}
项目:googles-monorepo-demo    文件:AbstractScheduledServiceTest.java   
public void testTimeout() {
  // Create a service whose executor will never run its commands
  Service service = new AbstractScheduledService() {
    @Override protected Scheduler scheduler() {
      return Scheduler.newFixedDelaySchedule(0, 1, TimeUnit.NANOSECONDS);
    }

    @Override protected ScheduledExecutorService executor() {
      return TestingExecutors.noOpScheduledExecutor();
    }

    @Override protected void runOneIteration() throws Exception {}

    @Override protected String serviceName() {
      return "Foo";
    }
  };
  try {
    service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS);
    fail("Expected timeout");
  } catch (TimeoutException e) {
    assertThat(e).hasMessage("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
  }
}
项目:googles-monorepo-demo    文件:AbstractExecutionThreadServiceTest.java   
public void testTimeout() {
  // Create a service whose executor will never run its commands
  Service service = new AbstractExecutionThreadService() {
    @Override protected void run() throws Exception {}

    @Override protected ScheduledExecutorService executor() {
      return TestingExecutors.noOpScheduledExecutor();
    }

    @Override protected String serviceName() {
      return "Foo";
    }
  };
  try {
    service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS);
    fail("Expected timeout");
  } catch (TimeoutException e) {
    assertThat(e).hasMessage("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
  }
}
项目:guava    文件:AbstractExecutionThreadServiceTest.java   
public void testTimeout() {
  // Create a service whose executor will never run its commands
  Service service =
      new AbstractExecutionThreadService() {
        @Override
        protected void run() throws Exception {}

        @Override
        protected ScheduledExecutorService executor() {
          return TestingExecutors.noOpScheduledExecutor();
        }

        @Override
        protected String serviceName() {
          return "Foo";
        }
      };
  try {
    service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS);
    fail("Expected timeout");
  } catch (TimeoutException e) {
    assertThat(e).hasMessage("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
  }
}
项目:guava    文件:AbstractExecutionThreadServiceTest.java   
public void testTimeout() {
  // Create a service whose executor will never run its commands
  Service service =
      new AbstractExecutionThreadService() {
        @Override
        protected void run() throws Exception {}

        @Override
        protected ScheduledExecutorService executor() {
          return TestingExecutors.noOpScheduledExecutor();
        }

        @Override
        protected String serviceName() {
          return "Foo";
        }
      };
  try {
    service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS);
    fail("Expected timeout");
  } catch (TimeoutException e) {
    assertThat(e).hasMessage("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
  }
}
项目:guava    文件:AbstractScheduledServiceTest.java   
public void testTimeout() {
  // Create a service whose executor will never run its commands
  Service service =
      new AbstractScheduledService() {
        @Override
        protected Scheduler scheduler() {
          return Scheduler.newFixedDelaySchedule(0, 1, TimeUnit.NANOSECONDS);
        }

        @Override
        protected ScheduledExecutorService executor() {
          return TestingExecutors.noOpScheduledExecutor();
        }

        @Override
        protected void runOneIteration() throws Exception {}

        @Override
        protected String serviceName() {
          return "Foo";
        }
      };
  try {
    service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS);
    fail("Expected timeout");
  } catch (TimeoutException e) {
    assertThat(e).hasMessage("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
  }
}
项目:guava    文件:AbstractScheduledServiceTest.java   
public void testTimeout() {
  // Create a service whose executor will never run its commands
  Service service =
      new AbstractScheduledService() {
        @Override
        protected Scheduler scheduler() {
          return Scheduler.newFixedDelaySchedule(0, 1, TimeUnit.NANOSECONDS);
        }

        @Override
        protected ScheduledExecutorService executor() {
          return TestingExecutors.noOpScheduledExecutor();
        }

        @Override
        protected void runOneIteration() throws Exception {}

        @Override
        protected String serviceName() {
          return "Foo";
        }
      };
  try {
    service.startAsync().awaitRunning(1, TimeUnit.MILLISECONDS);
    fail("Expected timeout");
  } catch (TimeoutException e) {
    assertThat(e).hasMessage("Timed out waiting for Foo [STARTING] to reach the RUNNING state.");
  }
}