コード例 #1
0
    public void execute(WorkerProcessContext workerProcessContext) {
      // Check environment
      assertThat(System.getProperty("test.system.property"), equalTo("value"));
      assertThat(System.getenv().get("TEST_ENV_VAR"), equalTo("value"));

      // Check ClassLoaders
      ClassLoader antClassLoader = Project.class.getClassLoader();
      ClassLoader thisClassLoader = getClass().getClassLoader();
      ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();

      assertThat(antClassLoader, not(sameInstance(systemClassLoader)));
      assertThat(thisClassLoader, not(sameInstance(systemClassLoader)));
      assertThat(antClassLoader.getParent(), equalTo(systemClassLoader.getParent()));
      try {
        assertThat(
            thisClassLoader.loadClass(Project.class.getName()),
            sameInstance((Object) Project.class));
      } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
      }

      // Send some messages
      TestListenerInterface sender =
          workerProcessContext.getServerConnection().addOutgoing(TestListenerInterface.class);
      sender.send("message 1", 1);
      sender.send("message 2", 2);
    }
コード例 #2
0
 public void execute(WorkerProcessContext workerProcessContext) {
   TestListenerInterface sender =
       workerProcessContext.getServerConnection().addOutgoing(TestListenerInterface.class);
   sender.send("message 1", 1);
   sender.send("message 2", 2);
   // crash
   Runtime.getRuntime().halt(1);
 }
コード例 #3
0
    public void execute(WorkerProcessContext workerProcessContext) {
      final Lock lock = new ReentrantLock();
      lock.lock();
      new Thread(
              new Runnable() {
                public void run() {
                  lock.lock();
                }
              })
          .start();

      TestListenerInterface sender =
          workerProcessContext.getServerConnection().addOutgoing(TestListenerInterface.class);
      sender.send("message 1", 1);
      sender.send("message 2", 2);
    }
コード例 #4
0
 public void execute(WorkerProcessContext workerProcessContext) {
   TestListenerInterface sender =
       workerProcessContext.getServerConnection().addOutgoing(TestListenerInterface.class);
   sender.send("other 1", 1);
   sender.send("other 2", 2);
 }