本文整理汇总了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));
}
示例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));
}
示例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();
}
示例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();
}