Skip to content

Instantly share code, notes, and snippets.

View junit-test.java
package com.anjlab.sat3;
import java.util.Properties;
import org.junit.BeforeClass;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cern.colt.list.ObjectArrayList;
View SortHandlerTest.java
package com.anjlab.ssf4j;
import static org.junit.Assert.assertArrayEquals;
import org.junit.Test;
public class SortHandlerTest {
@Test
public void testSort() {
View snippet.java
private Map<String, List<String>> traces = new HashMap<String, List<String>>();
private void writeSummary(final List<String> headers) throws IOException {
SortHandler<Integer> handler = new SortHandler<Integer>() {
public int to() {
return headers.size() - 1;
}
public void swap(int i, int j) {
Collections.swap(headers, i, j);
@dmitrygusev
dmitrygusev / AppModule.java
Created Mar 30, 2013
Tapestry5 Skicky Forms
View AppModule.java
import java.util.List;
public class AppModule
{
public static void bind(ServiceBinder binder) throws ClassNotFoundException
{
binder.bind(StickyFormSource.class, StickyFormSourceImpl.class);
}
@Contribute(StickyFormSource.class)
View EventResponseRenderer.java
public interface EventResponseRenderer
{
String render(RenderEvent renderEvent);
}
View CompanyBlocks.java
import x.y.z.entities.Company;
import org.apache.tapestry5.Block;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
public class CompanyBlocks
{
@Property private Company company;
@dmitrygusev
dmitrygusev / AppModule.java
Created May 12, 2013
Eager load Tapestry5 services on startup
View AppModule.java
public void contributeApplicationInitializer(OrderedConfiguration<ApplicationInitializerFilter> configuration,
@Symbol(TapestryEagerLoadInitializer.FORCE_EAGER_LOAD) boolean forceEagerLoad)
{
if (forceEagerLoad)
{
configuration.addInstance("EagerLoad", TapestryEagerLoadInitializer.class, "before:*");
}
}
@dmitrygusev
dmitrygusev / XeroObjectMapperContextResolver.java
Created Jun 20, 2013
Example of calling Xero API using JSON format via Resteasy client with custom ObjectMapper
View XeroObjectMapperContextResolver.java
import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.ParsePosition;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.ws.rs.ext.ContextResolver;
import org.codehaus.jackson.map.ObjectMapper;
@dmitrygusev
dmitrygusev / AbstractWorker.java
Last active Dec 23, 2015
Tapestry Workers & Tasks
View AbstractWorker.java
package com.anjlab.spelling.web.services.workers;
import java.lang.Thread.UncaughtExceptionHandler;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import org.apache.tapestry5.ioc.Messages;
View BaseIntegrationTest.java
// see http://svn.apache.org/repos/asf/shiro/tags/shiro-root-1.2.2/core/src/test/java/org/apache/shiro/test/AbstractShiroTest.java
public class BaseIntegrationTest extends AbstractShiroTest
{
public static Registry registry;
@BeforeClass
public static void setup()
{