summaryrefslogtreecommitdiffstats
path: root/client-compiler/src
diff options
context:
space:
mode:
authorAhmed Ashour <asashour@yahoo.com>2017-10-03 12:56:25 +0200
committerHenri Sara <henri.sara@gmail.com>2017-10-03 13:56:25 +0300
commitccad305464af83826de4a4bd25a383360fb356d0 (patch)
treed399448d2910c4cf373e64c690b053740dff43ba /client-compiler/src
parent28b52d687dade66154a4fcd545415bf0d01b0a53 (diff)
downloadvaadin-framework-ccad305464af83826de4a4bd25a383360fb356d0.tar.gz
vaadin-framework-ccad305464af83826de4a4bd25a383360fb356d0.zip
Use static import of Assert in tests (#10126)
Also removes dependency on junit.framework.TestCase .
Diffstat (limited to 'client-compiler/src')
-rw-r--r--client-compiler/src/test/java/com/vaadin/tools/CvalAddonsCheckerTest.java35
-rw-r--r--client-compiler/src/test/java/com/vaadin/tools/CvalAddonstCheckerUseCasesTest.java18
-rw-r--r--client-compiler/src/test/java/com/vaadin/tools/CvalCheckerTest.java49
3 files changed, 53 insertions, 49 deletions
diff --git a/client-compiler/src/test/java/com/vaadin/tools/CvalAddonsCheckerTest.java b/client-compiler/src/test/java/com/vaadin/tools/CvalAddonsCheckerTest.java
index a1a4d835d1..919e5a5b0e 100644
--- a/client-compiler/src/test/java/com/vaadin/tools/CvalAddonsCheckerTest.java
+++ b/client-compiler/src/test/java/com/vaadin/tools/CvalAddonsCheckerTest.java
@@ -32,12 +32,15 @@ import static com.vaadin.tools.CvalCheckerTest.readSystemOut;
import static com.vaadin.tools.CvalCheckerTest.saveCache;
import static com.vaadin.tools.CvalCheckerTest.unreachableLicenseProvider;
import static com.vaadin.tools.CvalCheckerTest.validLicenseProvider;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.List;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -81,10 +84,10 @@ public class CvalAddonsCheckerTest {
addonChecker.setLicenseProvider(validLicenseProvider);
try {
addonChecker.run();
- Assert.fail();
+ fail();
} catch (InvalidCvalException expected) {
}
- Assert.assertFalse(cacheExists(productNameCval));
+ assertFalse(cacheExists(productNameCval));
// We have a license that has never been validated from the server and
// we are offline
@@ -94,8 +97,8 @@ public class CvalAddonsCheckerTest {
addonChecker.setLicenseProvider(unreachableLicenseProvider);
captureSystemOut();
addonChecker.run();
- Assert.assertTrue(readSystemOut().contains("has not been validated"));
- Assert.assertFalse(cacheExists(productNameCval));
+ assertTrue(readSystemOut().contains("has not been validated"));
+ assertFalse(cacheExists(productNameCval));
// Valid license has previously been validated from the server and we
// are offline
@@ -104,7 +107,7 @@ public class CvalAddonsCheckerTest {
addonChecker.setLicenseProvider(validLicenseProvider);
captureSystemOut();
addonChecker.run();
- Assert.assertTrue(cacheExists(productNameCval));
+ assertTrue(cacheExists(productNameCval));
addonChecker.setLicenseProvider(unreachableLicenseProvider);
addonChecker.run();
@@ -124,7 +127,7 @@ public class CvalAddonsCheckerTest {
"normal");
try {
addonChecker.run();
- Assert.fail();
+ fail();
} catch (InvalidCvalException expected) {
}
@@ -137,9 +140,9 @@ public class CvalAddonsCheckerTest {
"evaluation");
try {
addonChecker.run();
- Assert.fail();
+ fail();
} catch (InvalidCvalException expected) {
- Assert.assertTrue(expected.getMessage().contains("expired"));
+ assertTrue(expected.getMessage().contains("expired"));
}
// Valid evaluation license
@@ -151,9 +154,9 @@ public class CvalAddonsCheckerTest {
setCacheFileTs(System.currentTimeMillis() + GRACE_DAYS_MSECS,
"evaluation");
List<CValUiInfo> uiInfo = addonChecker.run();
- Assert.assertEquals(1, uiInfo.size());
- Assert.assertEquals("Test " + productNameCval, uiInfo.get(0).product);
- Assert.assertEquals("evaluation", uiInfo.get(0).type);
+ assertEquals(1, uiInfo.size());
+ assertEquals("Test " + productNameCval, uiInfo.get(0).product);
+ assertEquals("evaluation", uiInfo.get(0).type);
// Valid real license
// -> Work as expected
@@ -164,7 +167,7 @@ public class CvalAddonsCheckerTest {
addonChecker.setLicenseProvider(validLicenseProvider);
captureSystemOut();
addonChecker.run();
- Assert.assertTrue(readSystemOut().contains("valid"));
+ assertTrue(readSystemOut().contains("valid"));
}
@Test
@@ -178,9 +181,9 @@ public class CvalAddonsCheckerTest {
captureSystemOut();
addonChecker.run();
String out = readSystemOut();
- Assert.assertTrue(out.contains("valid"));
- Assert.assertTrue(out.contains("AGPL"));
- Assert.assertTrue(cacheExists(productNameCval));
+ assertTrue(out.contains("valid"));
+ assertTrue(out.contains("AGPL"));
+ assertTrue(cacheExists(productNameCval));
}
private void setCacheFileTs(long expireTs, String type) {
diff --git a/client-compiler/src/test/java/com/vaadin/tools/CvalAddonstCheckerUseCasesTest.java b/client-compiler/src/test/java/com/vaadin/tools/CvalAddonstCheckerUseCasesTest.java
index 4d1696b62a..e3180c4743 100644
--- a/client-compiler/src/test/java/com/vaadin/tools/CvalAddonstCheckerUseCasesTest.java
+++ b/client-compiler/src/test/java/com/vaadin/tools/CvalAddonstCheckerUseCasesTest.java
@@ -34,11 +34,12 @@ import static com.vaadin.tools.CvalCheckerTest.saveCache;
import static com.vaadin.tools.CvalCheckerTest.unreachableLicenseProvider;
import static com.vaadin.tools.CvalCheckerTest.validEvaluationLicenseProvider;
import static com.vaadin.tools.CvalCheckerTest.validLicenseProvider;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.net.URL;
import java.net.URLClassLoader;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -220,7 +221,8 @@ public class CvalAddonstCheckerUseCasesTest {
deleteCache(productNameCval);
} else {
String type = lic == License.EVAL || lic == License.EVAL_EXPIRED
- ? "evaluation" : null;
+ ? "evaluation"
+ : null;
Boolean expired = lic == License.EVAL_EXPIRED
|| lic == License.REAL_EXPIRED ? true : null;
String key = val == Validated.OLD_KEY ? "oldkey" : null;
@@ -247,26 +249,24 @@ public class CvalAddonstCheckerUseCasesTest {
addonChecker.run();
message = readSystemOut();
if (res == Compile.NO) {
- Assert.fail(testNumber + "Exception not thrown:" + message);
+ fail(testNumber + "Exception not thrown:" + message);
}
} catch (Exception e) {
restoreSystemOut();
message = e.getMessage();
if (res == Compile.YES) {
- Assert.fail(
- testNumber + "Unexpected Exception: " + e.getMessage());
+ fail(testNumber + "Unexpected Exception: " + e.getMessage());
}
}
// System.err.println("\n> " + testNumber + " " + lic + " " + ver + " "
// + val + " " + net + " " + res + " " + cached + "\n" + message);
- Assert.assertTrue(testNumber + "Fail:\n" + message + "\nDoes not match:"
+ assertTrue(testNumber + "Fail:\n" + message + "\nDoes not match:"
+ msg.msg, message.matches("(?s).*" + msg.msg + ".*"));
String c = cachedPreferences(productNameCval);
- Assert.assertTrue(testNumber + "Fail: cacheExists != "
- + (cached == Cached.YES) + "\n " + c,
- (c != null) == (cached == Cached.YES));
+ assertTrue(testNumber + "Fail: cacheExists != " + (cached == Cached.YES)
+ + "\n " + c, (c != null) == (cached == Cached.YES));
}
}
diff --git a/client-compiler/src/test/java/com/vaadin/tools/CvalCheckerTest.java b/client-compiler/src/test/java/com/vaadin/tools/CvalCheckerTest.java
index 441a8aa626..3e71eef4ca 100644
--- a/client-compiler/src/test/java/com/vaadin/tools/CvalCheckerTest.java
+++ b/client-compiler/src/test/java/com/vaadin/tools/CvalCheckerTest.java
@@ -25,8 +25,10 @@ import static com.vaadin.tools.CvalChecker.cacheLicenseInfo;
import static com.vaadin.tools.CvalChecker.deleteCache;
import static com.vaadin.tools.CvalChecker.parseJson;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -43,7 +45,6 @@ import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import java.util.prefs.Preferences;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -162,58 +163,58 @@ public class CvalCheckerTest {
try {
licenseChecker.validateProduct(productNameCval, "2.1",
productTitleCval);
- Assert.fail();
+ fail();
} catch (InvalidCvalException expected) {
assertEquals(productNameCval, expected.name);
}
- Assert.assertFalse(cacheExists(productNameCval));
+ assertFalse(cacheExists(productNameCval));
// If the license key is empty, throw an exception
System.setProperty(licenseName, "");
try {
licenseChecker.validateProduct(productNameCval, "2.1",
productTitleCval);
- Assert.fail();
+ fail();
} catch (InvalidCvalException expected) {
assertEquals(productNameCval, expected.name);
}
- Assert.assertFalse(cacheExists(productNameCval));
+ assertFalse(cacheExists(productNameCval));
// If license key is invalid, throw an exception
System.setProperty(licenseName, "invalid");
try {
licenseChecker.validateProduct(productNameCval, "2.1",
productTitleCval);
- Assert.fail();
+ fail();
} catch (InvalidCvalException expected) {
assertEquals(productNameCval, expected.name);
}
- Assert.assertFalse(cacheExists(productNameCval));
+ assertFalse(cacheExists(productNameCval));
// Fail if version is bigger
System.setProperty(licenseName, VALID_KEY);
try {
licenseChecker.validateProduct(productNameCval, "3.0",
productTitleCval);
- Assert.fail();
+ fail();
} catch (InvalidCvalException expected) {
assertEquals(productNameCval, expected.name);
assertTrue(expected.getMessage().contains("is not valid"));
}
- Assert.assertFalse(cacheExists(productNameCval));
+ assertFalse(cacheExists(productNameCval));
// Success if license key and version are valid
System.setProperty(licenseName, VALID_KEY);
licenseChecker.validateProduct(productNameCval, "2.1",
productTitleCval);
- Assert.assertTrue(cacheExists(productNameCval));
+ assertTrue(cacheExists(productNameCval));
// Success if license and cache file are valid, although the license
// server is offline
licenseChecker.setLicenseProvider(unreachableLicenseProvider);
licenseChecker.validateProduct(productNameCval, "2.1",
productTitleCval);
- Assert.assertTrue(cacheExists(productNameCval));
+ assertTrue(cacheExists(productNameCval));
// Fail if license key changes although cache file were validated
// previously and it is ok, we are offline
@@ -221,13 +222,13 @@ public class CvalCheckerTest {
System.setProperty(licenseName, INVALID_KEY);
licenseChecker.validateProduct(productNameCval, "2.1",
productTitleCval);
- Assert.fail();
+ fail();
} catch (InvalidCvalException expected) {
- Assert.fail();
+ fail();
} catch (UnreachableCvalServerException expected) {
assertEquals(productNameCval, expected.name);
}
- Assert.assertFalse(cacheExists(productNameCval));
+ assertFalse(cacheExists(productNameCval));
// Fail with unreachable exception if license has never verified and
// server is offline
@@ -235,13 +236,13 @@ public class CvalCheckerTest {
System.setProperty(licenseName, VALID_KEY);
licenseChecker.validateProduct(productNameCval, "2.1",
productTitleCval);
- Assert.fail();
+ fail();
} catch (InvalidCvalException expected) {
- Assert.fail();
+ fail();
} catch (UnreachableCvalServerException expected) {
assertEquals(productNameCval, expected.name);
}
- Assert.assertFalse(cacheExists(productNameCval));
+ assertFalse(cacheExists(productNameCval));
// Fail when expired flag comes in the server response, although the
// expired is valid.
@@ -250,20 +251,20 @@ public class CvalCheckerTest {
try {
licenseChecker.validateProduct(productNameCval, "2.1",
productTitleCval);
- Assert.fail();
+ fail();
} catch (InvalidCvalException expected) {
assertEquals(productNameCval, expected.name);
// Check that we use server customized message if it comes
- Assert.assertTrue(expected.getMessage().contains("Custom"));
+ assertTrue(expected.getMessage().contains("Custom"));
}
- Assert.assertTrue(cacheExists(productNameCval));
+ assertTrue(cacheExists(productNameCval));
// Check an unlimited license
deleteCache(productNameCval);
licenseChecker.setLicenseProvider(unlimitedLicenseProvider);
licenseChecker.validateProduct(productNameCval, "2.1",
productTitleCval);
- Assert.assertTrue(cacheExists(productNameCval));
+ assertTrue(cacheExists(productNameCval));
// Fail if expired flag does not come, but expired epoch is in the past
System.setProperty(licenseName, VALID_KEY);
@@ -272,17 +273,17 @@ public class CvalCheckerTest {
try {
licenseChecker.validateProduct(productNameCval, "2.1",
productTitleCval);
- Assert.fail();
+ fail();
} catch (InvalidCvalException expected) {
assertEquals(productNameCval, expected.name);
}
- Assert.assertTrue(cacheExists(productNameCval));
+ assertTrue(cacheExists(productNameCval));
deleteCache(productNameCval);
licenseChecker.setLicenseProvider(nullVersionLicenseProvider);
licenseChecker.validateProduct(productNameCval, "2.1",
productTitleCval);
- Assert.assertTrue(cacheExists(productNameCval));
+ assertTrue(cacheExists(productNameCval));
}
/*