Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Julian Dehm
briar
Commits
1081a08e
Verified
Commit
1081a08e
authored
Dec 12, 2016
by
Torsten Grote
Browse files
Move all unit tests to their modules and remove briar-tests
parent
32be148c
Changes
130
Hide whitespace changes
Inline
Side-by-side
bramble-api/build.gradle
View file @
1081a08e
...
...
@@ -5,18 +5,37 @@ targetCompatibility = 1.6
apply
plugin:
'witness'
dependencies
{
compile
"com.google.dagger:dagger:2.
0.2
"
compile
'com.google.dagger:dagger-compiler:2.
0.2
'
compile
"com.google.dagger:dagger:2.
8
"
compile
'com.google.dagger:dagger-compiler:2.
8
'
compile
'com.google.code.findbugs:jsr305:3.0.1'
testCompile
'junit:junit:4.12'
testCompile
"org.jmock:jmock:2.8.1"
testCompile
"org.jmock:jmock-junit4:2.8.1"
testCompile
"org.jmock:jmock-legacy:2.8.1"
testCompile
"org.hamcrest:hamcrest-library:1.3"
testCompile
"org.hamcrest:hamcrest-core:1.3"
}
dependencyVerification
{
verify
=
[
'com.google.dagger:dagger:84c0282ed8be73a29e0475d639da030b55dee72369e58dd35ae7d4fe6243dcf9'
,
'com.google.dagger:dagger-compiler:b74bc9de063dd4c6400b232231f2ef5056145b8fbecbf5382012007dd1c071b3'
,
'com.google.dagger:dagger:5070e1dff5c551a4908ba7b93125c0243de2a688aed3d2f475357d86d9d7c0ad'
,
'com.google.dagger:dagger-compiler:7b2686f94907868c5364e9965601ffe2f020ba4af1849ad9b57dad5fe3fa6242'
,
'com.google.code.findbugs:jsr305:c885ce34249682bc0236b4a7d56efcc12048e6135a5baf7a9cde8ad8cda13fcd'
,
'javax.inject:javax.inject:91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff'
,
'com.google.dagger:dagger-producers:99ec15e8a0507ba569e7655bc1165ee5e5ca5aa914b3c8f7e2c2458f724edd6b'
,
'com.google.guava:guava:d664fbfc03d2e5ce9cab2a44fb01f1d0bf9dfebeccc1a473b1f9ea31f79f6f99'
,
'com.google.code.findbugs:jsr305:c885ce34249682bc0236b4a7d56efcc12048e6135a5baf7a9cde8ad8cda13fcd'
'com.google.dagger:dagger-producers:1e4043e85f67de381d19e22c7932aaf7ff1611091be7e1aaae93f2c37f331cf2'
,
'com.google.guava:guava:ff89d4a4a6b303c4084194975a5a35f55a8af6f7337678b4cc8ddbea9005c323'
,
]
}
// needed to make test output available to bramble-core and briar-core
configurations
{
testOutput
.
extendsFrom
(
testCompile
)
}
task
jarTest
(
type:
Jar
,
dependsOn:
testClasses
)
{
from
sourceSets
.
test
.
output
classifier
=
'test'
}
artifacts
{
testOutput
jarTest
}
br
iar-tests/src
/org/briarproject/
Briar
MockTestCase.java
→
br
amble-api/src/test/java
/org/briarproject/
bramble/Bramble
MockTestCase.java
View file @
1081a08e
package
org.briarproject
;
package
org.briarproject
.bramble
;
import
org.jmock.Mockery
;
import
org.junit.After
;
public
abstract
class
BriarMockTestCase
extends
BriarTestCase
{
public
abstract
class
BrambleMockTestCase
extends
BrambleTestCase
{
protected
final
Mockery
context
=
new
Mockery
();
...
...
br
iar-tests/src
/org/briarproject/
Briar
TestCase.java
→
br
amble-api/src/test/java
/org/briarproject/
bramble/Bramble
TestCase.java
View file @
1081a08e
package
org.briarproject
;
package
org.briarproject
.bramble
;
import
java.lang.Thread.UncaughtExceptionHandler
;
import
static
org
.
junit
.
Assert
.
fail
;
public
abstract
class
Br
iar
TestCase
{
public
abstract
class
Br
amble
TestCase
{
public
Br
iar
TestCase
()
{
public
Br
amble
TestCase
()
{
// Ensure exceptions thrown on worker threads cause tests to fail
UncaughtExceptionHandler
fail
=
new
UncaughtExceptionHandler
()
{
@Override
...
...
br
iar-tests/src
/org/briarproject/ImmediateExecutor.java
→
br
amble-api/src/test/java
/org/briarproject/
bramble/
ImmediateExecutor.java
View file @
1081a08e
package
org.briarproject
;
package
org.briarproject
.bramble
;
import
org.briarproject.bramble.api.nullsafety.NotNullByDefault
;
...
...
br
iar-tests/src
/org/briarproject/TestDatabaseConfig.java
→
br
amble-api/src/test/java
/org/briarproject/
bramble/
TestDatabaseConfig.java
View file @
1081a08e
package
org.briarproject
;
package
org.briarproject
.bramble
;
import
org.briarproject.bramble.api.crypto.SecretKey
;
import
org.briarproject.bramble.api.db.DatabaseConfig
;
...
...
br
iar-tests/src
/org/briarproject/TestDatabaseModule.java
→
br
amble-api/src/test/java
/org/briarproject/
bramble/
TestDatabaseModule.java
View file @
1081a08e
package
org.briarproject
;
package
org.briarproject
.bramble
;
import
org.briarproject.bramble.api.db.DatabaseConfig
;
import
org.briarproject.bramble.api.db.DatabaseExecutor
;
...
...
br
iar-tests/src
/org/briarproject/TestSeedProvider.java
→
br
amble-api/src/test/java
/org/briarproject/
bramble/
TestSeedProvider.java
View file @
1081a08e
package
org.briarproject
;
package
org.briarproject
.bramble
;
import
org.briarproject.bramble.api.nullsafety.NotNullByDefault
;
import
org.briarproject.bramble.api.system.SeedProvider
;
...
...
br
iar-tests/src
/org/briarproject/TestSeedProviderModule.java
→
br
amble-api/src/test/java
/org/briarproject/
bramble/
TestSeedProviderModule.java
View file @
1081a08e
package
org.briarproject
;
package
org.briarproject
.bramble
;
import
org.briarproject.bramble.api.system.SeedProvider
;
...
...
br
iar-tests/src
/org/briarproject/TestUtils.java
→
br
amble-api/src/test/java
/org/briarproject/
bramble/
TestUtils.java
View file @
1081a08e
package
org.briarproject
;
package
org.briarproject
.bramble
;
import
org.briarproject.bramble.api.UniqueId
;
import
org.briarproject.bramble.api.crypto.SecretKey
;
import
org.briarproject.bramble.api.db.DbException
;
import
org.briarproject.bramble.api.sync.GroupId
;
import
org.briarproject.bramble.util.IoUtils
;
import
org.briarproject.briar.api.client.MessageTracker
;
import
org.briarproject.briar.api.client.MessageTracker.GroupCount
;
import
java.io.File
;
import
java.util.Random
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
public
class
TestUtils
{
private
static
final
AtomicInteger
nextTestDir
=
...
...
@@ -51,19 +45,4 @@ public class TestUtils {
return
new
SecretKey
(
getRandomBytes
(
SecretKey
.
LENGTH
));
}
public
static
void
assertGroupCount
(
MessageTracker
tracker
,
GroupId
g
,
long
msgCount
,
long
unreadCount
,
long
latestMsgTime
)
throws
DbException
{
GroupCount
groupCount
=
tracker
.
getGroupCount
(
g
);
assertEquals
(
msgCount
,
groupCount
.
getMsgCount
());
assertEquals
(
unreadCount
,
groupCount
.
getUnreadCount
());
assertEquals
(
latestMsgTime
,
groupCount
.
getLatestMsgTime
());
}
public
static
void
assertGroupCount
(
MessageTracker
tracker
,
GroupId
g
,
long
msgCount
,
long
unreadCount
)
throws
DbException
{
GroupCount
c1
=
tracker
.
getGroupCount
(
g
);
assertEquals
(
msgCount
,
c1
.
getMsgCount
());
assertEquals
(
unreadCount
,
c1
.
getUnreadCount
());
}
}
br
iar-tests/src
/org/briarproject/ValidatorTestCase.java
→
br
amble-api/src/test/java
/org/briarproject/
bramble/
ValidatorTestCase.java
View file @
1081a08e
package
org.briarproject
;
package
org.briarproject
.bramble
;
import
org.briarproject.bramble.api.client.ClientHelper
;
import
org.briarproject.bramble.api.data.MetadataEncoder
;
...
...
@@ -10,7 +10,7 @@ import org.briarproject.bramble.api.sync.Message;
import
org.briarproject.bramble.api.sync.MessageId
;
import
org.briarproject.bramble.api.system.Clock
;
public
abstract
class
ValidatorTestCase
extends
Br
iar
MockTestCase
{
public
abstract
class
ValidatorTestCase
extends
Br
amble
MockTestCase
{
protected
final
ClientHelper
clientHelper
=
context
.
mock
(
ClientHelper
.
class
);
...
...
br
iar-tests/src
/org/briarproject/bramble/data/BdfDictionaryTest.java
→
br
amble-api/src/test/java
/org/briarproject/bramble/
api/
data/BdfDictionaryTest.java
View file @
1081a08e
package
org.briarproject.bramble.data
;
package
org.briarproject.bramble.
api.
data
;
import
org.briarproject.
Briar
TestCase
;
import
org.briarproject.
bramble.Bramble
TestCase
;
import
org.briarproject.bramble.api.Bytes
;
import
org.briarproject.bramble.api.data.BdfDictionary
;
import
org.briarproject.bramble.api.data.BdfEntry
;
import
org.junit.Test
;
import
java.util.Collections
;
...
...
@@ -15,7 +13,7 @@ import static org.junit.Assert.assertArrayEquals;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
class
BdfDictionaryTest
extends
Br
iar
TestCase
{
public
class
BdfDictionaryTest
extends
Br
amble
TestCase
{
@Test
public
void
testConstructors
()
{
...
...
br
iar-tests/src
/org/briarproject/bramble/data/BdfListTest.java
→
br
amble-api/src/test/java
/org/briarproject/bramble/
api/
data/BdfListTest.java
View file @
1081a08e
package
org.briarproject.bramble.data
;
package
org.briarproject.bramble.
api.
data
;
import
org.briarproject.
Briar
TestCase
;
import
org.briarproject.
bramble.Bramble
TestCase
;
import
org.briarproject.bramble.api.Bytes
;
import
org.briarproject.bramble.api.FormatException
;
import
org.briarproject.bramble.api.data.BdfDictionary
;
import
org.briarproject.bramble.api.data.BdfEntry
;
import
org.briarproject.bramble.api.data.BdfList
;
import
org.junit.Test
;
import
java.util.Arrays
;
...
...
@@ -15,7 +12,7 @@ import static org.briarproject.bramble.api.data.BdfDictionary.NULL_VALUE;
import
static
org
.
junit
.
Assert
.
assertArrayEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
public
class
BdfListTest
extends
Br
iar
TestCase
{
public
class
BdfListTest
extends
Br
amble
TestCase
{
@Test
public
void
testConstructors
()
{
...
...
bramble-core/.gitignore
View file @
1081a08e
bin
build
test.tmp
.settings
bramble-core/build.gradle
View file @
1081a08e
...
...
@@ -14,10 +14,7 @@ dependencies {
compile
'com.madgag.spongycastle:core:1.54.0.0'
compile
'com.h2database:h2:1.4.190'
testCompile
project
(
':briar-tests'
)
// TODO remove when moving unit tests (#778)
testCompile
'junit:junit:4.12'
testCompile
'com.google.dagger:dagger-compiler:2.8'
testApt
'com.google.dagger:dagger-compiler:2.8'
testCompile
project
(
path:
':bramble-api'
,
configuration:
'testOutput'
)
}
dependencyVerification
{
...
...
@@ -26,3 +23,15 @@ dependencyVerification {
'com.h2database:h2:23ba495a07bbbb3bd6c3084d10a96dad7a23741b8b6d64b213459a784195a98c'
]
}
// needed to make test output available to bramble-j2se
configurations
{
testOutput
.
extendsFrom
(
testCompile
)
}
task
jarTest
(
type:
Jar
,
dependsOn:
testClasses
)
{
from
sourceSets
.
test
.
output
classifier
=
'test'
}
artifacts
{
testOutput
jarTest
}
br
iar-tests/src
/org/briarproject/RunAction.java
→
br
amble-core/src/test/java
/org/briarproject/
bramble/
RunAction.java
View file @
1081a08e
package
org.briarproject
;
package
org.briarproject
.bramble
;
import
org.hamcrest.Description
;
import
org.jmock.api.Action
;
...
...
br
iar-tests/src
/org/briarproject/bramble/client/BdfMessageValidatorTest.java
→
br
amble-core/src/test/java
/org/briarproject/bramble/client/BdfMessageValidatorTest.java
View file @
1081a08e
package
org.briarproject.bramble.client
;
import
org.briarproject.ValidatorTestCase
;
import
org.briarproject.
bramble.
ValidatorTestCase
;
import
org.briarproject.bramble.api.FormatException
;
import
org.briarproject.bramble.api.client.BdfMessageContext
;
import
org.briarproject.bramble.api.client.BdfMessageValidator
;
...
...
br
iar-tests/src
/org/briarproject/bramble/client/ClientHelperImplTest.java
→
br
amble-core/src/test/java
/org/briarproject/bramble/client/ClientHelperImplTest.java
View file @
1081a08e
package
org.briarproject.bramble.client
;
import
org.briarproject.
Briar
TestCase
;
import
org.briarproject.TestUtils
;
import
org.briarproject.
bramble.Bramble
TestCase
;
import
org.briarproject.
bramble.
TestUtils
;
import
org.briarproject.bramble.api.FormatException
;
import
org.briarproject.bramble.api.client.ClientHelper
;
import
org.briarproject.bramble.api.crypto.CryptoComponent
;
...
...
@@ -32,13 +32,13 @@ import java.util.Collections;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
org
.
briarproject
.
TestUtils
.
getRandomBytes
;
import
static
org
.
briarproject
.
TestUtils
.
getRandomId
;
import
static
org
.
briarproject
.
bramble
.
TestUtils
.
getRandomBytes
;
import
static
org
.
briarproject
.
bramble
.
TestUtils
.
getRandomId
;
import
static
org
.
junit
.
Assert
.
assertArrayEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
fail
;
public
class
ClientHelperImplTest
extends
Br
iar
TestCase
{
public
class
ClientHelperImplTest
extends
Br
amble
TestCase
{
private
final
Mockery
context
=
new
Mockery
();
private
final
DatabaseComponent
db
=
context
.
mock
(
DatabaseComponent
.
class
);
...
...
@@ -165,7 +165,8 @@ public class ClientHelperImplTest extends BriarTestCase {
@Test
public
void
testGetMessageMetadataAsDictionaryMap
()
throws
Exception
{
final
Map
<
MessageId
,
BdfDictionary
>
map
=
new
HashMap
<>();
final
Map
<
MessageId
,
BdfDictionary
>
map
=
new
HashMap
<
MessageId
,
BdfDictionary
>();
map
.
put
(
messageId
,
dictionary
);
final
Transaction
txn
=
new
Transaction
(
null
,
true
);
...
...
@@ -187,7 +188,8 @@ public class ClientHelperImplTest extends BriarTestCase {
@Test
public
void
testGetMessageMetadataAsDictionaryQuery
()
throws
Exception
{
final
Map
<
MessageId
,
BdfDictionary
>
map
=
new
HashMap
<>();
final
Map
<
MessageId
,
BdfDictionary
>
map
=
new
HashMap
<
MessageId
,
BdfDictionary
>();
map
.
put
(
messageId
,
dictionary
);
final
BdfDictionary
query
=
BdfDictionary
.
of
(
new
BdfEntry
(
"query"
,
"me"
));
...
...
br
iar-tests/src
/org/briarproject/bramble/contact/ContactManagerImplTest.java
→
br
amble-core/src/test/java
/org/briarproject/bramble/contact/ContactManagerImplTest.java
View file @
1081a08e
package
org.briarproject.bramble.contact
;
import
org.briarproject.
Briar
MockTestCase
;
import
org.briarproject.
bramble.Bramble
MockTestCase
;
import
org.briarproject.bramble.api.contact.Contact
;
import
org.briarproject.bramble.api.contact.ContactId
;
import
org.briarproject.bramble.api.contact.ContactManager
;
...
...
@@ -19,13 +19,13 @@ import java.util.ArrayList;
import
java.util.Collection
;
import
java.util.Collections
;
import
static
org
.
briarproject
.
TestUtils
.
getRandomBytes
;
import
static
org
.
briarproject
.
TestUtils
.
getRandomId
;
import
static
org
.
briarproject
.
TestUtils
.
getSecretKey
;
import
static
org
.
briarproject
.
bramble
.
TestUtils
.
getRandomBytes
;
import
static
org
.
briarproject
.
bramble
.
TestUtils
.
getRandomId
;
import
static
org
.
briarproject
.
bramble
.
TestUtils
.
getSecretKey
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
class
ContactManagerImplTest
extends
Br
iar
MockTestCase
{
public
class
ContactManagerImplTest
extends
Br
amble
MockTestCase
{
private
final
Mockery
context
=
new
Mockery
();
private
final
DatabaseComponent
db
=
context
.
mock
(
DatabaseComponent
.
class
);
...
...
@@ -132,7 +132,8 @@ public class ContactManagerImplTest extends BriarMockTestCase {
@Test
public
void
testActiveContacts
()
throws
Exception
{
Collection
<
Contact
>
activeContacts
=
Collections
.
singletonList
(
contact
);
final
Collection
<
Contact
>
contacts
=
new
ArrayList
<>(
activeContacts
);
final
Collection
<
Contact
>
contacts
=
new
ArrayList
<
Contact
>(
activeContacts
);
contacts
.
add
(
new
Contact
(
new
ContactId
(
3
),
remote
,
local
,
true
,
false
));
final
Transaction
txn
=
new
Transaction
(
null
,
true
);
context
.
checking
(
new
Expectations
()
{{
...
...
br
iar-tests/src
/org/briarproject/bramble/crypto/AsciiArmourTest.java
→
br
amble-core/src/test/java
/org/briarproject/bramble/crypto/AsciiArmourTest.java
View file @
1081a08e
package
org.briarproject.bramble.crypto
;
import
org.briarproject.
Briar
TestCase
;
import
org.briarproject.
bramble.Bramble
TestCase
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.
assertArrayEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
public
class
AsciiArmourTest
extends
Br
iar
TestCase
{
public
class
AsciiArmourTest
extends
Br
amble
TestCase
{
@Test
public
void
testWrapOnSingleLine
()
{
...
...
br
iar-tests/src
/org/briarproject/bramble/crypto/Blake2sDigestTest.java
→
br
amble-core/src/test/java
/org/briarproject/bramble/crypto/Blake2sDigestTest.java
View file @
1081a08e
package
org.briarproject.bramble.crypto
;
import
org.briarproject.
Briar
TestCase
;
import
org.briarproject.
bramble.Bramble
TestCase
;
import
org.briarproject.bramble.util.StringUtils
;
import
org.junit.Test
;
...
...
@@ -8,7 +8,7 @@ import java.util.Random;
import
static
org
.
junit
.
Assert
.
assertArrayEquals
;
public
class
Blake2sDigestTest
extends
Br
iar
TestCase
{
public
class
Blake2sDigestTest
extends
Br
amble
TestCase
{
// Vectors from BLAKE2 web site: https://blake2.net/blake2s-test.txt
private
static
final
String
[][]
keyedTestVectors
=
{
...
...
Prev
1
2
3
4
5
…
7
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment