DocumentSharingSiteApplication
+ * @author luojiarui **/ @EnableAsync(proxyTargetClass=true) @ServletComponentScan(basePackages = "com.jiaruiblog.filter") @SpringBootApplication -public class DocumentSharingSiteApplication { +public class AllDocsApplication { public static void main(String[] args) { - SpringApplication.run(DocumentSharingSiteApplication.class, args); + SpringApplication.run(AllDocsApplication.class, args); } } \ No newline at end of file diff --git a/src/main/java/com/jiaruiblog/util/network/InternetConnectionChecker.java b/src/main/java/com/jiaruiblog/util/network/InternetConnectionChecker.java new file mode 100644 index 0000000..bba27dc --- /dev/null +++ b/src/main/java/com/jiaruiblog/util/network/InternetConnectionChecker.java @@ -0,0 +1,24 @@ +package com.jiaruiblog.util.network; + +import java.net.InetAddress; + +public class InternetConnectionChecker { + public static boolean isInternetAvailable() { + try { + // 尝试解析 Google 的域名 + InetAddress address = InetAddress.getByName("github.com"); + // 如果能返回地址,说明可以连接到互联网 + return address.isReachable(2000); // 超时设置为 2 秒 + } catch (Exception e) { + return false; // 出现异常说明无法连接互联网 + } + } + + public static void main(String[] args) { + if (isInternetAvailable()) { + System.out.println("Can connect to the Internet."); + } else { + System.out.println("Cannot connect to the Internet."); + } + } +} diff --git a/src/test/java/com/jiaruiblog/controller/DocReviewControllerTest.java b/src/test/java/com/jiaruiblog/controller/DocReviewControllerTest.java index 6e7636c..2af4fd0 100644 --- a/src/test/java/com/jiaruiblog/controller/DocReviewControllerTest.java +++ b/src/test/java/com/jiaruiblog/controller/DocReviewControllerTest.java @@ -2,7 +2,7 @@ import com.alibaba.fastjson.JSON; import com.google.common.collect.Lists; -import com.jiaruiblog.DocumentSharingSiteApplication; +import com.jiaruiblog.AllDocsApplication; import com.jiaruiblog.common.MessageConstant; import com.jiaruiblog.entity.dto.RefuseBatchDTO; import com.jiaruiblog.entity.dto.RefuseDTO; @@ -30,7 +30,7 @@ import java.util.Map; @RunWith(SpringRunner.class) -@SpringBootTest(classes = DocumentSharingSiteApplication.class) +@SpringBootTest(classes = AllDocsApplication.class) public class DocReviewControllerTest { private MockMvc mockMvc; diff --git a/src/test/java/com/jiaruiblog/controller/DocumentControllerTest.java b/src/test/java/com/jiaruiblog/controller/DocumentControllerTest.java index e37332b..9d91b7f 100644 --- a/src/test/java/com/jiaruiblog/controller/DocumentControllerTest.java +++ b/src/test/java/com/jiaruiblog/controller/DocumentControllerTest.java @@ -1,6 +1,6 @@ package com.jiaruiblog.controller; -import com.jiaruiblog.DocumentSharingSiteApplication; +import com.jiaruiblog.AllDocsApplication; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -24,7 +24,7 @@ //测试环境使用,用来表示测试环境使用的ApplicationContext将是WebApplicationContext类型的 @WebAppConfiguration @PropertySource(value = "classpath:application.xproperties") -@SpringBootTest(classes = {DocumentSharingSiteApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.NONE) +@SpringBootTest(classes = {AllDocsApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.NONE) public class DocumentControllerTest { private MockMvc mockMvc; diff --git a/src/test/java/com/jiaruiblog/controller/SystemConfigControllerTest.java b/src/test/java/com/jiaruiblog/controller/SystemConfigControllerTest.java index cf76d7b..d0ab32e 100644 --- a/src/test/java/com/jiaruiblog/controller/SystemConfigControllerTest.java +++ b/src/test/java/com/jiaruiblog/controller/SystemConfigControllerTest.java @@ -1,7 +1,7 @@ package com.jiaruiblog.controller; import com.alibaba.fastjson.JSON; -import com.jiaruiblog.DocumentSharingSiteApplication; +import com.jiaruiblog.AllDocsApplication; import com.jiaruiblog.common.MessageConstant; import com.jiaruiblog.config.SystemConfig; import org.junit.After; @@ -24,7 +24,7 @@ import java.nio.charset.Charset; @RunWith(SpringRunner.class) -@SpringBootTest(classes = DocumentSharingSiteApplication.class) +@SpringBootTest(classes = AllDocsApplication.class) public class SystemConfigControllerTest { private MockMvc mockMvc; diff --git a/src/test/java/com/jiaruiblog/controller/UserControllerTest.java b/src/test/java/com/jiaruiblog/controller/UserControllerTest.java index 5138f0f..a27b6b2 100644 --- a/src/test/java/com/jiaruiblog/controller/UserControllerTest.java +++ b/src/test/java/com/jiaruiblog/controller/UserControllerTest.java @@ -2,7 +2,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.jiaruiblog.DocumentSharingSiteApplication; +import com.jiaruiblog.AllDocsApplication; import com.jiaruiblog.common.MessageConstant; import com.jiaruiblog.entity.dto.RegistryUserDTO; import com.jiaruiblog.entity.dto.UserDTO; @@ -29,7 +29,7 @@ import java.util.Date; @RunWith(SpringRunner.class) -@SpringBootTest(classes = DocumentSharingSiteApplication.class) +@SpringBootTest(classes = AllDocsApplication.class) public class UserControllerTest { private MockMvc mockMvc; diff --git a/src/test/java/com/jiaruiblog/service/CategoryServiceTest.java b/src/test/java/com/jiaruiblog/service/CategoryServiceTest.java index 96b2629..6c2710d 100644 --- a/src/test/java/com/jiaruiblog/service/CategoryServiceTest.java +++ b/src/test/java/com/jiaruiblog/service/CategoryServiceTest.java @@ -2,7 +2,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.jiaruiblog.DocumentSharingSiteApplication; +import com.jiaruiblog.AllDocsApplication; import com.jiaruiblog.service.impl.CategoryServiceImpl; import org.junit.Assert; import org.junit.Test; @@ -14,7 +14,7 @@ @RunWith(SpringRunner.class) -@SpringBootTest(classes = DocumentSharingSiteApplication.class) +@SpringBootTest(classes = AllDocsApplication.class) public class CategoryServiceTest { @Resource diff --git a/src/test/java/com/jiaruiblog/service/impl/CommentServiceImplTest.java b/src/test/java/com/jiaruiblog/service/impl/CommentServiceImplTest.java index 40feb92..e86ee40 100644 --- a/src/test/java/com/jiaruiblog/service/impl/CommentServiceImplTest.java +++ b/src/test/java/com/jiaruiblog/service/impl/CommentServiceImplTest.java @@ -1,7 +1,7 @@ package com.jiaruiblog.service.impl; import com.alibaba.fastjson.JSON; -import com.jiaruiblog.DocumentSharingSiteApplication; +import com.jiaruiblog.AllDocsApplication; import com.jiaruiblog.entity.dto.BasePageDTO; import org.junit.Test; import org.junit.runner.RunWith; @@ -10,7 +10,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) -@SpringBootTest(classes = DocumentSharingSiteApplication.class) +@SpringBootTest(classes = AllDocsApplication.class) public class CommentServiceImplTest { @Autowired diff --git a/src/test/java/com/jiaruiblog/service/impl/FileServiceImplTest.java b/src/test/java/com/jiaruiblog/service/impl/FileServiceImplTest.java index f50dd6e..e0814fc 100644 --- a/src/test/java/com/jiaruiblog/service/impl/FileServiceImplTest.java +++ b/src/test/java/com/jiaruiblog/service/impl/FileServiceImplTest.java @@ -2,7 +2,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.jiaruiblog.DocumentSharingSiteApplication; +import com.jiaruiblog.AllDocsApplication; import com.jiaruiblog.entity.FileDocument; import com.jiaruiblog.entity.dto.DocumentDTO; import com.jiaruiblog.enums.FilterTypeEnum; @@ -20,7 +20,7 @@ @RunWith(SpringRunner.class) -@SpringBootTest(classes = DocumentSharingSiteApplication.class) +@SpringBootTest(classes = AllDocsApplication.class) public class FileServiceImplTest { @Before diff --git a/src/test/java/com/jiaruiblog/service/impl/LikeServiceImplTest.java b/src/test/java/com/jiaruiblog/service/impl/LikeServiceImplTest.java index d3ff18d..d248b1b 100644 --- a/src/test/java/com/jiaruiblog/service/impl/LikeServiceImplTest.java +++ b/src/test/java/com/jiaruiblog/service/impl/LikeServiceImplTest.java @@ -1,6 +1,6 @@ package com.jiaruiblog.service.impl; -import com.jiaruiblog.DocumentSharingSiteApplication; +import com.jiaruiblog.AllDocsApplication; import com.jiaruiblog.service.LikeService; import com.jiaruiblog.task.like.UserLikeDetail; import org.apache.commons.lang3.RandomStringUtils; @@ -14,7 +14,7 @@ @RunWith(SpringRunner.class) -@SpringBootTest(classes = DocumentSharingSiteApplication.class) +@SpringBootTest(classes = AllDocsApplication.class) public class LikeServiceImplTest { @Resource diff --git a/src/test/java/com/jiaruiblog/service/impl/StatisticsServiceImplTest.java b/src/test/java/com/jiaruiblog/service/impl/StatisticsServiceImplTest.java index a07d8ab..a5e8fe2 100644 --- a/src/test/java/com/jiaruiblog/service/impl/StatisticsServiceImplTest.java +++ b/src/test/java/com/jiaruiblog/service/impl/StatisticsServiceImplTest.java @@ -2,7 +2,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.jiaruiblog.DocumentSharingSiteApplication; +import com.jiaruiblog.AllDocsApplication; import com.jiaruiblog.service.StatisticsService; import org.junit.Assert; import org.junit.Test; @@ -13,7 +13,7 @@ import javax.annotation.Resource; @RunWith(SpringRunner.class) -@SpringBootTest(classes = DocumentSharingSiteApplication.class) +@SpringBootTest(classes = AllDocsApplication.class) public class StatisticsServiceImplTest { @Resource diff --git a/src/test/java/com/jiaruiblog/service/impl/TagServiceImplTest.java b/src/test/java/com/jiaruiblog/service/impl/TagServiceImplTest.java index 996dcb8..ee6a81c 100644 --- a/src/test/java/com/jiaruiblog/service/impl/TagServiceImplTest.java +++ b/src/test/java/com/jiaruiblog/service/impl/TagServiceImplTest.java @@ -2,7 +2,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.jiaruiblog.DocumentSharingSiteApplication; +import com.jiaruiblog.AllDocsApplication; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -12,7 +12,7 @@ import javax.annotation.Resource; @RunWith(SpringRunner.class) -@SpringBootTest(classes = DocumentSharingSiteApplication.class) +@SpringBootTest(classes = AllDocsApplication.class) public class TagServiceImplTest { @Resource