[jboss-cvs] JBoss Messaging SVN: r6099 - trunk/tests/src/org/jboss/messaging/tests/unit/util.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Mar 16 23:45:56 EDT 2009


Author: clebert.suconic at jboss.com
Date: 2009-03-16 23:45:56 -0400 (Mon, 16 Mar 2009)
New Revision: 6099

Modified:
   trunk/tests/src/org/jboss/messaging/tests/unit/util/SimpleStringTest.java
Log:
Auto cleanup only ... no code changes at this commit

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/util/SimpleStringTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/util/SimpleStringTest.java	2009-03-17 03:08:17 UTC (rev 6098)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/util/SimpleStringTest.java	2009-03-17 03:45:56 UTC (rev 6099)
@@ -18,7 +18,7 @@
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */ 
+ */
 
 package org.jboss.messaging.tests.unit.util;
 
@@ -39,211 +39,211 @@
  */
 public class SimpleStringTest extends UnitTestCase
 {
-	public void testString() throws Exception
-	{
-		final String str = "hello123ABC__524`16254`6125!%^$!%$!%$!%$!%!$%!$$!\uA324";
-		
-		SimpleString s = new SimpleString(str);
-		
-		assertEquals(str, s.toString());
-		
-		assertEquals(2 * str.length(), s.getData().length);
-		
-		byte[] data = s.getData();
-		
-		SimpleString s2 = new SimpleString(data);
-		
-		assertEquals(str, s2.toString());
-	}
-	
-	public void testStartsWith() throws Exception
-	{
-		SimpleString s1 = new SimpleString("abcdefghi");
-		
-		assertTrue(s1.startsWith(new SimpleString("abc")));
-		
-		assertTrue(s1.startsWith(new SimpleString("abcdef")));
-		
-		assertTrue(s1.startsWith(new SimpleString("abcdefghi")));
-		
-		assertFalse(s1.startsWith(new SimpleString("abcdefghijklmn")));
-		
-		assertFalse(s1.startsWith(new SimpleString("aardvark")));
-		
-		assertFalse(s1.startsWith(new SimpleString("z")));
-	}
-	
-	public void testCharSequence() throws Exception
-	{
-		String s = "abcdefghijkl";
-		SimpleString s1 = new SimpleString(s);
-		
-		assertEquals('a', s1.charAt(0));
-		assertEquals('b', s1.charAt(1));
-		assertEquals('c', s1.charAt(2));
-		assertEquals('k', s1.charAt(10));
-		assertEquals('l', s1.charAt(11));
-		
-		try
-		{
-			s1.charAt(-1);
-			fail("Should throw exception");
-		}
-		catch (IndexOutOfBoundsException e)
-		{
-			//OK
-		}
-		
-		try
-		{
-			s1.charAt(-2);
-			fail("Should throw exception");
-		}
-		catch (IndexOutOfBoundsException e)
-		{
-			//OK
-		}
-		
-		try
-		{
-			s1.charAt(s.length());
-			fail("Should throw exception");
-		}
-		catch (IndexOutOfBoundsException e)
-		{
-			//OK
-		}
-		
-		try
-		{
-			s1.charAt(s.length() + 1);
-			fail("Should throw exception");
-		}
-		catch (IndexOutOfBoundsException e)
-		{
-			//OK
-		}
-		
-		assertEquals(s.length(), s1.length());
-		
-		CharSequence ss = s1.subSequence(0, s1.length());
-		
-		assertEquals(ss, s1);
-		
-		ss = s1.subSequence(1, 4);
-		assertEquals(ss, new SimpleString("bcd"));
-		
-		ss = s1.subSequence(5, 10);
-		assertEquals(ss, new SimpleString("fghij"));
-		
-		ss = s1.subSequence(5, 12);
-		assertEquals(ss, new SimpleString("fghijkl"));
-		
-		try
-		{
-			s1.subSequence(-1, 2);
-			fail("Should throw exception");
-		}
-		catch (IndexOutOfBoundsException e)
-		{
-			//OK
-		}
-		
-		try
-		{
-			s1.subSequence(-4, -2);
-			fail("Should throw exception");
-		}
-		catch (IndexOutOfBoundsException e)
-		{
-			//OK
-		}
-		
-		try
-		{
-			s1.subSequence(0, s1.length() + 1);
-			fail("Should throw exception");
-		}
-		catch (IndexOutOfBoundsException e)
-		{
-			//OK
-		}
-		
-		try
-		{
-			s1.subSequence(0, s1.length() + 2);
-			fail("Should throw exception");
-		}
-		catch (IndexOutOfBoundsException e)
-		{
-			//OK
-		}
-		
-		try
-		{
-			s1.subSequence(5, 1);
-			fail("Should throw exception");
-		}
-		catch (IndexOutOfBoundsException e)
-		{
-			//OK
-		}
-	}
-	
-	public void testEquals() throws Exception
-	{
-	   assertFalse(new SimpleString("abcdef").equals(new Object()));
-	   
-		assertEquals(new SimpleString("abcdef"), new SimpleString("abcdef"));
-		
-		assertFalse(new SimpleString("abcdef").equals(new SimpleString("abggcdef")));
+   public void testString() throws Exception
+   {
+      final String str = "hello123ABC__524`16254`6125!%^$!%$!%$!%$!%!$%!$$!\uA324";
+
+      SimpleString s = new SimpleString(str);
+
+      assertEquals(str, s.toString());
+
+      assertEquals(2 * str.length(), s.getData().length);
+
+      byte[] data = s.getData();
+
+      SimpleString s2 = new SimpleString(data);
+
+      assertEquals(str, s2.toString());
+   }
+
+   public void testStartsWith() throws Exception
+   {
+      SimpleString s1 = new SimpleString("abcdefghi");
+
+      assertTrue(s1.startsWith(new SimpleString("abc")));
+
+      assertTrue(s1.startsWith(new SimpleString("abcdef")));
+
+      assertTrue(s1.startsWith(new SimpleString("abcdefghi")));
+
+      assertFalse(s1.startsWith(new SimpleString("abcdefghijklmn")));
+
+      assertFalse(s1.startsWith(new SimpleString("aardvark")));
+
+      assertFalse(s1.startsWith(new SimpleString("z")));
+   }
+
+   public void testCharSequence() throws Exception
+   {
+      String s = "abcdefghijkl";
+      SimpleString s1 = new SimpleString(s);
+
+      assertEquals('a', s1.charAt(0));
+      assertEquals('b', s1.charAt(1));
+      assertEquals('c', s1.charAt(2));
+      assertEquals('k', s1.charAt(10));
+      assertEquals('l', s1.charAt(11));
+
+      try
+      {
+         s1.charAt(-1);
+         fail("Should throw exception");
+      }
+      catch (IndexOutOfBoundsException e)
+      {
+         // OK
+      }
+
+      try
+      {
+         s1.charAt(-2);
+         fail("Should throw exception");
+      }
+      catch (IndexOutOfBoundsException e)
+      {
+         // OK
+      }
+
+      try
+      {
+         s1.charAt(s.length());
+         fail("Should throw exception");
+      }
+      catch (IndexOutOfBoundsException e)
+      {
+         // OK
+      }
+
+      try
+      {
+         s1.charAt(s.length() + 1);
+         fail("Should throw exception");
+      }
+      catch (IndexOutOfBoundsException e)
+      {
+         // OK
+      }
+
+      assertEquals(s.length(), s1.length());
+
+      CharSequence ss = s1.subSequence(0, s1.length());
+
+      assertEquals(ss, s1);
+
+      ss = s1.subSequence(1, 4);
+      assertEquals(ss, new SimpleString("bcd"));
+
+      ss = s1.subSequence(5, 10);
+      assertEquals(ss, new SimpleString("fghij"));
+
+      ss = s1.subSequence(5, 12);
+      assertEquals(ss, new SimpleString("fghijkl"));
+
+      try
+      {
+         s1.subSequence(-1, 2);
+         fail("Should throw exception");
+      }
+      catch (IndexOutOfBoundsException e)
+      {
+         // OK
+      }
+
+      try
+      {
+         s1.subSequence(-4, -2);
+         fail("Should throw exception");
+      }
+      catch (IndexOutOfBoundsException e)
+      {
+         // OK
+      }
+
+      try
+      {
+         s1.subSequence(0, s1.length() + 1);
+         fail("Should throw exception");
+      }
+      catch (IndexOutOfBoundsException e)
+      {
+         // OK
+      }
+
+      try
+      {
+         s1.subSequence(0, s1.length() + 2);
+         fail("Should throw exception");
+      }
+      catch (IndexOutOfBoundsException e)
+      {
+         // OK
+      }
+
+      try
+      {
+         s1.subSequence(5, 1);
+         fail("Should throw exception");
+      }
+      catch (IndexOutOfBoundsException e)
+      {
+         // OK
+      }
+   }
+
+   public void testEquals() throws Exception
+   {
+      assertFalse(new SimpleString("abcdef").equals(new Object()));
+
+      assertEquals(new SimpleString("abcdef"), new SimpleString("abcdef"));
+
+      assertFalse(new SimpleString("abcdef").equals(new SimpleString("abggcdef")));
       assertFalse(new SimpleString("abcdef").equals(new SimpleString("ghijkl")));
-	}
-	
-	public void testHashcode() throws Exception
+   }
+
+   public void testHashcode() throws Exception
    {
-	   SimpleString str = new SimpleString("abcdef");
+      SimpleString str = new SimpleString("abcdef");
       SimpleString sameStr = new SimpleString("abcdef");
       SimpleString differentStr = new SimpleString("ghijk");
-      
+
       assertTrue(str.hashCode() == sameStr.hashCode());
       assertFalse(str.hashCode() == differentStr.hashCode());
    }
-	
-	public void testUnicode() throws Exception
+
+   public void testUnicode() throws Exception
    {
       String myString = "abcdef&^*&!^ghijkl\uB5E2\uCAC7\uB2BB\uB7DD\uB7C7\uB3A3\uBCE4\uB5A5";
 
       SimpleString s = new SimpleString(myString);
       byte[] data = s.getData();
       s = new SimpleString(data);
-      
+
       assertEquals(myString, s.toString());
    }
-	
-	public void testUnicodeWithSurrogates() throws Exception
+
+   public void testUnicodeWithSurrogates() throws Exception
    {
       String myString = "abcdef&^*&!^ghijkl\uD900\uDD00";
 
       SimpleString s = new SimpleString(myString);
       byte[] data = s.getData();
       s = new SimpleString(data);
-      
+
       assertEquals(myString, s.toString());
    }
-	
-	public void testSizeofString() throws Exception
-   {	   
+
+   public void testSizeofString() throws Exception
+   {
       assertEquals(DataConstants.SIZE_INT, SimpleString.sizeofString(new SimpleString("")));
 
-	   SimpleString str = new SimpleString(randomString());
-	   assertEquals(DataConstants.SIZE_INT + str.getData().length, SimpleString.sizeofString(str));
+      SimpleString str = new SimpleString(randomString());
+      assertEquals(DataConstants.SIZE_INT + str.getData().length, SimpleString.sizeofString(str));
    }
-	
-	public void testSizeofNullableString() throws Exception
-   {     
+
+   public void testSizeofNullableString() throws Exception
+   {
       assertEquals(1, SimpleString.sizeofNullableString(null));
-      
+
       assertEquals(1 + DataConstants.SIZE_INT, SimpleString.sizeofNullableString(new SimpleString("")));
 
       SimpleString str = new SimpleString(randomString());
@@ -268,6 +268,7 @@
       assertEquals(strings[0], new SimpleString("abcd"));
       assertEquals(strings[1], new SimpleString("efghi"));
    }
+
    public void testSplitmanyDelimeters() throws Exception
    {
       SimpleString s = new SimpleString("abcd.efghi.jklmn.opqrs.tuvw.xyz");
@@ -322,29 +323,27 @@
       for (int i = 0; i < 10; i++)
       {
          assertEquals(new SimpleString("abcdefg-" + i), start.concat("-" + Integer.toString(i)));
-         
+
       }
    }
-   
-   
+
    public void testMultithreadHashCode() throws Exception
    {
       for (int repeat = 0; repeat < 10; repeat++)
       {
-         
+
          StringBuffer buffer = new StringBuffer();
-         
-         for (int i = 0 ; i < 100; i++)
+
+         for (int i = 0; i < 100; i++)
          {
             buffer.append("Some Big String " + i);
          }
          String strvalue = buffer.toString();
 
          final int initialhash = new SimpleString(strvalue).hashCode();
-         
+
          final SimpleString value = new SimpleString(strvalue);
-         
-         
+
          int nThreads = 100;
          final CountDownLatch latch = new CountDownLatch(nThreads);
          final CountDownLatch start = new CountDownLatch(1);
@@ -353,6 +352,7 @@
          {
             boolean failed = false;
 
+            @Override
             public void run()
             {
                try
@@ -361,7 +361,7 @@
                   start.await();
 
                   int newhash = value.hashCode();
-                  
+
                   if (newhash != initialhash)
                   {
                      failed = true;
@@ -396,5 +396,5 @@
          }
       }
    }
-   
+
 }




More information about the jboss-cvs-commits mailing list