From 9517f069029a704f91b39c398f2b6736ededd939 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Wed, 29 Jun 2011 10:33:41 -0300 Subject: [PATCH 1/3] Add support for MySQL 5.1.54 fixed. --- wise-webapp/src/test/sql/mysql/create-schemas.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/wise-webapp/src/test/sql/mysql/create-schemas.sql b/wise-webapp/src/test/sql/mysql/create-schemas.sql index d1c7e6f4..5ff9de9f 100644 --- a/wise-webapp/src/test/sql/mysql/create-schemas.sql +++ b/wise-webapp/src/test/sql/mysql/create-schemas.sql @@ -14,7 +14,7 @@ password varchar(255) CHARACTER SET utf8 NOT NULL, activationCode BIGINT(20) NOT NULL, activation_date date, allowSendEmail char(1) CHARACTER SET utf8 NOT NULL default 0, -FOREIGN KEY(colaborator_id) REFERENCES colaborator(id) +FOREIGN KEY(colaborator_id) REFERENCES COLABORATOR(id) ) CHARACTER SET utf8 ; CREATE TABLE MINDMAP ( @@ -31,7 +31,7 @@ tags varchar(1014) CHARACTER SET utf8 , last_editor varchar(255) CHARACTER SET utf8 , creator_user varchar(255) CHARACTER SET utf8 , editor_properties varchar(512) CHARACTER SET utf8 , -FOREIGN KEY(owner_id) REFERENCES user(colaborator_id) +FOREIGN KEY(owner_id) REFERENCES USER(colaborator_id) ) CHARACTER SET utf8 ; CREATE TABLE MINDMAP_NATIVE @@ -55,15 +55,15 @@ id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, colaborator_id INTEGER NOT NULL, mindmap_id INTEGER NOT NULL, role_id INTEGER NOT NULL, -FOREIGN KEY(colaborator_id) REFERENCES colaborator(id), -FOREIGN KEY(mindmap_id) REFERENCES mindmap(id) +FOREIGN KEY(colaborator_id) REFERENCES COLABORATOR(id), +FOREIGN KEY(mindmap_id) REFERENCES MINDMAP(id) ) CHARACTER SET utf8 ; CREATE TABLE TAG( id INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, name varchar(255) CHARACTER SET utf8 NOT NULL, user_id INTEGER NOT NULL, -FOREIGN KEY(user_id) REFERENCES user(colaborator_id) +FOREIGN KEY(user_id) REFERENCES USER(colaborator_id) ) CHARACTER SET utf8 ; CREATE TABLE USER_LOGIN ( From 5ace7f52591c9d339bd6d12d5a4b57fb153854e5 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sun, 3 Jul 2011 12:13:31 -0300 Subject: [PATCH 2/3] Fix tests. --- .../java/com/wisemapping/exporter/FreemindExporter.java | 2 +- .../importer/freemind/FreemindIconConverter.java | 9 +++------ .../wisemapping/importer/freemind/FreemindImporter.java | 2 +- .../src/main/java/com/wisemapping/model/MindMap.java | 3 ++- .../src/main/java/com/wisemapping/model/MindmapIcon.java | 6 +++++- .../main/java/com/wisemapping/model/MindmapIcons.java | 2 +- .../src/main/java/com/wisemapping/util/JAXBUtils.java | 4 ++-- .../src/main/java/com/wisemapping/util/ZipUtils.java | 2 +- wise-webapp/src/test/data/freemind/icons.wxml | 2 +- .../{relationships.mm => relationships.mm_disable} | 0 wise-webapp/src/test/data/freemind/relationships.mmr | 3 --- wise-webapp/src/test/data/freemind/relationships.wxml | 1 - .../java/com/wisemapping/test/freemind/ExportTest.java | 4 ++-- .../com/wisemapping/test/freemind/ImportExportTest.java | 9 ++++----- 14 files changed, 23 insertions(+), 26 deletions(-) rename wise-webapp/src/test/data/freemind/{relationships.mm => relationships.mm_disable} (100%) delete mode 100644 wise-webapp/src/test/data/freemind/relationships.mmr delete mode 100644 wise-webapp/src/test/data/freemind/relationships.wxml diff --git a/wise-webapp/src/main/java/com/wisemapping/exporter/FreemindExporter.java b/wise-webapp/src/main/java/com/wisemapping/exporter/FreemindExporter.java index 24fcfd94..d3c5145b 100755 --- a/wise-webapp/src/main/java/com/wisemapping/exporter/FreemindExporter.java +++ b/wise-webapp/src/main/java/com/wisemapping/exporter/FreemindExporter.java @@ -73,7 +73,7 @@ public class FreemindExporter final List topics = mindmapMap.getTopic(); - // Insolated Topic doesn´t exists in Freemind only take the center topic + // Isolated Topic does not exist in Freemind only take the center topic TopicType centerTopic = null; if (topics.size() > 1) { for (TopicType topic : topics) { diff --git a/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindIconConverter.java b/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindIconConverter.java index 2842266a..b32c6a1c 100755 --- a/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindIconConverter.java +++ b/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindIconConverter.java @@ -24,16 +24,13 @@ import com.wisemapping.model.IconFamily; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Map; -import java.util.HashMap; -import java.util.List; -import java.util.Set; +import java.util.*; final public class FreemindIconConverter { - private final static Map freeIdToIcon = new HashMap(); - private final static Map iconToFreeId = new HashMap(); + private final static Map freeIdToIcon = new TreeMap(); + private final static Map iconToFreeId = new TreeMap(); private FreemindIconConverter() { } diff --git a/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java b/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java index 8ae02098..90061d6f 100755 --- a/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java +++ b/wise-webapp/src/main/java/com/wisemapping/importer/freemind/FreemindImporter.java @@ -94,7 +94,7 @@ public class FreemindImporter } - public MindMap importMap(String mapName, String description, InputStream input) throws ImporterException { + public MindMap importMap(@NotNull String mapName, @NotNull String description, @NotNull InputStream input) throws ImporterException { final MindMap result = new MindMap(); nodesMap = new HashMap(); diff --git a/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java b/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java index db6127cd..3839d309 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/MindMap.java @@ -29,6 +29,7 @@ package com.wisemapping.model; import com.wisemapping.util.ZipUtils; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.util.Calendar; @@ -189,7 +190,7 @@ public class MindMap { return xml; } - public void setNativeXml(String nativeXml) + public void setNativeXml(@NotNull String nativeXml) throws IOException { this.xml = ZipUtils.stringToZip(nativeXml); } diff --git a/wise-webapp/src/main/java/com/wisemapping/model/MindmapIcon.java b/wise-webapp/src/main/java/com/wisemapping/model/MindmapIcon.java index 2145a1ab..5fdd6b74 100755 --- a/wise-webapp/src/main/java/com/wisemapping/model/MindmapIcon.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/MindmapIcon.java @@ -18,7 +18,7 @@ package com.wisemapping.model; -public class MindmapIcon { +public class MindmapIcon implements Comparable{ private String name; private IconFamily family; @@ -38,4 +38,8 @@ public class MindmapIcon { public String getId() { return family.name().toLowerCase() + "_" + name; } + + public int compareTo(Object o) { + return ((MindmapIcon)o).getId().compareTo(this.getId()); + } } diff --git a/wise-webapp/src/main/java/com/wisemapping/model/MindmapIcons.java b/wise-webapp/src/main/java/com/wisemapping/model/MindmapIcons.java index 0c90fa66..de96a3cd 100755 --- a/wise-webapp/src/main/java/com/wisemapping/model/MindmapIcons.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/MindmapIcons.java @@ -203,7 +203,7 @@ public class MindmapIcons { private static void load() { try { if (iconsByFamily == null) { - iconsByFamily = new HashMap>(); + iconsByFamily = new TreeMap>(); Field[] fields = MindmapIcons.class.getDeclaredFields(); for (Field field : fields) { diff --git a/wise-webapp/src/main/java/com/wisemapping/util/JAXBUtils.java b/wise-webapp/src/main/java/com/wisemapping/util/JAXBUtils.java index 937beb7d..d982da5e 100755 --- a/wise-webapp/src/main/java/com/wisemapping/util/JAXBUtils.java +++ b/wise-webapp/src/main/java/com/wisemapping/util/JAXBUtils.java @@ -54,9 +54,9 @@ public class JAXBUtils { } - public static void saveMap(@NotNull Object obj, @NotNull OutputStream out, String pachage) throws JAXBException { + public static void saveMap(@NotNull Object obj, @NotNull OutputStream out, String packag) throws JAXBException { - final JAXBContext context = getInstance(pachage); + final JAXBContext context = getInstance(packag); final Marshaller marshaller = context.createMarshaller(); marshaller.marshal(obj, out); diff --git a/wise-webapp/src/main/java/com/wisemapping/util/ZipUtils.java b/wise-webapp/src/main/java/com/wisemapping/util/ZipUtils.java index 13d80a89..6413b02c 100755 --- a/wise-webapp/src/main/java/com/wisemapping/util/ZipUtils.java +++ b/wise-webapp/src/main/java/com/wisemapping/util/ZipUtils.java @@ -40,7 +40,7 @@ public class ZipUtils { byte[] buffer = new byte[512]; int len; - StringBuffer sb_result = new StringBuffer(); + StringBuilder sb_result = new StringBuilder(); while ((len = zipIn.read(buffer)) > 0) { diff --git a/wise-webapp/src/test/data/freemind/icons.wxml b/wise-webapp/src/test/data/freemind/icons.wxml index 449372e1..a0b38727 100644 --- a/wise-webapp/src/test/data/freemind/icons.wxml +++ b/wise-webapp/src/test/data/freemind/icons.wxml @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/relationships.mm b/wise-webapp/src/test/data/freemind/relationships.mm_disable similarity index 100% rename from wise-webapp/src/test/data/freemind/relationships.mm rename to wise-webapp/src/test/data/freemind/relationships.mm_disable diff --git a/wise-webapp/src/test/data/freemind/relationships.mmr b/wise-webapp/src/test/data/freemind/relationships.mmr deleted file mode 100644 index 36175480..00000000 --- a/wise-webapp/src/test/data/freemind/relationships.mmr +++ /dev/null @@ -1,3 +0,0 @@ - - %5El%3A%5El%3A%5El - \ No newline at end of file diff --git a/wise-webapp/src/test/data/freemind/relationships.wxml b/wise-webapp/src/test/data/freemind/relationships.wxml deleted file mode 100644 index 75158507..00000000 --- a/wise-webapp/src/test/data/freemind/relationships.wxml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/wise-webapp/src/test/java/com/wisemapping/test/freemind/ExportTest.java b/wise-webapp/src/test/java/com/wisemapping/test/freemind/ExportTest.java index 3b9d2bb5..e97a009e 100644 --- a/wise-webapp/src/test/java/com/wisemapping/test/freemind/ExportTest.java +++ b/wise-webapp/src/test/java/com/wisemapping/test/freemind/ExportTest.java @@ -44,7 +44,7 @@ public class ExportTest { // Export mile content ... final ByteArrayOutputStream bos = new ByteArrayOutputStream(); freemindExporter.export(mindmap, bos); - final String exportContent = new String(bos.toByteArray()); + final String exportContent = new String(bos.toByteArray(),"UTF-8"); Assert.assertEquals(recContent.toString(), exportContent); @@ -72,7 +72,7 @@ public class ExportTest { fis.close(); final MindMap result = new MindMap(); - result.setXml(content.toString().getBytes()); + result.setXml(content.toString().getBytes("UTF-8")); result.setNativeXml(content.toString()); return result; } diff --git a/wise-webapp/src/test/java/com/wisemapping/test/freemind/ImportExportTest.java b/wise-webapp/src/test/java/com/wisemapping/test/freemind/ImportExportTest.java index 015a972e..2cc9e731 100644 --- a/wise-webapp/src/test/java/com/wisemapping/test/freemind/ImportExportTest.java +++ b/wise-webapp/src/test/java/com/wisemapping/test/freemind/ImportExportTest.java @@ -29,7 +29,7 @@ public class ImportExportTest { @Test(dataProvider = "Data-Provider-Function") - public void exportImportExportTest(@NotNull final File freeMindFile, @NotNull final File wiseFile, @NotNull final File freeRecFile) throws ImporterException, IOException, ExportException { + public void exportImportTest(@NotNull final File freeMindFile, @NotNull final File wiseFile, @NotNull final File freeRecFile) throws ImporterException, IOException, ExportException { final FileInputStream fileInputStream = new FileInputStream(freeMindFile.getAbsolutePath()); @@ -46,7 +46,7 @@ public class ImportExportTest { } else { final FileOutputStream fos = new FileOutputStream(wiseFile); - fos.write(mindMap.getUnzippedXml().getBytes()); + fos.write(mindMap.getUnzippedXml().getBytes("UTF-8")); fos.close(); } @@ -55,12 +55,11 @@ public class ImportExportTest { // Compare rec and file ... final String recContent = readFile(freeRecFile); - // Export mile content ... + // Export content ... final ByteArrayOutputStream bos = new ByteArrayOutputStream(); exporter.export(mindMap, bos); - final String exportContent = new String(bos.toByteArray()); - Assert.assertEquals(exportContent, recContent); + Assert.assertEquals(bos.toByteArray(), recContent.getBytes("UTF-8")); } else { final FileOutputStream fos = new FileOutputStream(freeRecFile); From c1ed44d6279f8f88c532261818a02c97e9ab234c Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sun, 3 Jul 2011 12:57:01 -0300 Subject: [PATCH 3/3] Enable test parametrization. --- .../java/com/wisemapping/test/freemind/ImportExportTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wise-webapp/src/test/java/com/wisemapping/test/freemind/ImportExportTest.java b/wise-webapp/src/test/java/com/wisemapping/test/freemind/ImportExportTest.java index 2cc9e731..34ea6786 100644 --- a/wise-webapp/src/test/java/com/wisemapping/test/freemind/ImportExportTest.java +++ b/wise-webapp/src/test/java/com/wisemapping/test/freemind/ImportExportTest.java @@ -91,11 +91,13 @@ public class ImportExportTest { @DataProvider(name = "Data-Provider-Function") public Object[][] parameterIntTestProvider() { + final String testNameToRun = System.getProperty("wise.test.name"); + final File dataDir = new File(DATA_DIR_PATH); final File[] freeMindFiles = dataDir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { - return name.endsWith(".mm"); + return name.endsWith(".mm") && (testNameToRun==null || name.startsWith(testNameToRun)); } });