Zápočtový test 13. 2. 2018 (odpoledne; Jančík)

Předmět zaměřený na praktické programování v jazyku a prostředí Java
PObdr
Site Admin
Příspěvky: 11
Registrován: 5. 10. 2014 00:54
Typ studia: Informatika Bc.

Zápočtový test 13. 2. 2018 (odpoledne; Jančík)

Příspěvek od PObdr »

Zadáním bylo v podstatě simulovat curl, schopnost odeslat POST a GET na server. Byla k tomu hra s roboty.

Poznámka: robot je ovládán z počítače, nemusí mít žádnou inteligenci.

Oficiální zadání
2018-02-13-Robots.zip
Ze stránek zkoušejícího
(2.85 MiB) Staženo 346 x
Goal
On the http://u2-0.ms.mff.cuni.cz:8080/java/api address runs a web server.
Your goals is using following HTTP calls to
1) create a robot
2) kill another robot
3) go to the exit of the maze
Number of robots is you can create is unlimited.
The state of the simulation is show in server console and will be provided from the projector.

The server supports following endpoints.
* List of existing robots

Kód: Vybrat vše

curl -v -X GET http://u2-0.ms.mff.cuni.cz:8080/java/api/robots
Gets json array with list of exisitng robots and theirs ids.

* Create a new robot (will be deleted after a minute without any activity).
The robot will be created at random position with random orientation.

Kód: Vybrat vše

curl -X POST http://u2-0.ms.mff.cuni.cz:8080/java/api/robots -d '{"name": "my_first_robot"}'
Sample output: píše:

Kód: Vybrat vše

{
      "id": "1",
      "name": "my_second_robot"
}
* Get information about the robot

Kód: Vybrat vše

#curl -X GET http://u2-0.ms.mff.cuni.cz:8080/java/api/robots/{robot_id}/
curl -X GET http://u2-0.ms.mff.cuni.cz:8080/java/api/robots/1/
Sample output: píše:

Kód: Vybrat vše

{
      "id": "1",
      "name": "my_first_robot",
      "state": "NEED_KILL",
      "direction": "UP",
      "posX": 7,
      "posY": 8,
      "surrounding": " *   \n    *\n  R *\n    *\n    *\n"
}
* Gets information about executed and scheduled actions

Kód: Vybrat vše

#curl -v  http://u2-0.ms.mff.cuni.cz:8080/java/api/robots/{robot_id}/actions
curl -v  http://u2-0.ms.mff.cuni.cz:8080/java/api/robots/1/actions
Sample output: píše:

Kód: Vybrat vše

{
      "id": "1",
      "name": "my_first_robot",
      "executedActions": [
        "TURN_LEFT",
        "TURN_RIGHT"
      ],
      "plannedActions": [
        "FIRE",
        "FIRE"
      ]
}
* Schedule action of the robot
Output see GET method on the endpoint (see above)

Kód: Vybrat vše

curl -X POST http://u2-0.ms.mff.cuni.cz:8080/java/api/robots/{robot_id}/actions -d '{"action": "TURN_LEFT"}'
curl -X POST http://u2-0.ms.mff.cuni.cz:8080/java/api/robots/{robot_id}/actions -d '{"action": "TURN_RIGHT"}'
curl -X POST http://u2-0.ms.mff.cuni.cz:8080/java/api/robots/{robot_id}/actions -d '{"action": "MOVE_FORWARD"}'
curl -X POST http://u2-0.ms.mff.cuni.cz:8080/java/api/robots/{robot_id}/actions -d '{"action": "FIRE"}'

Notices:
Server source are located in Maven eclispse project (RobotServer.zip).
It build creates a "war" file - a part of this archive.
Run in various application server, tested in WLP (Websphere Liberty Profile), requred server.xml is provided in the archive
Copy the "robot" directory to WLP_HOME/usr/servers/
start the server WLP_HOME/bin/server start robot
logs with the state of the simulation can be found in WLP_HOME/usr/servers/robot/logs/console.log
Odpovědět

Zpět na „PGR013 Java“