1 17 package org.alfresco.repo.version.common.counter; 18 19 import org.alfresco.service.cmr.repository.NodeService; 20 import org.alfresco.service.cmr.repository.StoreRef; 21 import org.alfresco.util.BaseSpringTest; 22 23 26 public class VersionCounterDaoServiceTest extends BaseSpringTest 27 { 28 31 private final static String STORE_ID_1 = "test1_" + System.currentTimeMillis(); 32 private final static String STORE_ID_2 = "test2_" + System.currentTimeMillis(); 33 private static final String STORE_NONE = "test3_" + System.currentTimeMillis();; 34 35 private NodeService nodeService; 36 private VersionCounterDaoService counter; 37 38 @Override 39 public void onSetUpInTransaction() 40 { 41 nodeService = (NodeService) applicationContext.getBean("dbNodeService"); 42 counter = (VersionCounterDaoService) applicationContext.getBean("versionCounterDaoService"); 43 } 44 45 public void testSetUp() throws Exception 46 { 47 assertNotNull(nodeService); 48 assertNotNull(counter); 49 } 50 51 54 public void testNextVersionNumber() 55 { 56 StoreRef store1 = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, VersionCounterDaoServiceTest.STORE_ID_1); 58 StoreRef store2 = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, VersionCounterDaoServiceTest.STORE_ID_2); 59 StoreRef storeNone = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, VersionCounterDaoServiceTest.STORE_NONE); 60 61 int store1Version0 = this.counter.nextVersionNumber(store1); 62 assertEquals(store1Version0, 1); 63 64 int store1Version1 = this.counter.nextVersionNumber(store1); 65 assertEquals(store1Version1, 2); 66 67 int store2Version0 = this.counter.nextVersionNumber(store2); 68 assertEquals(store2Version0, 1); 69 70 int store1Version2 = this.counter.nextVersionNumber(store1); 71 assertEquals(store1Version2, 3); 72 73 int store2Version1 = this.counter.nextVersionNumber(store2); 74 assertEquals(store2Version1, 2); 75 76 int store1Current = this.counter.currentVersionNumber(store1); 77 assertEquals(store1Current, 3); 78 79 int store2Current = this.counter.currentVersionNumber(store2); 80 assertEquals(store2Current, 2); 81 82 int storeNoneCurrent = this.counter.currentVersionNumber(storeNone); 83 assertEquals(storeNoneCurrent, 0); 84 85 this.counter.resetVersionNumber(store1); 87 this.counter.resetVersionNumber(store2); 88 } 89 90 } 91 | Popular Tags |