camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [11/17] camel git commit: CAMEL-9748: fix CS
Date Sat, 17 Dec 2016 11:53:50 GMT
http://git-wip-us.apache.org/repos/asf/camel/blob/7d2907d2/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/ServerProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/ServerProducerTest.java
b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/ServerProducerTest.java
index 9e7315e..bf6dff2 100644
--- a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/ServerProducerTest.java
+++ b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/ServerProducerTest.java
@@ -16,22 +16,11 @@
  */
 package org.apache.camel.component.openstack.nova;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import java.util.UUID;
 
 import org.apache.camel.component.openstack.nova.producer.ServerProducer;
-
 import org.junit.Before;
 import org.junit.Test;
-
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.openstack4j.api.Builders;
@@ -41,115 +30,123 @@ import org.openstack4j.model.compute.Server;
 import org.openstack4j.model.compute.ServerCreate;
 import org.openstack4j.openstack.compute.domain.NovaServerCreate;
 
-import java.util.UUID;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 public class ServerProducerTest extends NovaProducerTestSupport {
-	@Mock
-	private org.openstack4j.model.compute.Server testOSServer;
-
-	private ServerCreate dummyServer;
-
-	@Before
-	public void setUp() {
-		producer = new ServerProducer(endpoint, client);
-
-		when(serverService.boot(any(NovaServerCreate.class))).thenReturn(testOSServer);
-
-		dummyServer = createDummyServer();
-		initServerMock();
-	}
-
-	@Test
-	public void createServer() throws Exception {
-		when(endpoint.getOperation()).thenReturn(NovaConstants.CREATE);
-		final String expectedFlavorID = UUID.randomUUID().toString();
-		when(testOSServer.getId()).thenReturn(expectedFlavorID);
-		msg.setBody(dummyServer);
-		producer.process(exchange);
-		final Server created = msg.getBody(Server.class);
-		checkCreatedServer(dummyServer, created);
-	}
-
-	@Test
-	public void createServerWithHeaders() throws Exception {
-		final String expectedFlavorID = UUID.randomUUID().toString();
-		when(testOSServer.getId()).thenReturn(expectedFlavorID);
-
-		msg.setHeader(NovaConstants.OPERATION, NovaConstants.CREATE);
-		msg.setHeader(NovaConstants.NAME, dummyServer.getName());
-		msg.setHeader(NovaConstants.FLAVOR_ID, dummyServer.getFlavorRef());
-		msg.setHeader(NovaConstants.IMAGE_ID, dummyServer.getImageRef());
-
-		producer.process(exchange);
-
-		final Server created = msg.getBody(Server.class);
-
-		checkCreatedServer(dummyServer, created);
-	}
-
-	@Test
-	public void serverAction() throws Exception {
-		when(serverService.action(anyString(), any(Action.class))).thenReturn(ActionResponse.actionSuccess());
-		when(endpoint.getOperation()).thenReturn(NovaConstants.ACTION);
-		String id = "myID";
-		msg.setHeader(NovaConstants.ACTION, Action.PAUSE);
-		msg.setHeader(NovaConstants.ID, id);
-		producer.process(exchange);
-
-		ArgumentCaptor<Action> actionArgumentCaptor = ArgumentCaptor.forClass(Action.class);
-		ArgumentCaptor<String> idArgumentCaptor = ArgumentCaptor.forClass(String.class);
-		verify(serverService).action(idArgumentCaptor.capture(), actionArgumentCaptor.capture());
-
-		assertEquals(id, idArgumentCaptor.getValue());
-		assertTrue(actionArgumentCaptor.getValue() == Action.PAUSE);
-		assertFalse(msg.isFault());
-		assertNull(msg.getBody());
-
-		//test fail
-		final String failReason = "fr";
-		when(serverService.action(anyString(), any(Action.class))).thenReturn(ActionResponse.actionFailed(failReason,
401));
-		producer.process(exchange);
-		assertTrue(msg.isFault());
-		assertTrue(msg.getBody(String.class).contains(failReason));
-	}
-
-	@Test
-	public void createSnapshot() throws Exception {
-		String id = "myID";
-		String snapshotName = "mySnapshot";
-
-		msg.setHeader(NovaConstants.OPERATION, NovaConstants.CREATE_SNAPSHOT);
-		msg.setHeader(NovaConstants.NAME, snapshotName);
-		msg.setHeader(NovaConstants.ID, id);
-		producer.process(exchange);
-
-		ArgumentCaptor<String> snapshot = ArgumentCaptor.forClass(String.class);
-		ArgumentCaptor<String> idCaptor = ArgumentCaptor.forClass(String.class);
-		verify(serverService).createSnapshot(idCaptor.capture(), snapshot.capture());
-
-		assertEquals(id, idCaptor.getValue());
-		assertEquals(snapshotName, snapshot.getValue());
-	}
-
-	private void initServerMock() {
-		when(testOSServer.getId()).thenReturn(UUID.randomUUID().toString());
-		when(testOSServer.getName()).thenReturn(dummyServer.getName());
-		when(testOSServer.getFlavorId()).thenReturn(dummyServer.getFlavorRef());
-		when(testOSServer.getImageId()).thenReturn(dummyServer.getImageRef());
-	}
-
-	private ServerCreate createDummyServer() {
-		return Builders.server()
-				.name("MyCoolServer")
-				.flavor("flavorID")
-				.image("imageID").build();
-	}
-
-	private void checkCreatedServer(ServerCreate old, Server created) {
-		assertEquals(old.getName(), created.getName());
-		assertEquals(old.getFlavorRef(), created.getFlavorId());
-		assertEquals(old.getImageRef(), created.getImageId());
-
-		assertNotNull(created.getId());
-	}
+    @Mock
+    private org.openstack4j.model.compute.Server testOSServer;
+
+    private ServerCreate dummyServer;
+
+    @Before
+    public void setUp() {
+        producer = new ServerProducer(endpoint, client);
+
+        when(serverService.boot(any(NovaServerCreate.class))).thenReturn(testOSServer);
+
+        dummyServer = createDummyServer();
+        initServerMock();
+    }
+
+    @Test
+    public void createServer() throws Exception {
+        when(endpoint.getOperation()).thenReturn(NovaConstants.CREATE);
+        final String expectedFlavorID = UUID.randomUUID().toString();
+        when(testOSServer.getId()).thenReturn(expectedFlavorID);
+        msg.setBody(dummyServer);
+        producer.process(exchange);
+        final Server created = msg.getBody(Server.class);
+        checkCreatedServer(dummyServer, created);
+    }
+
+    @Test
+    public void createServerWithHeaders() throws Exception {
+        final String expectedFlavorID = UUID.randomUUID().toString();
+        when(testOSServer.getId()).thenReturn(expectedFlavorID);
+
+        msg.setHeader(NovaConstants.OPERATION, NovaConstants.CREATE);
+        msg.setHeader(NovaConstants.NAME, dummyServer.getName());
+        msg.setHeader(NovaConstants.FLAVOR_ID, dummyServer.getFlavorRef());
+        msg.setHeader(NovaConstants.IMAGE_ID, dummyServer.getImageRef());
+
+        producer.process(exchange);
+
+        final Server created = msg.getBody(Server.class);
+
+        checkCreatedServer(dummyServer, created);
+    }
+
+    @Test
+    public void serverAction() throws Exception {
+        when(serverService.action(anyString(), any(Action.class))).thenReturn(ActionResponse.actionSuccess());
+        when(endpoint.getOperation()).thenReturn(NovaConstants.ACTION);
+        String id = "myID";
+        msg.setHeader(NovaConstants.ACTION, Action.PAUSE);
+        msg.setHeader(NovaConstants.ID, id);
+        producer.process(exchange);
+
+        ArgumentCaptor<Action> actionArgumentCaptor = ArgumentCaptor.forClass(Action.class);
+        ArgumentCaptor<String> idArgumentCaptor = ArgumentCaptor.forClass(String.class);
+        verify(serverService).action(idArgumentCaptor.capture(), actionArgumentCaptor.capture());
+
+        assertEquals(id, idArgumentCaptor.getValue());
+        assertTrue(actionArgumentCaptor.getValue() == Action.PAUSE);
+        assertFalse(msg.isFault());
+        assertNull(msg.getBody());
+
+        //test fail
+        final String failReason = "fr";
+        when(serverService.action(anyString(), any(Action.class))).thenReturn(ActionResponse.actionFailed(failReason,
401));
+        producer.process(exchange);
+        assertTrue(msg.isFault());
+        assertTrue(msg.getBody(String.class).contains(failReason));
+    }
+
+    @Test
+    public void createSnapshot() throws Exception {
+        String id = "myID";
+        String snapshotName = "mySnapshot";
+
+        msg.setHeader(NovaConstants.OPERATION, NovaConstants.CREATE_SNAPSHOT);
+        msg.setHeader(NovaConstants.NAME, snapshotName);
+        msg.setHeader(NovaConstants.ID, id);
+        producer.process(exchange);
+
+        ArgumentCaptor<String> snapshot = ArgumentCaptor.forClass(String.class);
+        ArgumentCaptor<String> idCaptor = ArgumentCaptor.forClass(String.class);
+        verify(serverService).createSnapshot(idCaptor.capture(), snapshot.capture());
+
+        assertEquals(id, idCaptor.getValue());
+        assertEquals(snapshotName, snapshot.getValue());
+    }
+
+    private void initServerMock() {
+        when(testOSServer.getId()).thenReturn(UUID.randomUUID().toString());
+        when(testOSServer.getName()).thenReturn(dummyServer.getName());
+        when(testOSServer.getFlavorId()).thenReturn(dummyServer.getFlavorRef());
+        when(testOSServer.getImageId()).thenReturn(dummyServer.getImageRef());
+    }
+
+    private ServerCreate createDummyServer() {
+        return Builders.server()
+                .name("MyCoolServer")
+                .flavor("flavorID")
+                .image("imageID").build();
+    }
+
+    private void checkCreatedServer(ServerCreate old, Server created) {
+        assertEquals(old.getName(), created.getName());
+        assertEquals(old.getFlavorRef(), created.getFlavorId());
+        assertEquals(old.getImageRef(), created.getImageId());
+
+        assertNotNull(created.getId());
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/7d2907d2/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/swift/ContainerProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/swift/ContainerProducerTest.java
b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/swift/ContainerProducerTest.java
index 980047e..5e618bb 100644
--- a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/swift/ContainerProducerTest.java
+++ b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/swift/ContainerProducerTest.java
@@ -16,178 +16,170 @@
  */
 package org.apache.camel.component.openstack.swift;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 import org.apache.camel.component.openstack.swift.producer.ContainerProducer;
-
 import org.junit.Before;
 import org.junit.Test;
-
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.openstack4j.model.common.ActionResponse;
-import org.openstack4j.model.common.Payload;
-import org.openstack4j.model.common.Payloads;
 import org.openstack4j.model.storage.object.SwiftContainer;
 import org.openstack4j.model.storage.object.options.ContainerListOptions;
 import org.openstack4j.model.storage.object.options.CreateUpdateContainerOptions;
-import org.openstack4j.model.storage.object.options.ObjectLocation;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 public class ContainerProducerTest extends SwiftProducerTestSupport {
 
-	private static final String CONTAINER_NAME = "containerName";
-
-	@Mock
-	private SwiftContainer mockOsContainer;
-
-	@Before
-	public void setUp() {
-		producer = new ContainerProducer(endpoint, client);
-	}
-
-	@Test
-	public void createTestWithoutOptions() throws Exception {
-		when(containerService.create(anyString(), any(CreateUpdateContainerOptions.class))).thenReturn(ActionResponse.actionSuccess());
-		msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.CREATE);
-		msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
-
-		producer.process(exchange);
+    private static final String CONTAINER_NAME = "containerName";
+
+    @Mock
+    private SwiftContainer mockOsContainer;
+
+    @Before
+    public void setUp() {
+        producer = new ContainerProducer(endpoint, client);
+    }
+
+    @Test
+    public void createTestWithoutOptions() throws Exception {
+        when(containerService.create(anyString(), any(CreateUpdateContainerOptions.class))).thenReturn(ActionResponse.actionSuccess());
+        msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.CREATE);
+        msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
+
+        producer.process(exchange);
 
-		ArgumentCaptor<String> containerNameCaptor = ArgumentCaptor.forClass(String.class);
-		ArgumentCaptor<CreateUpdateContainerOptions> optionsCaptor = ArgumentCaptor.forClass(CreateUpdateContainerOptions.class);
-
-		verify(containerService).create(containerNameCaptor.capture(), optionsCaptor.capture());
-		assertEquals(CONTAINER_NAME, containerNameCaptor.getValue());
-		assertNull(optionsCaptor.getValue());
-
-		assertFalse(msg.isFault());
-	}
-
-	@Test
-	public void createTestWithOptions() throws Exception {
-		when(containerService.create(anyString(), any(CreateUpdateContainerOptions.class))).thenReturn(ActionResponse.actionSuccess());
-		msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.CREATE);
-		msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
-		final CreateUpdateContainerOptions options = CreateUpdateContainerOptions.create().accessAnybodyRead();
-		msg.setBody(options);
-		producer.process(exchange);
+        ArgumentCaptor<String> containerNameCaptor = ArgumentCaptor.forClass(String.class);
+        ArgumentCaptor<CreateUpdateContainerOptions> optionsCaptor = ArgumentCaptor.forClass(CreateUpdateContainerOptions.class);
+
+        verify(containerService).create(containerNameCaptor.capture(), optionsCaptor.capture());
+        assertEquals(CONTAINER_NAME, containerNameCaptor.getValue());
+        assertNull(optionsCaptor.getValue());
+
+        assertFalse(msg.isFault());
+    }
+
+    @Test
+    public void createTestWithOptions() throws Exception {
+        when(containerService.create(anyString(), any(CreateUpdateContainerOptions.class))).thenReturn(ActionResponse.actionSuccess());
+        msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.CREATE);
+        msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
+        final CreateUpdateContainerOptions options = CreateUpdateContainerOptions.create().accessAnybodyRead();
+        msg.setBody(options);
+        producer.process(exchange);
 
-		ArgumentCaptor<String> containerNameCaptor = ArgumentCaptor.forClass(String.class);
-		ArgumentCaptor<CreateUpdateContainerOptions> optionsCaptor = ArgumentCaptor.forClass(CreateUpdateContainerOptions.class);
-
-		verify(containerService).create(containerNameCaptor.capture(), optionsCaptor.capture());
-		assertEquals(CONTAINER_NAME, containerNameCaptor.getValue());
-		assertEquals(options, optionsCaptor.getValue());
-		assertFalse(msg.isFault());
-	}
-
-	@Test
-	public void getTest() throws Exception {
-		List<SwiftContainer> list = new ArrayList<>();
-		list.add(mockOsContainer);
-		doReturn(list).when(containerService).list(any(ContainerListOptions.class));
-		when(endpoint.getOperation()).thenReturn(SwiftConstants.GET);
-
-		msg.setHeader(SwiftConstants.LIMIT, 10);
-		msg.setHeader(SwiftConstants.DELIMITER, 'x');
-
-		producer.process(exchange);
-		ArgumentCaptor<ContainerListOptions> optionsCaptor = ArgumentCaptor.forClass(ContainerListOptions.class);
-		verify(containerService).list(optionsCaptor.capture());
-		Map<String, String> options = optionsCaptor.getValue().getOptions();
-		assertEquals(String.valueOf(10), options.get(SwiftConstants.LIMIT));
-		assertEquals("x", options.get(SwiftConstants.DELIMITER));
-		assertEquals(list, msg.getBody(List.class));
-	}
-
-	@Test
-	public void getAllFromContainerTest() throws Exception {
-		List<SwiftContainer> list = new ArrayList<>();
-		list.add(mockOsContainer);
-		doReturn(list).when(containerService).list();
-
-		when(endpoint.getOperation()).thenReturn(SwiftConstants.GET_ALL);
-
-		msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
-
-		producer.process(exchange);
-		assertEquals(mockOsContainer, msg.getBody(List.class).get(0));
-	}
-
-	@Test
-	public void deleteObjectTest() throws Exception {
-		when(containerService.delete(anyString())).thenReturn(ActionResponse.actionSuccess());
-		msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.DELETE);
-		msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<String> containerNameCaptor = ArgumentCaptor.forClass(String.class);
-		verify(containerService).delete(containerNameCaptor.capture());
-		assertEquals(CONTAINER_NAME, containerNameCaptor.getValue());
-
-		assertFalse(msg.isFault());
-	}
-
-	@Test
-	public void deleteObjectFailTest() throws Exception {
-		final String failMessage = "fail";
-		when(containerService.delete(anyString())).thenReturn(ActionResponse.actionFailed(failMessage,
401));
-		msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.DELETE);
-		msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
-
-		producer.process(exchange);
-
-		assertTrue(msg.isFault());
-		assertTrue(msg.getBody(String.class).contains(failMessage));
-	}
-
-	@Test
-	public void createUpdateMetadataTest() throws Exception {
-		final Map<String, String> md = new HashMap<>();
-		md.put("key", "val");
-
-		msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.CREATE_UPDATE_METADATA);
-		msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
-		msg.setBody(md);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<String> nameCaptor = ArgumentCaptor.forClass(String.class);
-		ArgumentCaptor<Map> dataCaptor = ArgumentCaptor.forClass(Map.class);
-		verify(containerService).updateMetadata(nameCaptor.capture(), dataCaptor.capture());
-
-		assertEquals(CONTAINER_NAME, nameCaptor.getValue());
-		assertEquals(md, dataCaptor.getValue());
-	}
-
-	@Test
-	public void getMetadataTest() throws Exception {
-		final Map<String, String> md = new HashMap<>();
-		md.put("key", "val");
-
-		when(containerService.getMetadata(CONTAINER_NAME)).thenReturn(md);
-		msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.GET_METADATA);
-		msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
-
-		producer.process(exchange);
+        ArgumentCaptor<String> containerNameCaptor = ArgumentCaptor.forClass(String.class);
+        ArgumentCaptor<CreateUpdateContainerOptions> optionsCaptor = ArgumentCaptor.forClass(CreateUpdateContainerOptions.class);
+
+        verify(containerService).create(containerNameCaptor.capture(), optionsCaptor.capture());
+        assertEquals(CONTAINER_NAME, containerNameCaptor.getValue());
+        assertEquals(options, optionsCaptor.getValue());
+        assertFalse(msg.isFault());
+    }
+
+    @Test
+    public void getTest() throws Exception {
+        List<SwiftContainer> list = new ArrayList<>();
+        list.add(mockOsContainer);
+        doReturn(list).when(containerService).list(any(ContainerListOptions.class));
+        when(endpoint.getOperation()).thenReturn(SwiftConstants.GET);
+
+        msg.setHeader(SwiftConstants.LIMIT, 10);
+        msg.setHeader(SwiftConstants.DELIMITER, 'x');
+
+        producer.process(exchange);
+        ArgumentCaptor<ContainerListOptions> optionsCaptor = ArgumentCaptor.forClass(ContainerListOptions.class);
+        verify(containerService).list(optionsCaptor.capture());
+        Map<String, String> options = optionsCaptor.getValue().getOptions();
+        assertEquals(String.valueOf(10), options.get(SwiftConstants.LIMIT));
+        assertEquals("x", options.get(SwiftConstants.DELIMITER));
+        assertEquals(list, msg.getBody(List.class));
+    }
+
+    @Test
+    public void getAllFromContainerTest() throws Exception {
+        List<SwiftContainer> list = new ArrayList<>();
+        list.add(mockOsContainer);
+        doReturn(list).when(containerService).list();
+
+        when(endpoint.getOperation()).thenReturn(SwiftConstants.GET_ALL);
+
+        msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
+
+        producer.process(exchange);
+        assertEquals(mockOsContainer, msg.getBody(List.class).get(0));
+    }
+
+    @Test
+    public void deleteObjectTest() throws Exception {
+        when(containerService.delete(anyString())).thenReturn(ActionResponse.actionSuccess());
+        msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.DELETE);
+        msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<String> containerNameCaptor = ArgumentCaptor.forClass(String.class);
+        verify(containerService).delete(containerNameCaptor.capture());
+        assertEquals(CONTAINER_NAME, containerNameCaptor.getValue());
+
+        assertFalse(msg.isFault());
+    }
+
+    @Test
+    public void deleteObjectFailTest() throws Exception {
+        final String failMessage = "fail";
+        when(containerService.delete(anyString())).thenReturn(ActionResponse.actionFailed(failMessage,
401));
+        msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.DELETE);
+        msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
+
+        producer.process(exchange);
+
+        assertTrue(msg.isFault());
+        assertTrue(msg.getBody(String.class).contains(failMessage));
+    }
+
+    @Test
+    public void createUpdateMetadataTest() throws Exception {
+        final Map<String, String> md = new HashMap<>();
+        md.put("key", "val");
+
+        msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.CREATE_UPDATE_METADATA);
+        msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
+        msg.setBody(md);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<String> nameCaptor = ArgumentCaptor.forClass(String.class);
+        ArgumentCaptor<Map> dataCaptor = ArgumentCaptor.forClass(Map.class);
+        verify(containerService).updateMetadata(nameCaptor.capture(), dataCaptor.capture());
+
+        assertEquals(CONTAINER_NAME, nameCaptor.getValue());
+        assertEquals(md, dataCaptor.getValue());
+    }
+
+    @Test
+    public void getMetadataTest() throws Exception {
+        final Map<String, String> md = new HashMap<>();
+        md.put("key", "val");
+
+        when(containerService.getMetadata(CONTAINER_NAME)).thenReturn(md);
+        msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.GET_METADATA);
+        msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
+
+        producer.process(exchange);
 
-		assertEquals(md, msg.getBody(Map.class));
-	}
+        assertEquals(md, msg.getBody(Map.class));
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/7d2907d2/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/swift/ObjectProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/swift/ObjectProducerTest.java
b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/swift/ObjectProducerTest.java
index 1dd6a2d..d6b842d 100644
--- a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/swift/ObjectProducerTest.java
+++ b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/swift/ObjectProducerTest.java
@@ -16,22 +16,17 @@
  */
 package org.apache.camel.component.openstack.swift;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 
 import org.apache.camel.component.openstack.swift.producer.ObjectProducer;
-
 import org.junit.Before;
 import org.junit.Test;
-
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.openstack4j.model.common.ActionResponse;
@@ -40,152 +35,153 @@ import org.openstack4j.model.common.Payloads;
 import org.openstack4j.model.storage.object.SwiftObject;
 import org.openstack4j.model.storage.object.options.ObjectLocation;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 public class ObjectProducerTest extends SwiftProducerTestSupport {
 
-	private static final String CONTAINER_NAME = "containerName";
-	private static final String OBJECT_NAME = "objectName";
-	private static final String ETAG = UUID.randomUUID().toString();
+    private static final String CONTAINER_NAME = "containerName";
+    private static final String OBJECT_NAME = "objectName";
+    private static final String ETAG = UUID.randomUUID().toString();
 
-	@Mock
-	private SwiftObject mockOsObject;
+    @Mock
+    private SwiftObject mockOsObject;
 
-	@Before
-	public void setUp() {
-		producer = new ObjectProducer(endpoint, client);
+    @Before
+    public void setUp() {
+        producer = new ObjectProducer(endpoint, client);
 
-		when(mockOsObject.getETag()).thenReturn(ETAG);
-	}
+        when(mockOsObject.getETag()).thenReturn(ETAG);
+    }
 
-	@Test
-	public void createTest() throws Exception {
-		when(objectService.put(anyString(), anyString(), any(Payload.class))).thenReturn(ETAG);
-		msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.CREATE);
-		msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
-		msg.setHeader(SwiftConstants.OBJECT_NAME, OBJECT_NAME);
-		final Payload payload = getTmpPayload();
-		msg.setBody(payload);
-
-		producer.process(exchange);
+    @Test
+    public void createTest() throws Exception {
+        when(objectService.put(anyString(), anyString(), any(Payload.class))).thenReturn(ETAG);
+        msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.CREATE);
+        msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
+        msg.setHeader(SwiftConstants.OBJECT_NAME, OBJECT_NAME);
+        final Payload payload = getTmpPayload();
+        msg.setBody(payload);
+
+        producer.process(exchange);
 
-		ArgumentCaptor<String> containerNameCaptor = ArgumentCaptor.forClass(String.class);
-		ArgumentCaptor<String> objectNameCaptor = ArgumentCaptor.forClass(String.class);
-		ArgumentCaptor<Payload> payloadArgumentCaptor = ArgumentCaptor.forClass(Payload.class);
-		verify(objectService).put(containerNameCaptor.capture(), objectNameCaptor.capture(), payloadArgumentCaptor.capture());
-		assertEquals(CONTAINER_NAME, containerNameCaptor.getValue());
-		assertEquals(OBJECT_NAME, objectNameCaptor.getValue());
-		assertEquals(payload, payloadArgumentCaptor.getValue());
+        ArgumentCaptor<String> containerNameCaptor = ArgumentCaptor.forClass(String.class);
+        ArgumentCaptor<String> objectNameCaptor = ArgumentCaptor.forClass(String.class);
+        ArgumentCaptor<Payload> payloadArgumentCaptor = ArgumentCaptor.forClass(Payload.class);
+        verify(objectService).put(containerNameCaptor.capture(), objectNameCaptor.capture(),
payloadArgumentCaptor.capture());
+        assertEquals(CONTAINER_NAME, containerNameCaptor.getValue());
+        assertEquals(OBJECT_NAME, objectNameCaptor.getValue());
+        assertEquals(payload, payloadArgumentCaptor.getValue());
 
-		assertEquals(ETAG, msg.getBody(String.class));
-	}
+        assertEquals(ETAG, msg.getBody(String.class));
+    }
 
-	@Test
-	public void getTest() throws Exception {
-		when(objectService.get(CONTAINER_NAME, OBJECT_NAME)).thenReturn(mockOsObject);
-		when(endpoint.getOperation()).thenReturn(SwiftConstants.GET);
+    @Test
+    public void getTest() throws Exception {
+        when(objectService.get(CONTAINER_NAME, OBJECT_NAME)).thenReturn(mockOsObject);
+        when(endpoint.getOperation()).thenReturn(SwiftConstants.GET);
 
-		msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
-		msg.setHeader(SwiftConstants.OBJECT_NAME, OBJECT_NAME);
+        msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
+        msg.setHeader(SwiftConstants.OBJECT_NAME, OBJECT_NAME);
 
-		producer.process(exchange);
+        producer.process(exchange);
 
-		assertEquals(ETAG, msg.getBody(SwiftObject.class).getETag());
-	}
+        assertEquals(ETAG, msg.getBody(SwiftObject.class).getETag());
+    }
 
-	@Test
-	public void getAllFromContainerTest() throws Exception {
-		List<SwiftObject> objectsList = new ArrayList<>();
-		objectsList.add(mockOsObject);
-		doReturn(objectsList).when(objectService).list(CONTAINER_NAME);
+    @Test
+    public void getAllFromContainerTest() throws Exception {
+        List<SwiftObject> objectsList = new ArrayList<>();
+        objectsList.add(mockOsObject);
+        doReturn(objectsList).when(objectService).list(CONTAINER_NAME);
 
-		when(endpoint.getOperation()).thenReturn(SwiftConstants.GET_ALL);
+        when(endpoint.getOperation()).thenReturn(SwiftConstants.GET_ALL);
 
-		msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
+        msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
 
-		producer.process(exchange);
-		assertEquals(mockOsObject, msg.getBody(List.class).get(0));
-	}
+        producer.process(exchange);
+        assertEquals(mockOsObject, msg.getBody(List.class).get(0));
+    }
 
 
-	@Test
-	public void deleteObjectTest() throws Exception {
-		final String failMessage = "fail";
-		when(objectService.delete(anyString(), anyString())).thenReturn(ActionResponse.actionSuccess());
-		msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.DELETE);
-		msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
-		msg.setHeader(SwiftConstants.OBJECT_NAME, OBJECT_NAME);
+    @Test
+    public void deleteObjectTest() throws Exception {
+        final String failMessage = "fail";
+        when(objectService.delete(anyString(), anyString())).thenReturn(ActionResponse.actionSuccess());
+        msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.DELETE);
+        msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
+        msg.setHeader(SwiftConstants.OBJECT_NAME, OBJECT_NAME);
 
-		producer.process(exchange);
+        producer.process(exchange);
 
-		ArgumentCaptor<String> containerNameCaptor = ArgumentCaptor.forClass(String.class);
-		ArgumentCaptor<String> objectNameCaptor = ArgumentCaptor.forClass(String.class);
-		verify(objectService).delete(containerNameCaptor.capture(), objectNameCaptor.capture());
-		assertEquals(CONTAINER_NAME, containerNameCaptor.getValue());
-		assertEquals(OBJECT_NAME, objectNameCaptor.getValue());
+        ArgumentCaptor<String> containerNameCaptor = ArgumentCaptor.forClass(String.class);
+        ArgumentCaptor<String> objectNameCaptor = ArgumentCaptor.forClass(String.class);
+        verify(objectService).delete(containerNameCaptor.capture(), objectNameCaptor.capture());
+        assertEquals(CONTAINER_NAME, containerNameCaptor.getValue());
+        assertEquals(OBJECT_NAME, objectNameCaptor.getValue());
 
-		assertFalse(msg.isFault());
-	}
+        assertFalse(msg.isFault());
+    }
 
 
-	@Test
-	public void deleteObjectFailTest() throws Exception {
-		final String failMessage = "fail";
-		when(objectService.delete(anyString(), anyString())).thenReturn(ActionResponse.actionFailed(failMessage,
401));
-		msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.DELETE);
-		msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
-		msg.setHeader(SwiftConstants.OBJECT_NAME, OBJECT_NAME);
+    @Test
+    public void deleteObjectFailTest() throws Exception {
+        final String failMessage = "fail";
+        when(objectService.delete(anyString(), anyString())).thenReturn(ActionResponse.actionFailed(failMessage,
401));
+        msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.DELETE);
+        msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
+        msg.setHeader(SwiftConstants.OBJECT_NAME, OBJECT_NAME);
 
-		producer.process(exchange);
+        producer.process(exchange);
 
-		assertTrue(msg.isFault());
-		assertTrue(msg.getBody(String.class).contains(failMessage));
-	}
+        assertTrue(msg.isFault());
+        assertTrue(msg.getBody(String.class).contains(failMessage));
+    }
 
-	@Test
-	public void updateMetadataTest() throws Exception {
-		final Map<String, String> md = new HashMap<>();
-		md.put("key", "val");
+    @Test
+    public void updateMetadataTest() throws Exception {
+        final Map<String, String> md = new HashMap<>();
+        md.put("key", "val");
 
-		msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.CREATE_UPDATE_METADATA);
-		msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
-		msg.setHeader(SwiftConstants.OBJECT_NAME, OBJECT_NAME);
-		msg.setBody(md);
+        msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.CREATE_UPDATE_METADATA);
+        msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
+        msg.setHeader(SwiftConstants.OBJECT_NAME, OBJECT_NAME);
+        msg.setBody(md);
 
-		producer.process(exchange);
+        producer.process(exchange);
 
-		ArgumentCaptor<ObjectLocation> locationCaptor = ArgumentCaptor.forClass(ObjectLocation.class);
-		ArgumentCaptor<Map> dataCaptor = ArgumentCaptor.forClass(Map.class);
-		verify(objectService).updateMetadata(locationCaptor.capture(), dataCaptor.capture());
-		ObjectLocation location = locationCaptor.getValue();
-		assertEquals(CONTAINER_NAME, location.getContainerName());
-		assertEquals(OBJECT_NAME, location.getObjectName());
-		assertEquals(md, dataCaptor.getValue());
-	}
+        ArgumentCaptor<ObjectLocation> locationCaptor = ArgumentCaptor.forClass(ObjectLocation.class);
+        ArgumentCaptor<Map> dataCaptor = ArgumentCaptor.forClass(Map.class);
+        verify(objectService).updateMetadata(locationCaptor.capture(), dataCaptor.capture());
+        ObjectLocation location = locationCaptor.getValue();
+        assertEquals(CONTAINER_NAME, location.getContainerName());
+        assertEquals(OBJECT_NAME, location.getObjectName());
+        assertEquals(md, dataCaptor.getValue());
+    }
 
-	@Test
-	public void getMetadataTest() throws Exception {
-		final Map<String, String> md = new HashMap<>();
-		md.put("key", "val");
+    @Test
+    public void getMetadataTest() throws Exception {
+        final Map<String, String> md = new HashMap<>();
+        md.put("key", "val");
 
-		when(objectService.getMetadata(CONTAINER_NAME, OBJECT_NAME)).thenReturn(md);
-		msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.GET_METADATA);
-		msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
-		msg.setHeader(SwiftConstants.OBJECT_NAME, OBJECT_NAME);
+        when(objectService.getMetadata(CONTAINER_NAME, OBJECT_NAME)).thenReturn(md);
+        msg.setHeader(SwiftConstants.OPERATION, SwiftConstants.GET_METADATA);
+        msg.setHeader(SwiftConstants.CONTAINER_NAME, CONTAINER_NAME);
+        msg.setHeader(SwiftConstants.OBJECT_NAME, OBJECT_NAME);
 
-		producer.process(exchange);
+        producer.process(exchange);
 
-		assertEquals(md, msg.getBody(Map.class));
-	}
+        assertEquals(md, msg.getBody(Map.class));
+    }
 
 
-	private Payload getTmpPayload() throws IOException {
-		return Payloads.create(File.createTempFile("payloadPreffix", ".txt"));
-	}
+    private Payload getTmpPayload() throws IOException {
+        return Payloads.create(File.createTempFile("payloadPreffix", ".txt"));
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/7d2907d2/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/swift/SwiftProducerTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/swift/SwiftProducerTestSupport.java
b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/swift/SwiftProducerTestSupport.java
index 53ea867..354d7bc 100644
--- a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/swift/SwiftProducerTestSupport.java
+++ b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/swift/SwiftProducerTestSupport.java
@@ -16,37 +16,35 @@
  */
 package org.apache.camel.component.openstack.swift;
 
-import static org.mockito.Mockito.when;
-
 import org.apache.camel.component.openstack.AbstractProducerTestSupport;
-
 import org.junit.Before;
-
 import org.mockito.Mock;
 import org.openstack4j.api.storage.ObjectStorageContainerService;
 import org.openstack4j.api.storage.ObjectStorageObjectService;
 import org.openstack4j.api.storage.ObjectStorageService;
 
+import static org.mockito.Mockito.when;
+
 public class SwiftProducerTestSupport extends AbstractProducerTestSupport {
 
-	@Mock
-	protected SwiftEndpoint endpoint;
+    @Mock
+    protected SwiftEndpoint endpoint;
 
-	@Mock
-	protected ObjectStorageService objectStorageService;
+    @Mock
+    protected ObjectStorageService objectStorageService;
 
-	@Mock
-	protected ObjectStorageContainerService containerService;
+    @Mock
+    protected ObjectStorageContainerService containerService;
 
-	@Mock
-	protected ObjectStorageObjectService objectService;
+    @Mock
+    protected ObjectStorageObjectService objectService;
 
-	@Before
-	public void setUpComputeService(){
-		when(client.objectStorage()).thenReturn(objectStorageService);
-		when(objectStorageService.containers()).thenReturn(containerService);
-		when(objectStorageService.objects()).thenReturn(objectService);
-	}
+    @Before
+    public void setUpComputeService() {
+        when(client.objectStorage()).thenReturn(objectStorageService);
+        when(objectStorageService.containers()).thenReturn(containerService);
+        when(objectStorageService.objects()).thenReturn(objectService);
+    }
 
 
 }


Mime
View raw message