Skip to content
Snippets Groups Projects
Commit 87e1b7ce authored by amaehrle's avatar amaehrle
Browse files

Revert deletion of some classes

parent 039b1cee
No related branches found
No related tags found
1 merge request!17WIP: Feature #31 implement mobility model
Pipeline #
package input;
import core.Settings;
/**
* Broadcast creation external events generator. Creates uniformly distributed
* broadcast creation patterns whose message size and inter-message intervals can
* be configured.
*
* Created by Britta Heymann on 22.02.2017.
*/
public class BroadcastEventGenerator extends AbstractMessageEventGenerator {
public BroadcastEventGenerator(Settings s) {
super(s, true);
}
/**
* Returns the next broadcast creation event.
* @see EventQueue#nextEvent()
*/
@Override
public ExternalEvent nextEvent() {
/* Message is a one way message */
int responseSize = 0;
/* Draw additional message properties and create message. */
int interval = this.drawNextEventTimeDiff();
int sender = this.drawHostAddress(this.hostRange);
ExternalEvent messageCreateEvent = new BroadcastCreateEvent(
sender,
this.getID(),
this.drawMessageSize(),
responseSize,
this.nextEventsTime);
/* Update next event time before returning. */
this.advanceToNextEvent(interval);
return messageCreateEvent;
}
}
package test;
import input.AbstractMessageEventGenerator;
import org.junit.Before;
/**
* Contains common initialization for both {@link MessageEventGeneratorTest} and {@link BroadcastEventGeneratorTest}.
*
* Created by Britta Heymann on 22.02.2017.
*/
public abstract class AbstractMessageEventGeneratorTest {
/**
* The number of times a test is repeated for tests that might be non-deterministic.
*/
protected static final int NR_TRIALS_IN_TEST = 10;
protected TestSettings settings = new TestSettings();
@Before
public void init() {
this.settings.putSetting("Events.nrof", "1");
this.settings.putSetting("class", this.getMessageEventGeneratorClassName());
this.settings.putSetting(AbstractMessageEventGenerator.MESSAGE_INTERVAL_S, "1,2");
this.settings.putSetting(AbstractMessageEventGenerator.MESSAGE_SIZE_S, "500k,1M");
this.settings.putSetting(AbstractMessageEventGenerator.HOST_RANGE_S, "0,126");
this.settings.putSetting(AbstractMessageEventGenerator.MESSAGE_ID_PREFIX_S, "M");
}
/**
* Gets the class name of the class to generate message events with.
*/
protected abstract String getMessageEventGeneratorClassName();
}
package test;
import org.junit.Test;
import core.SettingsError;
import input.BroadcastCreateEvent;
import input.BroadcastEventGenerator;
import input.AbstractMessageEventGenerator;
import static org.junit.Assert.assertTrue;
/**
* Contains tests for the {@link BroadcastEventGenerator} class.
* Test set up is handled by the extended {@link AbstractMessageEventGeneratorTest} class.
*
* Created by Britta Heymann on 22.02.2017.
*/
public class BroadcastEventGeneratorTest extends AbstractMessageEventGeneratorTest {
@Test
public void testNextEventCreatesBroadcastMessages() {
AbstractMessageEventGenerator generator = new BroadcastEventGenerator(this.settings);
for(int i = 0; i < AbstractMessageEventGeneratorTest.NR_TRIALS_IN_TEST; i++) {
assertTrue(
"Event should have been the creation of a broadcast message.",
generator.nextEvent() instanceof BroadcastCreateEvent);
}
}
@Test(expected = SettingsError.class)
public void testBroadcastEventGeneratorConstructorThrowsErrorIfSingleHostIsSpecified() {
this.settings.putSetting(AbstractMessageEventGenerator.HOST_RANGE_S, "0,1");
new BroadcastEventGenerator(this.settings);
}
/**
* Gets the class name of the class to generate message events with.
*/
@Override
protected String getMessageEventGeneratorClassName() {
return BroadcastEventGenerator.class.toString();
}
}
  • Contributor

    SonarQube analysis reported 93 issues:

    • BLOCKER 3 blocker
    • CRITICAL 2 critical
    • MAJOR 25 major
    • MINOR 59 minor
    • INFO 4 info

    Watch the comments in this conversation to review them. Note: the following issues could not be reported as comments because they are located on lines that are not displayed in this commit:

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment