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"));
}
}