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

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


*/
public class ResourceShapeTest {
  @Test
  public void testDefaultResourceShape() throws Exception {
    // when
    ResourceShape resourceShape = ResourceShapeFactory.createResourceShape(TestResource.class, null);

    // then
    Property[] properties = resourceShape.getProperties();
    assertAllPropertiesExists(properties);
  }
View Full Code Here


  }

  @Test
  public void testDefaultResourceShapeForNestedResource() throws Exception {
    // given
    ResourceShape resourceShape = ResourceShapeFactory.createResourceShape(TestResource.class, null);
    Property[] properties = resourceShape.getProperties();
    Property resourceProperty = getPropertyWithName(properties, TestResource.RESOURCE_PROPERTY_NAME);

    // when
    ResourceShape nestedResourceShape = resourceProperty.getResourceShape();

    // then
    Property[] nestedProperties = nestedResourceShape.getProperties();
    assertEquals(1, nestedProperties.length);
    assertHasProperty(nestedProperties, TestResource.LOCATION_PROPERTY);
  }
View Full Code Here

  @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);
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);
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);
View Full Code Here

TOP

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

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.