@Test public void testCheckForUpdate() throws IOException { final ServletContext context = createNiceMock(ServletContext.class); expect(context.getMajorVersion()).andReturn(2).anyTimes(); expect(context.getMinorVersion()).andReturn(5).anyTimes(); expect(context.getContextPath()).andReturn("/test").anyTimes(); replay(context); Parameters.initialize(context); verify(context); final Collector collector = new Collector("test", Arrays.asList(new Counter("http", null), new Counter("sql", null))); JRobin.initBackendFactory(new Timer(getClass().getSimpleName(), true)); assertNotNull("SessionListener", new SessionListener()); TestDatabaseInformations.initJdbcDriverParameters(); collector.collectWithoutErrors(Arrays.asList(new JavaInformations(null, true))); final String serverUrl = "http: final UpdateChecker updateCheckerCollectorServer = UpdateChecker.createForTest(null, UpdateChecker.COLLECTOR_SERVER_APPLICATION_TYPE, serverUrl); try { updateCheckerCollectorServer.checkForUpdate(); } catch (final UnknownHostException e) { assertNotNull("updateCheckerCollectorServer", updateCheckerCollectorServer); } Utils.setProperty(Parameter.NO_DATABASE, "true"); Utils.setProperty(Parameter.LOG, "true"); if (CacheManager.getInstance().getCache("test") == null) { CacheManager.getInstance().addCache("test"); } final UpdateChecker updateChecker = UpdateChecker.createForTest(collector, "Classic", serverUrl); try { updateChecker.checkForUpdate(); } catch (final UnknownHostException e) { assertNotNull("updateChecker", updateChecker); } CacheManager.getInstance().removeCache("test"); }
void checkForUpdate() throws IOException { final String anonymousData = getAnonymousData(); final HttpURLConnection connection = (HttpURLConnection) new URL(serverUrl) .openConnection(); connection.setUseCaches(false); connection.setDoOutput(true); connection.setRequestMethod("POST"); connection.setConnectTimeout(60000); connection.setReadTimeout(60000); connection.setRequestProperty("data", anonymousData); connection.connect(); final Properties properties = new Properties(); final InputStream input = connection.getInputStream(); try { properties.load(input); } finally { input.close(); } final String javamelodyVersion = properties.getProperty("version"); if (javamelodyVersion != null && Parameters.JAVAMELODY_VERSION != null && javamelodyVersion.compareTo(Parameters.JAVAMELODY_VERSION) > 0) { setNewJavamelodyVersion(javamelodyVersion); } }
UpdateChecker { void checkForUpdate() throws IOException { final String anonymousData = getAnonymousData(); final HttpURLConnection connection = (HttpURLConnection) new URL(serverUrl) .openConnection(); connection.setUseCaches(false); connection.setDoOutput(true); connection.setRequestMethod("POST"); connection.setConnectTimeout(60000); connection.setReadTimeout(60000); connection.setRequestProperty("data", anonymousData); connection.connect(); final Properties properties = new Properties(); final InputStream input = connection.getInputStream(); try { properties.load(input); } finally { input.close(); } final String javamelodyVersion = properties.getProperty("version"); if (javamelodyVersion != null && Parameters.JAVAMELODY_VERSION != null && javamelodyVersion.compareTo(Parameters.JAVAMELODY_VERSION) > 0) { setNewJavamelodyVersion(javamelodyVersion); } } }
UpdateChecker { void checkForUpdate() throws IOException { final String anonymousData = getAnonymousData(); final HttpURLConnection connection = (HttpURLConnection) new URL(serverUrl) .openConnection(); connection.setUseCaches(false); connection.setDoOutput(true); connection.setRequestMethod("POST"); connection.setConnectTimeout(60000); connection.setReadTimeout(60000); connection.setRequestProperty("data", anonymousData); connection.connect(); final Properties properties = new Properties(); final InputStream input = connection.getInputStream(); try { properties.load(input); } finally { input.close(); } final String javamelodyVersion = properties.getProperty("version"); if (javamelodyVersion != null && Parameters.JAVAMELODY_VERSION != null && javamelodyVersion.compareTo(Parameters.JAVAMELODY_VERSION) > 0) { setNewJavamelodyVersion(javamelodyVersion); } } private  UpdateChecker(final Collector collector, final String applicationType,
			final String serverUrl); }
UpdateChecker { void checkForUpdate() throws IOException { final String anonymousData = getAnonymousData(); final HttpURLConnection connection = (HttpURLConnection) new URL(serverUrl) .openConnection(); connection.setUseCaches(false); connection.setDoOutput(true); connection.setRequestMethod("POST"); connection.setConnectTimeout(60000); connection.setReadTimeout(60000); connection.setRequestProperty("data", anonymousData); connection.connect(); final Properties properties = new Properties(); final InputStream input = connection.getInputStream(); try { properties.load(input); } finally { input.close(); } final String javamelodyVersion = properties.getProperty("version"); if (javamelodyVersion != null && Parameters.JAVAMELODY_VERSION != null && javamelodyVersion.compareTo(Parameters.JAVAMELODY_VERSION) > 0) { setNewJavamelodyVersion(javamelodyVersion); } } private  UpdateChecker(final Collector collector, final String applicationType,
			final String serverUrl); static void init(Timer timer, Collector collector, String applicationType); static String getNewJavamelodyVersion(); }
UpdateChecker { void checkForUpdate() throws IOException { final String anonymousData = getAnonymousData(); final HttpURLConnection connection = (HttpURLConnection) new URL(serverUrl) .openConnection(); connection.setUseCaches(false); connection.setDoOutput(true); connection.setRequestMethod("POST"); connection.setConnectTimeout(60000); connection.setReadTimeout(60000); connection.setRequestProperty("data", anonymousData); connection.connect(); final Properties properties = new Properties(); final InputStream input = connection.getInputStream(); try { properties.load(input); } finally { input.close(); } final String javamelodyVersion = properties.getProperty("version"); if (javamelodyVersion != null && Parameters.JAVAMELODY_VERSION != null && javamelodyVersion.compareTo(Parameters.JAVAMELODY_VERSION) > 0) { setNewJavamelodyVersion(javamelodyVersion); } } private  UpdateChecker(final Collector collector, final String applicationType,
			final String serverUrl); static void init(Timer timer, Collector collector, String applicationType); static String getNewJavamelodyVersion();  }