marciodrosa/VoyagerSE — Issue #2: Serializing to Properties format
Author: marciodrosa
Created: 2011-11-05 19:57:09+00:00
State: open

The issue #1 was implemented using tho classes called TextReaderSerializer and TextWriterSerializer, but it was very generic and not good.

Then, the first oficial serializer will be the PropertiesSerializer, that will saves and loads the data using the same format used by the Java Properties class.

Example:

#commentary line
key=value
otherkey=other value

Test criteria:

1) Loading from a string
Given a string
When this string is used to load an Resource object using the PropertiesSerializer
Then each line represents loads one attribute: first is readed the attribute name, then the separator '=' character, and then the value (not trimmed; the whitespaces in the borders are loaded too).

2) Saving to a string
Given a Resource object
When the object is saved to a string using the PropertiesSerializer
Then each attribute is saved in on line, using the format attributename=value

3) Commentaries and blank lines
Given a string
When this string is used to load an Resource object using the PropertiesSerializer
Then the blank lines or the lines that the first no-blanck character is '#' are ignored

4) Invalid lines
Given a string
When this string is used to load an Resource object using the PropertiesSerializer
And some line is not in the format "key=value" (and is not an blank or comentary line) or the "key" is not an know attribute name
Then the line is ignored (todo: a new issue will be created to handle errors and warnings)

5) Escape character and endlines when loading
Given a string with some value that contains the \ character or \n
When this string is used to load an Resource object using the PropertiesSerializer
Then the \n is substituted by end line
and the "\" is not readed, only if it is escaped by other "\" at left.

6) Escape character and endlines when saving
Given a Resource object with some attribute that contains the \ character or end lines
When this object is saved to a string using the PropertiesSerializer
Then each end line is substituted by "\n"
and each "\" is substituted by "\\".