ShardUndeployOperation extends AbstractShardOperation { @Override protected void execute(NodeContext context, String shardName, DeployResult deployResult) throws Exception { context.getProtocol().unpublishShard(context.getNode(), shardName); context.getContentServer().removeShard(shardName); context.getShardManager().uninstallShard(shardName); } ShardUndeployOperation(List<String> shards);   }
@Test public void testUneploy() throws Exception { List<String> shards = Arrays.asList("shard1", "shard2"); ShardUndeployOperation operation = new ShardUndeployOperation(shards); DeployResult result = operation.execute(_context); InOrder inOrder = inOrder(_protocol, _shardManager, _contentServer); for (String shard : operation.getShardNames()) { inOrder.verify(_protocol).unpublishShard(_node, shard); inOrder.verify(_contentServer).removeShard(shard); inOrder.verify(_shardManager).uninstallShard(shard); } assertEquals(0, result.getShardExceptions().size()); }
@Test public void testUneployWithError() throws Exception { List<String> shards = Arrays.asList("shard1", "shard2"); ShardUndeployOperation operation = new ShardUndeployOperation(shards); String failingShard = shards.get(0); doThrow(new Exception("testException")).when(_contentServer).removeShard(failingShard); DeployResult result = operation.execute(_context); InOrder inOrder = inOrder(_protocol, _shardManager, _contentServer); for (String shard : operation.getShardNames()) { inOrder.verify(_protocol).unpublishShard(_node, shard); inOrder.verify(_contentServer).removeShard(shard); inOrder.verify(_shardManager).uninstallShard(shard); } assertEquals(1, result.getShardExceptions().size()); }