Java tutorial
/** * Copyright 2013 Stockholm County Council * * This file is part of APIGW * * APIGW is free software; you can redistribute it and/or modify * it under the terms of version 2.1 of the GNU Lesser General Public * License as published by the Free Software Foundation. * * APIGW is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with APIGW; if not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307 USA * */ package org.apigw.authserver; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.client.RestTemplate; public class RemoteCalendar { public static void main(String[] args) throws Exception { for (int i = 0; i < 5; i++) { System.out.println("Starting thread: " + i); Thread t = new Thread(new Testing(i)); t.start(); } } private static class Testing implements Runnable { private final String url = "https://www.kalendercentralen.se/kalendercentralen-pKcMvkCalendarServer-module-web/kalender?guid=a0130fe7-023b-42f3-9871-5780df52f148"; private final RestTemplate client = new RestTemplate(); private final int threadNo; public Testing(int threadNo) { this.threadNo = threadNo; } public void run() { try { for (int i = 0; i < 5; i++) { Thread.sleep(250); try { ResponseEntity<String> resp = client.exchange(url, HttpMethod.GET, null, String.class); System.out.println(resp.getStatusCode()); System.out.println(resp.getBody().contains("BEGIN:VCALENDAR")); } catch (Exception e) { System.err.println("catching exception from thread " + threadNo); e.printStackTrace(); } } } catch (InterruptedException e) { } //} } } }