diff --git a/VERSION b/VERSION index b3d91f9c..450ad1e2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -5.9.0 +5.9.1 diff --git a/gortools/src/main/scala/gorsat/Utilities/IteratorUtilities.scala b/gortools/src/main/scala/gorsat/Utilities/IteratorUtilities.scala index df3a9877..b5d0ab1b 100644 --- a/gortools/src/main/scala/gorsat/Utilities/IteratorUtilities.scala +++ b/gortools/src/main/scala/gorsat/Utilities/IteratorUtilities.scala @@ -43,7 +43,7 @@ object IteratorUtilities { private val logger = LoggerFactory.getLogger(this.getClass) - private val ALLOW_DUPLICATE_COLUMNS = System.getProperty("gor.iterators.allowDuplicateColumns", "true").toBoolean + val ALLOW_DUPLICATE_COLUMNS_KEY = "gor.iterators.allowDuplicateColumns" def getHeader(filename: String, gorRoot: String, context: GorContext): String = { val gm: GorMonitor = null @@ -89,7 +89,7 @@ object IteratorUtilities { //just appending x to used columns var colToUp = column.toUpperCase while (usedCols.contains(colToUp)) { - if (ALLOW_DUPLICATE_COLUMNS || allowDuplicates) { + if (System.getProperty(ALLOW_DUPLICATE_COLUMNS_KEY, "false").toBoolean || allowDuplicates) { column = column + "x" colToUp = column.toUpperCase if (!allowDuplicates) { diff --git a/gortools/src/test/java/gorsat/UTestHeaderFlags.java b/gortools/src/test/java/gorsat/UTestHeaderFlags.java index d63415e2..4984fe5b 100644 --- a/gortools/src/test/java/gorsat/UTestHeaderFlags.java +++ b/gortools/src/test/java/gorsat/UTestHeaderFlags.java @@ -83,7 +83,6 @@ public void testValidHeaderUsedKeywordsWithDupAllowingDup() { Assert.assertFalse(systemErrRule.getLog().contains("Duplicate column name 'order'")); } - @Ignore("Only works if run alone, as the property is read only on class load") @Test public void testValidHeaderUsedKeywordsWithDupNotAllowingDup() { System.setProperty("gor.iterators.allowDuplicateColumns", "false"); @@ -94,6 +93,7 @@ public void testValidHeaderUsedKeywordsWithDupNotAllowingDup() { @Test public void testValidHeaderUsedKeywordsWithDupAllowingDupOnlyGlobal() { + System.setProperty("gor.iterators.allowDuplicateColumns", "true"); String testHeader = "#abc\tstart\tfrom\tselect\tmax\tmin\tfrom\tgroup\trange\torder\trank\torder"; String resultingHeader = IteratorUtilities.validHeader(testHeader, false); Assert.assertEquals("#abc\tstart\tfrom\tselect\tmax\tmin\tfromx\tgroup\trange\torder\trank\torderx", resultingHeader); diff --git a/gortools/src/test/java/gorsat/UTestRename.java b/gortools/src/test/java/gorsat/UTestRename.java index 347ea669..549d8fc4 100644 --- a/gortools/src/test/java/gorsat/UTestRename.java +++ b/gortools/src/test/java/gorsat/UTestRename.java @@ -25,13 +25,18 @@ import org.gorpipe.exceptions.GorDataException; import org.gorpipe.exceptions.GorParsingException; import org.junit.Assert; -import org.junit.Ignore; +import org.junit.Rule; import org.junit.Test; +import org.junit.contrib.java.lang.system.RestoreSystemProperties; import java.io.IOException; import java.nio.file.Files; public class UTestRename { + + @Rule + public final RestoreSystemProperties restoreSystemProperties = new RestoreSystemProperties(); + @Test public void testSimpleRename() { String query = "gorrow chr1,1,1 | calc Foo_0001 0 | rename Foo_0001 Bar_CAR | top 0"; @@ -141,12 +146,12 @@ public void renameStrictWithNoMatch() { @Test public void renameToExistingAllowDup() { + System.setProperty("gor.iterators.allowDuplicateColumns", "true"); String query = "gorrow chr1,1 | calc Foo 0 | calc Bar 1 | rename Foo Bar | top 0"; String result = TestUtils.runGorPipe(query); Assert.assertEquals("chrom\tpos\tBar\tBarx\n", result); } - @Ignore("Only works if run alone, as the property is read only on class load") @Test public void renameToExistingNotAllowDup() { System.setProperty("gor.iterators.allowDuplicateColumns", "false"); diff --git a/gortools/src/test/java/gorsat/parser/UTestCalc.java b/gortools/src/test/java/gorsat/parser/UTestCalc.java index 530a65b4..75397017 100644 --- a/gortools/src/test/java/gorsat/parser/UTestCalc.java +++ b/gortools/src/test/java/gorsat/parser/UTestCalc.java @@ -39,14 +39,12 @@ public void addsNewColumn() { Assert.assertEquals(expected, result); } - @Ignore("Only works if run alone, as the property is read only on class load") @Test public void addsNewExistingColumn() { System.setProperty("gor.iterators.allowDuplicateColumns", "false"); Assert.assertThrows(GorDataException.class, () -> TestUtils.runGorPipe("gorrow 1,1 | calc pos 42")); } - @Ignore("Only works if run alone, as the property is read only on class load") @Test public void addsNewColumnWithSuffixWhenItExists() { System.setProperty("gor.iterators.allowDuplicateColumns", "false");