add julia test file

This commit is contained in:
2026-03-09 02:29:14 +07:00
parent 19773fddc9
commit a2380282ff
4 changed files with 13 additions and 252 deletions

View File

@@ -13,7 +13,7 @@ include("../src/NATSBridge.jl")
using .NATSBridge
# Configuration
const SUBJECT = "/NATSBridge_mix_test"
const SUBJECT = "/natsbridge"
const NATS_URL = "nats.yiem.cc"
const FILESERVER_URL = "http://192.168.88.104:8080"
@@ -97,15 +97,10 @@ function test_mix_receive()
# Arrow table data - should be Arrow.Table
if isa(data, Arrow.Table)
log_trace(" Type: Arrow.Table")
log_trace(" Dimensions: $(size(data, 1)) rows x $(size(data, 2)) columns")
log_trace(" Columns: $(names(data))")
# Display first few rows
log_trace(" First 5 rows:")
display(data[1:min(5, size(data, 1)), :])
# Convert to DataFrame for display and save
df = DataFrame(data)
@show df[1:3, :]
output_path = "./received_$dataname.arrow"
io = IOBuffer()
Arrow.write(io, data)
@@ -117,18 +112,13 @@ function test_mix_receive()
elseif data_type == "jsontable"
# JSON table data - should be Vector{Dict} or Vector{NamedTuple}
if isa(data, Vector{<:Union{JSON.Object, Dict, NamedTuple}})
@show "jsontable" typeof(data)
if isa(data, Vector{Any})
log_trace(" Type: Vector{Dict/NamedTuple}")
log_trace(" Number of rows: $(length(data))")
# Display first few rows
log_trace(" First 3 rows:")
for i in 1:min(3, length(data))
log_trace(" Row $i: $(data[i])")
end
# Convert to DataFrame for display and save
df = DataFrame(data)
@show df[1:3, :]
log_trace(" Converted to DataFrame: $(size(df, 1)) rows x $(size(df, 2)) columns")
# Save as JSON file
@@ -147,28 +137,6 @@ function test_mix_receive()
log_trace(" ERROR: Expected Vector{Dict/NamedTuple}, got $(typeof(data))")
end
elseif data_type == "table"
# Table data - should be a DataFrame (backward compatibility)
data = DataFrame(data)
if isa(data, DataFrame)
log_trace(" Type: DataFrame")
log_trace(" Dimensions: $(size(data, 1)) rows x $(size(data, 2)) columns")
log_trace(" Columns: $(names(data))")
# Display first few rows
log_trace(" First 5 rows:")
display(data[1:min(5, size(data, 1)), :])
# Save to Arrow file
output_path = "./received_$dataname.arrow"
io = IOBuffer()
Arrow.write(io, data)
write(output_path, take!(io))
log_trace(" Saved to: $output_path")
else
log_trace(" ERROR: Expected DataFrame, got $(typeof(data))")
end
elseif data_type == "image"
# Image data - should be Vector{UInt8}
if isa(data, Vector{UInt8})
@@ -218,7 +186,7 @@ function test_mix_receive()
log_trace(" Size: $(length(data)) bytes")
# Save to file
output_path = "./received_$dataname.bin"
output_path = "./received_$dataname"
write(output_path, data)
log_trace(" Saved to: $output_path")
else
@@ -258,12 +226,12 @@ function test_mix_receive()
if data_type in ["image", "audio", "video", "binary"]
log_trace("$dataname: $(length(data)) bytes (binary)")
elseif data_type == "arrowtable"
log_trace("$dataname: $(size(data, 1)) rows x $(size(data, 2)) columns (Arrow.Table)")
# log_trace("$dataname: $(size(data, 1)) rows x $(size(data, 2)) columns (Arrow.Table)")
elseif data_type == "jsontable"
log_trace("$dataname: $(length(data)) rows (Vector{Dict/NamedTuple})")
elseif data_type == "table"
data = DataFrame(data)
log_trace("$dataname: $(size(data, 1)) rows x $(size(data, 2)) columns (DataFrame)")
# log_trace("$dataname: $(size(data, 1)) rows x $(size(data, 2)) columns (DataFrame)")
elseif data_type == "dictionary"
log_trace("$dataname: $(length(JSON.json(data))) bytes (Dict)")
elseif data_type == "text"