Tuesday, 15 July 2014

java - Is 234324.32423.234234.324234 a valid InetAddress? -


Is there a way that InetAddress.getByName (234324.32423.234234.324234) will return a non-empty address value? It seems that does this.

Since this is in a unit test, I have to force InetAddress to throw only one exception. Is there any reason why using the powermok will not do the following silent work? Before signature of my class, I have Annotation @ Runavath (PowerMonkar.class) and @PaperReports ({InetAddress.class})

  string testIp = "127.0.0.1"; PowerMockito.mockStatic (InetAddress.class); PowerMockito.when (InetAddress.getByName (testIp)) .thenThrow (unknownhost.example.class); MyClass someClassThatCallsInetAddressGetByName = New MyClass (32); SomeClassThatCallsInetAddressGetByName.setHostAddress (testIp); SomeClassThatCallsInetAddressGetByName.getHostAddress ();  

what 234324.32423 .234234.324234 is a valid InetAddress?

No

This is not a valid IPv4 address because the numbers of 4-part IPv4 address are decimal numbers in the range of 0 to 255.

This will not parse as an IPv6 address because components of an IPv6 address are separated by colons instead of dots. (Alternate IPv6 formats have colons and dots ... but at least one colon is always present.)


  • < Blockquote>

    In my local environment, this gives space. But when I went to the cloud, it is returning a valid address.

    It should always return null This is not a valid IP address string ... According to Jawadox. (What does "Migrate to the cloud" mean? Are you translating code into another language?)

    Is it possible? Is InetAddress platform dependent?

    It should not be, and not 1 .

    Check the categories of component numbers for the record doing IPv4 address parsing in OpenJDK.


    1 - Not for any recent version of Java, which is in conformity with the implementation of a non-compliance, but then it is Java (TM) Will not done.


    No comments:

    Post a Comment