Package org.hornetq.tests.integration.cluster.failover

Source Code of org.hornetq.tests.integration.cluster.failover.LargeMessageFailoverTest

/*
* Copyright 2009 Red Hat, Inc.
* Red Hat licenses this file to you under the Apache License, version
* 2.0 (the "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*    http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied.  See the License for the specific language governing
* permissions and limitations under the License.
*/

package org.hornetq.tests.integration.cluster.failover;

import junit.framework.Assert;

import org.hornetq.api.core.HornetQBuffer;
import org.hornetq.api.core.client.ClientMessage;
import org.hornetq.core.client.impl.ClientSessionFactoryInternal;
import org.hornetq.core.logging.Logger;
import org.hornetq.tests.util.UnitTestCase;

/**
* A LargeMessageFailoverTest
*
* @author <mailto:clebert.suconic@jboss.org">Clebert Suconic</a>
*
*
*/
public class LargeMessageFailoverTest extends FailoverTest
{

   // Constants -----------------------------------------------------

   private static final Logger log = Logger.getLogger(LargeMessageFailoverTest.class);

  
   private static final int MIN_LARGE_MESSAGE = 1024;
  
   private static final int LARGE_MESSAGE_SIZE = MIN_LARGE_MESSAGE * 3;
  
   // Attributes ----------------------------------------------------

   // Static --------------------------------------------------------

   // Constructors --------------------------------------------------

   // Public --------------------------------------------------------

   // Package protected ---------------------------------------------

   // Protected -----------------------------------------------------
  
   /**
    * @param name
    */
   public LargeMessageFailoverTest(final String name)
   {
      super(name);
   }

   /**
    *
    */
   public LargeMessageFailoverTest()
   {
      super();
   }

   /**
    * @param i
    * @param message
    */
   @Override
   protected void assertMessageBody(final int i, final ClientMessage message)
   {
      HornetQBuffer buffer = message.getBodyBuffer();

      for (int j = 0; j < LARGE_MESSAGE_SIZE; j++)
      {
         Assert.assertEquals("equal at " + j, buffer.readByte(), UnitTestCase.getSamplebyte(j));
      }
   }
  

   protected ClientSessionFactoryInternal getSessionFactory()
   {
      ClientSessionFactoryInternal sf = super.getSessionFactory();
      sf.setMinLargeMessageSize(LARGE_MESSAGE_SIZE);
      return sf;
   }



   /**
    * @param i
    * @param message
    */
   @Override
   protected void setBody(final int i, final ClientMessage message) throws Exception
   {
      message.setBodyInputStream(UnitTestCase.createFakeLargeStream(LARGE_MESSAGE_SIZE));
   }

   // Private -------------------------------------------------------

   // Inner classes -------------------------------------------------

}
TOP

Related Classes of org.hornetq.tests.integration.cluster.failover.LargeMessageFailoverTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.