improved test
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1198 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
efdff3ecfe
commit
d37179ed70
|
@ -187,8 +187,8 @@ public class JSONPojoConvertor implements JSON.Convertor
|
|||
catch(Exception e)
|
||||
{
|
||||
// TODO throw exception?
|
||||
Log.warn("{} property '{}' not set. (errors)", _pojoClass.getName(),
|
||||
setter.getPropertyName());
|
||||
Log.warn(_pojoClass.getName()+"#"+setter.getPropertyName()+" not set from "+
|
||||
(entry.getValue().getClass().getName())+"="+entry.getValue().toString());
|
||||
log(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ public class JSONPojoConvertorFactoryTest extends TestCase {
|
|||
|
||||
JSON.registerConvertor(Object.class, new JSONPojoConvertorFactory(jsonOut));
|
||||
JSON.registerConvertor(Object.class, new JSONPojoConvertorFactory(jsonIn));
|
||||
JSON.registerConvertor(Enum.class, new JSONEnumConvertor());
|
||||
|
||||
Foo foo = new Foo();
|
||||
foo._name = "Foo @ " + System.currentTimeMillis();
|
||||
|
@ -43,6 +44,7 @@ public class JSONPojoConvertorFactoryTest extends TestCase {
|
|||
Bar bar = new Bar("Hello", true, new Baz("World", Boolean.FALSE, foo), new Baz[]{
|
||||
new Baz("baz0", Boolean.TRUE, null), new Baz("baz1", Boolean.FALSE, null)
|
||||
});
|
||||
bar.setColor(Color.Green);
|
||||
|
||||
String s = jsonOut.toJSON(bar);
|
||||
|
||||
|
@ -60,7 +62,10 @@ public class JSONPojoConvertorFactoryTest extends TestCase {
|
|||
assertTrue(br.getBazs().length==2);
|
||||
assertEquals(br.getBazs()[0].getMessage(), "baz0");
|
||||
assertEquals(br.getBazs()[1].getMessage(), "baz1");
|
||||
assertEquals(Color.Green,br.getColor());
|
||||
}
|
||||
|
||||
enum Color { Red, Green, Blue };
|
||||
|
||||
public static class Bar
|
||||
{
|
||||
|
@ -68,6 +73,7 @@ public class JSONPojoConvertorFactoryTest extends TestCase {
|
|||
private Baz _baz;
|
||||
private boolean _boolean1;
|
||||
private Baz[] _bazs;
|
||||
private Color _color;
|
||||
|
||||
public Bar()
|
||||
{
|
||||
|
@ -94,7 +100,8 @@ public class JSONPojoConvertorFactoryTest extends TestCase {
|
|||
.append("\ntitle: ").append(getTitle())
|
||||
.append("\nboolean1: ").append(isBoolean1())
|
||||
.append("\nnullTest: ").append(getNullTest())
|
||||
.append("\nbaz: ").append(getBaz()).toString();
|
||||
.append("\nbaz: ").append(getBaz())
|
||||
.append("\ncolor: ").append(_color).toString();
|
||||
}
|
||||
|
||||
public void setTitle(String title)
|
||||
|
@ -147,6 +154,17 @@ public class JSONPojoConvertorFactoryTest extends TestCase {
|
|||
{
|
||||
return _bazs;
|
||||
}
|
||||
|
||||
public Color getColor()
|
||||
{
|
||||
return _color;
|
||||
}
|
||||
|
||||
public void setColor(Color color)
|
||||
{
|
||||
_color = color;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Baz
|
||||
|
|
Loading…
Reference in New Issue