name: java-test-library description: Java 25 test library development patterns for crypto-scout-test including MockData, PodmanCompose, and RabbitMQ utilities license: MIT compatibility: opencode metadata: language: java framework: junit6 domain: testing
What I Do
Provide guidance for developing and maintaining the crypto-scout-test library, a Java 25 Maven library offering test support utilities.
Project Structure
crypto-scout-test/
├── src/main/java/.../test/
│ ├── Constants.java # All configuration constants
│ ├── MockData.java # Typed mock data loader
│ ├── PodmanCompose.java # Container lifecycle
│ ├── DBUtils.java # Database utilities
│ ├── StreamTestPublisher.java # RabbitMQ Streams publisher
│ ├── StreamTestConsumer.java # RabbitMQ Streams consumer
│ ├── AmqpTestPublisher.java # AMQP publisher
│ ├── AmqpTestConsumer.java # AMQP consumer
│ └── Assertions.java # Test assertions
├── src/main/resources/
│ ├── bybit-spot/ # 12 JSON mock data files
│ ├── bybit-linear/ # 13 JSON mock data files
│ ├── crypto-scout/ # 6 JSON mock data files
│ └── podman/ # Container configuration
└── src/test/java/.../test/ # 9 test classes
Core Components
MockData
Typed API for loading bundled JSON fixtures:
// Load SPOT 1m klines
var spotKlines = MockData.get(MockData.Source.BYBIT_SPOT, MockData.Type.KLINE_1);
// Load LINEAR tickers
var linearTickers = MockData.get(MockData.Source.BYBIT_LINEAR, MockData.Type.TICKERS);
// Load crypto-scout FGI
var fgi = MockData.get(MockData.Source.CRYPTO_SCOUT, MockData.Type.FGI);
Sources: CRYPTO_SCOUT, BYBIT_SPOT, BYBIT_LINEAR
Types (17 total):
- Timeframes:
KLINE_1,KLINE_5,KLINE_15,KLINE_60,KLINE_240,KLINE_D,KLINE_W - Market data:
TICKERS,PUBLIC_TRADE - Order books:
ORDER_BOOK_1,ORDER_BOOK_50,ORDER_BOOK_200,ORDER_BOOK_1000 - Linear only:
ALL_LIQUIDATION - Crypto-scout:
FGI,LPL,BTC_PRICE_RISK,BTC_RISK_PRICE
PodmanCompose
Container lifecycle management:
@BeforeAll
static void setUp() {
PodmanCompose.up(); // Starts TimescaleDB + RabbitMQ, waits for readiness
}
@AfterAll
static void tearDown() {
PodmanCompose.down(); // Stops containers, removes volumes
}
Waits for:
- Database connectivity (port 5432)
- RabbitMQ Streams (port 5552)
RabbitMQ Utilities
Streams Protocol (port 5552):
StreamTestPublisher.create(reactor, executor, environment, stream)StreamTestConsumer.create(reactor, executor, environment, stream)
AMQP Protocol (port 5672):
AmqpTestPublisher.create(reactor, executor, connectionFactory, queue)AmqpTestConsumer.create(reactor, executor, connectionFactory, queue)
Features:
- Thread-safe using
AtomicReference - ActiveJ
ReactiveServiceintegration - Automatic connection/channel management
- 5s confirmation timeout for AMQP publisher
DBUtils
// Check connectivity
DBUtils.canConnect();
// Clean tables for test isolation
DBUtils.deleteFromTables(dataSource,
"crypto_scout.bybit_spot_tickers",
"crypto_scout.bybit_spot_kline_1m");
Assertions
Assertions.assertTableCount("crypto_scout.bybit_spot_tickers", 5);
Configuration
All settings via system properties:
| Property | Default | Description |
|---|---|---|
test.db.jdbc.url |
jdbc:postgresql://localhost:5432/crypto_scout |
Database URL |
test.db.user |
crypto_scout_db |
Database user |
test.db.password |
crypto_scout_db |
Database password |
test.mq.host |
localhost |
RabbitMQ host |
test.mq.port |
5552 |
RabbitMQ Streams port |
test.mq.user |
crypto_scout_mq |
RabbitMQ user |
test.mq.password |
crypto_scout_mq |
RabbitMQ password |
podman.compose.cmd |
podman-compose |
Podman Compose binary |
podman.compose.up.timeout.min |
3 |
Container startup timeout |
podman.compose.down.timeout.min |
1 |
Container shutdown timeout |
podman.compose.ready.interval.sec |
2 |
Readiness check interval |
Resource Files
Located in src/main/resources/:
Mock Data:
bybit-spot/- 12 JSON files (klines, tickers, orderbooks, trades)bybit-linear/- 13 JSON files (includes allLiquidation)crypto-scout/- 6 JSON files (fgi, lpl, btc price/risk)
Podman Configuration:
podman/podman-compose.yml- Service definitionspodman/script/init.sql- Database initializationpodman/script/bybit_spot_tables.sql- Spot table schemaspodman/script/bybit_linear_tables.sql- Linear table schemaspodman/script/crypto_scout_tables.sql- Crypto scout table schemaspodman/rabbitmq/enabled_plugins- RabbitMQ pluginspodman/rabbitmq/rabbitmq.conf- RabbitMQ configurationpodman/rabbitmq/definitions.json- RabbitMQ definitions
When to Use Me
Use this skill when:
- Implementing new test utilities or mock data fixtures
- Understanding the library's component architecture
- Configuring test environments with Podman containers
- Working with RabbitMQ Streams or AMQP in tests
- Managing database state in integration tests