Java Code Examples for java.util.concurrent.TimeoutException#printStackTrace()

The following examples show how to use java.util.concurrent.TimeoutException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeleteAll.java    From jclouds-examples with Apache License 2.0 6 votes vote down vote up
private void deleteCloudDNS() throws IOException, TimeoutException {
   System.out.format("Delete DNS Domains%n");

   CloudDNSApi cloudDNSApi = ContextBuilder.newBuilder(System.getProperty("provider.cdns", "rackspace-clouddns-us"))
         .credentials(username, apiKey)
         .buildApi(CloudDNSApi.class);

   try {
      Set<Domain> allDomains = cloudDNSApi.getDomainApi().list().concat().toSet();
      Iterable<Domain> topLevelDomains = Iterables.filter(allDomains, IS_DOMAIN);
      Iterable<Integer> topLevelDomainIds = Iterables.transform(topLevelDomains, GET_DOMAIN_ID);

      if (!allDomains.isEmpty()) {
         awaitComplete(cloudDNSApi, cloudDNSApi.getDomainApi().delete(topLevelDomainIds, true));
         System.out.format("  Deleted %s domains%n", Iterables.size(topLevelDomainIds));
      }
   } catch (TimeoutException e) {
      e.printStackTrace();
   }

   Closeables.close(cloudDNSApi, true);
}
 
Example 2
Source File: RabbitMqBenchmarkDriver.java    From openmessaging-benchmark with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(File configurationFile, StatsLogger statsLogger) throws IOException {
    config = mapper.readValue(configurationFile, RabbitMqConfig.class);

    ConnectionFactory connectionFactory = new ConnectionFactory();
    connectionFactory.setAutomaticRecoveryEnabled(true);
    connectionFactory.setHost(config.brokerAddress);
    connectionFactory.setUsername("admin");
    connectionFactory.setPassword("admin");

    try {
        connection = connectionFactory.newConnection();
    } catch (TimeoutException e) {
        e.printStackTrace();
    }
}
 
Example 3
Source File: TestTriggerActivity.java    From Trigger with Apache License 2.0 6 votes vote down vote up
@Test
void testTrigger2with2() {
    timeoutLatch = new TimeoutLatch(2);
    Job job1 = new Job(new Act())
            .withExtra(new Cond1());
    Job job2 = new Job(new Act())
            .withExtra(new Cond2());
    trigger.schedule(job1, job2);
    sendBroadcastDelay(COND1, COND2);
    try {
        timeoutLatch.await(AWAIT_TIME);
        assertEquals(actCounter.get(), 2);
    } catch (TimeoutException e) {
        e.printStackTrace();
        assertEquals(1, 2);
    }
}
 
Example 4
Source File: ItServiceClicker.java    From SmoothClicker with MIT License 6 votes vote down vote up
/**
 * Tests the service start method with dummy values
 *
 * <i>A service can handle negative delays</i>
 */
//@Test
// FIXME To tests with UT instead of IT
public void startServiceWithNegativeValues1() {

    l(this, "@Test startServiceWithNegativeValues1");

    Intent startIntent = new Intent(InstrumentationRegistry.getTargetContext(), ServiceClicker.class);
    startIntent.setAction("pylapp.smoothclicker.android.clickers.ServiceClicker.START");
    startIntent.putExtra("0x000012", -20);   // How much delay for the start ?
    ArrayList<Integer> points = new ArrayList<>();
    points.add(0); // x0
    points.add(0); // y0
    startIntent.putIntegerArrayListExtra("0x000051", points); // The list of points
    try { mServiceRule.startService( startIntent ); } catch ( TimeoutException te ){te.printStackTrace();}

}
 
Example 5
Source File: ItServiceClicker.java    From SmoothClicker with MIT License 6 votes vote down vote up
/**
 * Tests the service start method with dummy values
 *
 *< i>A service can handle negative time gaps</i>
 */
//@Test
// FIXME To tests with UT instead of IT
public void startServiceWithNegativeValues2() {

    l(this, "@Test startServiceWithNegativeValues2");

    Intent startIntent = new Intent(InstrumentationRegistry.getTargetContext(), ServiceClicker.class);
    startIntent.setAction("pylapp.smoothclicker.android.clickers.ServiceClicker.START");
    startIntent.putExtra("0x000013", -2);    // The amount of time to wait between clicks
    ArrayList<Integer> points = new ArrayList<>();
    points.add(0); // x0
    points.add(0); // y0
    startIntent.putIntegerArrayListExtra("0x000051", points); // The list of points
    try { mServiceRule.startService( startIntent ); } catch ( TimeoutException te ){te.printStackTrace();}

}
 
Example 6
Source File: ItServiceClicker.java    From SmoothClicker with MIT License 6 votes vote down vote up
/**
 * Tests the service start method with dummy values
 *
 * <i>The service can handle negative repeat</i>
 */
//@Test
// FIXME To tests with UT instead of IT
public void startServiceWithNegativeValues3() {

    l(this, "@Test startServiceWithNegativeValues3");

    Intent startIntent = new Intent(InstrumentationRegistry.getTargetContext(), ServiceClicker.class);
    startIntent.setAction("pylapp.smoothclicker.android.clickers.ServiceClicker.START");
    startIntent.putExtra("0x000021", -10);    // The number of repeat to do
    ArrayList<Integer> points = new ArrayList<>();
    points.add(0); // x0
    points.add(0); // y0
    startIntent.putIntegerArrayListExtra("0x000051", points); // The list of points
    try { mServiceRule.startService( startIntent ); } catch ( TimeoutException te ){te.printStackTrace();}

}
 
Example 7
Source File: ItServiceClicker.java    From SmoothClicker with MIT License 6 votes vote down vote up
/**
 * Tests the service start method with dummy values
 *
 * <i>The service can handle points with negative coordinates</i>
 */
//@Test
// FIXME To tests with UT instead of IT
public void startServiceWithNegativeValues4() {

    l(this, "@Test startServiceWithNegativeValues4");

    Intent startIntent = new Intent(InstrumentationRegistry.getTargetContext(), ServiceClicker.class);
    startIntent.setAction("pylapp.smoothclicker.android.clickers.ServiceClicker.START");
    ArrayList<Integer> points = new ArrayList<>();
    points.add(0); // x0
    points.add(42); // y0
    points.add(1337); // x1
    points.add(-50); // y1
    startIntent.putIntegerArrayListExtra("0x000051", points); // The list of points
    try { mServiceRule.startService( startIntent ); } catch ( TimeoutException te ){te.printStackTrace();}

}
 
Example 8
Source File: TestTriggerActivity.java    From Trigger with Apache License 2.0 6 votes vote down vote up
@Test
void testTrigger2with1() {
    timeoutLatch = new TimeoutLatch(2);

    Job job1 = new Job(new Act())
            .withExtra(new Cond1());
    Job job2 = new Job(new Act())
            .withExtra(new Cond1());
    trigger.schedule(job1, job2);
    sendBroadcastDelay(COND1);
    try {
        timeoutLatch.await(AWAIT_TIME);
        assertEquals(actCounter.get(), 2);
    } catch (TimeoutException e) {
        e.printStackTrace();
        assertEquals(1, 2);
    }
}
 
Example 9
Source File: ItServiceClicker.java    From SmoothClicker with MIT License 6 votes vote down vote up
/**
 * Tests the service start method with dummy values
 *
 * <i>The service can handle points with too small coordinates</i>
 */
//@Test
// FIXME To tests with UT instead of IT
public void startServiceWithToSmallCoordinates() {

    l(this, "@Test startServiceWithToSmallCoordinates");

    Intent startIntent = new Intent(InstrumentationRegistry.getTargetContext(), ServiceClicker.class);
    startIntent.setAction("pylapp.smoothclicker.android.clickers.ServiceClicker.START");
    ArrayList<Integer> points = new ArrayList<>();
    points.add(Integer.MIN_VALUE); // x0
    points.add(Integer.MIN_VALUE); // y0
    startIntent.putIntegerArrayListExtra("0x000051", points); // The list of points
    try { mServiceRule.startService( startIntent ); } catch ( TimeoutException te ){te.printStackTrace();}

}
 
Example 10
Source File: ItServiceClicker.java    From SmoothClicker with MIT License 6 votes vote down vote up
/**
 * Tests the service start method without null values
 *
 * <i>The service can handle null values for the points</i>
 */
//@Test
// FIXME To tests with UT instead of IT
public void startServiceWithNullValues(){

    l(this, "@Test startServiceWithNullValues");

    Intent startIntent = new Intent(InstrumentationRegistry.getTargetContext(), ServiceClicker.class);
    // Create the Intent with the good action
    startIntent.setAction("pylapp.smoothclicker.android.clickers.ServiceClicker.START");

    // Defines the configuration to use
    startIntent.putExtra("0x000011", true); // Start delayed ?
    startIntent.putExtra("0x000012", 20);   // How much delay for the start ?
    startIntent.putExtra("0x000013", 2);    // The amount of time to wait between clicks
    startIntent.putExtra("0x000021", 10);    // The number of repeat to do
    startIntent.putExtra("0x000022", false);// Endless repeat ?
    startIntent.putExtra("0x000031", false);// Vibrate on start ?
    startIntent.putExtra("0x000032", false);// Vibrate on each click ?
    startIntent.putExtra("0x000041", true);// Make notifications ?
    ArrayList<Integer> points = new ArrayList<>();
    startIntent.putIntegerArrayListExtra("0x000051", points); // The list of points
    try { mServiceRule.startService( startIntent ); } catch ( TimeoutException te ){te.printStackTrace();}

}
 
Example 11
Source File: ItServiceClicker.java    From SmoothClicker with MIT License 5 votes vote down vote up
/**
 * Tests the service start method with dummy values
 *
 * <i>The service can handle points with too big coordinates</i>
 */
@Test
public void startServiceWithToBigCoordinates() {

    l(this, "@Test startServiceWithToBigCoordinates");

    Intent startIntent = new Intent(InstrumentationRegistry.getTargetContext(), ServiceClicker.class);
    startIntent.setAction("pylapp.smoothclicker.android.clickers.ServiceClicker.START");
    ArrayList<Integer> points = new ArrayList<>();
    points.add(Integer.MAX_VALUE); // x0
    points.add(Integer.MAX_VALUE); // y0
    startIntent.putIntegerArrayListExtra("0x000051", points); // The list of points
    try { mServiceRule.startService( startIntent ); } catch ( TimeoutException te ){te.printStackTrace();}

}
 
Example 12
Source File: BookContinuationClient.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws InterruptedException, ExecutionException {
    final String url = "http://localhost:" + PORT + "/async/bookstore/disconnect";
    WebClient wc = WebClient.create(url);
    try {
        System.out.println("server ready");
        wc.async().get().get(500, TimeUnit.MILLISECONDS);
    } catch (TimeoutException ex) {
        ex.printStackTrace();
    } finally {
        System.out.println("server stopped");
        System.out.println("done!");
        System.exit(0);
    }
}
 
Example 13
Source File: UITest.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@BeforeClass
public static void setupSpec() {
    try {
        FxToolkit.registerPrimaryStage();
        FxToolkit.hideStage();
    } catch (TimeoutException e) {
        logger.error(e.getMessage());
        e.printStackTrace();
    }
}
 
Example 14
Source File: AppConfigurationInitialisationTest.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
@Ignore
public void testAppConfigurationInitialisation() {
    try {
        FxToolkit.registerPrimaryStage();
        FxToolkit.setupFixture(() -> new AnnotationConfigApplicationContext(AppConfiguration.class));
    } catch (TimeoutException e) {
        e.printStackTrace();
        fail();
    }

}
 
Example 15
Source File: RMID.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Ask rmid to shutdown gracefully using a remote method call.
 * catch any errors that might occur from rmid not being present
 * at time of shutdown invocation. If the remote call is
 * successful, wait for the process to terminate. Return true
 * if the process terminated, otherwise return false.
 */
private boolean shutdown() throws InterruptedException {
    mesg("shutdown()");
    long startTime = System.currentTimeMillis();
    ActivationSystem system = lookupSystem(port);
    if (system == null) {
        mesg("lookupSystem() returned null after " +
            (System.currentTimeMillis() - startTime) + "ms.");
        return false;
    }

    try {
        mesg("ActivationSystem.shutdown()");
        system.shutdown();
    } catch (Exception e) {
        mesg("Caught exception from ActivationSystem.shutdown():");
        e.printStackTrace();
    }

    try {
        waitFor(TIMEOUT_SHUTDOWN_MS);
        mesg("Shutdown successful after " +
            (System.currentTimeMillis() - startTime) + "ms.");
        return true;
    } catch (TimeoutException ex) {
        mesg("Shutdown timed out after " +
            (System.currentTimeMillis() - startTime) + "ms:");
        ex.printStackTrace();
        return false;
    }
}
 
Example 16
Source File: ItServiceClicker.java    From SmoothClicker with MIT License 5 votes vote down vote up
/**
 * Tests the service start method with dummy values
 *
 * <i>A service can handle bad actions in its intent and make nothing / returns if it occurs</i>
 */
//@Test
// FIXME To tests with UT instead of IT
public void startServiceWithBadAction() {

    l(this, "@Test startServiceWithBadAction");

    Intent startIntent = new Intent(InstrumentationRegistry.getTargetContext(), ServiceClicker.class);
    startIntent.setAction("pylapp.smoothclicker.android.clickers.ServiceClicker.STOP");
    try { mServiceRule.startService( startIntent ); } catch ( TimeoutException te ){te.printStackTrace();}

}
 
Example 17
Source File: RabbitMqCollect.java    From light_drtc with Apache License 2.0 5 votes vote down vote up
/**
  * 关闭channel和connection。并非必须,因为隐含是自动调用的。
  * @throws IOException
  */
  public void close() throws IOException{
      try {
this.channel.close();
      } catch (TimeoutException e) {
e.printStackTrace();
      }
      this.connection.close();
  }
 
Example 18
Source File: RMID.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Ask rmid to shutdown gracefully but then destroy the rmid
 * process if it does not exit by itself.  This method only works
 * if rmid is a child process of the current VM.
 */
public void destroy() {
    if (vm == null) {
        throw new IllegalStateException("can't wait for RMID that isn't running");
    }

    long startTime = System.currentTimeMillis();

    // First, attempt graceful shutdown of the activation system.
    try {
        if (! shutdown()) {
            // Graceful shutdown failed, use Process.destroy().
            mesg("Destroying RMID process.");
            vm.destroy();
            try {
                waitFor(TIMEOUT_DESTROY_MS);
                mesg("Destroy successful after " +
                    (System.currentTimeMillis() - startTime) + "ms.");
            } catch (TimeoutException ex) {
                mesg("Destroy timed out, giving up after " +
                    (System.currentTimeMillis() - startTime) + "ms:");
                ex.printStackTrace();
            }
        }
    } catch (InterruptedException ie) {
        mesg("Shutdown/destroy interrupted, giving up at " +
            (System.currentTimeMillis() - startTime) + "ms.");
        ie.printStackTrace();
        Thread.currentThread().interrupt();
        return;
    }

    vm = null;
}
 
Example 19
Source File: ObjectCachedPooledObjectUnit.java    From Voovan with Apache License 2.0 4 votes vote down vote up
public void testBorrowConcurrent() {

        Object pooledId = null;
        ObjectPool<TestPoolObject> objectPool = new ObjectPool().minSize(1).maxSize(1).aliveTime(500000).supplier(()->{
            return  new TestPoolObject("element " + item++);
        }).create();



        ConcurrentLinkedQueue<TestPoolObject> queue = new ConcurrentLinkedQueue<TestPoolObject>();

        AtomicInteger count = new AtomicInteger(0);

        for(int i=0;i<100;i++){
            Thread t = new Thread(()->{
                while (count.incrementAndGet() < 50000) {
//                    if ((int) (Math.random() * 10 % 2) == 0) {
                        TestPoolObject object = null;
                        try {
                            object = objectPool.borrow(1000);
                        } catch (TimeoutException e) {
                            e.printStackTrace();
                        }

                        if (object != null) {
//                            queue.offer(object);
                            System.out.println("borrow->" + object);
                        } else {
                            System.out.println("borrow failed ================");
                        }
//                    } else {
//                        TestPoolObject object = queue.poll();
                        if (object != null) {
                            System.out.println("restitution->" + object);
                            objectPool.restitution(object);
                        }
//                    }
                }
            });

            t.start();
        }



        while(count.incrementAndGet() < 1000) {
            TEnv.sleep(1);
        }

        while(queue.size() >0){
            objectPool.restitution(queue.poll());
        }
    }
 
Example 20
Source File: Downloader.java    From nju-lib-downloader with GNU General Public License v3.0 4 votes vote down vote up
public void mergePDF(File inputFileArray[], int start, int end, File outputFile) throws IOException, InterruptedException {
        //获取输入文件列表
        StringBuffer inputPDFList = new StringBuffer();

        for (int i = start; i < end; i++) {
            File file = inputFileArray[i];
            inputPDFList.append(parsePathWithWhiteSpace(file.getAbsolutePath()));
            inputPDFList.append(" ");
        }
/*        for (File file : inputFileArray) {
            if (file.getName().endsWith(".pdf")) {
*//*                inputPDFList.append(file.toPath().getRoot());

                Iterator<Path>pathIterator=file.toPath().iterator();
                String firstPath=pathIterator.next().toString();
                if(firstPath!=null){
                    inputPDFList.append(firstPath);
                }
                while(pathIterator.hasNext()){
                    inputPDFList.append(System.getProperty("file.separator"));
                    inputPDFList.append(parsePathWithWhiteSpace(pathIterator.next().toString()));
                }*//*
                inputPDFList.append(parsePathWithWhiteSpace(file.getAbsolutePath()));
                inputPDFList.append(" ");
            }
        }*/
        // File outputFile = path.resolve(book.getId() +"-"+partID+ ".pdf").toFile();
        String command = (isWindows ? "gswin64c" : "gs") + " -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sOutputFile=\"" + outputFile.getPath() + "\" " + inputPDFList;

        try {
            if (isWindows) {
                new ProcessExecutor().command(command.split(" "))
                        .redirectOutput(Slf4jStream.of(getClass()).asInfo())
                        .readOutput(true).execute().outputUTF8();
            } else {
                File bashFile = path.resolve(book.getId() + (isWindows ? ".bat" : ".sh")).toFile();
                FileWriter fileWriter = new FileWriter(bashFile);
                fileWriter.write(command);
                fileWriter.close();
                new ProcessExecutor().command("bash", parsePathWithWhiteSpace(bashFile.getName()))
                        .redirectOutput(Slf4jStream.of(getClass()).asInfo())
                        .readOutput(true).execute().outputUTF8();
                bashFile.delete();
            }
        } catch (TimeoutException e) {
            e.printStackTrace();
        }
    }