This file contains 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
@RunWith(JUnitRunner.class) | |
public class DummyTest { | |
@Test | |
@Transactional | |
public void testTest() { | |
assertTrue(false); | |
} | |
} |
This file contains 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
@Reliable | |
@RuleHandler(ExampleRule.class) | |
public @interface ExampleAnnotation { | |
} | |
@Traceable | |
@RuleHandler(ReliableRule.class) | |
public @interface Reliable { | |
} |
This file contains 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
@Test | |
@Reliable | |
public void demoFixtureArguments(FixtureExample one, FixtureExample two, FixtureExample three) { | |
System.out.println("demonstrateFixtureArguments(" + one + ", " + two + ", " + three + ")"); | |
} |
This file contains 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 javax.validation.constraints.Max; | |
import javax.validation.constraints.Min; | |
import javax.validation.constraints.Pattern; | |
import javax.validation.constraints.Size; | |
@Configuration | |
public class MysqlXADataSource { | |
@Property(desc = "User name to use for connection authentication.") | |
@Size(min = 6, max = 255) | |
private String user = ""; // default value - hence optional property |
This file contains 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 interface Decoder<T> { | |
public T decode(ByteBuffer buffer); | |
} |
This file contains 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 TextRowDecoder implements Decoder<byte[][]> { | |
private static final byte LF = 10; | |
private final int numFields; | |
private final byte delimiter; | |
public TextRowDecoder(int numFields, byte delimiter) { | |
this.numFields = numFields; | |
this.delimiter = delimiter; | |
} | |
@Override | |
public byte[][] decode(ByteBuffer buffer) { |
This file contains 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 FileReader implements Iterable<List<T>> { | |
private static final long CHUNK_SIZE = 4096; | |
private final Decoder<T> decoder; | |
private Iterator<File> files; | |
private FileReader(Decoder<T> decoder, File... files) { | |
this(decoder, Arrays.asList(files)); | |
} | |
private FileReader(Decoder<T> decoder, List<File> files) { | |
this.files = files.iterator(); |
This file contains 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
TextRowDecoder decoder = new TextRowDecoder(4, comma); | |
FileReader<byte[][]> reader = FileReader.create(decoder, file.listFiles()); | |
for (List<byte[][]> chunk : reader) { | |
// do something with each chunk | |
} |
This file contains 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 PeriodEntries<T extends Timestamped> implements Iterable<List<T>> { | |
private final Iterator<List<T extends Timestamped>> entriesIt; | |
private final long interval; | |
private PeriodEntries(Iterable<List<T>> entriesIt, long interval) { | |
this.entriesIt = entriesIt.iterator(); | |
this.interval = interval; | |
} | |
public static <T extends Timestamped> PeriodEntries<T> create(Iterable<List<T>> entriesIt, long interval) { | |
return new PeriodEntries<T>(entriesIt, interval); |
This file contains 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
TrueFxDecoder decoder = new TrueFxDecoder(); | |
FileReader<TrueFxData> reader = FileReader.create(decoder, file.listFiles()); | |
long periodLength = TimeUnit.DAYS.toMillis(1); | |
PeriodEntries<TrueFxData> periods = PeriodEntries.create(reader, periodLength); | |
for (List<TrueFxData> entries : periods) { | |
// data for each day | |
for (TrueFxData entry : entries) { | |
// process each entry | |
} |