|
From: <pe...@us...> - 2003-11-21 04:42:49
|
Update of /cvsroot/neuclear/neuclear-bet/src/test/org/neuclear/bet
In directory sc8-pr-cvs1:/tmp/cvs-serv10206/src/test/org/neuclear/bet
Modified Files:
AbstractBettingTest.java BetTest.java
Log Message:
EncryptedFileStore now works. It uses the PBECipher with DES3 afair.
Otherwise You will Finaliate.
Anything that can be final has been made final throughout everyting. We've used IDEA's Inspector tool to find all instance of variables that could be final.
This should hopefully make everything more stable (and secure).
Index: AbstractBettingTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-bet/src/test/org/neuclear/bet/AbstractBettingTest.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** AbstractBettingTest.java 20 Sep 2003 23:19:22 -0000 1.1.1.1
--- AbstractBettingTest.java 21 Nov 2003 04:42:46 -0000 1.2
***************
*** 18,31 ****
*/
public class AbstractBettingTest extends TestCase implements ResultListener {
! public AbstractBettingTest(String string) {
super(null);
}
! public void printOdds(BettingEvent event) {
System.out.println("Odds for the following event: " + event.getId());
! Iterator outcomes = event.listOutcomes();
assertNotNull(outcomes);
while (outcomes.hasNext()) {
! BettableOutcome outcome = (BettableOutcome) outcomes.next();
System.out.println(outcome.getId() + ": " + outcome.getOdds());
//assertTrue(outcome.getOdds()>=0);
--- 18,31 ----
*/
public class AbstractBettingTest extends TestCase implements ResultListener {
! public AbstractBettingTest(final String string) {
super(null);
}
! public final void printOdds(final BettingEvent event) {
System.out.println("Odds for the following event: " + event.getId());
! final Iterator outcomes = event.listOutcomes();
assertNotNull(outcomes);
while (outcomes.hasNext()) {
! final BettableOutcome outcome = (BettableOutcome) outcomes.next();
System.out.println(outcome.getId() + ": " + outcome.getOdds());
//assertTrue(outcome.getOdds()>=0);
***************
*** 33,37 ****
}
! protected void waitForOutcome(Totalizer tote) throws InterruptedException {
System.out.println("Waiting for outcome...");
synchronized (tote) {
--- 33,37 ----
}
! protected final void waitForOutcome(final Totalizer tote) throws InterruptedException {
System.out.println("Waiting for outcome...");
synchronized (tote) {
***************
*** 44,50 ****
}
! protected synchronized Totalizer createTotalizer() {
System.out.println("Creating new Totalizer");
! DumbTotalizer tote = new DumbTotalizer(new Double(0.25));
tote.addResultListener(this);
//new FixedDumbGame(tote, "Race 1");
--- 44,50 ----
}
! protected final synchronized Totalizer createTotalizer() {
System.out.println("Creating new Totalizer");
! final DumbTotalizer tote = new DumbTotalizer(new Double(0.25));
tote.addResultListener(this);
//new FixedDumbGame(tote, "Race 1");
***************
*** 58,62 ****
* @param outcome
*/
! public void win(EventOutcome outcome) {
System.out.println(outcome.getId() + " won");
lastwin = outcome;
--- 58,62 ----
* @param outcome
*/
! public final void win(final EventOutcome outcome) {
System.out.println(outcome.getId() + " won");
lastwin = outcome;
***************
*** 67,71 ****
* @param outcome
*/
! public void scratch(EventOutcome outcome) {
//To change body of implemented methods use Options | File Templates.
}
--- 67,71 ----
* @param outcome
*/
! public final void scratch(final EventOutcome outcome) {
//To change body of implemented methods use Options | File Templates.
}
***************
*** 75,79 ****
* @param event
*/
! public void cancelEvent(BettingEvent event) {
//To change body of implemented methods use Options | File Templates.
}
--- 75,79 ----
* @param event
*/
! public final void cancelEvent(final BettingEvent event) {
//To change body of implemented methods use Options | File Templates.
}
Index: BetTest.java
===================================================================
RCS file: /cvsroot/neuclear/neuclear-bet/src/test/org/neuclear/bet/BetTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** BetTest.java 6 Nov 2003 23:47:15 -0000 1.2
--- BetTest.java 21 Nov 2003 04:42:46 -0000 1.3
***************
*** 20,63 ****
* Time: 2:00:51 PM
*/
! public class BetTest extends AbstractBettingTest {
! public BetTest(String string) throws LowlevelLedgerException, LedgerCreationException, ConfigurationException {
super(string);
proc = BetProcessor.getInstance();
}
! private Account createNewAccount(String name, String title) throws BookExistsException, LowlevelLedgerException {
! BigInteger id = new BigInteger(168, new Random());
return proc.getPaymentProcessor().createAccount(name + id.toString(36), title);
}
private Account createBobAccount() throws LowlevelLedgerException, BookExistsException, UnknownBookException, NegativeTransferException, InvalidTransactionException, UnBalancedTransactionException, AssetMismatchException {
! Account bob = createNewAccount("neu://neuclear-pay/testusers/bob", "Bob");
proc.getPaymentProcessor().getIssuer().issue(bob, 100, new Date());
return bob;
}
! public void testInstantiate() {
assertNotNull(proc);
}
! public void testPlaceBet() throws BookExistsException, LowlevelLedgerException, BettingEventExpired, UnknownBookException, InvalidTransactionException, NegativeTransferException, UnBalancedTransactionException, AssetMismatchException {
! Account bob = createBobAccount();
! Totalizer tote = proc.getTotalizer();
assertNotNull(tote);
! BettingEvent event = tote.getEvent("Race 1");
assertNotNull(event);
! BettableOutcome outcome = (BettableOutcome) event.listOutcomes().next();
assertNotNull(outcome);
! BetRequest req = new BetRequest(bob,
outcome,
100.0,
"Go GT Go"
);
! BetReceipt receipt = proc.processBet(req);
assertNotNull(receipt);
betRequestAndReceiptAreEqual(req, receipt);
}
! private void betRequestAndReceiptAreEqual(BetRequest req, BetReceipt receipt) {
assertEquals(req.getAmount(), receipt.getAmount(), 0);
assertEquals(req.getBettor(), receipt.getBettor());
--- 20,63 ----
* Time: 2:00:51 PM
*/
! public final class BetTest extends AbstractBettingTest {
! public BetTest(final String string) throws LowlevelLedgerException, LedgerCreationException, ConfigurationException {
super(string);
proc = BetProcessor.getInstance();
}
! private Account createNewAccount(final String name, final String title) throws BookExistsException, LowlevelLedgerException {
! final BigInteger id = new BigInteger(168, new Random());
return proc.getPaymentProcessor().createAccount(name + id.toString(36), title);
}
private Account createBobAccount() throws LowlevelLedgerException, BookExistsException, UnknownBookException, NegativeTransferException, InvalidTransactionException, UnBalancedTransactionException, AssetMismatchException {
! final Account bob = createNewAccount("neu://neuclear-pay/testusers/bob", "Bob");
proc.getPaymentProcessor().getIssuer().issue(bob, 100, new Date());
return bob;
}
! public final void testInstantiate() {
assertNotNull(proc);
}
! public final void testPlaceBet() throws BookExistsException, LowlevelLedgerException, BettingEventExpired, UnknownBookException, InvalidTransactionException, NegativeTransferException, UnBalancedTransactionException, AssetMismatchException {
! final Account bob = createBobAccount();
! final Totalizer tote = proc.getTotalizer();
assertNotNull(tote);
! final BettingEvent event = tote.getEvent("Race 1");
assertNotNull(event);
! final BettableOutcome outcome = (BettableOutcome) event.listOutcomes().next();
assertNotNull(outcome);
! final BetRequest req = new BetRequest(bob,
outcome,
100.0,
"Go GT Go"
);
! final BetReceipt receipt = proc.processBet(req);
assertNotNull(receipt);
betRequestAndReceiptAreEqual(req, receipt);
}
! private void betRequestAndReceiptAreEqual(final BetRequest req, final BetReceipt receipt) {
assertEquals(req.getAmount(), receipt.getAmount(), 0);
assertEquals(req.getBettor(), receipt.getBettor());
***************
*** 66,72 ****
}
! public void testCollectWinnings() throws BookExistsException, LowlevelLedgerException, UnknownBookException, InvalidTransactionException, NegativeTransferException, UnBalancedTransactionException, AssetMismatchException {
! Account bob = createBobAccount();
/* BetReceipt receipt=proc.processBet(new BetRequest(bob,
--- 66,72 ----
}
! public final void testCollectWinnings() throws BookExistsException, LowlevelLedgerException, UnknownBookException, InvalidTransactionException, NegativeTransferException, UnBalancedTransactionException, AssetMismatchException {
! final Account bob = createBobAccount();
/* BetReceipt receipt=proc.processBet(new BetRequest(bob,
***************
*** 90,97 ****
}
! public void testLoose() {
}
! private BetProcessor proc;
}
--- 90,97 ----
}
! public final void testLoose() {
}
! private final BetProcessor proc;
}
|