[jboss-cvs] JBoss Messaging SVN: r6175 - in trunk/tests: src/org/jboss/messaging/tests/integration and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Mar 26 11:27:51 EDT 2009


Author: jmesnil
Date: 2009-03-26 11:27:51 -0400 (Thu, 26 Mar 2009)
New Revision: 6175

Added:
   trunk/tests/src/org/jboss/messaging/tests/integration/String64KLimitTest.java
Removed:
   trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java
Log:
moved String64KLimit test to the core integration tests

Deleted: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java	2009-03-26 14:42:43 UTC (rev 6174)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/String64KLimitTest.java	2009-03-26 15:27:51 UTC (rev 6175)
@@ -1,228 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * 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.test.messaging.jms;
-
-import javax.jms.Connection;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.ObjectMessage;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-
-/**
- * 
- * There is a bug in JDK1.3, 1.4 whereby writeUTF fails if more than 64K bytes are written
- * we need to work with all size of strings
- * 
- * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4806007
- * http://jira.jboss.com/jira/browse/JBAS-2641
- * 
- * @author <a href="tim.fox at jboss.com">Tim Fox</a>
- * @version $Revision$
- *
- * $Id$
- */
-public class String64KLimitTest extends JMSTestCase
-{
-   // Constants -----------------------------------------------------
-
-   // Static --------------------------------------------------------
-   
-   // Attributes ----------------------------------------------------
-
-   // Constructors --------------------------------------------------
-
-   // TestCase overrides -------------------------------------------
-
-   // Public --------------------------------------------------------
-         
-   protected String genString(int len)
-   {
-      char[] chars = new char[len];
-      for (int i = 0; i < len; i++)
-      {
-         chars[i] = (char)(65 + i % 26);
-      }
-      return new String(chars);
-   }
-   
-
-   public void test64KLimitWithTextMessage() throws Exception
-   {            
-      Connection conn = null;
-      
-      try
-      {         
-         conn = cf.createConnection();
-   
-         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         
-         MessageProducer prod = sess.createProducer(queue1);
-         
-         MessageConsumer cons = sess.createConsumer(queue1);
-         
-         conn.start();                  
-               
-         String s1 = genString(16 * 1024);   
-         
-         String s2 = genString(32 * 1024); 
-         
-         String s3 = genString(64 * 1024); 
-         
-         String s4 = genString(10 * 64 * 1024); 
-         
-         TextMessage tm1 = sess.createTextMessage(s1);
-         
-         TextMessage tm2 = sess.createTextMessage(s2);
-         
-         TextMessage tm3 = sess.createTextMessage(s3);
-         
-         TextMessage tm4 = sess.createTextMessage(s4);
-         
-         prod.send(tm1);
-         
-         prod.send(tm2);
-         
-         prod.send(tm3);
-         
-         prod.send(tm4);
-   
-         TextMessage rm1 = (TextMessage)cons.receive(1000);
-         
-         assertNotNull(rm1);           
-         
-         TextMessage rm2 = (TextMessage)cons.receive(1000);
-         
-         assertNotNull(rm2);
-         
-         TextMessage rm3 = (TextMessage)cons.receive(1000);
-         
-         assertNotNull(rm3);
-         
-         TextMessage rm4 = (TextMessage)cons.receive(1000);
-         
-         assertNotNull(rm4);
-         
-         assertEquals(s1.length(), rm1.getText().length());
-         
-         assertEquals(s1, rm1.getText());
-         
-         assertEquals(s2.length(), rm2.getText().length());
-         
-         assertEquals(s2, rm2.getText());
-         
-         assertEquals(s3.length(), rm3.getText().length());
-         
-         assertEquals(s3, rm3.getText());
-         
-         assertEquals(s4.length(), rm4.getText().length());
-         
-         assertEquals(s4, rm4.getText());
-      }
-      finally
-      {            
-         if (conn != null)
-         {
-            conn.close();
-         }
-      }
-   }
-         
-   public void test64KLimitWithObjectMessage() throws Exception
-   {            
-      Connection conn = null;
-      
-      try
-      {         
-         conn = cf.createConnection();
-   
-         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-         
-         MessageProducer prod = sess.createProducer(queue1);
-         
-         MessageConsumer cons = sess.createConsumer(queue1);
-         
-         conn.start();
-               
-         String s1 = genString(16 * 1024);   
-         
-         String s2 = genString(32 * 1024); 
-         
-         String s3 = genString(64 * 1024); 
-         
-         String s4 = genString(10 * 64 * 1024);
-         
-         ObjectMessage om1 = sess.createObjectMessage();
-         
-         om1.setObject(s1);
-         
-         ObjectMessage om2 = sess.createObjectMessage();
-         
-         om2.setObject(s2);
-         
-         ObjectMessage om3 = sess.createObjectMessage();
-         
-         om3.setObject(s3);
-         
-         ObjectMessage om4 = sess.createObjectMessage();
-         
-         om4.setObject(s4);
-         
-         prod.send(om1);
-         
-         prod.send(om2);
-         
-         prod.send(om3);
-         
-         prod.send(om4);
-   
-         ObjectMessage rm1 = (ObjectMessage)cons.receive(1000);
-         
-         assertNotNull(rm1);
-         
-         ObjectMessage rm2 = (ObjectMessage)cons.receive(1000);
-         
-         assertNotNull(rm2);
-         
-         ObjectMessage rm3 = (ObjectMessage)cons.receive(1000);
-         
-         assertNotNull(rm3);
-         
-         ObjectMessage rm4 = (ObjectMessage)cons.receive(1000);
-         
-         assertNotNull(rm4);
-         
-         assertEquals(s1, rm1.getObject());
-         
-         assertEquals(s2, rm2.getObject());
-         
-         assertEquals(s3, rm3.getObject());
-         
-         assertEquals(s4, rm4.getObject());
-      }
-      finally
-      {            
-         conn.close();
-      }
-   }
-}

Added: trunk/tests/src/org/jboss/messaging/tests/integration/String64KLimitTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/integration/String64KLimitTest.java	                        (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/integration/String64KLimitTest.java	2009-03-26 15:27:51 UTC (rev 6175)
@@ -0,0 +1,231 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * 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.integration;
+
+import static org.jboss.messaging.tests.util.RandomUtil.randomSimpleString;
+
+import org.jboss.messaging.core.client.ClientConsumer;
+import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.client.ClientProducer;
+import org.jboss.messaging.core.client.ClientSession;
+import org.jboss.messaging.core.client.ClientSessionFactory;
+import org.jboss.messaging.core.client.impl.ClientSessionFactoryImpl;
+import org.jboss.messaging.core.config.Configuration;
+import org.jboss.messaging.core.config.TransportConfiguration;
+import org.jboss.messaging.core.config.impl.ConfigurationImpl;
+import org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory;
+import org.jboss.messaging.core.server.Messaging;
+import org.jboss.messaging.core.server.impl.MessagingServiceImpl;
+import org.jboss.messaging.tests.util.UnitTestCase;
+import org.jboss.messaging.utils.SimpleString;
+
+/**
+ * 
+ * There is a bug in JDK1.3, 1.4 whereby writeUTF fails if more than 64K bytes are written
+ * we need to work with all size of strings
+ * 
+ * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4806007
+ * http://jira.jboss.com/jira/browse/JBAS-2641
+ * 
+ * @author <a href="tim.fox at jboss.com">Tim Fox</a>
+ * @version $Revision: 6016 $
+ *
+ * $Id: String64KLimitTest.java 6016 2009-03-06 10:40:09Z jmesnil $
+ */
+public class String64KLimitTest extends UnitTestCase
+{
+   // Constants -----------------------------------------------------
+
+   // Static --------------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private MessagingServiceImpl service;
+
+   private ClientSession session;
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   protected String genString(int len)
+   {
+      char[] chars = new char[len];
+      for (int i = 0; i < len; i++)
+      {
+         chars[i] = (char)(65 + i % 26);
+      }
+      return new String(chars);
+   }
+
+   public void test64KLimitWithWriteString() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      SimpleString queue = randomSimpleString();
+
+      session.createQueue(address, queue, false);
+
+      ClientProducer producer = session.createProducer(address);
+      ClientConsumer consumer = session.createConsumer(queue);
+      session.start();
+
+      String s1 = genString(16 * 1024);
+
+      String s2 = genString(32 * 1024);
+
+      String s3 = genString(64 * 1024);
+
+      String s4 = genString(10 * 64 * 1024);
+
+      ClientMessage tm1 = session.createClientMessage(false);
+      tm1.getBody().writeString(s1);
+
+      ClientMessage tm2 = session.createClientMessage(false);
+      tm2.getBody().writeString(s2);
+
+      ClientMessage tm3 = session.createClientMessage(false);
+      tm3.getBody().writeString(s3);
+
+      ClientMessage tm4 = session.createClientMessage(false);
+      tm4.getBody().writeString(s4);
+
+      producer.send(tm1);
+
+      producer.send(tm2);
+
+      producer.send(tm3);
+
+      producer.send(tm4);
+
+      ClientMessage rm1 = consumer.receive(1000);
+
+      assertNotNull(rm1);
+
+      ClientMessage rm2 = consumer.receive(1000);
+
+      assertNotNull(rm2);
+
+      ClientMessage rm3 = consumer.receive(1000);
+
+      assertNotNull(rm3);
+
+      ClientMessage rm4 = consumer.receive(1000);
+
+      assertNotNull(rm4);
+
+      assertEquals(s1, rm1.getBody().readString());
+
+      assertEquals(s2, rm2.getBody().readString());
+
+      assertEquals(s3, rm3.getBody().readString());
+
+      assertEquals(s4, rm4.getBody().readString());
+   }
+
+   public void test64KLimitWithWriteUTF() throws Exception
+   {
+      SimpleString address = randomSimpleString();
+      SimpleString queue = randomSimpleString();
+      
+      session.createQueue(address, queue, false);
+
+      ClientProducer producer = session.createProducer(address);
+      ClientConsumer consumer = session.createConsumer(queue);
+
+      session.start();
+      
+      String s1 = genString(16 * 1024);
+
+      String s2 = genString(32 * 1024);
+
+      String s3 = genString(64 * 1024);
+
+      String s4 = genString(10 * 64 * 1024);
+
+      ClientMessage tm1 = session.createClientMessage(false);
+      tm1.getBody().writeUTF(s1);
+
+      ClientMessage tm2 = session.createClientMessage(false);
+      tm2.getBody().writeUTF(s2);
+
+      try
+      {
+         ClientMessage tm3 = session.createClientMessage(false);
+         tm3.getBody().writeUTF(s3);
+         fail("can not write UTF string bigger than 64K");
+      }
+      catch (Exception e)
+      {
+      }
+
+      try
+      {
+         ClientMessage tm4 = session.createClientMessage(false);
+         tm4.getBody().writeUTF(s4);
+         fail("can not write UTF string bigger than 64K");
+      }
+      catch (Exception e)
+      {
+      }
+
+      producer.send(tm1);
+      producer.send(tm2);
+
+      ClientMessage rm1 = consumer.receive(1000);
+
+      assertNotNull(rm1);
+
+      ClientMessage rm2 = consumer.receive(1000);
+
+      assertNotNull(rm2);
+     
+      assertEquals(s1, rm1.getBody().readUTF());
+      assertEquals(s2, rm2.getBody().readUTF());
+   }
+
+   // Protected -----------------------------------------------------
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      Configuration config = new ConfigurationImpl();
+      config.setSecurityEnabled(false);
+      service = Messaging.newNullStorageMessagingService(config);
+      service.start();
+
+      ClientSessionFactory sf = new ClientSessionFactoryImpl(new TransportConfiguration(InVMConnectorFactory.class.getName()));
+      session = sf.createSession(false, true, true);
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      session.close();
+
+      service.stop();
+
+      super.tearDown();
+   }
+}




More information about the jboss-cvs-commits mailing list