Package desmoj.extensions.crossbar

Source Code of desmoj.extensions.crossbar.MessageCrossbarTest

package desmoj.extensions.crossbar;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import desmoj.core.simulator.Experiment;
import desmoj.core.simulator.Model;
import desmoj.core.simulator.SimProcess;

public class MessageCrossbarTest {

  private Model owner;

  @Test
  public void canbeCreated() throws Exception {
    new MessageCrossbar<SimProcess>(owner, "crossbar", true, true);
  }

  @Test
  public void canCreateDifferentlyNamedMessageChannels() {
    MessageCrossbar<SimProcess> messageCrossbar = new MessageCrossbar<SimProcess>(owner, "crossbar", true, true);
    Assert.assertNotNull(messageCrossbar.createMessageChannel("channel1"));
    Assert.assertNotNull(messageCrossbar.createMessageChannel("channel2"));
  }

  @Test
  public void canCreateMessageChannel() {
    MessageCrossbar<SimProcess> messageCrossbar = new MessageCrossbar<SimProcess>(owner, "crossbar", true, true);
    Assert.assertNotNull(messageCrossbar.createMessageChannel("channel1"));
  }

  @Test
  public void cantCreateIdenticallyNamedMessageChannels() {
    MessageCrossbar<SimProcess> messageCrossbar = new MessageCrossbar<SimProcess>(owner, "crossbar", true, true);
    Assert.assertNotNull(messageCrossbar.createMessageChannel("channel1"));
    Assert.assertNull(messageCrossbar.createMessageChannel("channel1"));
  }

  @Test
  public void cantCreateIncorrectlyNamedMessageChannels() {
    MessageCrossbar<SimProcess> messageCrossbar = new MessageCrossbar<SimProcess>(owner, "crossbar", true, true);
    Assert.assertNull(messageCrossbar.createMessageChannel(""));
    Assert.assertNull(messageCrossbar.createMessageChannel(null));
  }

  @Before
  public void setUp() {
    owner = new Model(null, "TestModel", true, true) {

      @Override
      public String description() {
        return "TestModel";
      }

      @Override
      public void doInitialSchedules() {

      }

      @Override
      public void init() {

      }
    };

    owner.connectToExperiment(new Experiment("TestExperiment"));
  }

}
TOP

Related Classes of desmoj.extensions.crossbar.MessageCrossbarTest

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.