labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ber...@apache.org
Subject svn commit: r649193 - in /labs/vysper/src: main/java/org/apache/vysper/xmpp/addressing/EntityConformance.java test/java/org/apache/vysper/xmpp/addressing/EntityConformanceTestCase.java
Date Thu, 17 Apr 2008 17:22:55 GMT
Author: berndf
Date: Thu Apr 17 10:22:47 2008
New Revision: 649193

URL: http://svn.apache.org/viewvc?rev=649193&view=rev
Log:
[vysper] make entity checks even more conformant

Modified:
    labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityConformance.java
    labs/vysper/src/test/java/org/apache/vysper/xmpp/addressing/EntityConformanceTestCase.java

Modified: labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityConformance.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityConformance.java?rev=649193&r1=649192&r2=649193&view=diff
==============================================================================
--- labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityConformance.java (original)
+++ labs/vysper/src/main/java/org/apache/vysper/xmpp/addressing/EntityConformance.java Thu
Apr 17 10:22:47 2008
@@ -35,7 +35,7 @@
     }
 
     private static boolean checkPartConformity(String part) {
-        return part == null || part.getBytes().length < 1023;
+        return part == null || part.getBytes().length <= 1023;
     }
 
     private static boolean checkPartIsEmpty(String part) {

Modified: labs/vysper/src/test/java/org/apache/vysper/xmpp/addressing/EntityConformanceTestCase.java
URL: http://svn.apache.org/viewvc/labs/vysper/src/test/java/org/apache/vysper/xmpp/addressing/EntityConformanceTestCase.java?rev=649193&r1=649192&r2=649193&view=diff
==============================================================================
--- labs/vysper/src/test/java/org/apache/vysper/xmpp/addressing/EntityConformanceTestCase.java
(original)
+++ labs/vysper/src/test/java/org/apache/vysper/xmpp/addressing/EntityConformanceTestCase.java
Thu Apr 17 10:22:47 2008
@@ -1,38 +1,42 @@
 package org.apache.vysper.xmpp.addressing;
 
-import java.util.Arrays;
-
 import junit.framework.TestCase;
 
+import java.util.Arrays;
+
 public class EntityConformanceTestCase extends TestCase {
 
 	public void testCheckRFC3920Conformance() {
-		String error = buildLargeString();
-		String ok = "x";
-
-		assertFalse(doCheck(error, ok, ok));
-		assertFalse(doCheck(ok, error, ok));
-		assertFalse(doCheck(ok, ok, error));
-		assertFalse(doCheck(ok, null, ok));
-		assertFalse(doCheck(ok, "", ok));
-		
-		assertTrue(doCheck(ok, ok, ok));
-		assertTrue(doCheck(null, ok, null));
-		assertTrue(doCheck(ok, ok, null));
-		assertTrue(doCheck(null, ok, ok));
-		assertTrue(doCheck("", ok, ""));
-		assertTrue(doCheck(ok, ok, ""));
-		assertTrue(doCheck("", ok, ok));
-		
-	}
+		String error = buildLargeString(1024);
+		String okButOnTheEdge = buildLargeString(1023);
+        runAllChecks(error, "x");
+        runAllChecks(error, okButOnTheEdge);
+    }
+
+    private void runAllChecks(String error, String ok) {
+
+        assertFalse(doCheck(error, ok, ok));
+        assertFalse(doCheck(ok, error, ok));
+        assertFalse(doCheck(ok, ok, error));
+        assertFalse(doCheck(ok, null, ok));
+        assertFalse(doCheck(ok, "", ok));
+
+        assertTrue(doCheck(ok, ok, ok));
+        assertTrue(doCheck(null, ok, null));
+        assertTrue(doCheck(ok, ok, null));
+        assertTrue(doCheck(null, ok, ok));
+        assertTrue(doCheck("", ok, ""));
+        assertTrue(doCheck(ok, ok, ""));
+        assertTrue(doCheck("", ok, ok));
+    }
 
-	private boolean doCheck(String node, String domain, String resource) {
+    private boolean doCheck(String node, String domain, String resource) {
 		return EntityConformance.checkRFC3920Conformance(new EntityImpl(
 				node, domain, resource));
 	}
 
-	private String buildLargeString() {
-		char[] chars = new char[1024];
+	private String buildLargeString(int length) {
+		char[] chars = new char[length];
 		Arrays.fill(chars, 'x');
 		return new String(chars);
 	}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message