summaryrefslogtreecommitdiffstats
path: root/client-compiler/tests
diff options
context:
space:
mode:
Diffstat (limited to 'client-compiler/tests')
-rw-r--r--client-compiler/tests/src/com/vaadin/tools/CvalCheckerTest.java27
1 files changed, 23 insertions, 4 deletions
diff --git a/client-compiler/tests/src/com/vaadin/tools/CvalCheckerTest.java b/client-compiler/tests/src/com/vaadin/tools/CvalCheckerTest.java
index 2985f61631..64a38fae2e 100644
--- a/client-compiler/tests/src/com/vaadin/tools/CvalCheckerTest.java
+++ b/client-compiler/tests/src/com/vaadin/tools/CvalCheckerTest.java
@@ -66,9 +66,14 @@ public class CvalCheckerTest {
static final String responseJson = "{'licenseKey':'" + VALID_KEY + "',"
+ "'licensee':'Test User','type':'normal',"
- + "'expiredEpoch':'1893511225000'," + "'product':{'name':'"
+ + "'expiredEpoch':1893511225000," + "'product':{'name':'"
+ productNameCval + "', 'version': 2}}";
+ static final String responseJsonWithNullVersion = "{'licenseKey':'" + VALID_KEY + "',"
+ + "'licensee':'Test User','type':'normal',"
+ + "'expiredEpoch':1893511225000," + "'product':{'name':'"
+ + productNameCval + "', 'version': null}}";
+
private static ByteArrayOutputStream outContent;
// A provider returning a valid license if productKey is valid or null if
@@ -114,7 +119,7 @@ public class CvalCheckerTest {
static final CvalServer unlimitedLicenseProvider = new CvalServer() {
@Override
String askServer(String productName, String productKey, int timeout) {
- return responseJson.replaceFirst("1893511225000", "");
+ return responseJson.replaceFirst("1893511225000", "null");
}
};
// An unreachable provider
@@ -128,6 +133,14 @@ public class CvalCheckerTest {
return super.askServer(productName, productKey, 1000);
}
};
+ // A provider with 'null' in the version field
+ static final CvalServer nullVersionLicenseProvider = new CvalServer() {
+ @Override
+ String askServer(String productName, String productKey, int timeout)
+ throws IOException {
+ return responseJsonWithNullVersion;
+ }
+ };
private CvalChecker licenseChecker;
private String licenseName;
@@ -245,6 +258,7 @@ public class CvalCheckerTest {
Assert.assertTrue(cacheExists(productNameCval));
// Check an unlimited license
+ deleteCache(productNameCval);
licenseChecker.setLicenseProvider(unlimitedLicenseProvider);
licenseChecker
.validateProduct(productNameCval, "2.1", productTitleCval);
@@ -262,6 +276,12 @@ public class CvalCheckerTest {
assertEquals(productNameCval, expected.name);
}
Assert.assertTrue(cacheExists(productNameCval));
+
+ deleteCache(productNameCval);
+ licenseChecker.setLicenseProvider(nullVersionLicenseProvider);
+ licenseChecker
+ .validateProduct(productNameCval, "2.1", productTitleCval);
+ Assert.assertTrue(cacheExists(productNameCval));
}
/*
@@ -282,8 +302,7 @@ public class CvalCheckerTest {
testManifest.getMainAttributes().putValue(VAADIN_ADDON_VERSION, "2");
// Create a temporary Jar
- String tmpDir = System.getProperty("java.io.tmpdir");
- File testJarFile = new File(tmpDir + "vaadin." + productName + ".jar");
+ File testJarFile = File.createTempFile("vaadin." + productName, "jar");
testJarFile.deleteOnExit();
JarOutputStream target = new JarOutputStream(new FileOutputStream(
testJarFile), testManifest);