001/* 002 * Licensed to DuraSpace under one or more contributor license agreements. 003 * See the NOTICE file distributed with this work for additional information 004 * regarding copyright ownership. 005 * 006 * DuraSpace licenses this file to you under the Apache License, 007 * Version 2.0 (the "License"); you may not use this file except in 008 * compliance with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.fcrepo.camel.integration; 019 020import static org.apache.camel.Exchange.ACCEPT_CONTENT_TYPE; 021import static org.fcrepo.camel.integration.FcrepoTestUtils.getFcrepoEndpointUri; 022 023import org.apache.camel.EndpointInject; 024import org.apache.camel.Produce; 025import org.apache.camel.ProducerTemplate; 026import org.apache.camel.builder.RouteBuilder; 027import org.apache.camel.component.mock.MockEndpoint; 028import org.apache.camel.test.junit4.CamelTestSupport; 029import org.junit.Test; 030 031/** 032 * Test the retrieved content-type from a fcrepo endpoint 033 * when the Accept type is put directly on the endpoint. 034 * @author Aaron Coburn 035 * @since November 7, 2014 036 */ 037public class FcrepoContentTypeEndpointIT extends CamelTestSupport { 038 039 @EndpointInject(uri = "mock:result") 040 protected MockEndpoint resultEndpoint; 041 042 @Produce(uri = "direct:start") 043 public ProducerTemplate template; 044 045 @Test 046 public void testContentTypeTurtle() throws InterruptedException { 047 resultEndpoint.expectedHeaderReceived("Content-Type", "text/turtle"); 048 resultEndpoint.expectedMessageCount(1); 049 050 template.sendBody(null); 051 052 resultEndpoint.assertIsSatisfied(); 053 } 054 055 @Test 056 public void testContentTypeN3() throws InterruptedException { 057 resultEndpoint.expectedHeaderReceived("Content-Type", "text/turtle"); 058 resultEndpoint.expectedMessageCount(2); 059 060 template.sendBodyAndHeader(null, "Accept", "application/n-triples"); 061 template.sendBodyAndHeader(null, ACCEPT_CONTENT_TYPE, "application/n-triples"); 062 063 resultEndpoint.assertIsSatisfied(); 064 } 065 066 @Override 067 protected RouteBuilder createRouteBuilder() { 068 return new RouteBuilder() { 069 070 @Override 071 public void configure() { 072 final String fcrepo_uri = getFcrepoEndpointUri(); 073 074 from("direct:start") 075 .to(fcrepo_uri + "?accept=text/turtle") 076 .to("mock:result"); 077 } 078 }; 079 } 080}