diff --git a/pom.xml b/pom.xml
index 860cda3c..f85b7573 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,6 +88,13 @@
${jackson.version}true
+
+
+ org.codehaus.jackson
+ jackson-mapper-asl
+ ${jackson.version}
+ test
+ org.hamcrest
diff --git a/src/main/java/org/springframework/hateoas/ResourceSupport.java b/src/main/java/org/springframework/hateoas/ResourceSupport.java
index e233a500..3641078d 100755
--- a/src/main/java/org/springframework/hateoas/ResourceSupport.java
+++ b/src/main/java/org/springframework/hateoas/ResourceSupport.java
@@ -21,6 +21,7 @@ import java.util.List;
import javax.xml.bind.annotation.XmlElement;
+import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import org.springframework.util.Assert;
@@ -42,6 +43,7 @@ public class ResourceSupport implements Identifiable {
/**
* Returns the {@link Link} with a rel of {@link Link#REL_SELF}.
*/
+ @JsonIgnore
public Link getId() {
return getLink(Link.REL_SELF);
}
diff --git a/src/test/java/org/springframework/hateoas/AbstractMarshallingIntegrationTests.java b/src/test/java/org/springframework/hateoas/AbstractMarshallingIntegrationTests.java
new file mode 100644
index 00000000..aa245ef6
--- /dev/null
+++ b/src/test/java/org/springframework/hateoas/AbstractMarshallingIntegrationTests.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.hateoas;
+
+import java.io.StringWriter;
+import java.io.Writer;
+
+import org.codehaus.jackson.map.ObjectMapper;
+import org.junit.Before;
+
+/**
+ * Base class to eas integration tests for {@link ObjectMapper} marshalling.
+ *
+ * @author Oliver Gierke
+ */
+public abstract class AbstractMarshallingIntegrationTests {
+
+ ObjectMapper mapper;
+
+ @Before
+ public void setUp() {
+ mapper = new ObjectMapper();
+ }
+
+ protected String write(Object object) throws Exception {
+
+ Writer writer = new StringWriter();
+ mapper.writeValue(writer, object);
+ return writer.toString();
+ }
+}
diff --git a/src/test/java/org/springframework/hateoas/ResourceIntegrationTest.java b/src/test/java/org/springframework/hateoas/ResourceIntegrationTest.java
new file mode 100644
index 00000000..045296c9
--- /dev/null
+++ b/src/test/java/org/springframework/hateoas/ResourceIntegrationTest.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.hateoas;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
+
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
+import org.junit.Test;
+
+/**
+ * Integration tests for {@link Resource}.
+ *
+ * @author Oliver Gierke
+ */
+public class ResourceIntegrationTest extends AbstractMarshallingIntegrationTests {
+
+ @Test
+ public void inlinesContent() throws Exception {
+
+ Person person = new Person();
+ person.firstname = "Dave";
+ person.lastname = "Matthews";
+
+ assertThat(write(new Resource(person)),
+ is("{\"links\":[],\"firstname\":\"Dave\",\"lastname\":\"Matthews\"}"));
+ }
+
+ @JsonAutoDetect(fieldVisibility = Visibility.ANY)
+ static class Person {
+
+ String firstname;
+ String lastname;
+ }
+}
diff --git a/src/test/java/org/springframework/hateoas/ResourceSupportIntegrationTest.java b/src/test/java/org/springframework/hateoas/ResourceSupportIntegrationTest.java
new file mode 100644
index 00000000..60a502ed
--- /dev/null
+++ b/src/test/java/org/springframework/hateoas/ResourceSupportIntegrationTest.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.hateoas;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+/**
+ * Integration tests for {@link ResourceSupport}.
+ *
+ * @author Oliver Gierke
+ */
+public class ResourceSupportIntegrationTest extends AbstractMarshallingIntegrationTests {
+
+ /**
+ * @see #7
+ */
+ @Test
+ public void doesNotRenderId() throws Exception {
+
+ ResourceSupport resourceSupport = new ResourceSupport();
+ resourceSupport.add(new Link("localhost"));
+
+ assertThat(write(resourceSupport), is("{\"links\":[{\"rel\":\"self\",\"href\":\"localhost\"}]}"));
+ }
+}