Save This Page
Home » openjdk-7 » net » sf » rvpf » messaging » [javadoc | source]
    1   /**
    2    * Related Values Processing Framework.
    3    *
    4    * Copyright (C) 2003 Serge Brisson.
    5    *
    6    * This software is distributable under LGPL license.
    7    * See details at the bottom of this file.
    8    *
    9    * $Header: /cvsroot/rvpf/RVPF/tests/java/src/net/sf/rvpf/messaging/TestForwarderService.java,v 1.8 2003/10/29 15:37:07 sfb Exp $
   10    */
   11   package net.sf.rvpf.messaging;
   12   
   13   import net.sf.rvpf.document.ConfigDocument;
   14   import net.sf.rvpf.mbean.ForwarderService;
   15   import net.sf.rvpf.metadata.MJD;
   16   import net.sf.rvpf.metadata.Metadata;
   17   import net.sf.rvpf.metadata.UUID;
   18   import net.sf.rvpf.store.PointValue;
   19   import net.sf.rvpf.util.Config;
   20   import net.sf.rvpf.util.Queuing;
   21   import net.sf.rvpf.util.TestService;
   22   import net.sf.rvpf.util.Queuing.Receiver;
   23   import net.sf.rvpf.util.Queuing.Sender;
   24   
   25   /** Test Forwarder Service Cycle.
   26    * 
   27    * @author Serge Brisson
   28    * @version $Revision: 1.8 $
   29    */
   30   public class TestForwarderService extends TestService {
   31   
   32       // Instance Methods.
   33   
   34       public void setUp() throws Exception {
   35           Config config;
   36           Metadata metadata;
   37           Receiver receiver;
   38   
   39           config = ConfigDocument.loadConfig(FORWARDER_SERVICE_NAME, getConfigURI());
   40           metadata = new Metadata(config);
   41   
   42           this.queuing = Queuing.create(metadata);
   43           this.queuing.setUpSession(false);
   44           this.receiver = this.queuing.createReceiver(OUTPUT_QUEUE_PROPERTY);
   45           this.receiver.purge();
   46   
   47           receiver = this.queuing.createReceiver(INPUT_QUEUE_PROPERTY);
   48           receiver.purge();
   49           receiver.close();
   50           this.sender = this.queuing.createSender(INPUT_QUEUE_PROPERTY, false);
   51   
   52           setService(new ForwarderService());
   53           super.setUp();
   54       }
   55   
   56       public void tearDown() {
   57           super.tearDown();
   58   
   59           this.sender.close();
   60           this.sender = null;
   61           this.receiver.close();
   62           this.receiver = null;
   63           this.queuing.tearDown();
   64           this.queuing = null;
   65       }
   66   
   67       // Protected Instance Methods.
   68   
   69       protected void useService() throws InterruptedException {
   70           Metadata metadata = getService().getMetadata();
   71           UUID uuid = new UUID(GHOST_POINT_UUID);
   72           Notice notice;
   73   
   74           notice = new Notice(
   75               new PointValue(
   76                   uuid.toBytes(), new MJD().getStamp(), new Integer(2)));
   77           this.sender.send(this.queuing.createMessage(notice));
   78           notice = (Notice) this.receiver.receive().getObject();
   79           assertEquals(uuid, notice.getPointUUID());
   80           assertEquals(new Integer(2), notice.getValue());
   81       }
   82   
   83       // Class Constants.
   84   
   85       private static final String GHOST_POINT_UUID = "45e8e68723655645a2238171802df725";
   86       private static final String INPUT_QUEUE_PROPERTY = ForwarderThread.INPUT_QUEUE_PROPERTY;
   87       private static final String OUTPUT_QUEUE_PROPERTY = ForwarderThread.OUTPUT_QUEUE_PROPERTY;
   88   
   89       // Instance Attributes.
   90   
   91       private Queuing queuing = null;
   92       private Receiver receiver = null;
   93       private Sender sender = null;
   94   }
   95   
   96   // $Log: TestForwarderService.java,v $
   97   // Revision 1.8  2003/10/29 15:37:07  sfb
   98   // Adapted to changes in TestService.
   99   //
  100   // Revision 1.7  2003/10/28 22:27:39  sfb
  101   // Made use of ForwarderThread class constants.
  102   //
  103   
  104   /*
  105    * This is free software; you can redistribute it and/or modify
  106    * it under the terms of the GNU Lesser General Public License
  107    * as published by the Free Software Foundation; either version 2.1
  108    * of the License, or (at your option) any later version.
  109    *
  110    * This software is distributed in the hope that it will be useful,
  111    * but WITHOUT ANY WARRANTY; without even the implied warranty of
  112    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  113    * Lesser General Public License for more details.
  114    *
  115    * You should have received a copy of the GNU Lesser General Public
  116    * License along with this software; if not, write to the Free Software
  117    * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  118    */

Save This Page
Home » openjdk-7 » net » sf » rvpf » messaging » [javadoc | source]