Skip to content

Commit

Permalink
7.3.6
Browse files Browse the repository at this point in the history
- Fixed google ping (again)
  • Loading branch information
Osiris-Team committed Sep 7, 2023
1 parent 1d83d1c commit c3b2b58
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<version>5.9.2</version>
<scope>test</scope>
</dependency>

Expand Down
12 changes: 10 additions & 2 deletions src/main/java/com/osiris/autoplug/client/SystemChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import com.osiris.jlib.logger.AL;

import java.io.*;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.URL;

public class SystemChecker {

Expand Down Expand Up @@ -45,8 +47,14 @@ public void checkInternetAccess() throws Exception {
boolean reachable = InetAddress.getByName("www.google.com").isReachable(10000);
if (!reachable) throw new Exception("Failed to reach www.google.com!");
} catch (Exception e) {
System.err.println("Make sure that you have an internet connection!");
throw e;
try {
HttpURLConnection connection = (HttpURLConnection) new URL("https://www.google.com").openConnection();
connection.connect();
connection.disconnect();
} catch (Exception ex) {
System.err.println("Make sure that you have an internet connection!");
throw ex;
}
}
}

Expand Down
31 changes: 31 additions & 0 deletions src/test/java/com/osiris/autoplug/client/SystemCheckerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2023 Osiris-Team.
* All rights reserved.
*
* This software is copyrighted work, licensed under the terms
* of the MIT-License. Consult the "LICENSE" file for details.
*/

package com.osiris.autoplug.client;

import org.junit.jupiter.api.Test;

import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.URL;

class SystemCheckerTest {

@Test
void checkInternetAccessMethod1() throws Exception {
boolean reachable = InetAddress.getByName("www.google.com").isReachable(10000);
if (!reachable) throw new Exception("Failed to reach www.google.com!");
}

@Test
void checkInternetAccessMethod2() throws Exception {
HttpURLConnection connection = (HttpURLConnection) new URL("https://www.google.com").openConnection();
connection.connect();
connection.disconnect();
}
}

0 comments on commit c3b2b58

Please sign in to comment.