Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of Protocol V2 #70

Open
wants to merge 97 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
5de7a9d
Adding 4 new tests for V2 protocol
Mar 25, 2018
dc54233
Implementation of Protocol V1
yosra-harbaoui Mar 27, 2018
160d7bc
test modification
yosra-harbaoui Mar 27, 2018
b4977ea
docker files
yosra-harbaoui Mar 27, 2018
32056c0
adding Tests for Protocol V2
yosra-harbaoui Mar 27, 2018
7c77d5a
Task 3 implemented, all tests passed
onicoleheig Mar 27, 2018
19d87e4
Test ProtocolV2 - SmithHeig
SmithHeig Mar 28, 2018
3d19ef0
add LionelNanchen V2 test
Mar 28, 2018
34bb3bd
Implementation of RouletteV1ClientImpl
christophe-joyet Mar 28, 2018
384a77e
adding test for protocol v2
Mar 31, 2018
83a84a9
Test for the Roulette protocol V2
mlabie Apr 1, 2018
cce4424
tests V2 impl added
onicoleheig Apr 3, 2018
d33ee1c
Added V2 tests
Angorance Apr 3, 2018
3da4065
adding tests
yannled Apr 3, 2018
2365dd4
implementation of Tests for the Roulette v2
LaghaOussama Apr 3, 2018
495c9ce
Adding some new tests
rlabinot Apr 3, 2018
5047a88
Adding tests for V2 protocol - Rochat Antoine & Schopfer Benoit
ouzgaga Apr 3, 2018
29436d1
2 tests added
romaingallay Apr 3, 2018
ade1984
Merge branch 'fb-lab02-v2-contrib' into fb-lab02-v2-tests
ouzgaga Apr 3, 2018
facb236
RouletteV2dorianekaffoTest
Apr 3, 2018
a2d1a9a
Rendu test personnalisé
shinopill Apr 3, 2018
68ddd3d
Adding tests for V2 protocol
ouzgaga Apr 3, 2018
b59aece
Merge branch 'fb-lab02-v2-contrib' into fb-lab02-v2-tests
ouzgaga Apr 3, 2018
c5f66ac
add test for v2
AdamZouari Apr 3, 2018
b06a7dd
Add tests methods name. Will be implemented
Apr 3, 2018
a523cf2
A few tests implemented
Schnoudli Apr 3, 2018
cc60bc3
A few tests are implemented
Schnoudli Apr 3, 2018
2d9bb13
add my own test for V2 protocol
Mantha32 Apr 3, 2018
66a7148
add V2 tests
ovesco Apr 4, 2018
7c46d65
Merge pull request #1 from romainSilvestri/fb-lab02-v2-contrib
wasadigi Apr 4, 2018
033701a
Merge pull request #3 from SmithHeig/fb-lab02-v2-tests
wasadigi Apr 4, 2018
a34835a
Merge pull request #4 from LionelNanchen/fb-lab02-v2-tests
wasadigi Apr 4, 2018
bb59dfc
Merge pull request #6 from olivierKopp/fb-lab02-v2-contrib
wasadigi Apr 4, 2018
36b4461
Merge pull request #15 from Angorance/fb-lab02-v2-contrib
wasadigi Apr 4, 2018
1bad178
Merge pull request #16 from yannled/test
wasadigi Apr 4, 2018
79b1ae0
Merge pull request #18 from rlabinot/fb-lab02-v2-tests
wasadigi Apr 4, 2018
1b74230
Merge pull request #19 from ouzgaga/fb-lab02-v2-tests
wasadigi Apr 4, 2018
379a55e
Merge pull request #21 from shinopill/fb-lab02-v2-contrib
wasadigi Apr 4, 2018
51ed056
Merge pull request #23 from AdamZouari/fb-lab02-v2-contrib
wasadigi Apr 4, 2018
498a94a
Merge pull request #24 from Mantha32/fb-lab02-v2-contrib
wasadigi Apr 4, 2018
6db3601
Merge pull request #27 from sysmoh/fb-lab02-v2-contrib
wasadigi Apr 4, 2018
07bd65a
Merge pull request #28 from tranqui793/fb-lab02-v2-contrib
wasadigi Apr 4, 2018
09f400e
implement of tests v2
christophe-joyet Apr 4, 2018
34b46fa
rm change from clientImpl
christophe-joyet Apr 4, 2018
e12cf50
rm change from impl file
christophe-joyet Apr 4, 2018
12d3d6a
rm change from file implClient
christophe-joyet Apr 4, 2018
de89e9e
...
christophe-joyet Apr 4, 2018
0f969e2
...
christophe-joyet Apr 4, 2018
c0f82dc
version_1_2
fabano237 Apr 4, 2018
de09a7a
First batch of student tests for v2; cleaned up; pass reference imple…
wasadigi Apr 4, 2018
173b1cc
6 Tests for the V2 Protocol added by Frueh and Muaremi
Ludwig9392 Apr 4, 2018
f7693e4
Test RouletteV2 Bryan Curchod/François Burgener
francoisburgener Apr 4, 2018
78d80a6
Récupération des testes
francoisburgener Apr 4, 2018
51da0f1
test v2
GZeed Apr 4, 2018
1e3c016
automated tests to specify the behaviour of the v2 protocol
Dumoria Apr 4, 2018
3770534
tests implemented
SachaKor Apr 4, 2018
966651b
resotre files...
onicoleheig Apr 4, 2018
70d6d2d
ajout tests pour RouletteV2Protocol
Apr 4, 2018
aac4560
restore files.. again
onicoleheig Apr 4, 2018
089d287
V2 tests Schurch Kaufmann
Jokau Apr 4, 2018
551ddbb
Added tests Roulette v2 github id: nfluckiger and manalito
manalito Apr 4, 2018
7f2f5e2
update tests Roulette v2 github id: nfluckiger and manalito
manalito Apr 4, 2018
b459c9e
Protocol V2 Tests - Adrien Allemand, Loyse Krug
Grogath Apr 4, 2018
fb9a49f
enfin ?
Nortalle Apr 4, 2018
a231229
With correct file staged ^^'
Grogath Apr 4, 2018
3cb7c92
Merge branch 'fb-lab02-v2-tests' of https://github.com/Nortalle/Teach…
Nortalle Apr 4, 2018
ac2bbb3
Some more tests
Schnoudli Apr 4, 2018
79f7c0d
tests implemented
SachaKor Apr 4, 2018
d329bc6
Remove hardcoded port for V2 and useless unimplemented tests
Apr 4, 2018
51c8b67
Correct mistake
Apr 4, 2018
c835f57
test v2
GZeed Apr 4, 2018
68662b2
Merge branch 'fb-labo02-v2-newcontrib' of https://github.com/GZeed/Te…
GZeed Apr 4, 2018
4f3d4a1
delete properties
GZeed Apr 4, 2018
9a0ae0d
Final commit
Apr 4, 2018
e2dadaf
tests v2 submitted
maxcaduff Apr 4, 2018
0b66499
Merge pull request #20 from dorianekaffo/fb-lab02-v2-contrib
wasadigi Apr 5, 2018
9314ca7
Merge pull request #22 from francoisburgener/fb-lab02-v2-tests
wasadigi Apr 5, 2018
b44e6e2
Merge pull request #29 from christophe-joyet/fb-lab02-v2-contrib
wasadigi Apr 5, 2018
18edde8
Merge pull request #30 from ericafabrice/fb-lab02-v2-contrib
wasadigi Apr 5, 2018
42c9b5f
Merge pull request #31 from Ludwig9392/fb-lab02-v2-contrib
wasadigi Apr 5, 2018
baaf06b
Merge pull request #32 from GZeed/fb-labo02-v2-newcontrib
wasadigi Apr 5, 2018
4b7016e
Merge pull request #33 from yosra-harbaoui/fb-lab02-v2-contrib
wasadigi Apr 5, 2018
baec97b
Merge pull request #35 from Dumoria/fb-lab02-v2-contrib
wasadigi Apr 5, 2018
2618c99
Merge pull request #40 from Jokau/fb-lab02-v2-contrib
wasadigi Apr 5, 2018
db5891e
Merge pull request #41 from mathieujee/fb-lab02-v2-contrib
wasadigi Apr 5, 2018
8350c1b
Merge pull request #42 from LoyseKrug/fb-lab02-v2-tests
wasadigi Apr 5, 2018
aae8eee
Merge pull request #43 from manalito/fb-lab02-v2-contrib
wasadigi Apr 5, 2018
58754f9
Merge pull request #44 from Nortalle/fb-lab02-v2-tests
wasadigi Apr 5, 2018
5077abb
Merge pull request #10 from onicoleheig/fb-lab02-v2-contrib
wasadigi Apr 5, 2018
6a10e91
Merge pull request #46 from mlabie/fb-lab02-v2-contrib
wasadigi Apr 5, 2018
790c9a0
Merge pull request #47 from amadeous/fb-lab02-v2-contrib
wasadigi Apr 5, 2018
8632d11
Merge pull request #49 from SachaKor/fb-lab02-v2-contrib
wasadigi Apr 5, 2018
b953a22
Merge pull request #51 from p-stackouse/fb-lab02-v2-contrib
wasadigi Apr 5, 2018
f48b078
Merge pull request #53 from maxcaduff/fb-lab02-v2-contrib
wasadigi Apr 5, 2018
660181f
Add second batch of curated student contributions; reference impl pas…
wasadigi Apr 5, 2018
34c74e0
Merge branch 'fb-lab02-v2-tests' of https://github.com/SoftEng-HEIGVD…
yosra-harbaoui Apr 7, 2018
806ae79
implementation of V2
yosra-harbaoui Apr 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM java:8
Maintainer Yosra Harbaoui <[email protected]>

COPY QuizRouletteServer-code-1.0-SNAPSHOT-standalone.jar /opt/app/server.jar

EXPOSE 1313

ENTRYPOINT ["java", "-jar", "/opt/app/server.jar"]
Binary file not shown.
10 changes: 10 additions & 0 deletions Docker/build-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Ask maven to build the executable jar file from the source files
mvn clean install --file ../QuizRouletteServer-build/pom.xml

# Copy the executable jar file in the current directory
cp ../QuizRouletteServer-build/QuizRouletteServer-code/target/QuizRouletteServer-code-1.0-SNAPSHOT-standalone.jar .

# Build the Docker image locally
docker build --tag java-server .
3 changes: 3 additions & 0 deletions Docker/run-container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker run -it -p 1313:1313 java-server
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void importData(BufferedReader reader) throws IOException {
LOG.log(Level.INFO, "Importing data from input reader of type {0}", reader.getClass());
List<Student> studentsToAdd = new ArrayList<>();
String record;
boolean endReached = false;
boolean endReached = false;
while (!endReached && (record = reader.readLine()) != null) {
if (record.equalsIgnoreCase(RouletteV1Protocol.CMD_LOAD_ENDOFDATA_MARKER)) {
LOG.log(Level.INFO, "End of stream reached. New students have been added to the store. How many? We'll tell you when the lab is complete...");
Expand All @@ -68,8 +68,7 @@ public void importData(BufferedReader reader) throws IOException {
}
synchronized (this) {
students.addAll(studentsToAdd);
}
}
LOG.log(Level.INFO, "There are now {0} students in the store.", getNumberOfStudents());
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/**
*
* @author Olivier Liechti
* @author Yosra Harbaoui
*/
public interface IRouletteV2Client extends IRouletteV1Client {

Expand All @@ -27,5 +28,25 @@ public interface IRouletteV2Client extends IRouletteV1Client {
* @throws IOException
*/
public List<Student> listStudents() throws IOException;


/**
* Get the number of commands sent to the server
* @return the number of commands sent to the server
* @throw IOException
*/
public int getNumberOfCommands() throws IOException;

/**
* Get the number of students stored in the server.
* @return the number of students stored in the server
* @throws IOException
*/
public int getNumberOfStudentAdded() throws IOException;

/**
* Check if the command was successfully done
* @return a boolean the success of the command
* @throws IOException
*/
public boolean checkSuccessOfCommand() throws IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,58 +13,166 @@
import java.io.PrintWriter;
import java.net.Socket;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* This class implements the client side of the protocol specification (version 1).
*
* This class implements the client side of the protocol specification (version
* 1).
*
* @author Olivier Liechti
* @author Yosra Harbaoui
*/
public class RouletteV1ClientImpl implements IRouletteV1Client {

private static final Logger LOG = Logger.getLogger(RouletteV1ClientImpl.class.getName());
private static final Logger LOG = Logger.getLogger(RouletteV1ClientImpl.class.getName());

@Override
public void connect(String server, int port) throws IOException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
/**
* protected : to be used by subclasses outside the package
*/
protected Socket socket = null;
protected BufferedReader reader = null;
protected PrintWriter writer = null;

@Override
public void disconnect() throws IOException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void connect(String server, int port) throws IOException {
/**
* 1. connection to the server
*/
socket = new Socket(server, port);

@Override
public boolean isConnected() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
/**
* 2.creation of reader and writer to communicate with the server
*/
reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
// writer = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()), true);
writer = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()), true);

@Override
public void loadStudent(String fullname) throws IOException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

@Override
public void loadStudents(List<Student> students) throws IOException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
/**
* 3.read the 1st line
*/
reader.readLine();
}

@Override
public Student pickRandomStudent() throws EmptyStoreException, IOException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void disconnect() throws IOException {
/**
* 1. send the BYE command throw the writer to close the connection
*/
writer.println(RouletteV1Protocol.CMD_BYE);
writer.flush();

reader.readLine();
/**
* 2.close the objects used to communicate with the server
*/
writer.close();
reader.close();
socket.close();
}

@Override
public int getNumberOfStudents() throws IOException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public boolean isConnected() {
return socket != null && socket.isConnected();
}

@Override
public String getProtocolVersion() throws IOException {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
@Override
public void loadStudent(String fullname) throws IOException {
/**
* 1. send the LOAD command throw the writer to load information from
* the server
*/
writer.println(RouletteV1Protocol.CMD_LOAD);
writer.flush();

/**
* 2.read the information sent from the server
*/
reader.readLine();

/**
* 3. send the full name of the student throw the writer
*/
writer.println(fullname);

/**
* 4. send the ENDOFDATA_MARKER
*/
writer.println(RouletteV1Protocol.CMD_LOAD_ENDOFDATA_MARKER);
writer.flush();

/**
* 4. read the information sent from the server
*/
reader.readLine();
}

@Override
public void loadStudents(List<Student> students) throws IOException {

writer.println(RouletteV1Protocol.CMD_LOAD);
reader.readLine();
for (Student s : students) {
writer.println(s.getFullname());
}
writer.println(RouletteV1Protocol.CMD_LOAD_ENDOFDATA_MARKER);
reader.readLine();

}

@Override
public Student pickRandomStudent() throws EmptyStoreException, IOException {
/**
* 1. send the RANDOM command throw the writer
*/
writer.println(RouletteV1Protocol.CMD_RANDOM);
writer.flush();

/**
* 2. load information to read the random name sent from the server
*/
RandomCommandResponse randomResponse = JsonObjectMapper.parseJson(reader.readLine(), RandomCommandResponse.class);

/**
* if information sent from the server is an error
*/
if (randomResponse.getError() != null) {
throw new EmptyStoreException();
}

return new Student(randomResponse.getFullname());
}

@Override
public int getNumberOfStudents() throws IOException {
/**
* 1. send the INFO command throw the writer
*/
writer.println(RouletteV1Protocol.CMD_INFO);
writer.flush();

/**
* 2. return the number of Students using information sent from the server
*/

InfoCommandResponse res = JsonObjectMapper.parseJson(reader.readLine(), InfoCommandResponse.class);

return res.getNumberOfStudents();
}

@Override
public String getProtocolVersion() throws IOException {
/**
* 1. send the INFO command throw the writer
*/
writer.println(RouletteV1Protocol.CMD_INFO);
writer.flush();

/**
* 2. return the protocol version using information sent from the server
*/
return JsonObjectMapper.parseJson(reader.readLine(),
InfoCommandResponse.class).getProtocolVersion();
}

}
Loading