summaryrefslogtreecommitdiffstats
path: root/client-compiler
diff options
context:
space:
mode:
Diffstat (limited to 'client-compiler')
-rw-r--r--client-compiler/build.xml15
-rw-r--r--client-compiler/ivy.xml7
-rw-r--r--client-compiler/src/com/vaadin/tools/CvalChecker.java13
-rw-r--r--client-compiler/tests/src/com/vaadin/tools/CvalCheckerTest.java27
4 files changed, 50 insertions, 12 deletions
diff --git a/client-compiler/build.xml b/client-compiler/build.xml
index 97189fc437..be8dec18bc 100644
--- a/client-compiler/build.xml
+++ b/client-compiler/build.xml
@@ -16,7 +16,16 @@
<path id="classpath.compile.custom">
<fileset file="${gwt.dev.jar}" />
</path>
-
+ <path id="classpath.test.custom">
+ <fileset dir="${result.dir}/classes">
+ <include name="**/*" />
+ </fileset>
+ </path>
+ <property name="extra.classes" value="**/*.properties" />
+ <!-- don't try to copy the same files twice (first from classes and then
+ from sources) in order for the build not to fail when packaging the
+ JAR -->
+ <property name="jar.exclude" value="**/*.properties" />
<union id="compiler.includes">
<union refid="client-compiler.gwt.includes" />
<fileset dir="${result.dir}">
@@ -62,8 +71,8 @@
</target>
<target name="test" depends="checkstyle">
- <!--<antcall target="common.test.run" /> -->
- <echo>WHAT? No tests for ${module.name}!</echo>
+ <antcall target="common.test.run" />
+ <!--<echo>WHAT? No tests for ${module.name}!</echo>-->
</target>
</project>
diff --git a/client-compiler/ivy.xml b/client-compiler/ivy.xml
index af60b76e22..d30dea5136 100644
--- a/client-compiler/ivy.xml
+++ b/client-compiler/ivy.xml
@@ -11,6 +11,7 @@
<conf name="build" />
<conf name="build-provided" />
<conf name="ide" visibility="private" />
+ <conf name="test" visibility="private" />
</configurations>
<publications>
<artifact type="jar" ext="jar" />
@@ -24,7 +25,7 @@
<dependency org="com.vaadin" name="vaadin-server"
rev="${vaadin.version}" conf="build" />
<dependency org="com.vaadin" name="vaadin-client"
- rev="${vaadin.version}" conf="build" />
+ rev="${vaadin.version}" conf="build,test" />
<dependency org="com.vaadin" name="vaadin-sass-compiler"
rev="${vaadin.sass.version}" conf="build,ide->default">
<!-- remove cssparser override once sass-compiler is updated -->
@@ -96,6 +97,10 @@
<dependency org="com.vaadin" name="vaadin-client-compiler-deps"
rev="1.2.0" conf="build,ide -> default" />
+ <dependency org="junit" name="junit" rev="4.11"
+ conf="test,ide -> default" />
+
+
</dependencies>
</ivy-module>
diff --git a/client-compiler/src/com/vaadin/tools/CvalChecker.java b/client-compiler/src/com/vaadin/tools/CvalChecker.java
index b3345c7658..645667be94 100644
--- a/client-compiler/src/com/vaadin/tools/CvalChecker.java
+++ b/client-compiler/src/com/vaadin/tools/CvalChecker.java
@@ -35,16 +35,17 @@ import java.util.prefs.Preferences;
import org.apache.commons.io.IOUtils;
import elemental.json.JsonException;
+import elemental.json.JsonNull;
import elemental.json.JsonObject;
import elemental.json.impl.JsonUtil;
/**
* This class is able to validate the vaadin CVAL license.
- *
+ *
* It reads the developer license file and asks the server to validate the
* licenseKey. If the license is invalid it throws an exception with the
* information about the problem and the server response.
- *
+ *
* @since 7.3
*/
public final class CvalChecker {
@@ -80,6 +81,10 @@ public final class CvalChecker {
private static <T> T get(JsonObject o, String k, Class<T> clz) {
Object ret = null;
try {
+ if (o == null || o.get(k) == null
+ || o.get(k) instanceof JsonNull) {
+ return null;
+ }
if (clz == String.class) {
ret = o.getString(k);
} else if (clz == JsonObject.class) {
@@ -299,7 +304,7 @@ public final class CvalChecker {
/**
* Given a product name returns the name of the file with the license key.
- *
+ *
* Traditionally we have delivered license keys with a name like
* 'vaadin.touchkit.developer.license' but our database product name is
* 'vaadin-touchkit' so we have to replace '-' by '.' to maintain
@@ -340,7 +345,7 @@ public final class CvalChecker {
/**
* Validate whether there is a valid license key for a product.
- *
+ *
* @param productName
* for example vaadin-touchkit
* @param productVersion
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);