1 /*2 * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright3 * notice. All rights reserved.4 */5 package com.tc.objectserver.tx;6 7 import com.tc.test.TCTestCase;8 9 public class TransactionBatchManagerImplTest extends TCTestCase {10 11 public TransactionBatchManagerImplTest() {12 super();13 }14 15 // private TransactionBatchManagerImpl mgr;16 //17 // protected void setUp() throws Exception {18 // super.setUp();19 // this.mgr = new TransactionBatchManagerImpl();20 // }21 22 public void tests() throws Exception {23 // ChannelID channelID1 = new ChannelID(1);24 // TransactionID txID1 = new TransactionID(1);25 // TxnBatchID batchID1 = new TxnBatchID(1);26 //27 // int count = 10;28 //29 // List batchDescriptors = new LinkedList();30 // for (int i = 1; i <= 2; i++) {31 // batchDescriptors.add(new BatchDescriptor(new ChannelID(i), new TxnBatchID(1), count));32 // batchDescriptors.add(new BatchDescriptor(new ChannelID(i), new TxnBatchID(2), count));33 // }34 //35 // // make sure that you can't call batchComponentComplete unless define batch has been called for that36 // // batch already.37 // try {38 // mgr.batchComponentComplete(channelID1, batchID1, txID1);39 // fail("Expected a NoSuchBatchException");40 // } catch (NoSuchBatchException e) {41 // // expected42 // }43 //44 // // define batches45 // for (Iterator i = batchDescriptors.iterator(); i.hasNext();) {46 // defineBatchFor((BatchDescriptor) i.next());47 // }48 //49 // // make sure that you can't define the same batch more than once50 // for (Iterator i = batchDescriptors.iterator(); i.hasNext();) {51 // try {52 // defineBatchFor((BatchDescriptor) i.next());53 // fail("Expected a BatchDefinedException");54 // } catch (BatchDefinedException e) {55 // // expected56 // }57 // }58 //59 // // call batchComponentComplete() until all the components are complete60 // for (Iterator i = batchDescriptors.iterator(); i.hasNext();) {61 // BatchDescriptor desc = (BatchDescriptor) i.next();62 // for (int j = 1; j <= desc.count; j++) {63 // boolean isComplete = j == desc.count;64 // assertEquals(isComplete, mgr.batchComponentComplete(desc.channelID, desc.batchID, new TransactionID(j)));65 // }66 // }67 //68 // // XXX: This is a bit of a weird way to test this.69 // // Now that the batches have been completed, you should be able to define them again70 // for (Iterator i = batchDescriptors.iterator(); i.hasNext();) {71 // defineBatchFor((BatchDescriptor) i.next());72 // }73 //74 // // now kill a client75 // BatchDescriptor desc = (BatchDescriptor) batchDescriptors.get(0);76 // mgr.shutdownClient(desc.channelID);77 // for (Iterator batchDesIter = batchDescriptors.iterator(); batchDesIter.hasNext();) {78 // BatchDescriptor bd = (BatchDescriptor) batchDesIter.next();79 // if (bd.channelID.equals(desc.channelID)) {80 // for (int i = 1; i <= desc.count; i++) {81 // // batchComponentComplete should never return true...82 // assertFalse(mgr.batchComponentComplete(desc.channelID, desc.batchID, new TransactionID(i)));83 // }84 // }85 // }86 //87 // // now calling batchComponentComplete on an undefined batch if the client has been killed should throw and88 // exception89 // for (int i = 1; i <= desc.count; i++) {90 // try {91 // mgr.batchComponentComplete(desc.channelID, desc.batchID, new TransactionID(i));92 // fail("Expected a NoSuchBatchException");93 // } catch (NoSuchBatchException e) {94 // // expected95 // }96 // }97 //98 }99 //100 // private void defineBatchFor(BatchDescriptor desc) throws Exception {101 // mgr.defineBatch(desc.channelID, desc.batchID, desc.count);102 // }103 //104 // private final class BatchDescriptor {105 // public final ChannelID channelID;106 // public final TxnBatchID batchID;107 // public final int count;108 //109 // private BatchDescriptor(ChannelID channelID, TxnBatchID batchID, int count) {110 // this.channelID = channelID;111 // this.batchID = batchID;112 // this.count = count;113 // }114 // }115 116 }117