Use a delegate to make OsisParser cleaner

This commit is contained in:
Bradlee Speice
2014-11-11 10:09:47 -05:00
parent c57babd68a
commit c394fce273
6 changed files with 85 additions and 15 deletions

View File

@ -0,0 +1,39 @@
package org.bspeice.minimalbible.test;
import org.bspeice.minimalbible.FinalDelegate;
import org.bspeice.minimalbible.MBTestCase;
import kotlin.PropertyMetadataImpl;
/**
* Test that the FinalDelegate actually obeys its contract
*/
public class FinalDelegateTest extends MBTestCase {
FinalDelegate<String> delegate;
public void setUp() {
delegate = new FinalDelegate<String>();
}
public void testDelegateNullSafety() {
try {
delegate.get(null, new PropertyMetadataImpl(""));
} catch (IllegalStateException e) {
return;
}
fail("Exception not thrown!");
}
public void testDelegateAssignOnce() {
try {
delegate.set(null, new PropertyMetadataImpl(""), "");
delegate.set(null, new PropertyMetadataImpl(""), "");
} catch (IllegalStateException e) {
return;
}
fail("Allowed to set twice!");
}
}

View File

@ -17,7 +17,7 @@ public class OsisParserTest extends MBTestCase {
OsisParser parser;
public void setUp() {
parser = new OsisParser(null);
parser = new OsisParser();
}
@SuppressLint("NewApi")