From f4be9f5fe16463f8c183a41399c01ca22de21b3d Mon Sep 17 00:00:00 2001 From: omkar Date: Mon, 15 Oct 2018 22:28:30 +0530 Subject: [PATCH] Misc refactoring and made all the tests in the SmartSplitTests class independent by replacing BeforeSuite with BeforeTest --- .../functions/strings/SmartSplitTests.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/main/tests/server/src/com/google/refine/tests/expr/functions/strings/SmartSplitTests.java b/main/tests/server/src/com/google/refine/tests/expr/functions/strings/SmartSplitTests.java index a7d34f6e4..1b7fba3ac 100644 --- a/main/tests/server/src/com/google/refine/tests/expr/functions/strings/SmartSplitTests.java +++ b/main/tests/server/src/com/google/refine/tests/expr/functions/strings/SmartSplitTests.java @@ -2,9 +2,11 @@ package com.google.refine.tests.expr.functions.strings; import static org.junit.Assert.assertArrayEquals; import static org.testng.Assert.assertTrue; + import java.util.Properties; -import org.testng.annotations.AfterSuite; -import org.testng.annotations.BeforeSuite; + +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; import com.google.refine.expr.EvalError; @@ -16,29 +18,28 @@ import com.google.refine.tests.util.TestUtils; public class SmartSplitTests { private static Properties bindings; - private static String FUNCTION_NAME = "smartSplit"; - @BeforeSuite + @BeforeTest public void setUp() { bindings = new Properties(); } - @AfterSuite + @AfterTest public void tearDown() { bindings = null; } @Test public void testSmartSplitInvalidParams() { - assertTrue(invoke(FUNCTION_NAME) instanceof EvalError); - assertTrue(invoke(FUNCTION_NAME, "teststring1", 1, "teststring2", 2) instanceof EvalError); + assertTrue(invoke("smartSplit") instanceof EvalError); + assertTrue(invoke("smartSplit", "teststring1", 1, "teststring2", 2) instanceof EvalError); } @Test public void testSmartSplitGuessComma() { String testString = "teststring1,teststring2,teststring3,teststring4"; String[] expected = { "teststring1", "teststring2", "teststring3", "teststring4" }; - String[] actual = (String[]) invoke(FUNCTION_NAME, testString); + String[] actual = (String[]) invoke("smartSplit", testString); assertArrayEquals(expected, actual); } @@ -46,7 +47,7 @@ public class SmartSplitTests { public void testSmartSplitGuessTab() { String testString = "teststring1 teststring2 teststring3 teststring4"; String[] expected = { "teststring1", "teststring2", "teststring3", "teststring4" }; - String[] actual = (String[]) invoke(FUNCTION_NAME, testString); + String[] actual = (String[]) invoke("smartSplit", testString); assertArrayEquals(expected, actual); } @@ -54,7 +55,7 @@ public class SmartSplitTests { public void testSmartSplitCharSepGiven() { String testString = "teststring1#teststring2#teststring3#teststring4"; String[] expected = { "teststring1", "teststring2", "teststring3", "teststring4" }; - String[] actual = (String[]) invoke(FUNCTION_NAME, testString, '#'); + String[] actual = (String[]) invoke("smartSplit", testString, '#'); assertArrayEquals(expected, actual); } @@ -62,7 +63,7 @@ public class SmartSplitTests { public void testSmartSplitCharSepSpace() { String testString = "teststring1 teststring2 teststring3 teststring4"; String[] expected = { "teststring1", "teststring2", "teststring3", "teststring4" }; - String[] actual = (String[]) invoke(FUNCTION_NAME, testString, ' '); + String[] actual = (String[]) invoke("smartSplit", testString, ' '); assertArrayEquals(expected, actual); } @@ -70,7 +71,7 @@ public class SmartSplitTests { public void testSmartSplitStringSepGiven() { String testString = "teststring1#@$teststring2#@$teststring3#@$teststring4"; String[] expected = { "teststring1", "teststring2", "teststring3", "teststring4" }; - String[] actual = (String[]) invoke(FUNCTION_NAME, testString, "#@$"); + String[] actual = (String[]) invoke("smartSplit", testString, "#@$"); assertArrayEquals(expected, actual); }