Skip to content

Commit

Permalink
Non-rdf resources emit /fcr:metadata events instead of /jcr:content
Browse files Browse the repository at this point in the history
  • Loading branch information
escowles committed Oct 23, 2014
1 parent fb9075e commit 560b815
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
Expand Up @@ -94,7 +94,11 @@ public Message getMessage(final FedoraEvent jcrEvent,

final Message message = jmsSession.createMessage();
message.setLongProperty(TIMESTAMP_HEADER_NAME, jcrEvent.getDate());
message.setStringProperty(IDENTIFIER_HEADER_NAME, jcrEvent.getPath());
String path = jcrEvent.getPath();
if ( path.endsWith("jcr:content") ) {
path = path.replaceAll("jcr:content","fcr:metadata");
}
message.setStringProperty(IDENTIFIER_HEADER_NAME, path);
message.setStringProperty(EVENT_TYPE_HEADER_NAME, getEventURIs( jcrEvent
.getTypes()));
message.setStringProperty(BASE_URL_HEADER_NAME, baseURL);
Expand Down
Expand Up @@ -67,15 +67,26 @@ public void setUp() throws JMSException {

@Test
public void testBuildMessage() throws RepositoryException, JMSException {
doTestBuildMessage("base-url");
final String testPath = "/path/to/resource";
final Message msg = doTestBuildMessage("base-url", testPath);
assertEquals("Got wrong identifier in message!", testPath, msg.getStringProperty(IDENTIFIER_HEADER_NAME));
}

@Test
public void testBuildMessageNullUrl() throws RepositoryException, JMSException {
doTestBuildMessage(null);
final String testPath = "/path/to/resource";
final Message msg = doTestBuildMessage(null, testPath);
assertEquals("Got wrong identifier in message!", testPath, msg.getStringProperty(IDENTIFIER_HEADER_NAME));
}
@Test
public void testBuildMessageContent() throws RepositoryException, JMSException {
final String testPath = "/path/to/resource";
final Message msg = doTestBuildMessage("base-url", testPath + "/jcr:content");
assertEquals("Got wrong identifier in message!", testPath + "/fcr:metadata",
msg.getStringProperty(IDENTIFIER_HEADER_NAME));
}

private void doTestBuildMessage(final String baseUrl) throws RepositoryException, JMSException {
private Message doTestBuildMessage(final String baseUrl, final String id) throws RepositoryException, JMSException {
final Long testDate = 46647758568747L;
when(mockEvent.getDate()).thenReturn(testDate);

Expand All @@ -84,8 +95,7 @@ private void doTestBuildMessage(final String baseUrl) throws RepositoryException
url = "{\"baseURL\":\"" + baseUrl + "\"}";
}
when(mockEvent.getUserData()).thenReturn(url);
final String testPath = "super/calli/fragi/listic";
when(mockEvent.getPath()).thenReturn(testPath);
when(mockEvent.getPath()).thenReturn(id);
final Set<Integer> testTypes = singleton(NODE_ADDED);
final String testReturnType = REPOSITORY_NAMESPACE + EventType.valueOf(NODE_ADDED).toString();
when(mockEvent.getTypes()).thenReturn(testTypes);
Expand All @@ -94,10 +104,10 @@ private void doTestBuildMessage(final String baseUrl) throws RepositoryException

final Message msg = testDefaultMessageFactory.getMessage(mockEvent, mockSession);
assertEquals("Got wrong date in message!", testDate, (Long) msg.getLongProperty(TIMESTAMP_HEADER_NAME));
assertEquals("Got wrong identifier in message!", testPath, msg.getStringProperty(IDENTIFIER_HEADER_NAME));
assertEquals("Got wrong type in message!", testReturnType, msg.getStringProperty(EVENT_TYPE_HEADER_NAME));
assertEquals("Got wrong base-url in message", baseUrl, msg.getStringProperty(BASE_URL_HEADER_NAME));
assertEquals("Got wrong property in message", prop, msg.getStringProperty(PROPERTIES_HEADER_NAME));
return msg;
}

}

0 comments on commit 560b815

Please sign in to comment.