You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by pt...@apache.org on 2018/01/17 07:24:15 UTC
[5/8] ignite git commit: IGNITE-5725: Adapt TracerTest for TC builds
IGNITE-5725: Adapt TracerTest for TC builds
this closes #3363
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7274c156
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7274c156
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7274c156
Branch: refs/heads/ignite-2.4
Commit: 7274c1565368c0ca1a1fcd45b2123be583348f5e
Parents: 6eccf23
Author: Oleg Ignatenko <oi...@gridgain.com>
Authored: Tue Jan 16 13:35:41 2018 +0300
Committer: Yury Babak <yb...@gridgain.com>
Committed: Tue Jan 16 13:35:41 2018 +0300
----------------------------------------------------------------------
.../org/apache/ignite/ml/math/TracerTest.java | 37 +++++++++++++++-----
1 file changed, 29 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/7274c156/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
----------------------------------------------------------------------
diff --git a/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java b/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
index 1a8534e..cee66eb 100644
--- a/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
+++ b/modules/ml/src/test/java/org/apache/ignite/ml/math/TracerTest.java
@@ -18,6 +18,7 @@
package org.apache.ignite.ml.math;
import java.awt.Color;
+import java.awt.Desktop;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -26,11 +27,11 @@ import java.util.Optional;
import org.apache.ignite.ml.math.impls.MathTestConstants;
import org.apache.ignite.ml.math.impls.matrix.DenseLocalOnHeapMatrix;
import org.apache.ignite.ml.math.impls.vector.DenseLocalOnHeapVector;
-import org.junit.Ignore;
import org.junit.Test;
import static java.nio.file.Files.createTempFile;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
/**
* Tests for {@link Tracer}.
@@ -103,28 +104,26 @@ public class TracerTest {
/** */
@Test
- @Ignore("Can not run on TeamCity yet, see IGNITE-5725")
public void testHtmlVectorTracer() throws IOException {
Vector vec1 = makeRandomVector(1000);
// Default color mapping.
- Tracer.showHtml(vec1);
+ verifyShowHtml(() -> Tracer.showHtml(vec1));
// Custom color mapping.
- Tracer.showHtml(vec1, COLOR_MAPPER);
+ verifyShowHtml(() -> Tracer.showHtml(vec1, COLOR_MAPPER));
// Default color mapping with sorted vector.
- Tracer.showHtml(vec1.copy().sort());
+ verifyShowHtml(() -> Tracer.showHtml(vec1.copy().sort()));
}
/** */
@Test
- @Ignore("Can not run on TeamCity yet, see IGNITE-5725")
public void testHtmlMatrixTracer() throws IOException {
Matrix mtx1 = makeRandomMatrix(100, 100);
// Custom color mapping.
- Tracer.showHtml(mtx1, COLOR_MAPPER);
+ verifyShowHtml(() -> Tracer.showHtml(mtx1, COLOR_MAPPER));
Matrix mtx2 = new DenseLocalOnHeapMatrix(100, 100);
@@ -132,7 +131,7 @@ public class TracerTest {
mtx2.assign((x, y) -> (double)(x * y) / MAX);
- Tracer.showHtml(mtx2);
+ verifyShowHtml(() -> Tracer.showHtml(mtx2));
}
/** */
@@ -222,4 +221,26 @@ public class TracerTest {
Files.deleteIfExists(file);
}
+
+ /** */
+ private void verifyShowHtml(ShowHtml code) throws IOException {
+ final boolean browseSupported = Desktop.isDesktopSupported()
+ && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE);
+
+ try {
+ code.showHtml();
+ if (!browseSupported)
+ fail("Expected exception was not caught: " + UnsupportedOperationException.class.getSimpleName());
+ }
+ catch (UnsupportedOperationException uoe) {
+ if (browseSupported)
+ throw uoe;
+ }
+ }
+
+ /** */
+ @FunctionalInterface private interface ShowHtml {
+ /** */
+ void showHtml() throws IOException;
+ }
}