diff --git a/wise-webapp/pom.xml b/wise-webapp/pom.xml
index 2365c51a..6c819f5c 100644
--- a/wise-webapp/pom.xml
+++ b/wise-webapp/pom.xml
@@ -48,6 +48,12 @@
jdk15
+ com.intellij
+ annotations
+ 7.0.3
+ compile
+
+
org.springframework
spring-webmvc
2.5.6
diff --git a/wise-webapp/src/main/java/com/wisemapping/exporter/freemind/FreemindExporter.java b/wise-webapp/src/main/java/com/wisemapping/exporter/freemind/FreemindExporter.java
index 26b93dfd..d7f0a093 100755
--- a/wise-webapp/src/main/java/com/wisemapping/exporter/freemind/FreemindExporter.java
+++ b/wise-webapp/src/main/java/com/wisemapping/exporter/freemind/FreemindExporter.java
@@ -26,6 +26,7 @@ import com.wisemapping.xml.freemind.*;
import com.wisemapping.xml.mindmap.RelationshipType;
import com.wisemapping.xml.mindmap.TopicType;
import com.wisemapping.xml.mindmap.Icon;
+import org.jetbrains.annotations.NotNull;
import javax.xml.bind.JAXBException;
import java.io.IOException;
@@ -110,7 +111,7 @@ public class FreemindExporter
}
}
- private void addNodeFromTopic(TopicType mainTopic, Node destNode) {
+ private void addNodeFromTopic(@NotNull final TopicType mainTopic, @NotNull final Node destNode) {
final List currentTopic = mainTopic.getTopic();
for (TopicType topicType : currentTopic) {
@@ -120,10 +121,10 @@ public class FreemindExporter
destNode.getArrowlinkOrCloudOrEdge().add(newNode);
addNodeFromTopic(topicType, newNode);
String position = topicType.getPosition();
- if(position!=null){
+ if (position != null) {
String xPos = position.split(",")[0];
int x = Integer.valueOf(xPos);
- newNode.setPOSITION((x<0?POSITION_LEFT:POSITION_RIGHT));
+ newNode.setPOSITION((x < 0 ? POSITION_LEFT : POSITION_RIGHT));
}
}
}
diff --git a/wise-webapp/src/test/data/freemind/basic.mmr b/wise-webapp/src/test/data/freemind/basic.mmr
new file mode 100644
index 00000000..7c198754
--- /dev/null
+++ b/wise-webapp/src/test/data/freemind/basic.mmr
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/wise-webapp/src/test/data/freemind/basice.mm b/wise-webapp/src/test/data/freemind/basice.mm
deleted file mode 100644
index 8bf97d1c..00000000
--- a/wise-webapp/src/test/data/freemind/basice.mm
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/wise-webapp/src/test/data/freemind/test.xml b/wise-webapp/src/test/data/freemind/test.xml
deleted file mode 100644
index 63de9db1..00000000
--- a/wise-webapp/src/test/data/freemind/test.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
\ No newline at end of file
diff --git a/wise-webapp/src/test/java/com/wisemapping/test/freemind/FreeMindExportTest.java b/wise-webapp/src/test/java/com/wisemapping/test/freemind/FreeMindExportTest.java
index 03d358a0..ecb74549 100644
--- a/wise-webapp/src/test/java/com/wisemapping/test/freemind/FreeMindExportTest.java
+++ b/wise-webapp/src/test/java/com/wisemapping/test/freemind/FreeMindExportTest.java
@@ -8,30 +8,83 @@ import com.wisemapping.importer.ImporterException;
import com.wisemapping.importer.ImporterFactory;
import com.wisemapping.model.MindMap;
+import org.jetbrains.annotations.NotNull;
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.io.*;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
@Test
public class FreeMindExportTest {
private static final String DATA_DIR_PATH = "src/test/data/freemind/";
- @Test
- public void exportImportExportTest() throws ImporterException, IOException, ExportException {
+ @Test(dataProvider = "Data-Provider-Function")
+ public void exportImportExportTest(@NotNull final File freeMindFile, @NotNull final File recFile) throws ImporterException, IOException, ExportException {
ImporterFactory instance = ImporterFactory.getInstance();
Importer importer = instance.getImporter(ImportFormat.FREEMIND);
- FileInputStream fileInputStream = new FileInputStream(new File(DATA_DIR_PATH, "basic.mm").getAbsolutePath());
+ FileInputStream fileInputStream = new FileInputStream(freeMindFile.getAbsolutePath());
final MindMap mindMap = importer.importMap("basic", "basic", fileInputStream);
-
-
-
final FreemindExporter freemindExporter = new FreemindExporter();
- FileOutputStream fos = new FileOutputStream(new File(DATA_DIR_PATH,"basice.mm"));
- freemindExporter.export(mindMap,fos);
- fos.close();
+ if (recFile.exists()) {
+ // Compare rec and file ...
+
+ // Load rec file co
+ final FileInputStream fis = new FileInputStream(recFile);
+ final InputStreamReader isr = new InputStreamReader(fis);
+ final BufferedReader br = new BufferedReader(isr);
+
+ final StringBuilder recContent = new StringBuilder();
+ String line = br.readLine();
+ while (line != null) {
+ recContent.append(line);
+ line = br.readLine();
+
+ }
+
+ fis.close();
+
+ // Export mile content ...
+ final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ freemindExporter.export(mindMap, bos);
+ final String exportContent = new String(bos.toByteArray());
+
+ Assert.assertEquals(recContent.toString(), exportContent);
+
+ } else {
+ final FileOutputStream fos = new FileOutputStream(recFile);
+ freemindExporter.export(mindMap, fos);
+ fos.close();
+ }
+
+
+ }
+
+ //This function will provide the parameter data
+ @DataProvider(name = "Data-Provider-Function")
+ public Object[][] parameterIntTestProvider() {
+
+ 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");
+ }
+ });
+
+ final Object[][] result = new Object[freeMindFiles.length][2];
+ for (int i = 0; i < freeMindFiles.length; i++) {
+ File freeMindFile = freeMindFiles[i];
+ final String name = freeMindFile.getName();
+ result[i] = new Object[]{freeMindFile, new File(DATA_DIR_PATH, name.substring(0, name.lastIndexOf(".")) + ".mmr")};
+ }
+
+ return result;
}