camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [12/17] camel git commit: CAMEL-9748: fix CS
Date Sat, 17 Dec 2016 11:53:51 GMT
http://git-wip-us.apache.org/repos/asf/camel/blob/7d2907d2/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/keystone/UserProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/keystone/UserProducerTest.java b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/keystone/UserProducerTest.java
index a9315d0..4b78e32 100644
--- a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/keystone/UserProducerTest.java
+++ b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/keystone/UserProducerTest.java
@@ -16,23 +16,13 @@
  */
 package org.apache.camel.component.openstack.keystone;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-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.List;
 
 import org.apache.camel.component.openstack.keystone.producer.UserProducer;
 import org.apache.camel.component.openstack.neutron.NeutronConstants;
-
 import org.junit.Before;
 import org.junit.Test;
-
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.openstack4j.api.Builders;
@@ -40,140 +30,147 @@ import org.openstack4j.model.common.ActionResponse;
 import org.openstack4j.model.identity.v3.User;
 import org.openstack4j.model.network.Network;
 
-import java.util.ArrayList;
-import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+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 UserProducerTest extends KeystoneProducerTestSupport {
 
-	private User dummyUser;
-
-	@Mock
-	private User testOSuser;
-
-	@Before
-	public void setUp() {
-		producer = new UserProducer(endpoint, client);
-		
-		when(userService.create(any(User.class))).thenReturn(testOSuser);
-		when(userService.get(anyString())).thenReturn(testOSuser);
-
-		List<User> getAllList = new ArrayList<>();
-		getAllList.add(testOSuser);
-		getAllList.add(testOSuser);
-		doReturn(getAllList).when(userService).list();
-		
-		dummyUser = createUser();
-
-		when(testOSuser.getName()).thenReturn(dummyUser.getName());
-		when(testOSuser.getDescription()).thenReturn(dummyUser.getDescription());
-		when(testOSuser.getPassword()).thenReturn(dummyUser.getPassword());
-		when(testOSuser.getDomainId()).thenReturn(dummyUser.getDomainId());
-		when(testOSuser.getEmail()).thenReturn(dummyUser.getEmail());
-	}
-	
-	@Test
-	public void createTest() throws Exception {
-		msg.setHeader(KeystoneConstants.OPERATION, KeystoneConstants.CREATE);
-		msg.setHeader(KeystoneConstants.NAME, dummyUser.getName());
-		msg.setHeader(KeystoneConstants.DESCRIPTION, dummyUser.getDescription());
-		msg.setHeader(KeystoneConstants.DOMAIN_ID, dummyUser.getDomainId());
-		msg.setHeader(KeystoneConstants.PASSWORD, dummyUser.getPassword());
-		msg.setHeader(KeystoneConstants.EMAIL, dummyUser.getEmail());
-
-		producer.process(exchange);
-
-		ArgumentCaptor<User> captor = ArgumentCaptor.forClass(User.class);
-		verify(userService).create(captor.capture());
-
-		assertEqualsUser(dummyUser, captor.getValue());
-	}
-
-	@Test
-	public void getTest() throws Exception {
-		final String id = "id";
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET);
-		msg.setHeader(NeutronConstants.ID, id);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
-		verify(userService).get(captor.capture());
-
-		assertEquals(id, captor.getValue());
-		assertEqualsUser(testOSuser, msg.getBody(User.class));
-	}
-
-	@Test
-	public void getAllTest() throws Exception {
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET_ALL);
-
-		producer.process(exchange);
-
-		final List<Network> result = msg.getBody(List.class);
-		assertTrue(result.size() == 2);
-		assertEquals(testOSuser, result.get(0));
-	}
-
-	@Test
-	public void updateTest() throws Exception {
-		final String id = "myID";
-		msg.setHeader(KeystoneConstants.OPERATION, KeystoneConstants.UPDATE);
-
-		when(testOSuser.getId()).thenReturn(id);
-		final String newDescription = "ndesc";
-		when(testOSuser.getDescription()).thenReturn(newDescription);
-
-		when(userService.update(any(User.class))).thenReturn(testOSuser);
-		msg.setBody(testOSuser);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<User> captor = ArgumentCaptor.forClass(User.class);
-		verify(userService).update(captor.capture());
-
-		assertEqualsUser(testOSuser, captor.getValue());
-		assertNotNull(captor.getValue().getId());
-		assertEquals(newDescription, msg.getBody(User.class).getDescription());
-	}
-	
-	@Test
-	public void deleteTest() throws Exception {
-		when(userService.delete(anyString())).thenReturn(ActionResponse.actionSuccess());
-		final String networkID = "myID";
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.DELETE);
-		msg.setHeader(NeutronConstants.ID, networkID);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
-		verify(userService).delete(captor.capture());
-		assertEquals(networkID, captor.getValue());
-		assertFalse(msg.isFault());
-
-		//in case of failure
-		final String failureMessage = "fail";
-		when(userService.delete(anyString())).thenReturn(ActionResponse.actionFailed(failureMessage, 404));
-		producer.process(exchange);
-		assertTrue(msg.isFault());
-		assertTrue(msg.getBody(String.class).contains(failureMessage));
-	}
-
-	private void assertEqualsUser(User old, User newUser) {
-		assertEquals(old.getName(), newUser.getName());
-		assertEquals(old.getDomainId(), newUser.getDomainId());
-		assertEquals(old.getPassword(), newUser.getPassword());
-		assertEquals(old.getDescription(), newUser.getDescription());
-		assertEquals(old.getEmail(), newUser.getEmail());
-	}
-
-	private User createUser() {
-		return Builders.user()
-				.name("User name")
-				.domainId("domainId")
-				.password("password")
-				.description("desc")
-				.email("email@mail.com")
-				.build();
-	}
+    private User dummyUser;
+
+    @Mock
+    private User testOSuser;
+
+    @Before
+    public void setUp() {
+        producer = new UserProducer(endpoint, client);
+
+        when(userService.create(any(User.class))).thenReturn(testOSuser);
+        when(userService.get(anyString())).thenReturn(testOSuser);
+
+        List<User> getAllList = new ArrayList<>();
+        getAllList.add(testOSuser);
+        getAllList.add(testOSuser);
+        doReturn(getAllList).when(userService).list();
+
+        dummyUser = createUser();
+
+        when(testOSuser.getName()).thenReturn(dummyUser.getName());
+        when(testOSuser.getDescription()).thenReturn(dummyUser.getDescription());
+        when(testOSuser.getPassword()).thenReturn(dummyUser.getPassword());
+        when(testOSuser.getDomainId()).thenReturn(dummyUser.getDomainId());
+        when(testOSuser.getEmail()).thenReturn(dummyUser.getEmail());
+    }
+
+    @Test
+    public void createTest() throws Exception {
+        msg.setHeader(KeystoneConstants.OPERATION, KeystoneConstants.CREATE);
+        msg.setHeader(KeystoneConstants.NAME, dummyUser.getName());
+        msg.setHeader(KeystoneConstants.DESCRIPTION, dummyUser.getDescription());
+        msg.setHeader(KeystoneConstants.DOMAIN_ID, dummyUser.getDomainId());
+        msg.setHeader(KeystoneConstants.PASSWORD, dummyUser.getPassword());
+        msg.setHeader(KeystoneConstants.EMAIL, dummyUser.getEmail());
+
+        producer.process(exchange);
+
+        ArgumentCaptor<User> captor = ArgumentCaptor.forClass(User.class);
+        verify(userService).create(captor.capture());
+
+        assertEqualsUser(dummyUser, captor.getValue());
+    }
+
+    @Test
+    public void getTest() throws Exception {
+        final String id = "id";
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET);
+        msg.setHeader(NeutronConstants.ID, id);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
+        verify(userService).get(captor.capture());
+
+        assertEquals(id, captor.getValue());
+        assertEqualsUser(testOSuser, msg.getBody(User.class));
+    }
+
+    @Test
+    public void getAllTest() throws Exception {
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET_ALL);
+
+        producer.process(exchange);
+
+        final List<Network> result = msg.getBody(List.class);
+        assertTrue(result.size() == 2);
+        assertEquals(testOSuser, result.get(0));
+    }
+
+    @Test
+    public void updateTest() throws Exception {
+        final String id = "myID";
+        msg.setHeader(KeystoneConstants.OPERATION, KeystoneConstants.UPDATE);
+
+        when(testOSuser.getId()).thenReturn(id);
+        final String newDescription = "ndesc";
+        when(testOSuser.getDescription()).thenReturn(newDescription);
+
+        when(userService.update(any(User.class))).thenReturn(testOSuser);
+        msg.setBody(testOSuser);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<User> captor = ArgumentCaptor.forClass(User.class);
+        verify(userService).update(captor.capture());
+
+        assertEqualsUser(testOSuser, captor.getValue());
+        assertNotNull(captor.getValue().getId());
+        assertEquals(newDescription, msg.getBody(User.class).getDescription());
+    }
+
+    @Test
+    public void deleteTest() throws Exception {
+        when(userService.delete(anyString())).thenReturn(ActionResponse.actionSuccess());
+        final String networkID = "myID";
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.DELETE);
+        msg.setHeader(NeutronConstants.ID, networkID);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
+        verify(userService).delete(captor.capture());
+        assertEquals(networkID, captor.getValue());
+        assertFalse(msg.isFault());
+
+        //in case of failure
+        final String failureMessage = "fail";
+        when(userService.delete(anyString())).thenReturn(ActionResponse.actionFailed(failureMessage, 404));
+        producer.process(exchange);
+        assertTrue(msg.isFault());
+        assertTrue(msg.getBody(String.class).contains(failureMessage));
+    }
+
+    private void assertEqualsUser(User old, User newUser) {
+        assertEquals(old.getName(), newUser.getName());
+        assertEquals(old.getDomainId(), newUser.getDomainId());
+        assertEquals(old.getPassword(), newUser.getPassword());
+        assertEquals(old.getDescription(), newUser.getDescription());
+        assertEquals(old.getEmail(), newUser.getEmail());
+    }
+
+    private User createUser() {
+        return Builders.user()
+                .name("User name")
+                .domainId("domainId")
+                .password("password")
+                .description("desc")
+                .email("email@mail.com")
+                .build();
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/7d2907d2/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/NetworkProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/NetworkProducerTest.java b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/NetworkProducerTest.java
index 888326a..bcf5d6d 100644
--- a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/NetworkProducerTest.java
+++ b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/NetworkProducerTest.java
@@ -16,133 +16,129 @@
  */
 package org.apache.camel.component.openstack.neutron;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-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.List;
+import java.util.UUID;
 
 import org.apache.camel.component.openstack.neutron.producer.NetworkProducer;
-
 import org.junit.Before;
 import org.junit.Test;
-
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.openstack4j.api.Builders;
 import org.openstack4j.model.common.ActionResponse;
-import org.openstack4j.model.compute.Flavor;
 import org.openstack4j.model.network.Network;
 import org.openstack4j.model.network.NetworkType;
 
-import java.util.ArrayList;
-import java.util.List;
-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.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 NetworkProducerTest extends NeutronProducerTestSupport {
 
-	private Network dummyNetwork;
-
-	@Mock
-	private Network testOSnetwork;
-
-	@Before
-	public void setUp() {
-		producer = new NetworkProducer(endpoint, client);
-		when(networkService.create(any(Network.class))).thenReturn(testOSnetwork);
-		when(networkService.get(anyString())).thenReturn(testOSnetwork);
-
-		List<Network> getAllList = new ArrayList<>();
-		getAllList.add(testOSnetwork);
-		getAllList.add(testOSnetwork);
-		doReturn(getAllList).when(networkService).list();
-
-		dummyNetwork = createNetwork();
-		when(testOSnetwork.getName()).thenReturn(dummyNetwork.getName());
-		when(testOSnetwork.getTenantId()).thenReturn(dummyNetwork.getTenantId());
-		when(testOSnetwork.getNetworkType()).thenReturn(dummyNetwork.getNetworkType());
-		when(testOSnetwork.getId()).thenReturn(UUID.randomUUID().toString());
-	}
-
-	@Test
-	public void createTest() throws Exception {
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.CREATE);
-		msg.setHeader(NeutronConstants.NAME, dummyNetwork.getName());
-		msg.setHeader(NeutronConstants.NETWORK_TYPE, dummyNetwork.getNetworkType());
-		msg.setHeader(NeutronConstants.TENANT_ID, dummyNetwork.getTenantId());
-
-		producer.process(exchange);
-
-		ArgumentCaptor<Network> captor = ArgumentCaptor.forClass(Network.class);
-		verify(networkService).create(captor.capture());
-
-		assertEqualsNetwork(dummyNetwork, captor.getValue());
-		assertNotNull(msg.getBody(Network.class).getId());
-	}
-
-	@Test
-	public void getTest() throws Exception {
-		final String networkID = "myNetID";
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET);
-		msg.setHeader(NeutronConstants.NETWORK_ID, networkID);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
-		verify(networkService).get(captor.capture());
-
-		assertEquals(networkID, captor.getValue());
-		assertEqualsNetwork(testOSnetwork, msg.getBody(Network.class));
-	}
-
-	@Test
-	public void getAllTest() throws Exception {
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET_ALL);
-
-		producer.process(exchange);
-
-		final List<Network> result = msg.getBody(List.class);
-		assertTrue(result.size() == 2);
-		assertEquals(testOSnetwork, result.get(0));
-	}
-
-	@Test
-	public void deleteTest() throws Exception {
-		when(networkService.delete(anyString())).thenReturn(ActionResponse.actionSuccess());
-		final String networkID = "myNetID";
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.DELETE);
-		msg.setHeader(NeutronConstants.ID, networkID);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
-		verify(networkService).delete(captor.capture());
-		assertEquals(networkID, captor.getValue());
-		assertFalse(msg.isFault());
-
-		//in case of failure
-		final String failureMessage = "fail";
-		when(networkService.delete(anyString())).thenReturn(ActionResponse.actionFailed(failureMessage, 404));
-		producer.process(exchange);
-		assertTrue(msg.isFault());
-		assertTrue(msg.getBody(String.class).contains(failureMessage));
-	}
-
-	private Network createNetwork() {
-		return Builders.network()
-				.name("name")
-				.tenantId("tenantID")
-				.networkType(NetworkType.LOCAL).build();
-	}
-
-	private void assertEqualsNetwork(Network old, Network newNetwork) {
-		assertEquals(old.getName(), newNetwork.getName());
-		assertEquals(old.getTenantId(), newNetwork.getTenantId());
-		assertEquals(old.getNetworkType(), newNetwork.getNetworkType());
-	}
+    private Network dummyNetwork;
+
+    @Mock
+    private Network testOSnetwork;
+
+    @Before
+    public void setUp() {
+        producer = new NetworkProducer(endpoint, client);
+        when(networkService.create(any(Network.class))).thenReturn(testOSnetwork);
+        when(networkService.get(anyString())).thenReturn(testOSnetwork);
+
+        List<Network> getAllList = new ArrayList<>();
+        getAllList.add(testOSnetwork);
+        getAllList.add(testOSnetwork);
+        doReturn(getAllList).when(networkService).list();
+
+        dummyNetwork = createNetwork();
+        when(testOSnetwork.getName()).thenReturn(dummyNetwork.getName());
+        when(testOSnetwork.getTenantId()).thenReturn(dummyNetwork.getTenantId());
+        when(testOSnetwork.getNetworkType()).thenReturn(dummyNetwork.getNetworkType());
+        when(testOSnetwork.getId()).thenReturn(UUID.randomUUID().toString());
+    }
+
+    @Test
+    public void createTest() throws Exception {
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.CREATE);
+        msg.setHeader(NeutronConstants.NAME, dummyNetwork.getName());
+        msg.setHeader(NeutronConstants.NETWORK_TYPE, dummyNetwork.getNetworkType());
+        msg.setHeader(NeutronConstants.TENANT_ID, dummyNetwork.getTenantId());
+
+        producer.process(exchange);
+
+        ArgumentCaptor<Network> captor = ArgumentCaptor.forClass(Network.class);
+        verify(networkService).create(captor.capture());
+
+        assertEqualsNetwork(dummyNetwork, captor.getValue());
+        assertNotNull(msg.getBody(Network.class).getId());
+    }
+
+    @Test
+    public void getTest() throws Exception {
+        final String networkID = "myNetID";
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET);
+        msg.setHeader(NeutronConstants.NETWORK_ID, networkID);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
+        verify(networkService).get(captor.capture());
+
+        assertEquals(networkID, captor.getValue());
+        assertEqualsNetwork(testOSnetwork, msg.getBody(Network.class));
+    }
+
+    @Test
+    public void getAllTest() throws Exception {
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET_ALL);
+
+        producer.process(exchange);
+
+        final List<Network> result = msg.getBody(List.class);
+        assertTrue(result.size() == 2);
+        assertEquals(testOSnetwork, result.get(0));
+    }
+
+    @Test
+    public void deleteTest() throws Exception {
+        when(networkService.delete(anyString())).thenReturn(ActionResponse.actionSuccess());
+        final String networkID = "myNetID";
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.DELETE);
+        msg.setHeader(NeutronConstants.ID, networkID);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
+        verify(networkService).delete(captor.capture());
+        assertEquals(networkID, captor.getValue());
+        assertFalse(msg.isFault());
+
+        //in case of failure
+        final String failureMessage = "fail";
+        when(networkService.delete(anyString())).thenReturn(ActionResponse.actionFailed(failureMessage, 404));
+        producer.process(exchange);
+        assertTrue(msg.isFault());
+        assertTrue(msg.getBody(String.class).contains(failureMessage));
+    }
+
+    private Network createNetwork() {
+        return Builders.network()
+                .name("name")
+                .tenantId("tenantID")
+                .networkType(NetworkType.LOCAL).build();
+    }
+
+    private void assertEqualsNetwork(Network old, Network newNetwork) {
+        assertEquals(old.getName(), newNetwork.getName());
+        assertEquals(old.getTenantId(), newNetwork.getTenantId());
+        assertEquals(old.getNetworkType(), newNetwork.getNetworkType());
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/7d2907d2/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/NeutronProducerTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/NeutronProducerTestSupport.java b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/NeutronProducerTestSupport.java
index e5f5e63..2d58054 100644
--- a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/NeutronProducerTestSupport.java
+++ b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/NeutronProducerTestSupport.java
@@ -16,12 +16,8 @@
  */
 package org.apache.camel.component.openstack.neutron;
 
-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.networking.NetworkService;
 import org.openstack4j.api.networking.NetworkingService;
@@ -29,32 +25,34 @@ import org.openstack4j.api.networking.PortService;
 import org.openstack4j.api.networking.RouterService;
 import org.openstack4j.api.networking.SubnetService;
 
+import static org.mockito.Mockito.when;
+
 public class NeutronProducerTestSupport extends AbstractProducerTestSupport {
 
-	@Mock
-	protected NeutronEndpoint endpoint;
+    @Mock
+    protected NeutronEndpoint endpoint;
 
-	@Mock
-	protected NetworkingService networkingService;
+    @Mock
+    protected NetworkingService networkingService;
 
-	@Mock
-	PortService portService;
+    @Mock
+    PortService portService;
 
-	@Mock
-	RouterService routerService;
+    @Mock
+    RouterService routerService;
 
-	@Mock
-	SubnetService subnetService;
+    @Mock
+    SubnetService subnetService;
 
-	@Mock
-	NetworkService networkService;
+    @Mock
+    NetworkService networkService;
 
-	@Before
-	public void setUpComputeService(){
-		when(client.networking()).thenReturn(networkingService);
-		when(networkingService.port()).thenReturn(portService);
-		when(networkingService.router()).thenReturn(routerService);
-		when(networkingService.subnet()).thenReturn(subnetService);
-		when(networkingService.network()).thenReturn(networkService);
-	}
+    @Before
+    public void setUpComputeService() {
+        when(client.networking()).thenReturn(networkingService);
+        when(networkingService.port()).thenReturn(portService);
+        when(networkingService.router()).thenReturn(routerService);
+        when(networkingService.subnet()).thenReturn(subnetService);
+        when(networkingService.network()).thenReturn(networkService);
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/7d2907d2/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/PortProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/PortProducerTest.java b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/PortProducerTest.java
index 6e46a5b..3b01ab8 100644
--- a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/PortProducerTest.java
+++ b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/PortProducerTest.java
@@ -16,159 +16,155 @@
  */
 package org.apache.camel.component.openstack.neutron;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-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.List;
+import java.util.UUID;
 
 import org.apache.camel.component.openstack.neutron.producer.PortProducer;
-
 import org.junit.Before;
 import org.junit.Test;
-
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.openstack4j.api.Builders;
 import org.openstack4j.model.common.ActionResponse;
 import org.openstack4j.model.network.Port;
-import org.openstack4j.model.network.Router;
 
-import java.util.ArrayList;
-import java.util.List;
-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.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 PortProducerTest extends NeutronProducerTestSupport {
 
-	private Port dummyPort;
+    private Port dummyPort;
 
-	@Mock
-	private Port testOSport;
-
-	@Before
-	public void setUp() {
-		producer = new PortProducer(endpoint, client);
-		when(portService.create(any(Port.class))).thenReturn(testOSport);
-		when(portService.get(anyString())).thenReturn(testOSport);
-
-		List<Port> getAllList = new ArrayList<>();
-		getAllList.add(testOSport);
-		getAllList.add(testOSport);
-		doReturn(getAllList).when(portService).list();
-
-		dummyPort = createPort();
-		when(testOSport.getName()).thenReturn(dummyPort.getName());
-		when(testOSport.getNetworkId()).thenReturn(dummyPort.getNetworkId());
-		when(testOSport.getMacAddress()).thenReturn(dummyPort.getMacAddress());
-		when(testOSport.getDeviceId()).thenReturn(dummyPort.getDeviceId());
-		when(testOSport.getId()).thenReturn(UUID.randomUUID().toString());
-	}
-
-	@Test
-	public void createTest() throws Exception {
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.CREATE);
-		msg.setHeader(NeutronConstants.NAME, dummyPort.getName());
-		msg.setHeader(NeutronConstants.TENANT_ID, dummyPort.getTenantId());
-		msg.setHeader(NeutronConstants.NETWORK_ID, dummyPort.getNetworkId());
-		msg.setHeader(NeutronConstants.MAC_ADDRESS, dummyPort.getMacAddress());
-		msg.setHeader(NeutronConstants.DEVICE_ID, dummyPort.getDeviceId());
-
-		producer.process(exchange);
-
-		ArgumentCaptor<Port> captor = ArgumentCaptor.forClass(Port.class);
-		verify(portService).create(captor.capture());
-
-		assertEqualsPort(dummyPort, captor.getValue());
-		assertNotNull(msg.getBody(Port.class).getId());
-	}
-
-	@Test
-	public void getTest() throws Exception {
-		final String portID = "myNetID";
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET);
-		msg.setHeader(NeutronConstants.ID, portID);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
-		verify(portService).get(captor.capture());
-
-		assertEquals(portID, captor.getValue());
-		assertEqualsPort(testOSport, msg.getBody(Port.class));
-	}
-
-	@Test
-	public void getAllTest() throws Exception {
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET_ALL);
-
-		producer.process(exchange);
-
-		final List<Port> result = msg.getBody(List.class);
-		assertTrue(result.size() == 2);
-		assertEquals(testOSport, result.get(0));
-	}
-
-	@Test
-	public void updateTest() throws Exception {
-		final String portID = "myID";
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.UPDATE);
-		final String newDevId = "dev";
-		when(testOSport.getDeviceId()).thenReturn(newDevId);
-		when(testOSport.getId()).thenReturn(portID);
-		when(portService.update(any(Port.class))).thenReturn(testOSport);
-
-		msg.setBody(testOSport);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<Port> captor = ArgumentCaptor.forClass(Port.class);
-		verify(portService).update(captor.capture());
-
-		assertEqualsPort(testOSport, captor.getValue());
-		assertNotNull(captor.getValue().getId());
-	}
-
-	@Test
-	public void deleteTest() throws Exception {
-		when(portService.delete(anyString())).thenReturn(ActionResponse.actionSuccess());
-		final String portID = "myNetID";
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.DELETE);
-		msg.setHeader(NeutronConstants.ID, portID);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
-		verify(portService).delete(captor.capture());
-		assertEquals(portID, captor.getValue());
-		assertFalse(msg.isFault());
-
-		//in case of failure
-		final String failureMessage = "fail";
-		when(portService.delete(anyString())).thenReturn(ActionResponse.actionFailed(failureMessage, 404));
-		producer.process(exchange);
-		assertTrue(msg.isFault());
-		assertTrue(msg.getBody(String.class).contains(failureMessage));
-	}
-
-	private Port createPort() {
-		return Builders.port()
-				.name("name")
-				.tenantId("tenantID")
-				.networkId("netId")
-				.deviceId("devID")
-				.macAddress("mac").build();
-	}
-
-	private void assertEqualsPort(Port old, Port newPort) {
-		assertEquals(old.getName(), newPort.getName());
-		assertEquals(old.getTenantId(), newPort.getTenantId());
-		assertEquals(old.getNetworkId(), newPort.getNetworkId());
-		assertEquals(old.getDeviceId(), newPort.getDeviceId());
-		assertEquals(old.getMacAddress(), newPort.getMacAddress());
-	}
+    @Mock
+    private Port testOSport;
+
+    @Before
+    public void setUp() {
+        producer = new PortProducer(endpoint, client);
+        when(portService.create(any(Port.class))).thenReturn(testOSport);
+        when(portService.get(anyString())).thenReturn(testOSport);
+
+        List<Port> getAllList = new ArrayList<>();
+        getAllList.add(testOSport);
+        getAllList.add(testOSport);
+        doReturn(getAllList).when(portService).list();
+
+        dummyPort = createPort();
+        when(testOSport.getName()).thenReturn(dummyPort.getName());
+        when(testOSport.getNetworkId()).thenReturn(dummyPort.getNetworkId());
+        when(testOSport.getMacAddress()).thenReturn(dummyPort.getMacAddress());
+        when(testOSport.getDeviceId()).thenReturn(dummyPort.getDeviceId());
+        when(testOSport.getId()).thenReturn(UUID.randomUUID().toString());
+    }
+
+    @Test
+    public void createTest() throws Exception {
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.CREATE);
+        msg.setHeader(NeutronConstants.NAME, dummyPort.getName());
+        msg.setHeader(NeutronConstants.TENANT_ID, dummyPort.getTenantId());
+        msg.setHeader(NeutronConstants.NETWORK_ID, dummyPort.getNetworkId());
+        msg.setHeader(NeutronConstants.MAC_ADDRESS, dummyPort.getMacAddress());
+        msg.setHeader(NeutronConstants.DEVICE_ID, dummyPort.getDeviceId());
+
+        producer.process(exchange);
+
+        ArgumentCaptor<Port> captor = ArgumentCaptor.forClass(Port.class);
+        verify(portService).create(captor.capture());
+
+        assertEqualsPort(dummyPort, captor.getValue());
+        assertNotNull(msg.getBody(Port.class).getId());
+    }
+
+    @Test
+    public void getTest() throws Exception {
+        final String portID = "myNetID";
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET);
+        msg.setHeader(NeutronConstants.ID, portID);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
+        verify(portService).get(captor.capture());
+
+        assertEquals(portID, captor.getValue());
+        assertEqualsPort(testOSport, msg.getBody(Port.class));
+    }
+
+    @Test
+    public void getAllTest() throws Exception {
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET_ALL);
+
+        producer.process(exchange);
+
+        final List<Port> result = msg.getBody(List.class);
+        assertTrue(result.size() == 2);
+        assertEquals(testOSport, result.get(0));
+    }
+
+    @Test
+    public void updateTest() throws Exception {
+        final String portID = "myID";
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.UPDATE);
+        final String newDevId = "dev";
+        when(testOSport.getDeviceId()).thenReturn(newDevId);
+        when(testOSport.getId()).thenReturn(portID);
+        when(portService.update(any(Port.class))).thenReturn(testOSport);
+
+        msg.setBody(testOSport);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<Port> captor = ArgumentCaptor.forClass(Port.class);
+        verify(portService).update(captor.capture());
+
+        assertEqualsPort(testOSport, captor.getValue());
+        assertNotNull(captor.getValue().getId());
+    }
+
+    @Test
+    public void deleteTest() throws Exception {
+        when(portService.delete(anyString())).thenReturn(ActionResponse.actionSuccess());
+        final String portID = "myNetID";
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.DELETE);
+        msg.setHeader(NeutronConstants.ID, portID);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
+        verify(portService).delete(captor.capture());
+        assertEquals(portID, captor.getValue());
+        assertFalse(msg.isFault());
+
+        //in case of failure
+        final String failureMessage = "fail";
+        when(portService.delete(anyString())).thenReturn(ActionResponse.actionFailed(failureMessage, 404));
+        producer.process(exchange);
+        assertTrue(msg.isFault());
+        assertTrue(msg.getBody(String.class).contains(failureMessage));
+    }
+
+    private Port createPort() {
+        return Builders.port()
+                .name("name")
+                .tenantId("tenantID")
+                .networkId("netId")
+                .deviceId("devID")
+                .macAddress("mac").build();
+    }
+
+    private void assertEqualsPort(Port old, Port newPort) {
+        assertEquals(old.getName(), newPort.getName());
+        assertEquals(old.getTenantId(), newPort.getTenantId());
+        assertEquals(old.getNetworkId(), newPort.getNetworkId());
+        assertEquals(old.getDeviceId(), newPort.getDeviceId());
+        assertEquals(old.getMacAddress(), newPort.getMacAddress());
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/7d2907d2/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/RouterProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/RouterProducerTest.java b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/RouterProducerTest.java
index 18d0ecc..805f7e4 100644
--- a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/RouterProducerTest.java
+++ b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/RouterProducerTest.java
@@ -16,206 +16,202 @@
  */
 package org.apache.camel.component.openstack.neutron;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-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.List;
+import java.util.UUID;
 
 import org.apache.camel.component.openstack.neutron.producer.RouterProducer;
-
 import org.junit.Before;
 import org.junit.Test;
-
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.openstack4j.api.Builders;
 import org.openstack4j.model.common.ActionResponse;
 import org.openstack4j.model.network.AttachInterfaceType;
-import org.openstack4j.model.network.NetworkType;
 import org.openstack4j.model.network.Router;
 import org.openstack4j.model.network.RouterInterface;
 import org.openstack4j.openstack.networking.domain.NeutronRouterInterface;
 
-import java.util.ArrayList;
-import java.util.List;
-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.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 RouterProducerTest extends NeutronProducerTestSupport {
 
-	private Router dummyRouter;
-
-	@Mock
-	private Router testOSrouter;
-
-	@Before
-	public void setUp() {
-		producer = new RouterProducer(endpoint, client);
-		when(routerService.create(any(Router.class))).thenReturn(testOSrouter);
-		when(routerService.get(anyString())).thenReturn(testOSrouter);
-
-		List<Router> getAllList = new ArrayList<>();
-		getAllList.add(testOSrouter);
-		getAllList.add(testOSrouter);
-		doReturn(getAllList).when(routerService).list();
-
-		dummyRouter = createRouter();
-		when(testOSrouter.getName()).thenReturn(dummyRouter.getName());
-		when(testOSrouter.getTenantId()).thenReturn(dummyRouter.getTenantId());
-		when(testOSrouter.getId()).thenReturn(UUID.randomUUID().toString());
-	}
-
-	@Test
-	public void createTest() throws Exception {
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.CREATE);
-		msg.setHeader(NeutronConstants.NAME, dummyRouter.getName());
-		msg.setHeader(NeutronConstants.TENANT_ID, dummyRouter.getTenantId());
-
-		producer.process(exchange);
-
-		ArgumentCaptor<Router> captor = ArgumentCaptor.forClass(Router.class);
-		verify(routerService).create(captor.capture());
-
-		assertEqualsRouter(dummyRouter, captor.getValue());
-		assertNotNull(msg.getBody(Router.class).getId());
-	}
-
-	@Test
-	public void getTest() throws Exception {
-		final String routerID = "myRouterID";
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET);
-		msg.setHeader(NeutronConstants.ROUTER_ID, routerID);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
-		verify(routerService).get(captor.capture());
-
-		assertEquals(routerID, captor.getValue());
-		assertEqualsRouter(testOSrouter, msg.getBody(Router.class));
-	}
-
-	@Test
-	public void getAllTest() throws Exception {
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET_ALL);
-
-		producer.process(exchange);
-
-		final List<Router> result = msg.getBody(List.class);
-		assertTrue(result.size() == 2);
-		assertEquals(testOSrouter, result.get(0));
-	}
-
-	@Test
-	public void updateTest() throws Exception {
-		final String routerID = "myRouterID";
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.UPDATE);
-		final Router tmp = createRouter();
-		final String newName = "newName";
-		tmp.setName(newName);
-		when(routerService.update(any(Router.class))).thenReturn(tmp);
-		dummyRouter.setId(routerID);
-		msg.setBody(dummyRouter);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<Router> captor = ArgumentCaptor.forClass(Router.class);
-		verify(routerService).update(captor.capture());
-
-		assertEqualsRouter(dummyRouter, captor.getValue());
-		assertNotNull(captor.getValue().getId());
-		assertEquals(newName, msg.getBody(Router.class).getName());
-	}
-
-	@Test
-	public void deleteTest() throws Exception {
-		when(routerService.delete(anyString())).thenReturn(ActionResponse.actionSuccess());
-		final String routerID = "myRouterID";
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.DELETE);
-		msg.setHeader(NeutronConstants.ID, routerID);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
-		verify(routerService).delete(captor.capture());
-		assertEquals(routerID, captor.getValue());
-		assertFalse(msg.isFault());
-
-		//in case of failure
-		final String failureMessage = "fail";
-		when(routerService.delete(anyString())).thenReturn(ActionResponse.actionFailed(failureMessage, 404));
-		producer.process(exchange);
-		assertTrue(msg.isFault());
-		assertTrue(msg.getBody(String.class).contains(failureMessage));
-	}
-
-	@Test
-	public void detachTest() throws Exception {
-		final String routerID = "myRouterID";
-		final String portId = "port";
-		final String subnetId = "subnet";
-		final RouterInterface ifce = new NeutronRouterInterface(subnetId, portId);
-		when(routerService.detachInterface(anyString(), anyString(), anyString())).thenReturn(ifce);
-
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.DETACH_INTERFACE);
-		msg.setHeader(NeutronConstants.ROUTER_ID, routerID);
-		msg.setHeader(NeutronConstants.SUBNET_ID, subnetId);
-		msg.setHeader(NeutronConstants.PORT_ID, portId);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<String> routerC = ArgumentCaptor.forClass(String.class);
-		ArgumentCaptor<String> portC = ArgumentCaptor.forClass(String.class);
-		ArgumentCaptor<String> subnetC = ArgumentCaptor.forClass(String.class);
-		verify(routerService).detachInterface(routerC.capture(), subnetC.capture(), portC.capture());
-
-		assertEquals(routerID, routerC.getValue());
-		assertEquals(subnetId, subnetC.getValue());
-		assertEquals(portId, portC.getValue());
-
-		assertEquals(ifce, msg.getBody(RouterInterface.class));
-	}
-
-	@Test
-	public void attachTest() throws Exception {
-		final String routerID = "myRouterID";
-		final String subnetId = "subnet";
-		final RouterInterface ifce = new NeutronRouterInterface(subnetId, null);
-		when(routerService.attachInterface(anyString(), any(AttachInterfaceType.class), anyString())).thenReturn(ifce);
-
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.ATTACH_INTERFACE);
-		msg.setHeader(NeutronConstants.ROUTER_ID, routerID);
-		msg.setHeader(NeutronConstants.SUBNET_ID, subnetId);
-		msg.setHeader(NeutronConstants.ITERFACE_TYPE, AttachInterfaceType.SUBNET);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<String> routerC = ArgumentCaptor.forClass(String.class);
-		ArgumentCaptor<AttachInterfaceType> itfType = ArgumentCaptor.forClass(AttachInterfaceType.class);
-		ArgumentCaptor<String> subnetC = ArgumentCaptor.forClass(String.class);
-		verify(routerService).attachInterface(routerC.capture(), itfType.capture(), subnetC.capture());
-
-		assertEquals(routerID, routerC.getValue());
-		assertEquals(AttachInterfaceType.SUBNET, itfType.getValue());
-		assertEquals(subnetId, subnetC.getValue());
-
-		assertEquals(ifce, msg.getBody(RouterInterface.class));
-	}
-
-	private Router createRouter() {
-		return Builders.router()
-				.name("name")
-				.tenantId("tenantID")
-				.build();
-	}
-
-	private void assertEqualsRouter(Router old, Router newRouter) {
-		assertEquals(old.getName(), newRouter.getName());
-		assertEquals(old.getTenantId(), newRouter.getTenantId());
-	}
+    private Router dummyRouter;
+
+    @Mock
+    private Router testOSrouter;
+
+    @Before
+    public void setUp() {
+        producer = new RouterProducer(endpoint, client);
+        when(routerService.create(any(Router.class))).thenReturn(testOSrouter);
+        when(routerService.get(anyString())).thenReturn(testOSrouter);
+
+        List<Router> getAllList = new ArrayList<>();
+        getAllList.add(testOSrouter);
+        getAllList.add(testOSrouter);
+        doReturn(getAllList).when(routerService).list();
+
+        dummyRouter = createRouter();
+        when(testOSrouter.getName()).thenReturn(dummyRouter.getName());
+        when(testOSrouter.getTenantId()).thenReturn(dummyRouter.getTenantId());
+        when(testOSrouter.getId()).thenReturn(UUID.randomUUID().toString());
+    }
+
+    @Test
+    public void createTest() throws Exception {
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.CREATE);
+        msg.setHeader(NeutronConstants.NAME, dummyRouter.getName());
+        msg.setHeader(NeutronConstants.TENANT_ID, dummyRouter.getTenantId());
+
+        producer.process(exchange);
+
+        ArgumentCaptor<Router> captor = ArgumentCaptor.forClass(Router.class);
+        verify(routerService).create(captor.capture());
+
+        assertEqualsRouter(dummyRouter, captor.getValue());
+        assertNotNull(msg.getBody(Router.class).getId());
+    }
+
+    @Test
+    public void getTest() throws Exception {
+        final String routerID = "myRouterID";
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET);
+        msg.setHeader(NeutronConstants.ROUTER_ID, routerID);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
+        verify(routerService).get(captor.capture());
+
+        assertEquals(routerID, captor.getValue());
+        assertEqualsRouter(testOSrouter, msg.getBody(Router.class));
+    }
+
+    @Test
+    public void getAllTest() throws Exception {
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET_ALL);
+
+        producer.process(exchange);
+
+        final List<Router> result = msg.getBody(List.class);
+        assertTrue(result.size() == 2);
+        assertEquals(testOSrouter, result.get(0));
+    }
+
+    @Test
+    public void updateTest() throws Exception {
+        final String routerID = "myRouterID";
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.UPDATE);
+        final Router tmp = createRouter();
+        final String newName = "newName";
+        tmp.setName(newName);
+        when(routerService.update(any(Router.class))).thenReturn(tmp);
+        dummyRouter.setId(routerID);
+        msg.setBody(dummyRouter);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<Router> captor = ArgumentCaptor.forClass(Router.class);
+        verify(routerService).update(captor.capture());
+
+        assertEqualsRouter(dummyRouter, captor.getValue());
+        assertNotNull(captor.getValue().getId());
+        assertEquals(newName, msg.getBody(Router.class).getName());
+    }
+
+    @Test
+    public void deleteTest() throws Exception {
+        when(routerService.delete(anyString())).thenReturn(ActionResponse.actionSuccess());
+        final String routerID = "myRouterID";
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.DELETE);
+        msg.setHeader(NeutronConstants.ID, routerID);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
+        verify(routerService).delete(captor.capture());
+        assertEquals(routerID, captor.getValue());
+        assertFalse(msg.isFault());
+
+        //in case of failure
+        final String failureMessage = "fail";
+        when(routerService.delete(anyString())).thenReturn(ActionResponse.actionFailed(failureMessage, 404));
+        producer.process(exchange);
+        assertTrue(msg.isFault());
+        assertTrue(msg.getBody(String.class).contains(failureMessage));
+    }
+
+    @Test
+    public void detachTest() throws Exception {
+        final String routerID = "myRouterID";
+        final String portId = "port";
+        final String subnetId = "subnet";
+        final RouterInterface ifce = new NeutronRouterInterface(subnetId, portId);
+        when(routerService.detachInterface(anyString(), anyString(), anyString())).thenReturn(ifce);
+
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.DETACH_INTERFACE);
+        msg.setHeader(NeutronConstants.ROUTER_ID, routerID);
+        msg.setHeader(NeutronConstants.SUBNET_ID, subnetId);
+        msg.setHeader(NeutronConstants.PORT_ID, portId);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<String> routerC = ArgumentCaptor.forClass(String.class);
+        ArgumentCaptor<String> portC = ArgumentCaptor.forClass(String.class);
+        ArgumentCaptor<String> subnetC = ArgumentCaptor.forClass(String.class);
+        verify(routerService).detachInterface(routerC.capture(), subnetC.capture(), portC.capture());
+
+        assertEquals(routerID, routerC.getValue());
+        assertEquals(subnetId, subnetC.getValue());
+        assertEquals(portId, portC.getValue());
+
+        assertEquals(ifce, msg.getBody(RouterInterface.class));
+    }
+
+    @Test
+    public void attachTest() throws Exception {
+        final String routerID = "myRouterID";
+        final String subnetId = "subnet";
+        final RouterInterface ifce = new NeutronRouterInterface(subnetId, null);
+        when(routerService.attachInterface(anyString(), any(AttachInterfaceType.class), anyString())).thenReturn(ifce);
+
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.ATTACH_INTERFACE);
+        msg.setHeader(NeutronConstants.ROUTER_ID, routerID);
+        msg.setHeader(NeutronConstants.SUBNET_ID, subnetId);
+        msg.setHeader(NeutronConstants.ITERFACE_TYPE, AttachInterfaceType.SUBNET);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<String> routerC = ArgumentCaptor.forClass(String.class);
+        ArgumentCaptor<AttachInterfaceType> itfType = ArgumentCaptor.forClass(AttachInterfaceType.class);
+        ArgumentCaptor<String> subnetC = ArgumentCaptor.forClass(String.class);
+        verify(routerService).attachInterface(routerC.capture(), itfType.capture(), subnetC.capture());
+
+        assertEquals(routerID, routerC.getValue());
+        assertEquals(AttachInterfaceType.SUBNET, itfType.getValue());
+        assertEquals(subnetId, subnetC.getValue());
+
+        assertEquals(ifce, msg.getBody(RouterInterface.class));
+    }
+
+    private Router createRouter() {
+        return Builders.router()
+                .name("name")
+                .tenantId("tenantID")
+                .build();
+    }
+
+    private void assertEqualsRouter(Router old, Router newRouter) {
+        assertEquals(old.getName(), newRouter.getName());
+        assertEquals(old.getTenantId(), newRouter.getTenantId());
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/7d2907d2/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/SubnetProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/SubnetProducerTest.java b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/SubnetProducerTest.java
index 3cf82b8..c663bb3 100644
--- a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/SubnetProducerTest.java
+++ b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/neutron/SubnetProducerTest.java
@@ -16,22 +16,13 @@
  */
 package org.apache.camel.component.openstack.neutron;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-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.List;
+import java.util.UUID;
 
 import org.apache.camel.component.openstack.neutron.producer.SubnetProducer;
-
 import org.junit.Before;
 import org.junit.Test;
-
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.openstack4j.api.Builders;
@@ -39,107 +30,113 @@ import org.openstack4j.model.common.ActionResponse;
 import org.openstack4j.model.network.IPVersionType;
 import org.openstack4j.model.network.Subnet;
 
-import java.util.ArrayList;
-import java.util.List;
-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.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 SubnetProducerTest extends NeutronProducerTestSupport {
 
-	private Subnet dummySubnet;
-
-	@Mock
-	private Subnet testOSsubnet;
-
-	@Before
-	public void setUp() {
-		producer = new SubnetProducer(endpoint, client);
-		when(subnetService.create(any(Subnet.class))).thenReturn(testOSsubnet);
-		when(subnetService.get(anyString())).thenReturn(testOSsubnet);
-
-		List<Subnet> getAllList = new ArrayList<>();
-		getAllList.add(testOSsubnet);
-		getAllList.add(testOSsubnet);
-		doReturn(getAllList).when(subnetService).list();
-
-		dummySubnet = createSubnet();
-		when(testOSsubnet.getName()).thenReturn(dummySubnet.getName());
-		when(testOSsubnet.getNetworkId()).thenReturn(dummySubnet.getNetworkId());
-		when(testOSsubnet.getId()).thenReturn(UUID.randomUUID().toString());
-	}
-
-	@Test
-	public void createTest() throws Exception {
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.CREATE);
-		msg.setHeader(NeutronConstants.NAME, dummySubnet.getName());
-		msg.setHeader(NeutronConstants.NETWORK_ID , dummySubnet.getNetworkId());
-		msg.setHeader(NeutronConstants.IP_VERSION, IPVersionType.V4);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<Subnet> captor = ArgumentCaptor.forClass(Subnet.class);
-		verify(subnetService).create(captor.capture());
-
-		assertEqualsSubnet(dummySubnet, captor.getValue());
-		assertNotNull(msg.getBody(Subnet.class).getId());
-	}
-
-	@Test
-	public void getTest() throws Exception {
-		final String subnetID = "myNetID";
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET);
-		msg.setHeader(NeutronConstants.SUBNET_ID, subnetID);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
-		verify(subnetService).get(captor.capture());
-
-		assertEquals(subnetID, captor.getValue());
-		assertEqualsSubnet(testOSsubnet, msg.getBody(Subnet.class));
-	}
-
-	@Test
-	public void getAllTest() throws Exception {
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET_ALL);
-
-		producer.process(exchange);
-
-		final List<Subnet> result = msg.getBody(List.class);
-		assertTrue(result.size() == 2);
-		assertEquals(testOSsubnet, result.get(0));
-	}
-
-	@Test
-	public void deleteTest() throws Exception {
-		when(subnetService.delete(anyString())).thenReturn(ActionResponse.actionSuccess());
-		final String subnetID = "myNetID";
-		msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.DELETE);
-		msg.setHeader(NeutronConstants.ID, subnetID);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
-		verify(subnetService).delete(captor.capture());
-		assertEquals(subnetID, captor.getValue());
-		assertFalse(msg.isFault());
-
-		//in case of failure
-		final String failureMessage = "fail";
-		when(subnetService.delete(anyString())).thenReturn(ActionResponse.actionFailed(failureMessage, 404));
-		producer.process(exchange);
-		assertTrue(msg.isFault());
-		assertTrue(msg.getBody(String.class).contains(failureMessage));
-	}
-
-	private Subnet createSubnet() {
-		return Builders.subnet()
-				.name("name")
-				.networkId("netId")
-				.build();
-	}
-
-	private void assertEqualsSubnet(Subnet old, Subnet newSubnet) {
-		assertEquals(old.getName(), newSubnet.getName());
-		assertEquals(old.getNetworkId(), newSubnet.getNetworkId());
-	}
+    private Subnet dummySubnet;
+
+    @Mock
+    private Subnet testOSsubnet;
+
+    @Before
+    public void setUp() {
+        producer = new SubnetProducer(endpoint, client);
+        when(subnetService.create(any(Subnet.class))).thenReturn(testOSsubnet);
+        when(subnetService.get(anyString())).thenReturn(testOSsubnet);
+
+        List<Subnet> getAllList = new ArrayList<>();
+        getAllList.add(testOSsubnet);
+        getAllList.add(testOSsubnet);
+        doReturn(getAllList).when(subnetService).list();
+
+        dummySubnet = createSubnet();
+        when(testOSsubnet.getName()).thenReturn(dummySubnet.getName());
+        when(testOSsubnet.getNetworkId()).thenReturn(dummySubnet.getNetworkId());
+        when(testOSsubnet.getId()).thenReturn(UUID.randomUUID().toString());
+    }
+
+    @Test
+    public void createTest() throws Exception {
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.CREATE);
+        msg.setHeader(NeutronConstants.NAME, dummySubnet.getName());
+        msg.setHeader(NeutronConstants.NETWORK_ID, dummySubnet.getNetworkId());
+        msg.setHeader(NeutronConstants.IP_VERSION, IPVersionType.V4);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<Subnet> captor = ArgumentCaptor.forClass(Subnet.class);
+        verify(subnetService).create(captor.capture());
+
+        assertEqualsSubnet(dummySubnet, captor.getValue());
+        assertNotNull(msg.getBody(Subnet.class).getId());
+    }
+
+    @Test
+    public void getTest() throws Exception {
+        final String subnetID = "myNetID";
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET);
+        msg.setHeader(NeutronConstants.SUBNET_ID, subnetID);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
+        verify(subnetService).get(captor.capture());
+
+        assertEquals(subnetID, captor.getValue());
+        assertEqualsSubnet(testOSsubnet, msg.getBody(Subnet.class));
+    }
+
+    @Test
+    public void getAllTest() throws Exception {
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.GET_ALL);
+
+        producer.process(exchange);
+
+        final List<Subnet> result = msg.getBody(List.class);
+        assertTrue(result.size() == 2);
+        assertEquals(testOSsubnet, result.get(0));
+    }
+
+    @Test
+    public void deleteTest() throws Exception {
+        when(subnetService.delete(anyString())).thenReturn(ActionResponse.actionSuccess());
+        final String subnetID = "myNetID";
+        msg.setHeader(NeutronConstants.OPERATION, NeutronConstants.DELETE);
+        msg.setHeader(NeutronConstants.ID, subnetID);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<String> captor = ArgumentCaptor.forClass(String.class);
+        verify(subnetService).delete(captor.capture());
+        assertEquals(subnetID, captor.getValue());
+        assertFalse(msg.isFault());
+
+        //in case of failure
+        final String failureMessage = "fail";
+        when(subnetService.delete(anyString())).thenReturn(ActionResponse.actionFailed(failureMessage, 404));
+        producer.process(exchange);
+        assertTrue(msg.isFault());
+        assertTrue(msg.getBody(String.class).contains(failureMessage));
+    }
+
+    private Subnet createSubnet() {
+        return Builders.subnet()
+                .name("name")
+                .networkId("netId")
+                .build();
+    }
+
+    private void assertEqualsSubnet(Subnet old, Subnet newSubnet) {
+        assertEquals(old.getName(), newSubnet.getName());
+        assertEquals(old.getNetworkId(), newSubnet.getNetworkId());
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/7d2907d2/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/FlavorProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/FlavorProducerTest.java b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/FlavorProducerTest.java
index c09f3a6..2ca9000 100644
--- a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/FlavorProducerTest.java
+++ b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/FlavorProducerTest.java
@@ -16,21 +16,15 @@
  */
 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.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 java.util.UUID;
 
 import org.apache.camel.component.openstack.nova.producer.FlavorsProducer;
-
 import org.junit.Before;
 import org.junit.Test;
-
 import org.mockito.ArgumentCaptor;
 import org.mockito.Matchers;
 import org.mockito.Mock;
@@ -39,155 +33,158 @@ import org.openstack4j.model.common.ActionResponse;
 import org.openstack4j.model.compute.Flavor;
 import org.openstack4j.model.compute.builder.FlavorBuilder;
 
-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.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 public class FlavorProducerTest extends NovaProducerTestSupport {
 
-	@Mock
-	private Flavor testOSFlavor;
-
-	private Flavor dummyFlavor;
-
-	@Before
-	public void setUp() {
-		producer = new FlavorsProducer(endpoint, client);
-
-		when(flavorService.create(Matchers.any(org.openstack4j.model.compute.Flavor.class))).thenReturn(testOSFlavor);
-		when(flavorService.get(Matchers.anyString())).thenReturn(testOSFlavor);
-
-		List<org.openstack4j.model.compute.Flavor> getAllList = new ArrayList<>();
-		getAllList.add(testOSFlavor);
-		getAllList.add(testOSFlavor);
-		doReturn(getAllList).when(flavorService).list();
-
-		dummyFlavor = createTestFlavor();
-
-		when(testOSFlavor.getId()).thenReturn(UUID.randomUUID().toString());
-		when(testOSFlavor.getName()).thenReturn(dummyFlavor.getName());
-		when(testOSFlavor.getRam()).thenReturn(dummyFlavor.getRam());
-		when(testOSFlavor.getVcpus()).thenReturn(dummyFlavor.getVcpus());
-		when(testOSFlavor.getDisk()).thenReturn(dummyFlavor.getDisk());
-		when(testOSFlavor.getSwap()).thenReturn(dummyFlavor.getSwap());
-	}
-
-	@Test
-	public void createFlavor() throws Exception {
-		when(endpoint.getOperation()).thenReturn(NovaConstants.CREATE);
-		final String expectedFlavorID = UUID.randomUUID().toString();
-		when(testOSFlavor.getId()).thenReturn(expectedFlavorID);
-
-		//send dummyFlavor to create
-		msg.setBody(dummyFlavor);
-		producer.process(exchange);
-
-		ArgumentCaptor<Flavor> flavorCaptor = ArgumentCaptor.forClass(Flavor.class);
-		verify(flavorService).create(flavorCaptor.capture());
-		assertEquals(dummyFlavor, flavorCaptor.getValue());
-
-		final Flavor createdFlavor = msg.getBody(Flavor.class);
-		assertEqualsFlavors(dummyFlavor, createdFlavor);
-		assertNotNull(createdFlavor.getId());
-	}
-
-	@Test
-	public void createFlavorWithHeaders() throws Exception {
-		Map<String, Object> headers = new HashMap<>();
-		headers.put(NovaConstants.OPERATION, NovaConstants.CREATE);
-		headers.put(NovaConstants.NAME, dummyFlavor.getName());
-		headers.put(NovaConstants.VCPU, dummyFlavor.getVcpus());
-		headers.put(NovaConstants.DISK, dummyFlavor.getDisk());
-		headers.put(NovaConstants.SWAP, dummyFlavor.getSwap());
-		headers.put(NovaConstants.RAM, dummyFlavor.getRam());
-		msg.setHeaders(headers);
-		producer.process(exchange);
-
-		ArgumentCaptor<Flavor> flavorCaptor = ArgumentCaptor.forClass(Flavor.class);
-		verify(flavorService).create(flavorCaptor.capture());
-		assertEqualsFlavors(dummyFlavor, flavorCaptor.getValue());
-
-		final Flavor created = msg.getBody(Flavor.class);
-		assertNotNull(created.getId());
-		assertEqualsFlavors(dummyFlavor, created);
-	}
-
-	@Test
-	public void getTest() throws Exception {
-		msg.setHeader(NovaConstants.OPERATION, NovaConstants.GET);
-		msg.setHeader(NovaConstants.ID, "anything - client is mocked");
-
-		//should return dummyFlavor
-		producer.process(exchange);
-
-		final Flavor result = msg.getBody(Flavor.class);
-		assertEqualsFlavors(dummyFlavor, result);
-		assertNotNull(result.getId());
-	}
-
-	@Test
-	public void getAllTest() throws Exception {
-		when(endpoint.getOperation()).thenReturn(NovaConstants.GET_ALL);
-
-		producer.process(exchange);
-		List<Flavor> result = msg.getBody(List.class);
-
-		assertTrue(result.size() == 2);
-		for (Flavor f : result) {
-			assertEqualsFlavors(dummyFlavor, f);
-			assertNotNull(f.getId());
-		}
-	}
-
-	@Test
-	public void deleteSuccess() throws Exception {
-		when(flavorService.delete(Matchers.anyString())).thenReturn(ActionResponse.actionSuccess());
-		when(endpoint.getOperation()).thenReturn(NovaConstants.DELETE);
-		String id = "myID";
-		msg.setHeader(NovaConstants.ID, id);
-		producer.process(exchange);
-
-		ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);
-		verify(flavorService).delete(argumentCaptor.capture());
-		assertEquals(id, argumentCaptor.getValue());
-
-		assertFalse(msg.isFault());
-		assertNull(msg.getBody());
-	}
-
-	@Test
-	public void deleteFailure() throws Exception {
-		final String failReason = "unknown";
-		when(flavorService.delete(Matchers.anyString())).thenReturn(ActionResponse.actionFailed(failReason, 401));
-		when(endpoint.getOperation()).thenReturn(NovaConstants.DELETE);
-		String id = "myID";
-		msg.setHeader(NovaConstants.ID, id);
-		producer.process(exchange);
-
-		ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);
-		verify(flavorService).delete(argumentCaptor.capture());
-		assertEquals(id, argumentCaptor.getValue());
-
-		assertTrue(msg.isFault());
-		assertTrue(msg.getBody(String.class).contains(failReason));
-	}
-
-	private Flavor createTestFlavor() {
-		FlavorBuilder builder = Builders.flavor()
-				.name("dummy flavor")
-				.ram(3)
-				.vcpus(2)
-				.disk(5)
-				.swap(2);
-		return builder.build();
-	}
-
-	private void assertEqualsFlavors(Flavor old, Flavor createdFlavor) {
-		assertEquals(old.getName(), createdFlavor.getName());
-		assertEquals(old.getRam(), createdFlavor.getRam());
-		assertEquals(old.getVcpus(), createdFlavor.getVcpus());
-		assertEquals(old.getDisk(), createdFlavor.getDisk());
-	}
+    @Mock
+    private Flavor testOSFlavor;
+
+    private Flavor dummyFlavor;
+
+    @Before
+    public void setUp() {
+        producer = new FlavorsProducer(endpoint, client);
+
+        when(flavorService.create(Matchers.any(org.openstack4j.model.compute.Flavor.class))).thenReturn(testOSFlavor);
+        when(flavorService.get(Matchers.anyString())).thenReturn(testOSFlavor);
+
+        List<org.openstack4j.model.compute.Flavor> getAllList = new ArrayList<>();
+        getAllList.add(testOSFlavor);
+        getAllList.add(testOSFlavor);
+        doReturn(getAllList).when(flavorService).list();
+
+        dummyFlavor = createTestFlavor();
+
+        when(testOSFlavor.getId()).thenReturn(UUID.randomUUID().toString());
+        when(testOSFlavor.getName()).thenReturn(dummyFlavor.getName());
+        when(testOSFlavor.getRam()).thenReturn(dummyFlavor.getRam());
+        when(testOSFlavor.getVcpus()).thenReturn(dummyFlavor.getVcpus());
+        when(testOSFlavor.getDisk()).thenReturn(dummyFlavor.getDisk());
+        when(testOSFlavor.getSwap()).thenReturn(dummyFlavor.getSwap());
+    }
+
+    @Test
+    public void createFlavor() throws Exception {
+        when(endpoint.getOperation()).thenReturn(NovaConstants.CREATE);
+        final String expectedFlavorID = UUID.randomUUID().toString();
+        when(testOSFlavor.getId()).thenReturn(expectedFlavorID);
+
+        //send dummyFlavor to create
+        msg.setBody(dummyFlavor);
+        producer.process(exchange);
+
+        ArgumentCaptor<Flavor> flavorCaptor = ArgumentCaptor.forClass(Flavor.class);
+        verify(flavorService).create(flavorCaptor.capture());
+        assertEquals(dummyFlavor, flavorCaptor.getValue());
+
+        final Flavor createdFlavor = msg.getBody(Flavor.class);
+        assertEqualsFlavors(dummyFlavor, createdFlavor);
+        assertNotNull(createdFlavor.getId());
+    }
+
+    @Test
+    public void createFlavorWithHeaders() throws Exception {
+        Map<String, Object> headers = new HashMap<>();
+        headers.put(NovaConstants.OPERATION, NovaConstants.CREATE);
+        headers.put(NovaConstants.NAME, dummyFlavor.getName());
+        headers.put(NovaConstants.VCPU, dummyFlavor.getVcpus());
+        headers.put(NovaConstants.DISK, dummyFlavor.getDisk());
+        headers.put(NovaConstants.SWAP, dummyFlavor.getSwap());
+        headers.put(NovaConstants.RAM, dummyFlavor.getRam());
+        msg.setHeaders(headers);
+        producer.process(exchange);
+
+        ArgumentCaptor<Flavor> flavorCaptor = ArgumentCaptor.forClass(Flavor.class);
+        verify(flavorService).create(flavorCaptor.capture());
+        assertEqualsFlavors(dummyFlavor, flavorCaptor.getValue());
+
+        final Flavor created = msg.getBody(Flavor.class);
+        assertNotNull(created.getId());
+        assertEqualsFlavors(dummyFlavor, created);
+    }
+
+    @Test
+    public void getTest() throws Exception {
+        msg.setHeader(NovaConstants.OPERATION, NovaConstants.GET);
+        msg.setHeader(NovaConstants.ID, "anything - client is mocked");
+
+        //should return dummyFlavor
+        producer.process(exchange);
+
+        final Flavor result = msg.getBody(Flavor.class);
+        assertEqualsFlavors(dummyFlavor, result);
+        assertNotNull(result.getId());
+    }
+
+    @Test
+    public void getAllTest() throws Exception {
+        when(endpoint.getOperation()).thenReturn(NovaConstants.GET_ALL);
+
+        producer.process(exchange);
+        List<Flavor> result = msg.getBody(List.class);
+
+        assertTrue(result.size() == 2);
+        for (Flavor f : result) {
+            assertEqualsFlavors(dummyFlavor, f);
+            assertNotNull(f.getId());
+        }
+    }
+
+    @Test
+    public void deleteSuccess() throws Exception {
+        when(flavorService.delete(Matchers.anyString())).thenReturn(ActionResponse.actionSuccess());
+        when(endpoint.getOperation()).thenReturn(NovaConstants.DELETE);
+        String id = "myID";
+        msg.setHeader(NovaConstants.ID, id);
+        producer.process(exchange);
+
+        ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);
+        verify(flavorService).delete(argumentCaptor.capture());
+        assertEquals(id, argumentCaptor.getValue());
+
+        assertFalse(msg.isFault());
+        assertNull(msg.getBody());
+    }
+
+    @Test
+    public void deleteFailure() throws Exception {
+        final String failReason = "unknown";
+        when(flavorService.delete(Matchers.anyString())).thenReturn(ActionResponse.actionFailed(failReason, 401));
+        when(endpoint.getOperation()).thenReturn(NovaConstants.DELETE);
+        String id = "myID";
+        msg.setHeader(NovaConstants.ID, id);
+        producer.process(exchange);
+
+        ArgumentCaptor<String> argumentCaptor = ArgumentCaptor.forClass(String.class);
+        verify(flavorService).delete(argumentCaptor.capture());
+        assertEquals(id, argumentCaptor.getValue());
+
+        assertTrue(msg.isFault());
+        assertTrue(msg.getBody(String.class).contains(failReason));
+    }
+
+    private Flavor createTestFlavor() {
+        FlavorBuilder builder = Builders.flavor()
+                .name("dummy flavor")
+                .ram(3)
+                .vcpus(2)
+                .disk(5)
+                .swap(2);
+        return builder.build();
+    }
+
+    private void assertEqualsFlavors(Flavor old, Flavor createdFlavor) {
+        assertEquals(old.getName(), createdFlavor.getName());
+        assertEquals(old.getRam(), createdFlavor.getRam());
+        assertEquals(old.getVcpus(), createdFlavor.getVcpus());
+        assertEquals(old.getDisk(), createdFlavor.getDisk());
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/7d2907d2/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/KeypairProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/KeypairProducerTest.java b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/KeypairProducerTest.java
index 1c05caa..af08477 100644
--- a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/KeypairProducerTest.java
+++ b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/KeypairProducerTest.java
@@ -16,106 +16,103 @@
  */
 package org.apache.camel.component.openstack.nova;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-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.List;
 
 import org.apache.camel.component.openstack.nova.producer.KeypairProducer;
-
 import org.junit.Before;
 import org.junit.Test;
-
 import org.mockito.ArgumentCaptor;
 import org.mockito.Matchers;
 import org.mockito.Mock;
 import org.openstack4j.model.compute.Keypair;
 import org.openstack4j.openstack.compute.domain.NovaKeypair;
 
-import java.util.ArrayList;
-import java.util.List;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 public class KeypairProducerTest extends NovaProducerTestSupport {
-	private static final String KEYPAIR_NAME = "keypairName";
-
-	@Mock
-	private Keypair osTestKeypair;
-
-	private Keypair dummyKeypair;
-
-	@Before
-	public void setUp() {
-		producer = new KeypairProducer(endpoint, client);
-		dummyKeypair = createDummyKeypair();
-
-		when(keypairService.get(Matchers.anyString())).thenReturn(osTestKeypair);
-		when(keypairService.create(Matchers.anyString(), Matchers.anyString())).thenReturn(osTestKeypair);
-
-		List<org.openstack4j.model.compute.Keypair> getAllList = new ArrayList<>();
-		getAllList.add(osTestKeypair);
-		getAllList.add(osTestKeypair);
-		doReturn(getAllList).when(keypairService).list();
-
-		when(osTestKeypair.getName()).thenReturn(dummyKeypair.getName());
-		when(osTestKeypair.getPublicKey()).thenReturn(dummyKeypair.getPublicKey());
-	}
-
-	@Test
-	public void createKeypair() throws Exception {
-		final String fingerPrint = "fp";
-		final String privatecKey = "prk";
-		when(osTestKeypair.getName()).thenReturn(KEYPAIR_NAME);
-		when(osTestKeypair.getPublicKey()).thenReturn(dummyKeypair.getPublicKey());
-		when(osTestKeypair.getFingerprint()).thenReturn(fingerPrint);
-		when(osTestKeypair.getPrivateKey()).thenReturn(privatecKey);
-
-		msg.setHeader(NovaConstants.OPERATION, NovaConstants.CREATE);
-		msg.setHeader(NovaConstants.NAME, KEYPAIR_NAME);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<String> nameCaptor = ArgumentCaptor.forClass(String.class);
-		ArgumentCaptor<String> keypairCaptor = ArgumentCaptor.forClass(String.class);
-		verify(keypairService).create(nameCaptor.capture(), keypairCaptor.capture());
-
-		assertEquals(KEYPAIR_NAME, nameCaptor.getValue());
-		assertNull(keypairCaptor.getValue());
-
-		Keypair result = msg.getBody(Keypair.class);
-		assertEquals(fingerPrint, result.getFingerprint());
-		assertEquals(privatecKey, result.getPrivateKey());
-		assertEquals(dummyKeypair.getName(), result.getName());
-		assertEquals(dummyKeypair.getPublicKey(), result.getPublicKey());
-
-	}
-
-	@Test
-	public void createKeypairFromExisting() throws Exception {
-		msg.setHeader(NovaConstants.OPERATION, NovaConstants.CREATE);
-		msg.setHeader(NovaConstants.NAME, KEYPAIR_NAME);
-		String key = "existing public key string";
-		when(osTestKeypair.getPublicKey()).thenReturn(key);
-		msg.setBody(key);
-
-		producer.process(exchange);
-
-		ArgumentCaptor<String> nameCaptor = ArgumentCaptor.forClass(String.class);
-		ArgumentCaptor<String> keypairCaptor = ArgumentCaptor.forClass(String.class);
-		verify(keypairService).create(nameCaptor.capture(), keypairCaptor.capture());
-
-		assertEquals(KEYPAIR_NAME, nameCaptor.getValue());
-		assertEquals(key, keypairCaptor.getValue());
-
-		Keypair result = msg.getBody(Keypair.class);
-		assertEquals(dummyKeypair.getName(), result.getName());
-		assertEquals(dummyKeypair.getFingerprint(), result.getFingerprint());
-		assertEquals(dummyKeypair.getPrivateKey(), result.getPrivateKey());
-		assertEquals(key, result.getPublicKey());
-	}
-
-	private Keypair createDummyKeypair(){
-		return new NovaKeypair().create(KEYPAIR_NAME, "string contains private key");
-	}
+    private static final String KEYPAIR_NAME = "keypairName";
+
+    @Mock
+    private Keypair osTestKeypair;
+
+    private Keypair dummyKeypair;
+
+    @Before
+    public void setUp() {
+        producer = new KeypairProducer(endpoint, client);
+        dummyKeypair = createDummyKeypair();
+
+        when(keypairService.get(Matchers.anyString())).thenReturn(osTestKeypair);
+        when(keypairService.create(Matchers.anyString(), Matchers.anyString())).thenReturn(osTestKeypair);
+
+        List<org.openstack4j.model.compute.Keypair> getAllList = new ArrayList<>();
+        getAllList.add(osTestKeypair);
+        getAllList.add(osTestKeypair);
+        doReturn(getAllList).when(keypairService).list();
+
+        when(osTestKeypair.getName()).thenReturn(dummyKeypair.getName());
+        when(osTestKeypair.getPublicKey()).thenReturn(dummyKeypair.getPublicKey());
+    }
+
+    @Test
+    public void createKeypair() throws Exception {
+        final String fingerPrint = "fp";
+        final String privatecKey = "prk";
+        when(osTestKeypair.getName()).thenReturn(KEYPAIR_NAME);
+        when(osTestKeypair.getPublicKey()).thenReturn(dummyKeypair.getPublicKey());
+        when(osTestKeypair.getFingerprint()).thenReturn(fingerPrint);
+        when(osTestKeypair.getPrivateKey()).thenReturn(privatecKey);
+
+        msg.setHeader(NovaConstants.OPERATION, NovaConstants.CREATE);
+        msg.setHeader(NovaConstants.NAME, KEYPAIR_NAME);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<String> nameCaptor = ArgumentCaptor.forClass(String.class);
+        ArgumentCaptor<String> keypairCaptor = ArgumentCaptor.forClass(String.class);
+        verify(keypairService).create(nameCaptor.capture(), keypairCaptor.capture());
+
+        assertEquals(KEYPAIR_NAME, nameCaptor.getValue());
+        assertNull(keypairCaptor.getValue());
+
+        Keypair result = msg.getBody(Keypair.class);
+        assertEquals(fingerPrint, result.getFingerprint());
+        assertEquals(privatecKey, result.getPrivateKey());
+        assertEquals(dummyKeypair.getName(), result.getName());
+        assertEquals(dummyKeypair.getPublicKey(), result.getPublicKey());
+
+    }
+
+    @Test
+    public void createKeypairFromExisting() throws Exception {
+        msg.setHeader(NovaConstants.OPERATION, NovaConstants.CREATE);
+        msg.setHeader(NovaConstants.NAME, KEYPAIR_NAME);
+        String key = "existing public key string";
+        when(osTestKeypair.getPublicKey()).thenReturn(key);
+        msg.setBody(key);
+
+        producer.process(exchange);
+
+        ArgumentCaptor<String> nameCaptor = ArgumentCaptor.forClass(String.class);
+        ArgumentCaptor<String> keypairCaptor = ArgumentCaptor.forClass(String.class);
+        verify(keypairService).create(nameCaptor.capture(), keypairCaptor.capture());
+
+        assertEquals(KEYPAIR_NAME, nameCaptor.getValue());
+        assertEquals(key, keypairCaptor.getValue());
+
+        Keypair result = msg.getBody(Keypair.class);
+        assertEquals(dummyKeypair.getName(), result.getName());
+        assertEquals(dummyKeypair.getFingerprint(), result.getFingerprint());
+        assertEquals(dummyKeypair.getPrivateKey(), result.getPrivateKey());
+        assertEquals(key, result.getPublicKey());
+    }
+
+    private Keypair createDummyKeypair() {
+        return new NovaKeypair().create(KEYPAIR_NAME, "string contains private key");
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/7d2907d2/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/NovaProducerTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/NovaProducerTestSupport.java b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/NovaProducerTestSupport.java
index c2cb7cd..28e750c 100644
--- a/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/NovaProducerTestSupport.java
+++ b/components/camel-openstack/src/test/java/org/apache/camel/component/openstack/nova/NovaProducerTestSupport.java
@@ -16,40 +16,38 @@
  */
 package org.apache.camel.component.openstack.nova;
 
-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.compute.ComputeService;
 import org.openstack4j.api.compute.FlavorService;
 import org.openstack4j.api.compute.KeypairService;
 import org.openstack4j.api.compute.ServerService;
 
+import static org.mockito.Mockito.when;
+
 public class NovaProducerTestSupport extends AbstractProducerTestSupport {
 
-	@Mock
-	protected NovaEndpoint endpoint;
+    @Mock
+    protected NovaEndpoint endpoint;
 
-	@Mock
-	protected ComputeService computeService;
+    @Mock
+    protected ComputeService computeService;
 
-	@Mock
-	FlavorService flavorService;
+    @Mock
+    FlavorService flavorService;
 
-	@Mock
-	ServerService serverService;
+    @Mock
+    ServerService serverService;
 
-	@Mock
-	KeypairService keypairService;
+    @Mock
+    KeypairService keypairService;
 
-	@Before
-	public void setUpComputeService(){
-		when(client.compute()).thenReturn(computeService);
-		when(computeService.flavors()).thenReturn(flavorService);
-		when(computeService.servers()).thenReturn(serverService);
-		when(computeService.keypairs()).thenReturn(keypairService);
-	}
+    @Before
+    public void setUpComputeService() {
+        when(client.compute()).thenReturn(computeService);
+        when(computeService.flavors()).thenReturn(flavorService);
+        when(computeService.servers()).thenReturn(serverService);
+        when(computeService.keypairs()).thenReturn(keypairService);
+    }
 }


Mime
View raw message