コード例 #1
0
  @Test
  public void shouldBeAbleToDeserializeADogNamedDifferently() throws Exception {
    InputStream stream =
        new ByteArrayInputStream("<pet><name>Brutus</name><age>7</age></pet>".getBytes());

    mockery.checking(
        new Expectations() {
          {
            one(provider).parameterNamesFor(bark.getMethod());
            will(returnValue(new String[] {"pet"}));
          }
        });
    Object[] deserialized = deserializer.deserialize(stream, bark);

    assertThat(deserialized.length, is(1));
    assertThat(deserialized[0], is(instanceOf(Dog.class)));
    Dog dog = (Dog) deserialized[0];
    assertThat(dog.name, is("Brutus"));
    assertThat(dog.age, is(7));
  }
コード例 #2
0
 @Test(expected = IllegalArgumentException.class)
 public void shouldNotAcceptMethodsWithMoreThanOneArgument() throws Exception {
   deserializer.deserialize(new ByteArrayInputStream(new byte[0]), jump);
 }