简体   繁体   English

如何在Java中设置IP地址

[英]How to set ip address in java

I want to disable the network for testing like this solution in c#: How to simulate network failure for test purposes (in C#)? 我想禁用网络以像c#中的此解决方案那样进行测试: 如何出于测试目的模拟网络故障(在C#中)? It suggests setting the ip to a bogus static address. 建议将ip设置为伪静态地址。 How can I set the ip from Java or Groovy? 如何从Java或Groovy设置IP?

This solution is for windows . 此解决方案适用于Windows I'm using Mac. 我正在使用Mac。

How about setting a proxy for the JVM that drops all the requests ? 如何为丢弃所有请求的JVM设置代理?

You wouldn't have to change your system configuration, proxy handling could be done via fixtures if you want some advanced properties. 您无需更改系统配置,如果需要一些高级属性,可以通过固定装置完成代理处理。

That seems to me a way to explore 在我看来,这是一种探索的方式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM