[jvm-packages] jvm test should clean up after themselfs (#4706)

This commit is contained in:
Oleksandr Pryimak
2019-08-04 14:09:11 -07:00
committed by Nan Zhu
parent 4fe0d8203e
commit b68de018b8
5 changed files with 62 additions and 53 deletions

View File

@@ -126,11 +126,10 @@ public class BoosterImplTest {
Booster booster = trainBooster(trainMat, testMat);
Path tempDir = Files.createTempDirectory("boosterTest-");
File tempFile = Files.createTempFile("", "").toFile();
booster.saveModel(new FileOutputStream(tempFile));
ByteArrayOutputStream output = new ByteArrayOutputStream();
booster.saveModel(output);
IEvaluation eval = new EvalError();
Booster loadedBooster = XGBoost.loadModel(new FileInputStream(tempFile));
Booster loadedBooster = XGBoost.loadModel(new ByteArrayInputStream(output.toByteArray()));
float originalPredictError = eval.eval(booster.predict(testMat, true), testMat);
TestCase.assertTrue("originalPredictErr:" + originalPredictError,
originalPredictError < 0.1f);