thingsboard-aplcache

Fixed device api sql test

7/3/2017 5:34:11 AM

Details

diff --git a/application/src/test/java/org/thingsboard/server/system/SystemSqlTestSuite.java b/application/src/test/java/org/thingsboard/server/system/SystemSqlTestSuite.java
index 6a46ede..1f62027 100644
--- a/application/src/test/java/org/thingsboard/server/system/SystemSqlTestSuite.java
+++ b/application/src/test/java/org/thingsboard/server/system/SystemSqlTestSuite.java
@@ -32,8 +32,9 @@ public class SystemSqlTestSuite {
     @ClassRule
     public static CustomSqlUnit sqlUnit = new CustomSqlUnit(
             Arrays.asList("sql/schema.sql", "sql/system-data.sql"),
-            "sql-test.properties",
-            "sql/drop-all-tables.sql");
+            "sql/drop-all-tables.sql",
+            "sql-test.properties"
+    );
 
 
 }
diff --git a/dao/src/main/resources/sql/schema.sql b/dao/src/main/resources/sql/schema.sql
index a3aa723..9e1143f 100644
--- a/dao/src/main/resources/sql/schema.sql
+++ b/dao/src/main/resources/sql/schema.sql
@@ -228,7 +228,7 @@ CREATE TABLE IF NOT EXISTS widget_type (
     id uuid NOT NULL CONSTRAINT widget_type_pkey PRIMARY KEY,
     alias character varying(255),
     bundle_alias character varying(255),
-    descriptor varchar(2000000),
+    descriptor varchar(1000000),
     name character varying(255),
     tenant_id uuid
 );
diff --git a/dao/src/test/java/org/thingsboard/server/dao/CustomSqlUnit.java b/dao/src/test/java/org/thingsboard/server/dao/CustomSqlUnit.java
index 8bac128..491e642 100644
--- a/dao/src/test/java/org/thingsboard/server/dao/CustomSqlUnit.java
+++ b/dao/src/test/java/org/thingsboard/server/dao/CustomSqlUnit.java
@@ -36,16 +36,24 @@ import java.util.Properties;
 @Slf4j
 public class CustomSqlUnit extends ExternalResource {
 
-    private List<String> sqlFiles;
-    private String dropAllTablesSqlFile;
-    private String dbUrl;
-    private String dbUserName;
-    private String dbPassword;
+    private final List<String> sqlFiles;
+    private final String dropAllTablesSqlFile;
+    private final String dbUrl;
+    private final String dbUserName;
+    private final String dbPassword;
 
-    public CustomSqlUnit(List<String> sqlFiles, String configurationFileName, String dropAllTablesSqlFile) {
+    public CustomSqlUnit(List<String> sqlFiles, String dropAllTablesSqlFile, String configurationFileName) {
         this.sqlFiles = sqlFiles;
         this.dropAllTablesSqlFile = dropAllTablesSqlFile;
-        loadProperties(configurationFileName);
+        final Properties properties = new Properties();
+        try (final InputStream stream = this.getClass().getClassLoader().getResourceAsStream(configurationFileName)) {
+            properties.load(stream);
+            this.dbUrl = properties.getProperty("spring.datasource.url");
+            this.dbUserName = properties.getProperty("spring.datasource.username");
+            this.dbPassword = properties.getProperty("spring.datasource.password");
+        } catch (IOException e) {
+            throw new RuntimeException(e.getMessage(), e);
+        }
     }
 
     @Override
@@ -91,17 +99,4 @@ public class CustomSqlUnit extends ExternalResource {
             }
         }
     }
-
-    private void loadProperties(String fileName) {
-        final Properties properties = new Properties();
-        try (final InputStream stream = this.getClass().getClassLoader().getResourceAsStream(fileName)) {
-            properties.load(stream);
-            this.dbUrl = properties.getProperty("spring.datasource.url");
-            this.dbUserName = properties.getProperty("spring.datasource.username");
-            this.dbPassword = properties.getProperty("spring.datasource.password");
-        } catch (IOException e) {
-            throw new RuntimeException(e.getMessage(), e);
-        }
-
-    }
 }
diff --git a/dao/src/test/java/org/thingsboard/server/dao/JpaDaoTestSuite.java b/dao/src/test/java/org/thingsboard/server/dao/JpaDaoTestSuite.java
index afa991f..decd74b 100644
--- a/dao/src/test/java/org/thingsboard/server/dao/JpaDaoTestSuite.java
+++ b/dao/src/test/java/org/thingsboard/server/dao/JpaDaoTestSuite.java
@@ -24,14 +24,15 @@ import java.util.Arrays;
 
 @RunWith(ClasspathSuite.class)
 @ClassnameFilters({
-        "org.thingsboard.server.dao.sql.*ABTest"
+        "org.thingsboard.server.dao.sql.*AASDTest"
 })
 public class JpaDaoTestSuite {
 
     @ClassRule
     public static CustomSqlUnit sqlUnit = new CustomSqlUnit(
             Arrays.asList("sql/schema.sql", "sql/system-data.sql"),
-            "sql-test.properties",
-            "sql/drop-all-tables.sql");
+            "sql/drop-all-tables.sql",
+            "sql-test.properties"
+    );
 
 }
diff --git a/dao/src/test/java/org/thingsboard/server/dao/SqlDaoServiceTestSuite.java b/dao/src/test/java/org/thingsboard/server/dao/SqlDaoServiceTestSuite.java
index 0f0eacc..c0ae494 100644
--- a/dao/src/test/java/org/thingsboard/server/dao/SqlDaoServiceTestSuite.java
+++ b/dao/src/test/java/org/thingsboard/server/dao/SqlDaoServiceTestSuite.java
@@ -31,7 +31,8 @@ public class SqlDaoServiceTestSuite {
     @ClassRule
     public static CustomSqlUnit sqlUnit = new CustomSqlUnit(
             Arrays.asList("sql/schema.sql", "sql/system-data.sql", "sql/system-test.sql"),
-            "sql-test.properties",
-            "sql/drop-all-tables.sql");
+            "sql/drop-all-tables.sql",
+            "sql-test.properties"
+    );
 
 }