org.xmpp.packet
Class StringPrepCacheTest

java.lang.Object
  extended by org.xmpp.packet.StringPrepCacheTest

public class StringPrepCacheTest
extends java.lang.Object

A testcase that verifies the effect of stringprep caching in the JID class.

This testcase, amongst others, checks for a bug identified as TINDER-8: If the same cache is used to store StringPrep results, a problem might be introduced: a particular value might be valid for one identifier of the JID, while it is illegal for another identifier of the JID.

Implementation note: do not re-use the same values in different tests. As we have no control over the JID cache, we might end up testing against a cached value of the cache that's being tested by this JUnit testcase.

Author:
Guus der Kinderen, guus.der.kinderen@gmail.com
See Also:
Tinder bugtracker: TINDER-8

Constructor Summary
StringPrepCacheTest()
           
 
Method Summary
 void testNode()
          Verifies that when a cached instance is used to construct a JID, no unexpected exceptions pop up.
 void testNodeDomainCacheLookup()
          Verify cache usage, by inserting a value in the cache that's a valid node, but an invalid domain identifier.
 void testResourceDomainCacheLookup()
          Verify cache usage, by inserting a value in the cache that's a valid resource, but an invalid domain identifier.
 void testResourceNodeCacheLookup()
          Verify cache usage, by inserting a value in the cache that's a valid resource, but an invalid node identifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringPrepCacheTest

public StringPrepCacheTest()
Method Detail

testNode

public void testNode()
Verifies that when a cached instance is used to construct a JID, no unexpected exceptions pop up.


testNodeDomainCacheLookup

public void testNodeDomainCacheLookup()
Verify cache usage, by inserting a value in the cache that's a valid node, but an invalid domain identifier. Next, create a JID that uses this value for its domain identifier. This JID constructions should fail, but will succeed if the cache that was used to store the node-value is the same cache that's used to lookup previously stringprepped domain identifiers.


testResourceDomainCacheLookup

public void testResourceDomainCacheLookup()
Verify cache usage, by inserting a value in the cache that's a valid resource, but an invalid domain identifier. Next, create a JID that uses this value for its domain identifier. This JID constructions should fail, but will succeed if the cache that was used to store the resource-value is the same cache that's used to lookup previously stringprepped domain identifiers.


testResourceNodeCacheLookup

public void testResourceNodeCacheLookup()
Verify cache usage, by inserting a value in the cache that's a valid resource, but an invalid node identifier. Next, create a JID that uses this value for its domain identifier. This JID constructions should fail, but will succeed if the cache that was used to store the resource-value is the same cache that's used to lookup previously stringprepped node identifiers.