#!/bin/sh
# autopkgtest check: run the example Java code.
# (C) 2022 Pierre Gruet.
# Author: Pierre Gruet <pgt@debian.org>

set -e

WORKDIR=$(mktemp -d)
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM

cp /usr/share/doc/libgenomicsdb-java/examples/TestGenomicsDB.java $WORKDIR
cp -r tests/inputs $WORKDIR

cd $WORKDIR

(cd inputs/ && tar xf compatibility.pre.1.0.0.test.tar)

sed -i "s,#WORKSPACE_DIR#,${WORKDIR}/inputs," inputs/t0_1_2*

javac -cp /usr/share/java/genomicsdb.jar TestGenomicsDB.java
java -cp /usr/share/java/genomicsdb.jar:. TestGenomicsDB --query -l inputs/t0_1_2.json inputs/t0_1_2_java_vcf.json 
