Java Code Examples for org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer#nextLongValue()
The following examples show how to use
org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer#nextLongValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MaxValueIncrementerFactoryBeanIntegrationTest.java From rice with Educational Community License v2.0 | 6 votes |
/** * 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)); }
Example 2
Source File: MaxValueIncrementerFactoryIntegrationTest.java From rice with Educational Community License v2.0 | 6 votes |
/** * 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)); }
Example 3
Source File: MaxValueIncrementerFactoryBeanIntegrationTest.java From rice with Educational Community License v2.0 | 5 votes |
/** * 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(); }
Example 4
Source File: MaxValueIncrementerFactoryIntegrationTest.java From rice with Educational Community License v2.0 | 5 votes |
/** * 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(); }