Package org.waveprotocol.wave.media.model

Examples of org.waveprotocol.wave.media.model.AttachmentId


*/
public abstract class AttachmentStoreTestBase extends TestCase {

  public void testStoreReturnsNullForNonexistantId() throws IOException {
    AttachmentStore store = newAttachmentStore();
    AttachmentId id = new AttachmentId("", "some_madeup_id");
    assertNull(store.getAttachment(id));
  }
View Full Code Here


    assertNull(store.getAttachment(id));
  }

  public void testStoreCanStoreData() throws Exception {
    String testData = "some file data";
    AttachmentId id = new AttachmentId("", "id_1");
    AttachmentStore store = makeStoreWithData(id, testData);

    AttachmentData data = store.getAttachment(id);
    assertEquals(testData, dataToString(data));
  }
View Full Code Here

    assertEquals(testData, dataToString(data));
  }

  public void testContentLengthMatchesDataSize() throws Exception {
    String testData = "blah blah blah";
    AttachmentId id = new AttachmentId("", "id_2");
    AttachmentStore store = makeStoreWithData(id, testData);

    AttachmentData data = store.getAttachment(id);
    assertEquals(testData.length(), data.getSize());
  }
View Full Code Here

    assertEquals(testData.length(), data.getSize());
  }

  public void testStoreCanDeleteData() throws Exception {
    String testData = "some day, I'm going to run out of test strings";
    AttachmentId id = new AttachmentId("", "id_3");
    AttachmentStore store = makeStoreWithData(id, testData);

    store.deleteAttachment(id);
    AttachmentData data = store.getAttachment(id);
    assertNull(data);
View Full Code Here

    assertNull(data);
  }

  public void testAttachmentCanWriteToOutputStream() throws Exception {
    String testData = "maybe there's some easy way to generate test strings";
    AttachmentId id = new AttachmentId("", "id_4");
    AttachmentStore store = makeStoreWithData(id, testData);
    AttachmentData data = store.getAttachment(id);

    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    InputStream io = data.getInputStream();
View Full Code Here

    }
  }

  public void testAttachmentHasWorkingInputStream() throws Exception {
    String testData = "I suppose these strings don't actually need to be different";
    AttachmentId id = new AttachmentId("", "id_5");
    AttachmentStore store = makeStoreWithData(id, testData);
    AttachmentData data = store.getAttachment(id);

    BufferedReader reader = new BufferedReader(new InputStreamReader(data.getInputStream()));
View Full Code Here

    assertEquals(testData, builder.toString());
  }

  public void testGetStreamReturnsNewStream() throws Exception {
    String testData = "There's something quite peaceful about writing tests.";
    AttachmentId id = new AttachmentId("", "id_6");
    AttachmentStore store = makeStoreWithData(id, testData);
    AttachmentData data = store.getAttachment(id);

    InputStream is1 = data.getInputStream();
    InputStream is2 = data.getInputStream();
View Full Code Here

    }
  }

  public void testOverwriteAttachmentThrowsException() throws Exception {
    String testData = "First.";
    AttachmentId id = new AttachmentId("", "id_7");
    AttachmentStore store = makeStoreWithData(id, testData);

    boolean exceptionThrown=false;
    try {
      // A second element added with the same ID should not write.
View Full Code Here

  @Override
  public void execute(OperationRequest operation, OperationContext context, ParticipantId participant)
      throws InvalidRequestException {
    WaveId waveId;
    WaveletId waveletId;
    AttachmentId attachmentId;
    RawAttachmentData attachmentData;
    try {
      waveId = ApiIdSerializer.instance().deserialiseWaveId(
          OperationUtil.<String>getRequiredParameter(operation, ParamsProperty.WAVE_ID));
      waveletId = ApiIdSerializer.instance().deserialiseWaveletId(
View Full Code Here

  }

  @Override
  public void execute(OperationRequest operation, OperationContext context, ParticipantId participant)
      throws InvalidRequestException {
    AttachmentId attachmentId;
    try {
      attachmentId =  AttachmentId.deserialise(OperationUtil.<String>getRequiredParameter(operation,
          ParamsProperty.ATTACHMENT_ID));
    } catch (InvalidIdException ex) {
      throw new InvalidRequestException("Invalid id", operation, ex);
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.media.model.AttachmentId

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.