Package org.eclipse.orion.server.core.resources

Examples of org.eclipse.orion.server.core.resources.JSONSerializer


  protected URI cloneLocation;
  protected Repository db;
  private StoredConfig cfg;

  private GitObject() {
    this.jsonSerializer = new JSONSerializer();
  }
View Full Code Here


public class JSONSerializerTest {
  @Test
  public void testSerializeAllProperties() throws Exception {
    // given
    TestResource testResource = new TestResource();
    Serializer<JSONObject> jsonSerializer = new JSONSerializer();
    ResourceShape resourceShape = new ResourceShape();
    resourceShape.setProperties(TestResource.ALL_PROPERTIES);

    // when
    JSONObject jsonObject = jsonSerializer.serialize(testResource, resourceShape);
    String jsonString = jsonObject.toString();
    jsonObject = new JSONObject(jsonString);

    // then
    assertEquals(testResource.getName(), jsonObject.getString(TestResource.STRING_PROPERTY_NAME));
View Full Code Here

  @Test
  public void testSerializeSingleProperty() throws Exception {
    // given
    TestResource testResource = new TestResource();
    Serializer<JSONObject> jsonSerializer = new JSONSerializer();
    ResourceShape resourceShape = new ResourceShape();
    resourceShape.addProperty(TestResource.STRING_PROPERTY);

    // when
    JSONObject jsonObject = jsonSerializer.serialize(testResource, resourceShape);
    String jsonString = jsonObject.toString();
    jsonObject = new JSONObject(jsonString);

    // then
    assertEquals(testResource.getName(), jsonObject.getString(TestResource.STRING_PROPERTY_NAME));
View Full Code Here

  @Test(expected = IllegalArgumentException.class)
  public void testSerializeInvalidProperty() throws Exception {
    // given
    TestResource testResource = new TestResource();
    Serializer<JSONObject> jsonSerializer = new JSONSerializer();
    ResourceShape resourceShape = new ResourceShape();
    resourceShape.addProperty(new Property("invalid"));

    // when
    jsonSerializer.serialize(testResource, resourceShape);
  }
View Full Code Here

  @Test
  public void testSerializeExtendedTestResource() throws Exception {
    // given
    ExtendedTestResource testResource = new ExtendedTestResource();
    Serializer<JSONObject> jsonSerializer = new JSONSerializer();
    ResourceShape resourceShape = ResourceShapeFactory.createResourceShape(ExtendedTestResource.class, null);

    // when
    JSONObject jsonObject = jsonSerializer.serialize(testResource, resourceShape);
    String jsonString = jsonObject.toString();
    jsonObject = new JSONObject(jsonString);

    // then
    assertEquals(testResource.getName(), jsonObject.getString(TestResource.STRING_PROPERTY_NAME));
View Full Code Here

TOP

Related Classes of org.eclipse.orion.server.core.resources.JSONSerializer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.