-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #1656: improve the registration of txt4 controller
- if the SAME robot issue a registration request - with the same token - that has been approved in the past - then accept this token as approved
- Loading branch information
Showing
4 changed files
with
83 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
OpenRobertaRobot/src/test/java/de/fhg/iais/roberta/RobotCommunicatorTest.java
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
...ertaRobot/src/test/java/de/fhg/iais/roberta/robotCommunication/RobotCommunicatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package de.fhg.iais.roberta.robotCommunication; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import de.fhg.iais.roberta.util.dbc.DbcException; | ||
|
||
public class RobotCommunicatorTest { | ||
static RobotCommunicationData badRegistration = new RobotCommunicationData(null, null, null, null, null, null, null, null, null); | ||
static RobotCommunicationData goodRegistration1 = new RobotCommunicationData("12345678", null, "00:11:22:33:44:55", null, null, null, null, null, null); | ||
static RobotCommunicationData goodRegistration2 = new RobotCommunicationData("12345678", null, "13:05:98:29:12:99", null, null, null, null, null, null); | ||
|
||
@Test | ||
public void testFirstCanRegister() throws Exception { | ||
RobotCommunicator rc = new RobotCommunicator(); | ||
expect(rc.addNewRegistration(goodRegistration1), RobotCommunicator.RegistrationRequest.NEW_REGISTRATION_REQUEST); | ||
} | ||
|
||
@Test(expected = DbcException.class) | ||
public void testBadRegistrationIsRejected() throws Exception { | ||
RobotCommunicator rc = new RobotCommunicator(); | ||
rc.addNewRegistration(badRegistration); | ||
} | ||
|
||
@Test | ||
public void testRegisterTwiceWithSameIp() { | ||
RobotCommunicator rc = new RobotCommunicator(); | ||
rc.addNewRegistration(goodRegistration1); | ||
expect(rc.addNewRegistration(goodRegistration1), RobotCommunicator.RegistrationRequest.REPEATED_REGISTRATION_REQUEST); | ||
} | ||
|
||
@Test | ||
public void testCantRegisterTwice() { | ||
RobotCommunicator rc = new RobotCommunicator(); | ||
rc.addNewRegistration(goodRegistration1); | ||
expect(rc.addNewRegistration(goodRegistration2), RobotCommunicator.RegistrationRequest.TOKEN_INVALID); | ||
} | ||
|
||
private void expect(RobotCommunicator.RegistrationRequest result, RobotCommunicator.RegistrationRequest expected) { | ||
Assert.assertEquals(expected, result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters