mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 21:29:54 +01:00
Whitespace-only code formatting changes.
This commit is contained in:
@@ -74,7 +74,7 @@ public class BasicH2Test extends BriarTestCase {
|
||||
String[] oldNames = new String[BATCH_SIZE];
|
||||
String[] newNames = new String[BATCH_SIZE];
|
||||
Random random = new Random();
|
||||
for(int i = 0; i < BATCH_SIZE; i++) {
|
||||
for (int i = 0; i < BATCH_SIZE; i++) {
|
||||
random.nextBytes(ids[i]);
|
||||
oldNames[i] = TestUtils.createRandomString(50);
|
||||
newNames[i] = TestUtils.createRandomString(50);
|
||||
@@ -84,20 +84,20 @@ public class BasicH2Test extends BriarTestCase {
|
||||
// Update the names as a batch
|
||||
updateBatch(ids, newNames);
|
||||
// Check that the new names can be retrieved using the IDs
|
||||
for(int i = 0; i < BATCH_SIZE; i++) {
|
||||
for (int i = 0; i < BATCH_SIZE; i++) {
|
||||
assertTrue(rowExists(ids[i]));
|
||||
assertEquals(newNames[i], getName(ids[i]));
|
||||
}
|
||||
// Delete the rows as a batch
|
||||
boolean[] deleted = deleteBatch(ids);
|
||||
// Check that the rows no longer exist
|
||||
for(int i = 0; i < BATCH_SIZE; i++) {
|
||||
for (int i = 0; i < BATCH_SIZE; i++) {
|
||||
assertTrue(deleted[i]);
|
||||
assertFalse(rowExists(ids[i]));
|
||||
}
|
||||
// Deleting the rows again should have no effect
|
||||
deleted = deleteBatch(ids);
|
||||
for(int i = 0; i < BATCH_SIZE; i++) assertFalse(deleted[i]);
|
||||
for (int i = 0; i < BATCH_SIZE; i++) assertFalse(deleted[i]);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -146,7 +146,7 @@ public class BasicH2Test extends BriarTestCase {
|
||||
Statement s = connection.createStatement();
|
||||
s.executeUpdate(CREATE_TABLE);
|
||||
s.close();
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
connection.close();
|
||||
throw e;
|
||||
}
|
||||
@@ -156,13 +156,13 @@ public class BasicH2Test extends BriarTestCase {
|
||||
String sql = "INSERT INTO foo (uniqueId, name) VALUES (?, ?)";
|
||||
try {
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
if(id == null) ps.setNull(1, BINARY);
|
||||
if (id == null) ps.setNull(1, BINARY);
|
||||
else ps.setBytes(1, id);
|
||||
ps.setString(2, name);
|
||||
int affected = ps.executeUpdate();
|
||||
assertEquals(1, affected);
|
||||
ps.close();
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
connection.close();
|
||||
throw e;
|
||||
}
|
||||
@@ -180,7 +180,7 @@ public class BasicH2Test extends BriarTestCase {
|
||||
rs.close();
|
||||
ps.close();
|
||||
return found;
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
connection.close();
|
||||
throw e;
|
||||
}
|
||||
@@ -199,7 +199,7 @@ public class BasicH2Test extends BriarTestCase {
|
||||
rs.close();
|
||||
ps.close();
|
||||
return name;
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
connection.close();
|
||||
throw e;
|
||||
}
|
||||
@@ -209,12 +209,12 @@ public class BasicH2Test extends BriarTestCase {
|
||||
String sql = "UPDATE foo SET name = ? WHERE uniqueId = ?";
|
||||
try {
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
if(id == null) ps.setNull(2, BINARY);
|
||||
if (id == null) ps.setNull(2, BINARY);
|
||||
else ps.setBytes(2, id);
|
||||
ps.setString(1, name);
|
||||
assertEquals(1, ps.executeUpdate());
|
||||
ps.close();
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
connection.close();
|
||||
throw e;
|
||||
}
|
||||
@@ -224,12 +224,12 @@ public class BasicH2Test extends BriarTestCase {
|
||||
String sql = "DELETE FROM foo WHERE uniqueId = ?";
|
||||
try {
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
if(id == null) ps.setNull(1, BINARY);
|
||||
if (id == null) ps.setNull(1, BINARY);
|
||||
else ps.setBytes(1, id);
|
||||
int affected = ps.executeUpdate();
|
||||
ps.close();
|
||||
return affected == 1;
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
connection.close();
|
||||
throw e;
|
||||
}
|
||||
@@ -240,19 +240,19 @@ public class BasicH2Test extends BriarTestCase {
|
||||
String sql = "INSERT INTO foo (uniqueId, name) VALUES (?, ?)";
|
||||
try {
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
for(int i = 0; i < ids.length; i++) {
|
||||
if(ids[i] == null) ps.setNull(1, BINARY);
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
if (ids[i] == null) ps.setNull(1, BINARY);
|
||||
else ps.setBytes(1, ids[i]);
|
||||
ps.setString(2, names[i]);
|
||||
ps.addBatch();
|
||||
}
|
||||
int[] batchAffected = ps.executeBatch();
|
||||
assertEquals(ids.length, batchAffected.length);
|
||||
for(int i = 0; i < batchAffected.length; i++) {
|
||||
for (int i = 0; i < batchAffected.length; i++) {
|
||||
assertEquals(1, batchAffected[i]);
|
||||
}
|
||||
ps.close();
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
connection.close();
|
||||
throw e;
|
||||
}
|
||||
@@ -263,18 +263,18 @@ public class BasicH2Test extends BriarTestCase {
|
||||
String sql = "UPDATE foo SET name = ? WHERE uniqueId = ?";
|
||||
try {
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
for(int i = 0; i < ids.length; i++) {
|
||||
if(ids[i] == null) ps.setNull(2, BINARY);
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
if (ids[i] == null) ps.setNull(2, BINARY);
|
||||
else ps.setBytes(2, ids[i]);
|
||||
ps.setString(1, names[i]);
|
||||
ps.addBatch();
|
||||
}
|
||||
int[] batchAffected = ps.executeBatch();
|
||||
assertEquals(ids.length, batchAffected.length);
|
||||
for(int i = 0; i < batchAffected.length; i++)
|
||||
for (int i = 0; i < batchAffected.length; i++)
|
||||
assertEquals(1, batchAffected[i]);
|
||||
ps.close();
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
connection.close();
|
||||
throw e;
|
||||
}
|
||||
@@ -284,19 +284,19 @@ public class BasicH2Test extends BriarTestCase {
|
||||
String sql = "DELETE FROM foo WHERE uniqueId = ?";
|
||||
try {
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
for(int i = 0; i < ids.length; i++) {
|
||||
if(ids[i] == null) ps.setNull(1, BINARY);
|
||||
for (int i = 0; i < ids.length; i++) {
|
||||
if (ids[i] == null) ps.setNull(1, BINARY);
|
||||
else ps.setBytes(1, ids[i]);
|
||||
ps.addBatch();
|
||||
}
|
||||
int[] batchAffected = ps.executeBatch();
|
||||
assertEquals(ids.length, batchAffected.length);
|
||||
boolean[] ret = new boolean[ids.length];
|
||||
for(int i = 0; i < batchAffected.length; i++)
|
||||
for (int i = 0; i < batchAffected.length; i++)
|
||||
ret[i] = batchAffected[i] == 1;
|
||||
ps.close();
|
||||
return ret;
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
connection.close();
|
||||
throw e;
|
||||
}
|
||||
@@ -315,7 +315,7 @@ public class BasicH2Test extends BriarTestCase {
|
||||
rs.close();
|
||||
ps.close();
|
||||
return name;
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
connection.close();
|
||||
throw e;
|
||||
}
|
||||
@@ -327,11 +327,11 @@ public class BasicH2Test extends BriarTestCase {
|
||||
try {
|
||||
PreparedStatement ps = connection.prepareStatement(sql);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while(rs.next()) names.add(rs.getString(1));
|
||||
while (rs.next()) names.add(rs.getString(1));
|
||||
rs.close();
|
||||
ps.close();
|
||||
return names;
|
||||
} catch(SQLException e) {
|
||||
} catch (SQLException e) {
|
||||
connection.close();
|
||||
throw e;
|
||||
}
|
||||
@@ -339,7 +339,7 @@ public class BasicH2Test extends BriarTestCase {
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
if(connection != null) connection.close();
|
||||
if (connection != null) connection.close();
|
||||
TestUtils.deleteTestDirectory(testDir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class DatabaseCleanerImplTest extends BriarTestCase {
|
||||
// Start the cleaner - it should schedule itself with the timer
|
||||
cleaner.startCleaning(callback, 10);
|
||||
// Call the cleaner's run method six times
|
||||
for(int i = 0; i < 6; i++) cleaner.run();
|
||||
for (int i = 0; i < 6; i++) cleaner.run();
|
||||
// Stop the cleaner - it should cancel the timer
|
||||
cleaner.stopCleaning();
|
||||
// The database should have been cleaned three times
|
||||
|
||||
@@ -332,137 +332,137 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
|
||||
try {
|
||||
db.addEndpoint(endpoint);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
db.generateAck(contactId, 123);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
db.generateBatch(contactId, 123, 456);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
db.generateOffer(contactId, 123, 456);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
db.generateRetentionAck(contactId);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
db.generateRetentionUpdate(contactId, 123);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
db.generateSubscriptionAck(contactId);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
db.generateSubscriptionUpdate(contactId, 123);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
db.generateTransportAcks(contactId);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
db.generateTransportUpdates(contactId, 123);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
db.getContact(contactId);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
db.getInboxGroupId(contactId);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
db.incrementStreamCounter(contactId, transportId, 0);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
Ack a = new Ack(Arrays.asList(messageId));
|
||||
db.receiveAck(contactId, a);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
db.receiveMessage(contactId, message);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
Offer o = new Offer(Arrays.asList(messageId));
|
||||
db.receiveOffer(contactId, o);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
RetentionAck a = new RetentionAck(0);
|
||||
db.receiveRetentionAck(contactId, a);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
RetentionUpdate u = new RetentionUpdate(0, 1);
|
||||
db.receiveRetentionUpdate(contactId, u);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
SubscriptionAck a = new SubscriptionAck(0);
|
||||
db.receiveSubscriptionAck(contactId, a);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
SubscriptionUpdate u = new SubscriptionUpdate(
|
||||
Collections.<Group>emptyList(), 1);
|
||||
db.receiveSubscriptionUpdate(contactId, u);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
TransportAck a = new TransportAck(transportId, 0);
|
||||
db.receiveTransportAck(contactId, a);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
TransportUpdate u = new TransportUpdate(transportId,
|
||||
transportProperties, 1);
|
||||
db.receiveTransportUpdate(contactId, u);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
db.removeContact(contactId);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
db.setReorderingWindow(contactId, transportId, 0, 0, new byte[4]);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
try {
|
||||
db.setInboxGroup(contactId, group);
|
||||
fail();
|
||||
} catch(NoSuchContactException expected) {}
|
||||
} catch (NoSuchContactException expected) {}
|
||||
|
||||
context.assertIsSatisfied();
|
||||
}
|
||||
@@ -493,17 +493,17 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
|
||||
try {
|
||||
db.addContact(author, localAuthorId);
|
||||
fail();
|
||||
} catch(NoSuchLocalAuthorException expected) {}
|
||||
} catch (NoSuchLocalAuthorException expected) {}
|
||||
|
||||
try {
|
||||
db.getLocalAuthor(localAuthorId);
|
||||
fail();
|
||||
} catch(NoSuchLocalAuthorException expected) {}
|
||||
} catch (NoSuchLocalAuthorException expected) {}
|
||||
|
||||
try {
|
||||
db.removeLocalAuthor(localAuthorId);
|
||||
fail();
|
||||
} catch(NoSuchLocalAuthorException expected) {}
|
||||
} catch (NoSuchLocalAuthorException expected) {}
|
||||
|
||||
context.assertIsSatisfied();
|
||||
}
|
||||
@@ -531,27 +531,27 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
|
||||
try {
|
||||
db.getGroup(groupId);
|
||||
fail();
|
||||
} catch(NoSuchSubscriptionException expected) {}
|
||||
} catch (NoSuchSubscriptionException expected) {}
|
||||
|
||||
try {
|
||||
db.getMessageHeaders(groupId);
|
||||
fail();
|
||||
} catch(NoSuchSubscriptionException expected) {}
|
||||
} catch (NoSuchSubscriptionException expected) {}
|
||||
|
||||
try {
|
||||
db.getVisibility(groupId);
|
||||
fail();
|
||||
} catch(NoSuchSubscriptionException expected) {}
|
||||
} catch (NoSuchSubscriptionException expected) {}
|
||||
|
||||
try {
|
||||
db.removeGroup(group);
|
||||
fail();
|
||||
} catch(NoSuchSubscriptionException expected) {}
|
||||
} catch (NoSuchSubscriptionException expected) {}
|
||||
|
||||
try {
|
||||
db.setVisibility(groupId, Collections.<ContactId>emptyList());
|
||||
fail();
|
||||
} catch(NoSuchSubscriptionException expected) {}
|
||||
} catch (NoSuchSubscriptionException expected) {}
|
||||
|
||||
context.assertIsSatisfied();
|
||||
}
|
||||
@@ -603,42 +603,42 @@ public abstract class DatabaseComponentTest extends BriarTestCase {
|
||||
try {
|
||||
db.addEndpoint(endpoint);
|
||||
fail();
|
||||
} catch(NoSuchTransportException expected) {}
|
||||
} catch (NoSuchTransportException expected) {}
|
||||
|
||||
try {
|
||||
db.getConfig(transportId);
|
||||
fail();
|
||||
} catch(NoSuchTransportException expected) {}
|
||||
} catch (NoSuchTransportException expected) {}
|
||||
|
||||
try {
|
||||
db.getLocalProperties(transportId);
|
||||
fail();
|
||||
} catch(NoSuchTransportException expected) {}
|
||||
} catch (NoSuchTransportException expected) {}
|
||||
|
||||
try {
|
||||
db.mergeConfig(transportId, new TransportConfig());
|
||||
fail();
|
||||
} catch(NoSuchTransportException expected) {}
|
||||
} catch (NoSuchTransportException expected) {}
|
||||
|
||||
try {
|
||||
db.mergeLocalProperties(transportId, new TransportProperties());
|
||||
fail();
|
||||
} catch(NoSuchTransportException expected) {}
|
||||
} catch (NoSuchTransportException expected) {}
|
||||
|
||||
try {
|
||||
db.incrementStreamCounter(contactId, transportId, 0);
|
||||
fail();
|
||||
} catch(NoSuchTransportException expected) {}
|
||||
} catch (NoSuchTransportException expected) {}
|
||||
|
||||
try {
|
||||
db.removeTransport(transportId);
|
||||
fail();
|
||||
} catch(NoSuchTransportException expected) {}
|
||||
} catch (NoSuchTransportException expected) {}
|
||||
|
||||
try {
|
||||
db.setReorderingWindow(contactId, transportId, 0, 0, new byte[4]);
|
||||
fail();
|
||||
} catch(NoSuchTransportException expected) {}
|
||||
} catch (NoSuchTransportException expected) {}
|
||||
|
||||
context.assertIsSatisfied();
|
||||
}
|
||||
|
||||
@@ -418,7 +418,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
|
||||
// Allowing enough capacity for both messages should return both
|
||||
Collection<MessageId> ids = new HashSet<MessageId>();
|
||||
for(MessageId id : db.getOldMessages(txn, size * 2)) ids.add(id);
|
||||
for (MessageId id : db.getOldMessages(txn, size * 2)) ids.add(id);
|
||||
assertEquals(2, ids.size());
|
||||
assertTrue(ids.contains(messageId));
|
||||
assertTrue(ids.contains(messageId1));
|
||||
@@ -430,7 +430,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
@Test
|
||||
public void testGetFreeSpace() throws Exception {
|
||||
byte[] largeBody = new byte[ONE_MEGABYTE];
|
||||
for(int i = 0; i < largeBody.length; i++) largeBody[i] = (byte) i;
|
||||
for (int i = 0; i < largeBody.length; i++) largeBody[i] = (byte) i;
|
||||
Message message = new TestMessage(messageId, null, group, author,
|
||||
contentType, subject, timestamp, largeBody);
|
||||
Database<Connection> db = open(false);
|
||||
@@ -470,9 +470,9 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
try {
|
||||
closing.countDown();
|
||||
db.close();
|
||||
if(!transactionFinished.get()) error.set(true);
|
||||
if (!transactionFinished.get()) error.set(true);
|
||||
closed.countDown();
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
error.set(true);
|
||||
}
|
||||
}
|
||||
@@ -507,9 +507,9 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
try {
|
||||
closing.countDown();
|
||||
db.close();
|
||||
if(!transactionFinished.get()) error.set(true);
|
||||
if (!transactionFinished.get()) error.set(true);
|
||||
closed.countDown();
|
||||
} catch(Exception e) {
|
||||
} catch (Exception e) {
|
||||
error.set(true);
|
||||
}
|
||||
}
|
||||
@@ -903,12 +903,12 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
Collection<MessageHeader> headers = db.getMessageHeaders(txn, groupId);
|
||||
assertEquals(2, headers.size());
|
||||
boolean firstFound = false, secondFound = false;
|
||||
for(MessageHeader header : headers) {
|
||||
if(messageId.equals(header.getId())) {
|
||||
for (MessageHeader header : headers) {
|
||||
if (messageId.equals(header.getId())) {
|
||||
assertHeadersMatch(message, header);
|
||||
assertTrue(header.isRead());
|
||||
firstFound = true;
|
||||
} else if(messageId1.equals(header.getId())) {
|
||||
} else if (messageId1.equals(header.getId())) {
|
||||
assertHeadersMatch(message1, header);
|
||||
assertFalse(header.isRead());
|
||||
secondFound = true;
|
||||
@@ -926,10 +926,10 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
|
||||
private void assertHeadersMatch(Message m, MessageHeader h) {
|
||||
assertEquals(m.getId(), h.getId());
|
||||
if(m.getParent() == null) assertNull(h.getParent());
|
||||
if (m.getParent() == null) assertNull(h.getParent());
|
||||
else assertEquals(m.getParent(), h.getParent());
|
||||
assertEquals(m.getGroup().getId(), h.getGroupId());
|
||||
if(m.getAuthor() == null) assertNull(h.getAuthor());
|
||||
if (m.getAuthor() == null) assertNull(h.getAuthor());
|
||||
else assertEquals(m.getAuthor(), h.getAuthor());
|
||||
assertEquals(m.getContentType(), h.getContentType());
|
||||
assertEquals(m.getTimestamp(), h.getTimestamp());
|
||||
@@ -965,16 +965,16 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
Collection<MessageHeader> headers = db.getMessageHeaders(txn, groupId);
|
||||
assertEquals(3, headers.size());
|
||||
boolean firstFound = false, secondFound = false, thirdFound = false;
|
||||
for(MessageHeader header : headers) {
|
||||
if(messageId.equals(header.getId())) {
|
||||
for (MessageHeader header : headers) {
|
||||
if (messageId.equals(header.getId())) {
|
||||
assertHeadersMatch(message, header);
|
||||
assertEquals(Author.Status.VERIFIED, header.getAuthorStatus());
|
||||
firstFound = true;
|
||||
} else if(messageId1.equals(header.getId())) {
|
||||
} else if (messageId1.equals(header.getId())) {
|
||||
assertHeadersMatch(message1, header);
|
||||
assertEquals(Author.Status.UNKNOWN, header.getAuthorStatus());
|
||||
secondFound = true;
|
||||
} else if(messageId2.equals(header.getId())) {
|
||||
} else if (messageId2.equals(header.getId())) {
|
||||
assertHeadersMatch(message2, header);
|
||||
assertEquals(Author.Status.ANONYMOUS, header.getAuthorStatus());
|
||||
thirdFound = true;
|
||||
@@ -1075,7 +1075,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
public void testMultipleSubscriptionsAndUnsubscriptions() throws Exception {
|
||||
// Create some groups
|
||||
List<Group> groups = new ArrayList<Group>();
|
||||
for(int i = 0; i < 100; i++) {
|
||||
for (int i = 0; i < 100; i++) {
|
||||
GroupId id = new GroupId(TestUtils.getRandomId());
|
||||
String name = "Group " + i;
|
||||
groups.add(new Group(id, name, new byte[GROUP_SALT_LENGTH]));
|
||||
@@ -1087,16 +1087,16 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
// Add a contact and subscribe to the groups
|
||||
db.addLocalAuthor(txn, localAuthor);
|
||||
assertEquals(contactId, db.addContact(txn, author, localAuthorId));
|
||||
for(Group g : groups) db.addGroup(txn, g);
|
||||
for (Group g : groups) db.addGroup(txn, g);
|
||||
|
||||
// Make the groups visible to the contact
|
||||
Collections.shuffle(groups);
|
||||
for(Group g : groups) db.addVisibility(txn, contactId, g.getId());
|
||||
for (Group g : groups) db.addVisibility(txn, contactId, g.getId());
|
||||
|
||||
// Make some of the groups invisible to the contact and remove them all
|
||||
Collections.shuffle(groups);
|
||||
for(Group g : groups) {
|
||||
if(Math.random() < 0.5)
|
||||
for (Group g : groups) {
|
||||
if (Math.random() < 0.5)
|
||||
db.removeVisibility(txn, contactId, g.getId());
|
||||
db.removeGroup(txn, g.getId());
|
||||
}
|
||||
@@ -1156,24 +1156,24 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
Collection<TemporarySecret> secrets = db.getSecrets(txn);
|
||||
assertEquals(3, secrets.size());
|
||||
boolean foundFirst = false, foundSecond = false, foundThird = false;
|
||||
for(TemporarySecret s : secrets) {
|
||||
for (TemporarySecret s : secrets) {
|
||||
assertEquals(contactId, s.getContactId());
|
||||
assertEquals(transportId, s.getTransportId());
|
||||
assertEquals(epoch, s.getEpoch());
|
||||
assertEquals(alice, s.getAlice());
|
||||
if(s.getPeriod() == 0) {
|
||||
if (s.getPeriod() == 0) {
|
||||
assertArrayEquals(secret1, s.getSecret());
|
||||
assertEquals(outgoing1, s.getOutgoingStreamCounter());
|
||||
assertEquals(centre1, s.getWindowCentre());
|
||||
assertArrayEquals(bitmap1, s.getWindowBitmap());
|
||||
foundFirst = true;
|
||||
} else if(s.getPeriod() == 1) {
|
||||
} else if (s.getPeriod() == 1) {
|
||||
assertArrayEquals(secret2, s.getSecret());
|
||||
assertEquals(outgoing2, s.getOutgoingStreamCounter());
|
||||
assertEquals(centre2, s.getWindowCentre());
|
||||
assertArrayEquals(bitmap2, s.getWindowBitmap());
|
||||
foundSecond = true;
|
||||
} else if(s.getPeriod() == 2) {
|
||||
} else if (s.getPeriod() == 2) {
|
||||
assertArrayEquals(secret3, s.getSecret());
|
||||
assertEquals(outgoing3, s.getOutgoingStreamCounter());
|
||||
assertEquals(centre3, s.getWindowCentre());
|
||||
@@ -1193,24 +1193,24 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
assertEquals(3, secrets.size());
|
||||
foundSecond = foundThird = false;
|
||||
boolean foundFourth = false;
|
||||
for(TemporarySecret s : secrets) {
|
||||
for (TemporarySecret s : secrets) {
|
||||
assertEquals(contactId, s.getContactId());
|
||||
assertEquals(transportId, s.getTransportId());
|
||||
assertEquals(epoch, s.getEpoch());
|
||||
assertEquals(alice, s.getAlice());
|
||||
if(s.getPeriod() == 1) {
|
||||
if (s.getPeriod() == 1) {
|
||||
assertArrayEquals(secret2, s.getSecret());
|
||||
assertEquals(outgoing2, s.getOutgoingStreamCounter());
|
||||
assertEquals(centre2, s.getWindowCentre());
|
||||
assertArrayEquals(bitmap2, s.getWindowBitmap());
|
||||
foundSecond = true;
|
||||
} else if(s.getPeriod() == 2) {
|
||||
} else if (s.getPeriod() == 2) {
|
||||
assertArrayEquals(secret3, s.getSecret());
|
||||
assertEquals(outgoing3, s.getOutgoingStreamCounter());
|
||||
assertEquals(centre3, s.getWindowCentre());
|
||||
assertArrayEquals(bitmap3, s.getWindowBitmap());
|
||||
foundThird = true;
|
||||
} else if(s.getPeriod() == 3) {
|
||||
} else if (s.getPeriod() == 3) {
|
||||
assertArrayEquals(secret4, s.getSecret());
|
||||
assertEquals(outgoing4, s.getOutgoingStreamCounter());
|
||||
assertEquals(centre4, s.getWindowCentre());
|
||||
@@ -1387,13 +1387,13 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
Collection<Endpoint> endpoints = db.getEndpoints(txn);
|
||||
assertEquals(2, endpoints.size());
|
||||
boolean foundFirst = false, foundSecond = false;
|
||||
for(Endpoint ep : endpoints) {
|
||||
for (Endpoint ep : endpoints) {
|
||||
assertEquals(contactId, ep.getContactId());
|
||||
if(ep.getTransportId().equals(transportId1)) {
|
||||
if (ep.getTransportId().equals(transportId1)) {
|
||||
assertEquals(epoch1, ep.getEpoch());
|
||||
assertEquals(alice1, ep.getAlice());
|
||||
foundFirst = true;
|
||||
} else if(ep.getTransportId().equals(transportId2)) {
|
||||
} else if (ep.getTransportId().equals(transportId2)) {
|
||||
assertEquals(epoch2, ep.getEpoch());
|
||||
assertEquals(alice2, ep.getAlice());
|
||||
foundSecond = true;
|
||||
@@ -1530,7 +1530,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
|
||||
// Add some offered messages and count them
|
||||
List<MessageId> ids = new ArrayList<MessageId>();
|
||||
for(int i = 0; i < 10; i++) {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
MessageId m = new MessageId(TestUtils.getRandomId());
|
||||
db.addOfferedMessage(txn, contactId, m);
|
||||
ids.add(m);
|
||||
@@ -1595,7 +1595,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
// Ask for a nonexistent message - an exception should be thrown
|
||||
db.getRawMessage(txn, messageId);
|
||||
fail();
|
||||
} catch(DbException expected) {
|
||||
} catch (DbException expected) {
|
||||
// It should be possible to abort the transaction without error
|
||||
db.abortTransaction(txn);
|
||||
}
|
||||
@@ -1606,7 +1606,7 @@ public class H2DatabaseTest extends BriarTestCase {
|
||||
private Database<Connection> open(boolean resume) throws Exception {
|
||||
Database<Connection> db = new H2Database(new TestDatabaseConfig(testDir,
|
||||
MAX_SIZE), new TestFileUtils(), new SystemClock());
|
||||
if(!resume) TestUtils.deleteTestDirectory(testDir);
|
||||
if (!resume) TestUtils.deleteTestDirectory(testDir);
|
||||
db.open();
|
||||
return db;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user