Example usage for javax.jms TextMessage getStringProperty

List of usage examples for javax.jms TextMessage getStringProperty

Introduction

In this page you can find the example usage for javax.jms TextMessage getStringProperty.

Prototype


String getStringProperty(String name) throws JMSException;

Source Link

Document

Returns the value of the String property with the specified name.

Usage

From source file:org.btc4j.jms.BtcMessageConverter.java

@Override
public Object fromMessage(Message object) throws JMSException, MessageConversionException {
    if ((object != null) && (object instanceof TextMessage)) {
        BtcRequestMessage request = new BtcRequestMessage();
        TextMessage message = (TextMessage) object;
        request.setBody(message.getText());
        request.setAccount(message.getStringProperty(BtcRequestMessage.BTCAPI_ACCOUNT));
        request.setPassword(message.getStringProperty(BtcRequestMessage.BTCAPI_PASSWORD));
        return request;
    }//  w w  w  .  ja v  a 2s.  c o m
    return super.fromMessage(object);
}

From source file:com.oneops.controller.jms.CmsListenerTest.java

@Test
public void msgRelease() throws Exception {
    TextMessage message = mock(TextMessage.class);
    when(message.getStringProperty("source")).thenReturn("release");
    String msgJson = gson.toJson(createCmsRelease("active"));
    when(message.getText()).thenReturn(msgJson);

    listener.onMessage(message);/*from w  ww.j av  a2  s .  c  o  m*/
    //once more to get a SKIP
    when(message.getText()).thenReturn(gson.toJson(createCmsRelease("aintactive")));
    listener.onMessage(message);
}

From source file:com.oneops.controller.jms.CmsListenerTest.java

@Test
public void msgOpsProcedure() throws Exception {
    TextMessage message = mock(TextMessage.class);
    when(message.getStringProperty("source")).thenReturn("opsprocedure");
    when(message.getJMSCorrelationID()).thenReturn(null);

    String msgJson = gson.toJson(createCmsOpsProcedure(OpsProcedureState.active));
    when(message.getText()).thenReturn(msgJson);

    listener.onMessage(message);/*from   ww  w.  ja v a 2s.  c o m*/
    //once more to get a SKIP
    when(message.getText()).thenReturn(gson.toJson(createCmsOpsProcedure(OpsProcedureState.discarded)));
    listener.onMessage(message);
}

From source file:com.oneops.controller.jms.CmsListenerTest.java

@Test
public void msgDeployment() throws Exception {
    TextMessage message = mock(TextMessage.class);
    when(message.getStringProperty("source")).thenReturn("deployment");
    String msgJson = gson.toJson(createCmsDeployment("active"));
    when(message.getText()).thenReturn(msgJson);

    listener.onMessage(message);//from  ww  w  . ja  v  a2  s  . c o m
    //once more to get a SKIP
    when(message.getText()).thenReturn(gson.toJson(createCmsDeployment("is-not-active")));
    listener.onMessage(message);

    listener.cleanup();

    listener.getConnectionStats();
}

From source file:de.slub.fedora.jms.MessageMapperTest.java

@Test
public void returnsNoIndexJobForGetObjectXmlMessage() throws Exception {
    TextMessage message = mock(TextMessage.class);
    when(message.getStringProperty(eq("pid"))).thenReturn("test:4711");
    when(message.getStringProperty(eq("methodName"))).thenReturn("getObjectXML");
    when(message.getText()).thenReturn(getContent("/jms/getObjectXML.xml"));

    assertEquals(0, MessageMapper.map(message).size());
}

From source file:de.slub.fedora.jms.MessageMapperTest.java

@Test
public void returnsIndexJobForIngestMessage() throws Exception {
    TextMessage message = mock(TextMessage.class);
    when(message.getStringProperty(eq("pid"))).thenReturn("test-rest:1");
    when(message.getStringProperty(eq("methodName"))).thenReturn("ingest");
    when(message.getText()).thenReturn(getContent("/jms/ingest.xml"));

    IndexJob ij = findFirstByClass(MessageMapper.map(message), ObjectIndexJob.class);

    assertEquals(new ObjectIndexJob(IndexJob.Type.CREATE, "test-rest:1"), ij);
}

From source file:de.slub.fedora.jms.MessageMapperTest.java

@Test
public void returnsIndexJobForAddDatastreamMessage() throws Exception {
    TextMessage message = mock(TextMessage.class);
    when(message.getStringProperty(eq("pid"))).thenReturn("test-rest:1");
    when(message.getStringProperty(eq("methodName"))).thenReturn("addDatastream");
    when(message.getText()).thenReturn(getContent("/jms/addDatastream.xml"));

    IndexJob ij = findFirstByClass(MessageMapper.map(message), DatastreamIndexJob.class);

    assertEquals(new DatastreamIndexJob(IndexJob.Type.CREATE, "test-rest:1", "testAddDatastream"), ij);
}

From source file:de.slub.fedora.jms.MessageMapperTest.java

@Test
public void returnsIndexJobForModifyDatastreamByValueMessage() throws Exception {
    TextMessage message = mock(TextMessage.class);
    when(message.getStringProperty(eq("pid"))).thenReturn("test-rest:1");
    when(message.getStringProperty(eq("methodName"))).thenReturn("modifyDatastreamByValue");
    when(message.getText()).thenReturn(getContent("/jms/modifyDatastreamByValue.xml"));

    IndexJob ij = findFirstByClass(MessageMapper.map(message), DatastreamIndexJob.class);

    assertEquals(new DatastreamIndexJob(IndexJob.Type.UPDATE, "test-rest:1", "testModifyDatastream"), ij);
}

From source file:de.slub.fedora.jms.MessageMapperTest.java

@Test
public void returnsIndexJobForModifyObjectMessage() throws Exception {
    TextMessage message = mock(TextMessage.class);
    when(message.getStringProperty(eq("pid"))).thenReturn("test-rest:1");
    when(message.getStringProperty(eq("methodName"))).thenReturn("modifyObject");
    when(message.getText()).thenReturn(getContent("/jms/modifyObject.xml"));

    IndexJob ij = findFirstByClass(MessageMapper.map(message), ObjectIndexJob.class);

    assertEquals(new ObjectIndexJob(IndexJob.Type.UPDATE, "test-rest:1"), ij);
}

From source file:de.slub.fedora.jms.MessageMapperTest.java

@Test
public void returnsIndexJobForPurgeDatastreamMessage() throws Exception {
    TextMessage message = mock(TextMessage.class);
    when(message.getStringProperty(eq("pid"))).thenReturn("test-rest:1");
    when(message.getStringProperty(eq("methodName"))).thenReturn("purgeDatastream");
    when(message.getText()).thenReturn(getContent("/jms/purgeDatastream.xml"));

    IndexJob ij = MessageMapper.map(message).get(0);

    assertEquals(new DatastreamIndexJob(IndexJob.Type.DELETE, "test-rest:1", "testPurgeDatastream"), ij);
}