This is a tool that simplifies testing by allowing one to create test interface implementations from a yml object definition.
For example, consider the following interfaces:
public interface SomeInterface {
String getName();
int getIntValue();
SomeOtherInterface getRelatedObject();
}
public interface SomeOtherInterface {
String getOtherName();
Collection<SomeInterface> getLotsOfStuff();
}
One can easily piece together a definition of all of these objects using the following yml definition:
--- !SomeInterface
name: my name
intValue: 925
relatedObject:
otherName: other name
lotsOfStuff: !SomeInterface
- name: look, nested name
intValue: 1
- name: look, another nested name
intValue: 2
If the above file is in /tmp/test.yml, then the following
code should work:
YamlMock<SomeInterface> ym=new YamlMock<SomeInterface>(SomeInterface.class);
FileReader fr=new FileReader("/tmp/test.yml");
try {
SomeInterface si=ym.create(fr);
// The following will print ``my name'':
System.out.println(si.getName());
// The following will print ``nested name'':
System.out.println(si.getRelatedObject().iterator().next().getName());
} finally {
fr.close();
}
See the the API docs for more details.
My maven 1 repository has the latest binary version here:
http://bleu.west.spy.net/~dustin/repo/
The source can be downloaded or checked out from my mercurial repository.
This project is built on the JvYAML parser.