Added unit test for dynamic loading of contracts jar.

This commit is contained in:
Sofus Mortensen 2016-03-04 16:58:13 +01:00
parent 7f5eb5bf2f
commit 65c4eb829e
4 changed files with 45 additions and 1 deletions

1
.gitignore vendored
View File

@ -5,6 +5,7 @@ TODO
.gradle
/build/
/contracts/build
/sandbox/build
/core/build
/docs/build/doctrees

22
sandbox/build.gradle Normal file
View File

@ -0,0 +1,22 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "com.google.guava:guava:19.0"
}
}
apply plugin: 'java'
apply plugin: 'kotlin'
repositories {
mavenCentral()
}
dependencies {
testCompile 'junit:junit:4.12'
compile project(':core')
}

View File

@ -0,0 +1,20 @@
import core.Contract
import core.crypto.SecureHash
import org.junit.Test
import java.net.URL
import java.net.URLClassLoader
import kotlin.test.assertEquals
class LoaderTests {
@Test
fun loadContracts() {
var child = URLClassLoader(arrayOf(URL("file", "", "../contracts/build/libs/contracts.jar")))
var contractClass = Class.forName("contracts.Cash", true, child)
var contract = contractClass.newInstance() as Contract
assertEquals(SecureHash.sha256("https://www.big-book-of-banking-law.gov/cash-claims.html"), contract.legalContractReference)
}
}

View File

@ -1,3 +1,4 @@
rootProject.name = 'r3prototyping'
include 'contracts'
include 'core'
include 'core'
include 'sandbox'