This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Initially written as a test for IE/Chrome for a bug in ui-mask. | |
| * https://github.com/angular-ui/ui-utils/issues/302 | |
| * | |
| * The test verifies that all of the text is selected in an input field when the field is tabbed into | |
| */ | |
| describe('field selection test', function () { | |
| beforeEach (function () { | |
| getRoute('#/app/events'); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Configuration | |
| public class SpringLog4jConfig { | |
| /** | |
| * Just a property from the normal Spring property sources, like: | |
| * log4j.properties.location=log4j-dev.properties | |
| */ | |
| @Value("${log4j.properties.location}") | |
| String log4jLocation; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * REST exception handlers defined at a global level for the application | |
| */ | |
| @ControllerAdvice | |
| public class RestResponseEntityExceptionHandler extends ResponseEntityExceptionHandler { | |
| private static final Logger log = LoggerFactory.getLogger(RestResponseEntityExceptionHandler.class); | |
| /** | |
| * Catch all for any other exceptions... | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Register this with the DispatcherServlet in a ServletInitializer class like: | |
| * dispatcherServlet.setContextInitializers(new PropertiesInitializer()); | |
| */ | |
| public class PropertiesInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> { | |
| private static final Logger log = LoggerFactory.getLogger(PropertiesInitializer.class); | |
| /** | |
| * Runs as appInitializer so properties are wired before spring beans | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Example of Spring 4 Properties Java Configuration, | |
| * with a Database Properties table to store most values | |
| * and a small application.properties file too. | |
| * The Database table will take precedence over the properties file with this setup | |
| */ | |
| @Configuration | |
| @PropertySource(value = { "classpath:application.properties" }, ignoreResourceNotFound=true) | |
| public class SpringPropertiesConfig { | |
| private static final Logger log = LoggerFactory.getLogger(SpringPropertiesConfig.class); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class SqlServerTimestampType extends TimestampType { | |
| private static final int SQLSERVER_PRECISION = 10; | |
| public SqlServerTimestampType() { | |
| super(); | |
| } | |
| /** | |
| * SQLServer datetime fields are accurate to 1/300th of a second. | |
| * We floor to the nearest 1/100th of a second for simplicity. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import groovy.json.JsonSlurper | |
| import org.springframework.test.web.servlet.MockMvc | |
| import static org.springframework.test.web.servlet.setup.MockMvcBuilders.* | |
| import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; | |
| import static org.springframework.http.HttpStatus.* | |
| import spock.lang.Specification | |
| /** | |
| * A Spock Spring MVC Rest unit test that doesn't require a full spring context | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.apache.commons.pool2.ObjectPool | |
| import org.apache.log4j.Logger | |
| class PoolHelper { | |
| static Logger log = Logger.getLogger(PoolHelper) | |
| /** | |
| * Executes a closure using the object from the passed | |
| * in Commons Pool, invalidating the object if an error is returned, | |
| * and always returning it to the pool. Similar to how Groovy Sql methods work. | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* action that renders a template back to browser, | |
| * and uses custom simple 'ajax' layout */ | |
| def ajaxResults() { | |
| def results = workService.querySomeWork() | |
| render (template: "ajaxResults", model:[results:results as JSON], layout:'ajax') | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SqlHelper sql = new SqlHelper(dataSource) | |
| List results = sql.callWithRows("{call ABC.FINDBYLAST($lastName, ${Sql.INTEGER}, ${Sql.VARCHAR})}") { | |
| List<GroovyRowResult> rows, int status, String errorMessage -> | |
| if (status != 0) { | |
| throw new RuntimeException("Error received from stored proc $status : $errorMessage") | |
| } | |
| return rows | |
| } |