Minimal composable test assert utility.
Following code sample asserts complex application state model including:
- SCNNode as Tile and Scene
Minimal composable test assert utility.
Following code sample asserts complex application state model including:
| public static void main(final String[] args) throws Exception { | |
| // Read command line parameters | |
| CommandLineParams params = read(args); | |
| // Get bind address | |
| String bindAddress = params.get("-b", "--bind").orElse("localhost"); | |
| // Get production/development mode flag | |
| Boolean isProductionMode = params.getBool("-m", "--mode").orElse(Boolean.FALSE); | |
| ... |
| <@common.small_avatar_icon initials="JR" color="#62CB31"/> |
| <#macro avatar_icon initials color> | |
| <svg width="100" height="100"> | |
| <circle cx="50" cy="50" r="40" stroke="#62CB31" stroke-width="0" fill="${color}" /> | |
| <text x="50" y="57" fill="#ffffff" font-weight="bold" font-size="18px" font-family='"Open Sans","Helvetica Neue",Helvetica,Arial,sans-serif' text-anchor="middle">${initials}</text> | |
| </svg> | |
| </#macro> |
| Config config = new Config().addQueueConfig(queueConfig); | |
| HazelcastInstance hazelInst = Hazelcast.newHazelcastInstance(config); |
| // Create queue store configuration and set the queue store class name | |
| QueueStoreConfig storeConfig = new QueueStoreConfig().setClassName(MailQueueStore.class.getName()); | |
| storeConfig.setEnabled(true); | |
| // Configure queue store properties | |
| // All properties are described in hazecast documentation at https://github.com/hazelcast/hazelcast/blob/master/hazelcast-documentation/src/Queue-Persistence.md | |
| storeConfig.setProperty("memory-limit", 100); | |
| // Create config for queue which will be using our queue store | |
| QueueConfig queueConfig = new QueueConfig().setName(MailorRemoteAPIConstants.Queues.MAIL_INPUT); | |
| // Set previously created store configuration to queue configuration | |
| queueConfig.setQueueStoreConfig(storeConfig); |
| public class MailQueueStore implements QueueStore<InputMessageDto> { | |
| private static final Logger logger = LoggerFactory.getLogger(MailQueueStore.class); | |
| /** | |
| * Reference to MapDB database connection isntance. | |
| */ | |
| private DB database; | |
| public MailQueueStore() { |
| package com.mailor.app.test.util; | |
| import static java.lang.String.format; | |
| import static org.junit.Assert.fail; | |
| /** | |
| * Provides support for testing code executed asynchronously. | |
| * | |
| * @author krablak | |
| * |
| // Following sample shows simple case of executing task asynchronously without blocking current thread. | |
| // This is extremely handy for tasks which are not so important to block the execution of main program | |
| // and we do depend on their execution results. | |
| AsyncUtil.with(message).plan(MailSerializerUtil::toTempDir).async(); | |
| // It's also posible to chain async tasks plans | |
| AsyncUtil.with(message) | |
| .plan(MailSerializerUtil::toTempDir) | |
| .plan(MailSerializerUtil::logMessage) | |
| .async(); |
| global_semaphore = asyncio.Semaphore(5) | |
| def download(links=[], root_url="", download_loc="/tmp/"): | |
| # Prepare root url | |
| root_url_fixed = utils.peck_url_start(root_url) | |
| # Prepare download futures for each link | |
| down_futures = asyncio.wait([download_file(cur_link, root_url_fixed, download_loc) for cur_link in links]) | |
| # Execute prepared futures with download operations | |
| down_futures_res =asyncio.get_event_loop().run_until_complete(down_futures) | |
| # Return the futures result as array of downloaded files |