chore: initial import of lingniu-vehicle-ingest
Multi-module Spring Boot ingest service for vehicle telemetry. Modules: - ingest-api / ingest-core / ingest-codec-common: shared SPI, dispatcher, Disruptor event bus, BCC/BCD codec helpers - protocol-gb32960: GB/T 32960.3 inbound (Netty + per-version parser packages v2016/v2025), platform login auth, VIN whitelist, idle handler - protocol-jt808 / protocol-jt1078 / protocol-jsatl12: JT/T inbound - inbound-mqtt / inbound-xinda-push: alternative ingest channels - session-core: per-channel session state - sink-archive / sink-mq: persistence sinks (local file / Kafka) - command-gateway: terminal control command gateway - bootstrap-all: aggregator Spring Boot app - observability: Micrometer / Actuator wiring Includes hex-dump golden samples under protocol-gb32960/src/test/resources and the GB/T 32960.3-2016 / 2025 reference PDFs under reference/. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package com.lingniu.ingest.sink.archive;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class LocalArchiveStoreTest {
|
||||
|
||||
@Test
|
||||
void putThenGet(@TempDir Path tmp) throws Exception {
|
||||
LocalArchiveStore store = new LocalArchiveStore(tmp.toString());
|
||||
byte[] data = "hello-raw".getBytes();
|
||||
String ref = store.put("2026/04/13/sample.bin", new ByteArrayInputStream(data), data.length);
|
||||
assertThat(ref).startsWith("file://");
|
||||
assertThat(store.exists("2026/04/13/sample.bin")).isTrue();
|
||||
assertThat(store.size("2026/04/13/sample.bin")).isEqualTo(data.length);
|
||||
}
|
||||
|
||||
@Test
|
||||
void appendChunksAccumulate(@TempDir Path tmp) throws Exception {
|
||||
LocalArchiveStore store = new LocalArchiveStore(tmp.toString());
|
||||
store.append("chunks/a.bin", new byte[]{1, 2, 3});
|
||||
store.append("chunks/a.bin", new byte[]{4, 5});
|
||||
assertThat(store.size("chunks/a.bin")).isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsPathTraversal(@TempDir Path tmp) throws Exception {
|
||||
LocalArchiveStore store = new LocalArchiveStore(tmp.toString());
|
||||
store.append("../../evil.bin", new byte[]{1});
|
||||
// 目录穿越:每个 .. 被替换为 _
|
||||
assertThat(store.exists("_/_/evil.bin")).isTrue();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user