Verified Commit a65bda04 authored by akwizgran's avatar akwizgran
Browse files

Use more realistic LAN addresses for test contacts.

parent ed2c0336
...@@ -113,6 +113,7 @@ public class TestDataCreatorImpl implements TestDataCreator { ...@@ -113,6 +113,7 @@ public class TestDataCreatorImpl implements TestDataCreator {
this.ioExecutor = ioExecutor; this.ioExecutor = ioExecutor;
} }
@Override
public void createTestData(int numContacts, int numPrivateMsgs, public void createTestData(int numContacts, int numPrivateMsgs,
int numBlogPosts, int numForums, int numForumPosts) { int numBlogPosts, int numForums, int numForumPosts) {
if (numContacts == 0) if (numContacts == 0)
...@@ -216,8 +217,12 @@ public class TestDataCreatorImpl implements TestDataCreator { ...@@ -216,8 +217,12 @@ public class TestDataCreatorImpl implements TestDataCreator {
// LAN // LAN
TransportProperties lan = new TransportProperties(); TransportProperties lan = new TransportProperties();
String lanAddress = getRandomLanAddress(); StringBuilder sb = new StringBuilder();
lan.put(LanTcpConstants.PROP_IP_PORTS, lanAddress); for (int i = 0; i < 4; i++) {
if (sb.length() > 0) sb.append(',');
sb.append(getRandomLanAddress());
}
lan.put(LanTcpConstants.PROP_IP_PORTS, sb.toString());
props.put(LanTcpConstants.ID, lan); props.put(LanTcpConstants.ID, lan);
// Tor // Tor
...@@ -250,8 +255,14 @@ public class TestDataCreatorImpl implements TestDataCreator { ...@@ -250,8 +255,14 @@ public class TestDataCreatorImpl implements TestDataCreator {
private String getRandomLanAddress() { private String getRandomLanAddress() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
// address // address
for (int i = 0; i < 4; i++) { if (random.nextInt(5) == 0) {
if (sb.length() > 0) sb.append("."); sb.append("10.");
sb.append(random.nextInt(2)).append('.');
sb.append(random.nextInt(2)).append('.');
sb.append(random.nextInt(256));
} else {
sb.append("192.168.");
sb.append(random.nextInt(2)).append('.');
sb.append(random.nextInt(256)); sb.append(random.nextInt(256));
} }
// port // port
...@@ -264,7 +275,7 @@ public class TestDataCreatorImpl implements TestDataCreator { ...@@ -264,7 +275,7 @@ public class TestDataCreatorImpl implements TestDataCreator {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
// address // address
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
if (random.nextBoolean()) sb.append(2 + random.nextInt(5)); if (random.nextBoolean()) sb.append(2 + random.nextInt(6));
else sb.append((char) (random.nextInt(26) + 'a')); else sb.append((char) (random.nextInt(26) + 'a'));
} }
return sb.toString(); return sb.toString();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment