Index: /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/ResourceTypeTest.java
===================================================================
--- /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/ResourceTypeTest.java (revision 1877)
+++ /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/ResourceTypeTest.java (revision 1877)
@@ -0,0 +1,89 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor;
+
+import static org.junit.Assert.*;
+import net.fckeditor.handlers.PropertiesLoader;
+import net.fckeditor.handlers.ResourceTypeHandler;
+
+import org.junit.Test;
+
+/**
+ * Tests for {@link ResourceTypeHandler}.
+ *
+ * @version $Id$
+ */
+public class ResourceTypeTest {
+
+ @Test
+ public void getType01() throws Exception {
+ assertNull(ResourceTypeHandler.getResourceType("xyz"));
+ }
+
+ @Test
+ public void getType02() throws Exception {
+ assertEquals(ResourceTypeHandler.FILE, ResourceTypeHandler.getResourceType("File"));
+ }
+
+ @Test
+ public void getType03() throws Exception {
+ assertEquals(ResourceTypeHandler.IMAGE, ResourceTypeHandler.getResourceType("Image"));
+ }
+
+ @Test
+ public void isValid01() throws Exception {
+ assertFalse(ResourceTypeHandler.isValid("1234"));
+ }
+
+ @Test
+ public void isValid02() throws Exception {
+ assertFalse(ResourceTypeHandler.isValid("fLash"));
+ }
+
+ @Test
+ public void isValid03() throws Exception {
+ assertFalse(ResourceTypeHandler.isValid("MeDiA"));
+ }
+
+ @Test
+ public void getTypeDefault01() throws Exception {
+ assertEquals(ResourceTypeHandler.FILE, ResourceTypeHandler
+ .getDefaultResourceType("wrong-type"));
+ }
+
+ @Test
+ public void getTypeDefault02() throws Exception {
+ assertNotSame(ResourceTypeHandler.FLASH, ResourceTypeHandler
+ .getDefaultResourceType("flAsh"));
+ }
+
+ @Test
+ public void getSubDirForType01() throws Exception {
+ assertEquals(PropertiesLoader.getProperty("connector.resourceType.file.path"),
+ ResourceTypeHandler.getDefaultResourceType(null).getPath());
+ }
+
+ @Test
+ public void getSubDirForType02() throws Exception {
+ assertEquals(PropertiesLoader.getProperty("connector.resourceType.image.path"),
+ ResourceTypeHandler.getResourceType("Image").getPath());
+ }
+}
Index: /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/handlers/CommandHandlerTest.java
===================================================================
--- /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/handlers/CommandHandlerTest.java (revision 1877)
+++ /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/handlers/CommandHandlerTest.java (revision 1877)
@@ -0,0 +1,119 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.handlers;
+
+import static org.junit.Assert.*;
+import org.junit.Test;
+
+/**
+ * Tests for {@link CommandHandler}.
+ *
+ * @version $Id$
+ */
+public class CommandHandlerTest {
+
+ @Test
+ public void valueOf01() {
+ assertEquals(CommandHandler.FILE_UPLOAD, CommandHandler
+ .valueOf("FileUpload"));
+ }
+
+ @Test
+ public void valueOf02() {
+ assertEquals(CommandHandler.QUICK_UPLOAD, CommandHandler
+ .valueOf("QuickUpload"));
+ }
+
+ @Test
+ public void valueOf03() {
+ assertEquals(CommandHandler.CREATE_FOLDER, CommandHandler
+ .valueOf("CreateFolder"));
+ }
+
+ @Test
+ public void valueOf04() {
+ assertEquals(CommandHandler.GET_FOLDERS, CommandHandler
+ .valueOf("GetFolders"));
+ }
+
+ @Test
+ public void valueOf05() {
+ assertEquals(CommandHandler.GET_FOLDERS_AND_FILES, CommandHandler
+ .valueOf("GetFoldersAndFiles"));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void valueOfStringNull() {
+ CommandHandler.valueOf(null);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void valueOfInvalidCommand() {
+ CommandHandler.valueOf("GetAll");
+ }
+
+ @Test
+ public void getCommandNull() {
+ CommandHandler command = CommandHandler.getCommand(null);
+ assertNull(command);
+ }
+
+ @Test
+ public void getCommandInvalid() {
+ CommandHandler command = CommandHandler.getCommand("DeleteFolders");
+ assertNull(command);
+ }
+
+ @Test
+ public void getCommandValid() {
+ CommandHandler actual = CommandHandler.getCommand("FileUpload");
+ assertEquals(CommandHandler.FILE_UPLOAD, actual);
+ }
+
+ @Test
+ public void equalsNot01() {
+ assertFalse(CommandHandler.GET_FOLDERS
+ .equals(CommandHandler.FILE_UPLOAD));
+ }
+
+ @Test
+ public void equalsNot02() {
+ assertFalse(CommandHandler.GET_FOLDERS.equals(new Object()));
+ }
+
+ @Test
+ public void hashCode01() {
+ assertEquals("GetFoldersAndFiles".hashCode(),
+ CommandHandler.GET_FOLDERS_AND_FILES.hashCode());
+ }
+
+ @Test
+ public void hashCode02() {
+ assertNotSame(-1, CommandHandler.FILE_UPLOAD.hashCode());
+ }
+
+ @Test
+ public void toString01() {
+ assertEquals("GetFoldersAndFiles", CommandHandler.GET_FOLDERS_AND_FILES
+ .toString());
+ }
+
+}
Index: /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/handlers/ExtensionsHandlerTest.java
===================================================================
--- /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/handlers/ExtensionsHandlerTest.java (revision 1877)
+++ /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/handlers/ExtensionsHandlerTest.java (revision 1877)
@@ -0,0 +1,57 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2007 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.handlers;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+/**
+ * Tests for {@link ExtensionsHandler};
+ *
+ * @version $Id$
+ */
+public class ExtensionsHandlerTest {
+
+ @Test
+ public void testIsAllowed01() {
+ ResourceTypeHandler type = ResourceTypeHandler.FILE;
+ ExtensionsHandler.setExtensionsAllowed(type, "a");
+ ExtensionsHandler.setExtensionsDenied(type, "b");
+ assertTrue(ExtensionsHandler.getExtensionsAllowed(type).isEmpty());
+ assertTrue(ExtensionsHandler.getExtensionsDenied(type).contains("b"));
+ assertFalse(ExtensionsHandler.isAllowed(type, "b"));
+ assertTrue(ExtensionsHandler.isAllowed(type, "a"));
+ assertTrue(ExtensionsHandler.isAllowed(type, "c"));
+ }
+
+ @Test
+ public void testIsAllowed02() {
+ ResourceTypeHandler type = ResourceTypeHandler.FILE;
+ ExtensionsHandler.setExtensionsAllowed(type, "a|b|c");
+ assertTrue(ExtensionsHandler.isAllowed(type, "a"));
+ assertTrue(ExtensionsHandler.isAllowed(type, "b"));
+ assertTrue(ExtensionsHandler.isAllowed(type, "c"));
+ assertFalse(ExtensionsHandler.isAllowed(type, "d"));
+ }
+
+}
Index: /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/tool/CompatibilityTest.java
===================================================================
--- /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/tool/CompatibilityTest.java (revision 1877)
+++ /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/tool/CompatibilityTest.java (revision 1877)
@@ -0,0 +1,113 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.tool;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ * Tests for {@link Compatibility}.
+ * User-Agent-Strings are taken from: http://www.useragentstring.com/pages/useragentstring.php
+ *
+ * @version $Id$
+ */
+public class CompatibilityTest {
+
+ @Test
+ public void testIE4Win() throws Exception {
+ assertFalse(Compatibility.check("Mozilla/4.0 (compatible; MSIE 4.01; Windows NT 5.0)"));
+ }
+
+ @Test
+ public void testIE522Mac() throws Exception {
+ assertFalse(Compatibility.check("Mozilla/4.0 (compatible; MSIE 5.22; Mac_PowerPC)"));
+ }
+
+ @Test
+ public void testIE55Win98() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)"));
+ }
+
+ @Test
+ public void testIE60WinNT() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 5.1)"));
+ }
+
+ @Test
+ public void testIE70WinVista() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0;)"));
+ }
+
+ @Test
+ public void testIE70bWinVista() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 6.0)"));
+ }
+
+ @Test
+ public void testSafari204OSX() throws Exception {
+ assertFalse(Compatibility.check("Mozilla/5.0 (Macintosh; U; PPC Mac OS X; sv-se) AppleWebKit/419 (KHTML, like Gecko) Safari/419.3"));
+ }
+
+ @Test
+ public void testSafari30WinXP() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/5.0 (Windows; U; Windows NT 5.2; pt) AppleWebKit/522.11.3 (KHTML, like Gecko) Version/3.0 Safari/522.11.3"));
+ }
+
+ @Test
+ public void testSafari302OSX() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/522+ (KHTML, like Gecko) Version/3.0.2 Safari/522.12"));
+ }
+
+ @Test
+ public void testSafari31OSX() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_2; en-au) AppleWebKit/525.8+ (KHTML, like Gecko) Version/3.1 Safari/525.6"));
+ }
+
+ @Test
+ public void testFirefox200112OSX() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12"));
+ }
+
+ @Test
+ public void testFirefox1509LinuxDebian() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/1.5.0.9 (Debian-2.0.0.9-2)"));
+ }
+
+ @Test
+ public void testOper925Win2k() throws Exception {
+ assertFalse(Compatibility.check("Opera/9.25 (Windows NT 5.0; U; en)"));
+ }
+
+ @Test
+ public void testOpera854WinNT() throws Exception {
+ assertFalse(Compatibility.check("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; de) Opera 8.54"));
+ }
+
+ @Test
+ public void testOpera95OSX() throws Exception {
+ assertTrue(Compatibility.check("Opera/9.50 (Macintosh; Intel Mac OS X; U; en)"));
+ }
+
+ @Test
+ public void testOpera95WinVista() throws Exception {
+ assertTrue(Compatibility.check("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 6.0; en) Opera 9.50"));
+ }
+}
Index: /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/tool/UploadResponseTest.java
===================================================================
--- /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/tool/UploadResponseTest.java (revision 1877)
+++ /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/tool/UploadResponseTest.java (revision 1877)
@@ -0,0 +1,69 @@
+package net.fckeditor.tool;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import net.fckeditor.response.UploadResponse;
+
+public class UploadResponseTest {
+
+ @Test(expected = IllegalArgumentException.class)
+ public void noArguments() throws Exception {
+ new UploadResponse();
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void tooManyArguments() throws Exception {
+ new UploadResponse(101, "/some/url/file.txt", "file.txt",
+ "something's wrong", "arg no. 5");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void notANumber() throws Exception {
+ new UploadResponse("1");
+ }
+
+ @Test
+ public void onlyErrorNumber() throws Exception {
+ UploadResponse actual = new UploadResponse(
+ UploadResponse.EN_INVALID_EXTENSION);
+ String expected = new String("");
+ assertEquals(expected, actual.toString());
+ }
+
+ @Test
+ public void fourArguments() throws Exception {
+ UploadResponse actual = new UploadResponse(UploadResponse.EN_OK,"/fckeditor-java/userfiles/image/fredck.jpg");
+ String expected = new String("");
+ assertEquals(expected, actual.toString());
+ }
+
+ @Test
+ public void renamedFile() throws Exception {
+ UploadResponse actual = new UploadResponse(UploadResponse.EN_RENAMED,"/fckeditor-java/userfiles/image/hacked_php.txt","hacked_php.txt");
+ String expected = new String("");
+ assertEquals(expected, actual.toString());
+ }
+
+ @Test
+ public void customMessage() throws Exception {
+ UploadResponse actual = new UploadResponse(UploadResponse.EN_ERROR);
+ actual.setCustomMessage("some error");
+ String expected = new String("");
+ assertEquals(expected, actual.toString());
+ }
+
+
+ @Test
+ public void nullArguments() throws Exception {
+ UploadResponse actual = new UploadResponse(UploadResponse.EN_ERROR,null,null,null);
+ String expected = new String("");
+ assertEquals(expected, actual.toString());
+ }
+
+}
Index: /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/tool/UtilsFileTest.java
===================================================================
--- /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/tool/UtilsFileTest.java (revision 1877)
+++ /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/tool/UtilsFileTest.java (revision 1877)
@@ -0,0 +1,199 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.tool;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+
+/**
+ * Tests for {@link UtilsFile}.
+ *
+ * @version $Id$
+ */
+public class UtilsFileTest {
+
+ @Test
+ public void isSingleExtension01() {
+ boolean condition = UtilsFile.isSingleExtension("hacked.txt");
+ assertTrue(condition);
+ }
+
+ @Test
+ public void isSingleExtension02() {
+ boolean condition = UtilsFile.isSingleExtension("hacked.php_txt");
+ assertTrue(condition);
+ }
+
+ @Test
+ public void isSingleExtension03() {
+ boolean condition = UtilsFile.isSingleExtension("hacked.php.txt");
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isSingleExtension04() {
+ boolean condition = UtilsFile.isSingleExtension("hacked.txt.");
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isSingleExtension05() {
+ boolean condition = UtilsFile.isSingleExtension("hacked..txt");
+ assertFalse(condition);
+ }
+
+ @Test
+ public void forceSingleExtension01() {
+ String actual = UtilsFile.forceSingleExtension("hacked.txt");
+ assertEquals("hacked.txt", actual);
+ }
+
+ @Test
+ public void forceSingleExtension02() {
+ String actual = UtilsFile.forceSingleExtension("hacked.php_txt");
+ assertEquals("hacked.php_txt", actual);
+ }
+
+ @Test
+ public void forceSingleExtension03() {
+ String actual = UtilsFile.forceSingleExtension("hacked.php.txt");
+ assertEquals("hacked_php.txt", actual);
+ }
+
+ @Test
+ public void forceSingleExtension04() {
+ String actual = UtilsFile.forceSingleExtension("hacked..txt");
+ assertEquals("hacked_.txt", actual);
+ }
+
+ @Test
+ public void isValidPath01() {
+ String path = "";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isValidPath02() {
+ String path = "/";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertTrue(condition);
+ }
+
+ @Test
+ public void isValidPath03() {
+ String path = "/./";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isValidPath04() {
+ String path = "/newf/..";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isValidPath05() {
+ String path = "/../";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isValidPath06() {
+ String path = "/stuff/../..";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isValidPath07() {
+ String path = "/my/stuff/../";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isValidPath08() {
+ String path = "/my/stuff/";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertTrue(condition);
+ }
+
+ @Test
+ public void isValidPath09() {
+ String path = "/my/stuff";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isValidPath10() {
+ String path = "my/stuff/";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isValidPath11() {
+ String path = "/some/pa\\th/";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void isValidPath12() {
+ String path = "/\\/";
+ boolean condition = UtilsFile.isValidPath(path);
+ assertFalse(condition);
+ }
+
+ @Test
+ public void sanitizeFolder01() {
+ assertEquals("a_b_c_d_e_f_g_h_i_", UtilsFile.sanitizeFolderName("a.b|ce:f?g*h"));
+ }
+
+ @Test
+ public void sanitizeFolder02() {
+ assertEquals("a_b_c_d_e_f_g_h_i_", UtilsFile.sanitizeFolderName("a.b|c\u007Fd>e:f\u0005g*h"));
+ }
+
+ @Test
+ public void sanitizeFile01() {
+ assertEquals("b_c_d_e_f_g_h_i_", UtilsFile.sanitizeFileName("b|ce:f?g*h"));
+ }
+
+ @Test
+ public void sanitizeFile02() {
+ assertEquals("name_ext1.ext2", UtilsFile.sanitizeFileName("name.ext1.ext2"));
+ }
+
+ @Test
+ public void sanitizeFile03() {
+ assertEquals("b_c_d_e_f_g_h_i_", UtilsFile.sanitizeFileName("b|c\u007Fd>e:f\u0005g*h"));
+ }
+}
Index: /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/tool/UtilsTest.java
===================================================================
--- /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/tool/UtilsTest.java (revision 1877)
+++ /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/tool/UtilsTest.java (revision 1877)
@@ -0,0 +1,101 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.tool;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.Test;
+
+/**
+ * Tests for {@link Utils};
+ *
+ * @version $Id$
+ */
+public class UtilsTest {
+
+ @Test
+ public void getSet01() {
+ Set set = new HashSet();
+ set.add("a");
+ set.add("ab");
+ set.add("c");
+
+ Set newSet = Utils.getSet("a|Ab|c", "|");
+ for (String string : newSet) {
+ assertTrue(set.contains(string));
+ }
+ }
+
+ @Test
+ public void getSet02() {
+ Set set = new HashSet();
+ set.add("png");
+ set.add("jpg");
+ set.add("gif");
+
+ Set newSet = Utils.getSet("png|jpg|gif");
+ for (String string : newSet) {
+ assertTrue(set.contains(string));
+ }
+ }
+
+ @Test
+ public void getSet03() {
+ Set set = Utils.getSet(null);
+ assertTrue(set != null);
+ assertTrue(set.isEmpty());
+ }
+
+ @Test
+ public void getSet04() {
+ Set set = Utils.getSet("");
+ assertTrue(set != null);
+ assertTrue(set.isEmpty());
+ }
+
+ @Test
+ public void replaceAll01() {
+ String str = Utils.replaceAll("//a/b//c", "//", "/");
+ assertEquals(str, "/a/b/c");
+ }
+
+ @Test
+ public void replaceAll02() {
+ String str = Utils.replaceAll(null, "a", "c");
+ assertEquals(str, "");
+ }
+
+ @Test
+ public void replaceAll03() {
+ String str = Utils.replaceAll("foo", null, "c");
+ assertEquals(str, "foo");
+ }
+
+ @Test
+ public void replaceAll04() {
+ String str = Utils.replaceAll("foo", "o", "a");
+ assertEquals(str, "faa");
+ }
+}
Index: /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/tool/XHtmlTagToolTest.java
===================================================================
--- /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/tool/XHtmlTagToolTest.java (revision 1877)
+++ /FCKeditor.Java/branches/2.4/fckeditor-java/src/test/java/net/fckeditor/tool/XHtmlTagToolTest.java (revision 1877)
@@ -0,0 +1,103 @@
+/*
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ * - GNU General Public License Version 2 or later (the "GPL")
+ * http://www.gnu.org/licenses/gpl.html
+ *
+ * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * - Mozilla Public License Version 1.1 or later (the "MPL")
+ * http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ */
+package net.fckeditor.tool;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+/**
+ * Tests for {@link XHtmlTagTool}.
+ *
+ * @version $Id$
+ */
+public class XHtmlTagToolTest {
+
+ @Test
+ public void testClosingTag01() throws Exception {
+ XHtmlTagTool tag = new XHtmlTagTool("test");
+ assertEquals("", tag.toString());
+ }
+
+ @Test
+ public void testClosingTag02() throws Exception {
+ XHtmlTagTool tag = new XHtmlTagTool("test", "");
+ assertEquals("", tag.toString());
+ }
+
+ @Test
+ public void testClosingTag03() throws Exception {
+ XHtmlTagTool tag = new XHtmlTagTool("test", "val");
+ assertEquals("val", tag.toString());
+ }
+
+ @Test
+ public void testClosingTag04() throws Exception {
+ XHtmlTagTool tag = new XHtmlTagTool("test", XHtmlTagTool.SPACE);
+ assertEquals(" ", tag.toString());
+ }
+
+ @Test
+ public void deepEquals01() throws Exception {
+ XHtmlTagTool expected = new XHtmlTagTool("tag", "some text");
+ XHtmlTagTool actual = new XHtmlTagTool("tag", "some text");
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void deepEquals02() throws Exception {
+ XHtmlTagTool unexpected = new XHtmlTagTool("tag", "");
+ XHtmlTagTool actual = new XHtmlTagTool("tag", XHtmlTagTool.SPACE);
+ assertNotSame(unexpected, actual);
+ }
+
+ @Test
+ public void deepEquals03() throws Exception {
+ XHtmlTagTool expected = new XHtmlTagTool("tag", "some text");
+ expected.addAttribute("id", "some_tag_id");
+ expected.addAttribute("class", "grayShadow");
+ expected.addAttribute("style", "color: red");
+
+ XHtmlTagTool actual = new XHtmlTagTool("tag", "some text");
+
+ actual.addAttribute("style", "color: red");
+ actual.addAttribute("id", "some_tag_id");
+ actual.addAttribute("class", "grayShadow");
+
+ assertEquals(expected, actual);
+ }
+
+ @Test
+ public void deepEquals04() throws Exception {
+ XHtmlTagTool unexpected = new XHtmlTagTool("tag");
+ unexpected.addAttribute("id", "some_tag_id");
+ unexpected.addAttribute("class", "grayShadow");
+ unexpected.addAttribute("style", "color: red");
+
+ XHtmlTagTool actual = new XHtmlTagTool("tag");
+
+ actual.addAttribute("id", "some_tag_id");
+ actual.addAttribute("class", "grayShadow");
+ actual.addAttribute("style", "color: blue");
+
+ assertNotSame(unexpected, actual);
+ }
+}