Closed sphaso closed 9 years ago
Tests were failing when they were going fine a few days ago. I don't know if something on the DB changed, if DB is down or what. This is the issue with calling the DB inside tests. I'll rewrite them once we add an isolation framework. I'm sorry I had to take such a drastic approach.
All in all I really like what you've done. What sort of things should go into the datalayer - factories and repositories, or is it simply objects that represent data with no business logic attached?
Thanks Padda, and sorry again for the mess. I'll implement a better version tonight. On the datalayer I usually put classes that have to do with stuff in the "outside world" so DB, Web services, FTP... but mainly DB. So yeah, repositories and their factories (but not factories in general).
No worries, that's why there's such a thing as collaboration. :) Datalayer makes perfect sense then. Good job!
Also just realised the server writes a Response object out when logging in, but the client reads a String and parses a boolean from that... I'm not sure how sending objects over the network works, if it does at all - I've always converted to Strings and sent those. Perhaps we need to serialise and write out over a DataOutputStream and read DataInputStream and not the PrintWriter and BufferedReader we are currently using
You can declare objects as Serializable. I don't know exactly how it works because I've never actually done it. But we'll figure it out.
Google is our friend! I've serialized images before, but never custom classes. Will do some investigation
Do we still have an "inspector" user in the DB? I'm sure those tests were passing a few days ago...
Yes we do. Check reddit messages for your database username, etc. That test is failing because of the client expecting a boolean I would think
The test is on the server and is throwing a RowToModelParseException (the custom exception I throw in the Repository). I'll investigate.
Because of the broad catch statement?
Just noticed there are empty catches in DatabasePersistence. They were hiding the real exception.
IRC? My internet is being sketchy. Think those were intended for logging, but not implemented yet (I'll get onto it once this is finalised). If you want to change it up feel free.
Both fail because the Response object is being read as a string and parsed into a boolean. Need to use ObjectInputStream and ObjectOutputStream to send/receive Response objects then tests will pass.
The other issue is that the catch statements for fetching data from the DB in UserRepository are still too broad and so are catching a NullPointerException when username is incorrect as an error reading from database. Should rather throw an AuthenticationException.
1) I see. Can you give me a snippet \ example so I can implement it ASA I get back home?
2) OK, I'll throw an AuthenticationException if I get null from DatabasePersistence
Replace new BufferedReader
with new ObjectInputStream
and new PrintWriter
with new ObjectOutputStream
in ClientConnectionThread and ServerConnection. You must also implement Serializable in the Response object.
To write an object out:
out.writeObject(response);
To read an object:
Response response = (Response) in.readObject();
Merged :dancers:
Starting point to develop more involved user functionalities.