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


Java DataFieldMaxValueIncrementer.nextLongValue方法代码示例

本文整理汇总了Java中org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer.nextLongValue方法的典型用法代码示例。如果您正苦于以下问题:Java DataFieldMaxValueIncrementer.nextLongValue方法的具体用法?Java DataFieldMaxValueIncrementer.nextLongValue怎么用?Java DataFieldMaxValueIncrementer.nextLongValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer的用法示例。


在下文中一共展示了DataFieldMaxValueIncrementer.nextLongValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetIncrementer_nextValues

import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入方法依赖的package包/类
/**
 * Tests that the incrementer returned from the factory returns the proper next int, long, and String values.
 */
@Test
public void testGetIncrementer_nextValues() {
    DataFieldMaxValueIncrementer incrementer = (DataFieldMaxValueIncrementer) context.getBean(TEST_INCREMENTER);
    assertNotNull(incrementer);

    // now that we have our incrementer, let's get the next value
    int nextIntValue = incrementer.nextIntValue();
    assertTrue("nextIntValue should be greater than 0", nextIntValue > 0);

    // do it again, should be 1 larger!
    int nextNextIntValue = incrementer.nextIntValue();
    assertEquals("Next value should be one higher", nextIntValue + 1, nextNextIntValue);

    // try getting the next value as a long
    long nextLongValue = incrementer.nextLongValue();
    assertEquals(nextNextIntValue + 1, nextLongValue);

    // try getting it as a String now
    String nextStringValue = incrementer.nextStringValue();
    assertEquals(nextLongValue + 1, Long.parseLong(nextStringValue));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:25,代码来源:MaxValueIncrementerFactoryBeanIntegrationTest.java

示例2: testGetIncrementer_nextValues

import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入方法依赖的package包/类
/**
 * Tests that the incrementer returned from the factory returns the proper next int, long, and String values.
 */
@Test
public void testGetIncrementer_nextValues() {
    DataSource dataSource = TestHarnessServiceLocator.getDataSource();
    DataFieldMaxValueIncrementer incrementer =
            MaxValueIncrementerFactory.getIncrementer(dataSource, ARBITRARY_SEQUENCE);
    assertNotNull(incrementer);

    // now that we have our incrementer, let's get the next value
    int nextIntValue = incrementer.nextIntValue();
    assertTrue("nextIntValue should be greater than 0", nextIntValue > 0);

    // do it again, should be 1 larger!
    int nextNextIntValue = incrementer.nextIntValue();
    assertEquals("Next value should be one higher", nextIntValue + 1, nextNextIntValue);

    // try getting the next value as a long
    long nextLongValue = incrementer.nextLongValue();
    assertEquals(nextNextIntValue + 1, nextLongValue);

    // try getting it as a String now
    String nextStringValue = incrementer.nextStringValue();
    assertEquals(nextLongValue + 1, Long.parseLong(nextStringValue));
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:27,代码来源:MaxValueIncrementerFactoryIntegrationTest.java

示例3: testGetIncrementer_BadSequence

import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入方法依赖的package包/类
/**
 * Tests that if you try to use the factory with an invalid sequence name, it will throw a DataAccessException.
 */
@Test(expected = DataAccessException.class)
public void testGetIncrementer_BadSequence() {
    DataFieldMaxValueIncrementer incrementer = (DataFieldMaxValueIncrementer) context.getBean(INVALID_TEST_INCREMENTER);

    // the incrementer *may* still be retrieved successfully (depending on the database this integration test is run against)
    assertNotNull(incrementer);

    // but at the very least it should throw an exception when executed
    incrementer.nextLongValue();
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:14,代码来源:MaxValueIncrementerFactoryBeanIntegrationTest.java

示例4: testGetIncrementer_BadSequence

import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer; //导入方法依赖的package包/类
/**
 * Tests that if you try to use the factory with an invalid sequence name, it will throw a DataAccessException.
 */
@Test(expected = DataAccessException.class)
public void testGetIncrementer_BadSequence() {
    DataSource dataSource = TestHarnessServiceLocator.getDataSource();
    DataFieldMaxValueIncrementer incrementer =
            MaxValueIncrementerFactory.getIncrementer(dataSource, "OH_NO_YOU_DIDNT!");

    // the incrementer *may* still be retrieved successfully (depending on the database this integration test is run against)
    assertNotNull(incrementer);

    // but at the very least it should throw an exception when executed
    incrementer.nextLongValue();
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:16,代码来源:MaxValueIncrementerFactoryIntegrationTest.java


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