当前位置: 首页>>代码示例>>Java>>正文


Java UnitTestData类代码示例

本文整理汇总了Java中org.kuali.rice.test.data.UnitTestData的典型用法代码示例。如果您正苦于以下问题:Java UnitTestData类的具体用法?Java UnitTestData怎么用?Java UnitTestData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UnitTestData类属于org.kuali.rice.test.data包,在下文中一共展示了UnitTestData类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetPessimisticLocksForDocument

import org.kuali.rice.test.data.UnitTestData; //导入依赖的package包/类
/**
 * tests retrieving {@link PessimisticLock} objects by document number
 *
 * @throws Exception
 */
@UnitTestData(
        sqlStatements = {
                @UnitTestSql("DELETE FROM KRNS_PESSIMISTIC_LOCK_T"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1111, 'fbcb0362-7dfb-102c-97b6-ed716fdaf540', 0, NULL, '1234', {d '2007-07-01'}, 'fran', 'aa5d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1112, '055bef4a-7dfc-102c-97b6-ed716fdaf540', 0, NULL, '1237', {d '2007-10-01'}, 'frank', 'dd5d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1113, '0e0144ec-7dfc-102c-97b6-ed716fdaf540', 0, NULL, '1236', {d '2007-10-01'}, 'frank', 'dd5d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1114, '1891526c-7dfc-102c-97b6-ed716fdaf540', 0, NULL, '1237', {d '2007-08-01'}, 'fred', 'ab4d6c83-4d0f-4309-a528-c2f81ec00396')")
                }
        )
@Test
public void testGetPessimisticLocksForDocument() throws Exception {
    PessimisticLockService lockService = KRADServiceLocatorWeb.getPessimisticLockService();
    String docId = "1234";
    assertEquals("Document " + docId + " expected lock count incorrect", 1, lockService.getPessimisticLocksForDocument(docId).size());
    docId = "1237";
    assertEquals("Document " + docId + " expected lock count incorrect", 2, lockService.getPessimisticLocksForDocument(docId).size());
    docId = "1236";
    assertEquals("Document " + docId + " expected lock count incorrect", 1, lockService.getPessimisticLocksForDocument(docId).size());
    docId = "3948";
    assertEquals("Document " + docId + " expected lock count incorrect", 0, lockService.getPessimisticLocksForDocument(docId).size());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:27,代码来源:PessimisticLockServiceTest.java

示例2: testGetPessimisticLocksForSession

import org.kuali.rice.test.data.UnitTestData; //导入依赖的package包/类
/**
 * This method tests retrieving {@link PessimisticLock} objects by session id
 *
 * @throws Exception
 */
@UnitTestData(
        sqlStatements = {
                @UnitTestSql("DELETE FROM KRNS_PESSIMISTIC_LOCK_T"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1111, '24c40cd2-7dfc-102c-97b6-ed716fdaf540', 0, NULL, '1234', {d '2007-07-01'}, 'fran', 'ad4d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1112, '32602e8e-7dfc-102c-97b6-ed716fdaf540', 0, NULL, '1235', {d '2007-10-01'}, 'fran', 'bc5d6c66-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1113, '3acfc1ce-7dfc-102c-97b6-ed716fdaf540', 0, NULL, '1236', {d '2007-10-01'}, 'fran', 'ad4d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1114, '463cc642-7dfc-102c-97b6-ed716fdaf540', 0, NULL, '1237', {d '2007-08-01'}, 'fran', 'bc5d6c66-4d0f-4309-a528-c2f81ec00396')")
        }
)
@Test
public void testGetPessimisticLocksForSession() throws Exception {
    List<PessimisticLock> locks = KRADServiceLocatorWeb.getPessimisticLockService().getPessimisticLocksForSession(sessionId);
    assertEquals("Should return 2 locks for session " + sessionId, 2, locks.size());

    ArrayList<String> documentNumbers = new ArrayList<String>();
    for (PessimisticLock lock : locks) {
        documentNumbers.add(lock.getDocumentNumber());
    }
    assertTrue("Locks should contain a lock for document number 1234 but contained " + documentNumbers, documentNumbers.contains("1234"));
    assertTrue("Locks should contain a lock for document number 1236 but contained " + documentNumbers, documentNumbers.contains("1236"));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:27,代码来源:PessimisticLockServiceTest.java

示例3: testSaveLock

import org.kuali.rice.test.data.UnitTestData; //导入依赖的package包/类
/**
 * tests saving {@link PessimisticLock} objects
 *
 * @throws Exception
 */
@UnitTestData(
        sqlStatements = {
                @UnitTestSql("DELETE FROM KRNS_PESSIMISTIC_LOCK_T"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1111, '73f340de-7dfc-102c-97b6-ed716fdaf540', 0, NULL, '1234', {d '2007-07-01'}, 'fran', 'ad4d6c83-4d0f-4309-a528-c2f81ec00396')")
                }
        )
@Test
public void testSaveLock() throws Exception {
    String lockDescriptor = "new test lock descriptor";
    // get existing lock and update lock descriptor and save
    PessimisticLock lock = KRADServiceLocator.getDataObjectService().find(PessimisticLock.class, 1111L);
    lock.setLockDescriptor(lockDescriptor);
    KRADServiceLocatorWeb.getPessimisticLockService().save(lock);

    // verify retrieved lock has lock descriptor set previously
    PessimisticLock savedLock = KRADServiceLocator.getDataObjectService().find(PessimisticLock.class, 1111L);
    assertEquals("Lock descriptor is not correct from lock that was saved", lockDescriptor, savedLock.getLockDescriptor());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:24,代码来源:PessimisticLockServiceTest.java

示例4: testSaveLock

import org.kuali.rice.test.data.UnitTestData; //导入依赖的package包/类
/**
 * tests saving {@link PessimisticLock} objects
 *
 * @throws Exception
 */
@UnitTestData(
        sqlStatements = {
                @UnitTestSql("DELETE FROM KRNS_PESSIMISTIC_LOCK_T"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1111, '73f340de-7dfc-102c-97b6-ed716fdaf540', 0, NULL, '1234', {d '2007-07-01'}, 'fran', 'ad4d6c83-4d0f-4309-a528-c2f81ec00396')")
                }
        )
@Test
public void testSaveLock() throws Exception {
    String lockDescriptor = "new test lock descriptor";
    // get existing lock and update lock descriptor and save
    Map primaryKeys = new HashMap();
    primaryKeys.put(KRADPropertyConstants.ID, Long.valueOf("1111"));
    PessimisticLock lock = (PessimisticLock) KRADServiceLocator.getBusinessObjectService().findByPrimaryKey(PessimisticLock.class, primaryKeys);
    lock.setLockDescriptor(lockDescriptor);
    KRADServiceLocatorWeb.getPessimisticLockService().save(lock);

    // verify retrieved lock has lock descriptor set previously
    PessimisticLock savedLock = (PessimisticLock) KRADServiceLocator.getBusinessObjectService().findByPrimaryKey(PessimisticLock.class, primaryKeys);
    assertEquals("Lock descriptor is not correct from lock that was saved", lockDescriptor, savedLock.getLockDescriptor());
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:26,代码来源:PessimisticLockServiceTest.java

示例5: start

import org.kuali.rice.test.data.UnitTestData; //导入依赖的package包/类
public void start() throws Exception {
	if (annotatedClass.isAnnotationPresent(PerSuiteUnitTestData.class)) {
		UnitTestData[] data = annotatedClass.getAnnotation(PerSuiteUnitTestData.class).value();
           UnitTestDataUtils.executeDataLoader(data);
	}
	started = true;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:8,代码来源:PerSuiteDataLoaderLifecycle.java

示例6: stop

import org.kuali.rice.test.data.UnitTestData; //导入依赖的package包/类
public void stop() throws Exception {
    if (method.getDeclaringClass().isAnnotationPresent(PerTestUnitTestData.class)) {
           UnitTestData[] data = method.getDeclaringClass().getAnnotation(PerTestUnitTestData.class).tearDown();
           UnitTestDataUtils.executeDataLoader(data);
       }
	started = false;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:8,代码来源:PerTestDataLoaderLifecycle.java

示例7: testDeleteLocks

import org.kuali.rice.test.data.UnitTestData; //导入依赖的package包/类
/**
 * tests deleting {@link PessimisticLock} objects. Tests that invalid deletes throw exceptions and valid
 * deletes by owner users as well as lock admin users do work as expected
 *
 * @throws Exception
 */
@UnitTestData(
        sqlStatements = {
                @UnitTestSql("DELETE FROM KRNS_PESSIMISTIC_LOCK_T"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1111, '4f6bc9e2-7df8-102c-97b6-ed716fdaf540', 0, NULL, '1234', {d '2007-07-01'}, 'employee', 'aa5d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1112, '5add9cba-7df8-102c-97b6-ed716fdaf540', 0, NULL, '1235', {d '2007-10-01'}, 'frank', 'dd4d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1113, '69e42b8e-7df8-102c-97b6-ed716fdaf540', 0, NULL, '1236', {d '2007-08-01'}, 'fred', 'ad4d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1114, '76504650-7df8-102c-97b6-ed716fdaf540', 0, NULL, '1237', {d '2007-08-01'}, 'fred', 'ad4d6c83-4d0f-4309-a528-c2f81ec00396')")
                }
        )
@Test
public void testDeleteLocks() throws Exception {
	
    List<PessimisticLock> locks = KRADServiceLocator.getDataObjectService().findMatching(PessimisticLock.class, QueryByCriteria.Builder.create().build()).getResults();
    assertEquals("Should be 4 locks in DB", 4, locks.size());

    String userId = "employee";
    String[] lockIdsToVerify = new String[]{"1112", "1113"};
    assertFalse("User " + userId + " should not be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING,
            Collections.<String, String>emptyMap() ) );
    verifyDelete(userId, Arrays.asList(lockIdsToVerify), AuthorizationException.class, true);
    userId = "frank";
    lockIdsToVerify = new String[]{"1111", "1113"};
    assertFalse("User " + userId + " should not be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING, Collections.<String, String>emptyMap() ) );
    verifyDelete(userId, Arrays.asList(lockIdsToVerify), AuthorizationException.class, true);
    userId = "fred";
    lockIdsToVerify = new String[]{"1111", "1112"};
    assertFalse("User " + userId + " should not be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING, Collections.<String, String>emptyMap() ) );
    verifyDelete(userId, Arrays.asList(lockIdsToVerify), AuthorizationException.class, true);

    verifyDelete("employee", Arrays.asList(new String[]{"1111"}), null, false);
    verifyDelete("frank", Arrays.asList(new String[]{"1112"}), null, false);
    verifyDelete("fred", Arrays.asList(new String[]{"1113"}), null, false);
    locks = KRADServiceLocator.getDataObjectService().findMatching(PessimisticLock.class, QueryByCriteria.Builder.create().build()).getResults();
    assertEquals("Should be 1 lock left in DB", 1, locks.size());

    // test admin user can delete any lock
    userId = "fran";
    assertTrue("User " + userId + " should be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING, Collections.<String, String>emptyMap() ) );
    userId = "admin";
    assertTrue("User " + userId + " should be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING, Collections.<String, String>emptyMap() ) );
    verifyDelete(userId, Arrays.asList(new String[]{"1114"}), null, false);
    locks = KRADServiceLocator.getDataObjectService().findMatching(PessimisticLock.class, QueryByCriteria.Builder.create().build()).getResults();
    assertEquals("Should be 0 locks left in DB", 0, locks.size());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:51,代码来源:PessimisticLockServiceTest.java

示例8: testReleaseAllLocksForUser

import org.kuali.rice.test.data.UnitTestData; //导入依赖的package包/类
/**
 * This method tests releasing {@link PessimisticLock} objects for a specific user
 *
 * @throws Exception
 */
@UnitTestData(
        sqlStatements = {
                @UnitTestSql("DELETE FROM KRNS_PESSIMISTIC_LOCK_T"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1111, '24c40cd2-7dfc-102c-97b6-ed716fdaf540', 0, NULL, '1234', {d '2007-07-01'}, 'fran', 'ad4d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1112, '32602e8e-7dfc-102c-97b6-ed716fdaf540', 0, NULL, '1235', {d '2007-10-01'}, 'frank', 'bc5d6c66-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1113, '3acfc1ce-7dfc-102c-97b6-ed716fdaf540', 0, NULL, '1236', {d '2007-10-01'}, 'frank', 'bc5d6c66-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1114, '463cc642-7dfc-102c-97b6-ed716fdaf540', 0, NULL, '1237', {d '2007-08-01'}, 'fred', 'dd5d6c66-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1115, '4e66c4b2-7dfc-102c-97b6-ed716fdaf540', 0, 'Temporary Lock', '1234', {d '2007-07-01'}, 'fran', 'ad4d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1116, '55d99b02-7dfc-102c-97b6-ed716fdaf540', 0, 'Temporary Lock', '1235', {d '2007-10-01'}, 'frank', 'bc5d6c66-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1117, '5e47fb26-7dfc-102c-97b6-ed716fdaf540', 0, 'Temporary Lock', '1236', {d '2007-10-01'}, 'frank', 'bc5d6c66-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1118, '65c366d8-7dfc-102c-97b6-ed716fdaf540', 0, 'Temporary Lock', '1237', {d '2007-08-01'}, 'fred', 'dd5d6c66-4d0f-4309-a528-c2f81ec00396')")
                }
        )
@Test
public void testReleaseAllLocksForUser() throws Exception {
    String lockDescriptor = "Temporary Lock";
    List<PessimisticLock> locks = KRADServiceLocator.getDataObjectService().findMatching(PessimisticLock.class, QueryByCriteria.Builder.create().build()).getResults();
    assertEquals("Should be 8 manually inserted locks", 8, locks.size());

    KRADServiceLocatorWeb.getPessimisticLockService().releaseAllLocksForUser(locks, KimApiServiceLocator.getPersonService().getPerson("fran"), lockDescriptor);
    locks = KRADServiceLocator.getDataObjectService().findMatching(PessimisticLock.class, QueryByCriteria.Builder.create().build()).getResults();
    assertEquals("Should be 7 locks left after releasing locks for fran using lock descriptor " + lockDescriptor, 7, locks.size());

    KRADServiceLocatorWeb.getPessimisticLockService().releaseAllLocksForUser(locks, KimApiServiceLocator.getPersonService().getPerson("frank"), lockDescriptor);
    locks = KRADServiceLocator.getDataObjectService().findMatching(PessimisticLock.class, QueryByCriteria.Builder.create().build()).getResults();
    assertEquals("Should be 5 locks left after releasing locks for fran and frank using lock descriptor " + lockDescriptor, 5, locks.size());

    KRADServiceLocatorWeb.getPessimisticLockService().releaseAllLocksForUser(locks, KimApiServiceLocator.getPersonService().getPerson("fred"), lockDescriptor);
    locks = KRADServiceLocator.getDataObjectService().findMatching(PessimisticLock.class, QueryByCriteria.Builder.create().build()).getResults();
    assertEquals("Should be 4 locks left after releasing locks for fran, frank, and fred using lock descriptor " + lockDescriptor, 4, locks.size());

    KRADServiceLocatorWeb.getPessimisticLockService().releaseAllLocksForUser(locks, KimApiServiceLocator.getPersonService().getPerson("fran"));
    locks = KRADServiceLocator.getDataObjectService().findMatching(PessimisticLock.class, QueryByCriteria.Builder.create().build()).getResults();
    assertEquals("Should be 3 locks left after releasing locks for fran with no lock descriptor", 3, locks.size());

    KRADServiceLocatorWeb.getPessimisticLockService().releaseAllLocksForUser(locks, KimApiServiceLocator.getPersonService().getPerson("frank"));
    locks = KRADServiceLocator.getDataObjectService().findMatching(PessimisticLock.class, QueryByCriteria.Builder.create().build()).getResults();
    assertEquals("Should be 1 lock left after releasing locks for fran and frank with no lock descriptor", 1, locks.size());

    KRADServiceLocatorWeb.getPessimisticLockService().releaseAllLocksForUser(locks, KimApiServiceLocator.getPersonService().getPerson("fred"));
    locks = KRADServiceLocator.getDataObjectService().findMatching(PessimisticLock.class, QueryByCriteria.Builder.create().build()).getResults();
    assertEquals("Should be no locks left after releasing locks for fran, frank, and fred with no lock descriptor", 0, locks.size());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:49,代码来源:PessimisticLockServiceTest.java

示例9: testDeleteLocks

import org.kuali.rice.test.data.UnitTestData; //导入依赖的package包/类
/**
 * tests deleting {@link PessimisticLock} objects. Tests that invalid deletes throw exceptions and valid
 * deletes by owner users as well as lock admin users do work as expected
 *
 * @throws Exception
 */
@UnitTestData(
        sqlStatements = {
                @UnitTestSql("DELETE FROM KRNS_PESSIMISTIC_LOCK_T"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1111, '4f6bc9e2-7df8-102c-97b6-ed716fdaf540', 0, NULL, '1234', {d '2007-07-01'}, 'employee', 'aa5d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1112, '5add9cba-7df8-102c-97b6-ed716fdaf540', 0, NULL, '1235', {d '2007-10-01'}, 'frank', 'dd4d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1113, '69e42b8e-7df8-102c-97b6-ed716fdaf540', 0, NULL, '1236', {d '2007-08-01'}, 'fred', 'ad4d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1114, '76504650-7df8-102c-97b6-ed716fdaf540', 0, NULL, '1237', {d '2007-08-01'}, 'fred', 'ad4d6c83-4d0f-4309-a528-c2f81ec00396')")
                }
        )
@Test
public void testDeleteLocks() throws Exception {
	
    List<PessimisticLock> locks = (List<PessimisticLock>) KRADServiceLocator.getBusinessObjectService().findAll(PessimisticLock.class);
    assertEquals("Should be 4 locks in DB", 4, locks.size());

    String userId = "employee";
    String[] lockIdsToVerify = new String[]{"1112", "1113"};
    assertFalse("User " + userId + " should not be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING,
            Collections.<String, String>emptyMap() ) );
    verifyDelete(userId, Arrays.asList(lockIdsToVerify), AuthorizationException.class, true);
    userId = "frank";
    lockIdsToVerify = new String[]{"1111", "1113"};
    assertFalse("User " + userId + " should not be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING, Collections.<String, String>emptyMap() ) );
    verifyDelete(userId, Arrays.asList(lockIdsToVerify), AuthorizationException.class, true);
    userId = "fred";
    lockIdsToVerify = new String[]{"1111", "1112"};
    assertFalse("User " + userId + " should not be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING, Collections.<String, String>emptyMap() ) );
    verifyDelete(userId, Arrays.asList(lockIdsToVerify), AuthorizationException.class, true);

    verifyDelete("employee", Arrays.asList(new String[]{"1111"}), null, false);
    verifyDelete("frank", Arrays.asList(new String[]{"1112"}), null, false);
    verifyDelete("fred", Arrays.asList(new String[]{"1113"}), null, false);
    locks = (List<PessimisticLock>) KRADServiceLocator.getBusinessObjectService().findAll(PessimisticLock.class);
    assertEquals("Should be 1 lock left in DB", 1, locks.size());

    // test admin user can delete any lock
    userId = "fran";
    assertTrue("User " + userId + " should be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING, Collections.<String, String>emptyMap() ) );
    userId = "admin";
    assertTrue("User " + userId + " should be member of pessimistic lock admin permission", KimApiServiceLocator.getPermissionService().isAuthorized(new UserSession(userId).getPerson().getPrincipalId(), KRADConstants.KNS_NAMESPACE, PermissionNames.ADMIN_PESSIMISTIC_LOCKING, Collections.<String, String>emptyMap() ) );
    verifyDelete(userId, Arrays.asList(new String[]{"1114"}), null, false);
    locks = (List<PessimisticLock>) KRADServiceLocator.getBusinessObjectService().findAll(PessimisticLock.class);
    assertEquals("Should be 0 locks left in DB", 0, locks.size());
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:51,代码来源:PessimisticLockServiceTest.java

示例10: testReleaseAllLocksForUser

import org.kuali.rice.test.data.UnitTestData; //导入依赖的package包/类
/**
 * This method tests releasing {@link PessimisticLock} objects for a specific user
 *
 * @throws Exception
 */
@UnitTestData(
        sqlStatements = {
                @UnitTestSql("DELETE FROM KRNS_PESSIMISTIC_LOCK_T"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1111, '24c40cd2-7dfc-102c-97b6-ed716fdaf540', 0, NULL, '1234', {d '2007-07-01'}, 'fran', 'ad4d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1112, '32602e8e-7dfc-102c-97b6-ed716fdaf540', 0, NULL, '1235', {d '2007-10-01'}, 'frank', 'bc5d6c66-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1113, '3acfc1ce-7dfc-102c-97b6-ed716fdaf540', 0, NULL, '1236', {d '2007-10-01'}, 'frank', 'bc5d6c66-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1114, '463cc642-7dfc-102c-97b6-ed716fdaf540', 0, NULL, '1237', {d '2007-08-01'}, 'fred', 'dd5d6c66-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1115, '4e66c4b2-7dfc-102c-97b6-ed716fdaf540', 0, 'Temporary Lock', '1234', {d '2007-07-01'}, 'fran', 'ad4d6c83-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1116, '55d99b02-7dfc-102c-97b6-ed716fdaf540', 0, 'Temporary Lock', '1235', {d '2007-10-01'}, 'frank', 'bc5d6c66-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1117, '5e47fb26-7dfc-102c-97b6-ed716fdaf540', 0, 'Temporary Lock', '1236', {d '2007-10-01'}, 'frank', 'bc5d6c66-4d0f-4309-a528-c2f81ec00396')"),
                @UnitTestSql("INSERT INTO KRNS_PESSIMISTIC_LOCK_T (PESSIMISTIC_LOCK_ID,OBJ_ID,VER_NBR,LOCK_DESC_TXT,DOC_HDR_ID,GNRT_DT,PRNCPL_ID,SESN_ID) VALUES (1118, '65c366d8-7dfc-102c-97b6-ed716fdaf540', 0, 'Temporary Lock', '1237', {d '2007-08-01'}, 'fred', 'dd5d6c66-4d0f-4309-a528-c2f81ec00396')")
                }
        )
@Test
public void testReleaseAllLocksForUser() throws Exception {
    String lockDescriptor = "Temporary Lock";
    List<PessimisticLock> locks = (List<PessimisticLock>) KRADServiceLocator.getBusinessObjectService().findAll(PessimisticLock.class);
    assertEquals("Should be 8 manually inserted locks", 8, locks.size());

    KRADServiceLocatorWeb.getPessimisticLockService().releaseAllLocksForUser(locks, KimApiServiceLocator.getPersonService().getPerson("fran"), lockDescriptor);
    locks = (List<PessimisticLock>) KRADServiceLocator.getBusinessObjectService().findAll(PessimisticLock.class);
    assertEquals("Should be 7 locks left after releasing locks for fran using lock descriptor " + lockDescriptor, 7, locks.size());

    KRADServiceLocatorWeb.getPessimisticLockService().releaseAllLocksForUser(locks, KimApiServiceLocator.getPersonService().getPerson("frank"), lockDescriptor);
    locks = (List<PessimisticLock>) KRADServiceLocator.getBusinessObjectService().findAll(PessimisticLock.class);
    assertEquals("Should be 5 locks left after releasing locks for fran and frank using lock descriptor " + lockDescriptor, 5, locks.size());

    KRADServiceLocatorWeb.getPessimisticLockService().releaseAllLocksForUser(locks, KimApiServiceLocator.getPersonService().getPerson("fred"), lockDescriptor);
    locks = (List<PessimisticLock>) KRADServiceLocator.getBusinessObjectService().findAll(PessimisticLock.class);
    assertEquals("Should be 4 locks left after releasing locks for fran, frank, and fred using lock descriptor " + lockDescriptor, 4, locks.size());

    KRADServiceLocatorWeb.getPessimisticLockService().releaseAllLocksForUser(locks, KimApiServiceLocator.getPersonService().getPerson("fran"));
    locks = (List<PessimisticLock>) KRADServiceLocator.getBusinessObjectService().findAll(PessimisticLock.class);
    assertEquals("Should be 3 locks left after releasing locks for fran with no lock descriptor", 3, locks.size());

    KRADServiceLocatorWeb.getPessimisticLockService().releaseAllLocksForUser(locks, KimApiServiceLocator.getPersonService().getPerson("frank"));
    locks = (List<PessimisticLock>) KRADServiceLocator.getBusinessObjectService().findAll(PessimisticLock.class);
    assertEquals("Should be 1 lock left after releasing locks for fran and frank with no lock descriptor", 1, locks.size());

    KRADServiceLocatorWeb.getPessimisticLockService().releaseAllLocksForUser(locks, KimApiServiceLocator.getPersonService().getPerson("fred"));
    locks = (List<PessimisticLock>) KRADServiceLocator.getBusinessObjectService().findAll(PessimisticLock.class);
    assertEquals("Should be no locks left after releasing locks for fran, frank, and fred with no lock descriptor", 0, locks.size());
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:49,代码来源:PessimisticLockServiceTest.java


注:本文中的org.kuali.rice.test.data.UnitTestData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。