=== modified file 'dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2Component.java' --- dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2Component.java 2013-03-16 11:27:06 +0000 +++ dhis-2/dhis-services/dhis-service-integration/src/main/java/org/hisp/dhis/integration/components/Dxf2Component.java 2013-03-16 15:21:47 +0000 @@ -32,6 +32,7 @@ import org.hisp.dhis.dxf2.datavalueset.DataValueSetService; import org.hisp.dhis.dxf2.metadata.ImportService; import org.hisp.dhis.user.CurrentUserService; +import org.hisp.dhis.user.User; import org.springframework.beans.factory.annotation.Autowired; import java.util.Map; @@ -71,9 +72,11 @@ throw new UnsupportedOperationException( "Invalid dhis2 uri part " + remaining ); } + User user = currentUserService == null ? null : currentUserService.getCurrentUser(); + Endpoint endpoint = remaining.equals( DATA ) ? - new Dxf2DataEndpoint( currentUserService.getCurrentUser(), uri, this, dataValueSetService ) : - new Dxf2MetaDataEndpoint( currentUserService.getCurrentUser(), uri, this, importService ); + new Dxf2DataEndpoint( user, uri, this, dataValueSetService ) : + new Dxf2MetaDataEndpoint( user, uri, this, importService ); setProperties( endpoint, parameters ); return endpoint; === modified file 'dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis/integration/RoutesTest.java' --- dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis/integration/RoutesTest.java 2013-03-16 15:10:31 +0000 +++ dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis/integration/RoutesTest.java 2013-03-16 15:21:47 +0000 @@ -145,7 +145,6 @@ } @Test - @Ignore public void testImportDataValueSetXML() throws Exception { === modified file 'dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis/integration/dxf2/Dxf2ComponentTest.java' --- dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis/integration/dxf2/Dxf2ComponentTest.java 2012-04-16 15:12:08 +0000 +++ dhis-2/dhis-services/dhis-service-integration/src/test/java/org/hisp/dhis/integration/dxf2/Dxf2ComponentTest.java 2013-03-16 15:21:47 +0000 @@ -27,7 +27,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.io.InputStream; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit4.CamelSpringTestSupport; @@ -35,15 +34,18 @@ import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; -public class Dxf2ComponentTest extends CamelSpringTestSupport { - +import java.io.InputStream; + +public class Dxf2ComponentTest extends CamelSpringTestSupport +{ // just send some strings to the route and check they arrived // note we can't send to the actual endpoints yet till we wire in dhis2 services to the test context. // So for now this is only testing component endpoint creation :-( @Test - public void testDxf2() throws Exception { - MockEndpoint mock = getMockEndpoint("mock:result"); - mock.expectedMinimumMessageCount(3); + public void testDxf2() throws Exception + { + MockEndpoint mock = getMockEndpoint( "mock:result" ); + mock.expectedMinimumMessageCount( 3 ); //template.sendBody("direct:test",""); //template.sendBody("direct:test",""); //template.sendBody("direct:test",""); @@ -51,22 +53,25 @@ } @Override - protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { - public void configure() { - from("direct:test") - .convertBodyTo( InputStream.class) - .to("dhis2:data?dryRun=true&importStrategy=NEW_AND_UPDATES") - .to("mock:result"); + protected RouteBuilder createRouteBuilder() throws Exception + { + return new RouteBuilder() + { + public void configure() + { + from( "direct:test" ) + .convertBodyTo( InputStream.class ) + .to( "dhis2:data?dryRun=true&importStrategy=NEW_AND_UPDATES" ) + .to( "mock:result" ); } }; } - + @Override protected AbstractApplicationContext createApplicationContext() { - AbstractApplicationContext springContext = new ClassPathXmlApplicationContext("test-context.xml"); - + AbstractApplicationContext springContext = new ClassPathXmlApplicationContext( "test-context.xml" ); + return springContext; } }