2 * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.sal.connect.netconf.listener;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertNotNull;
13 import static org.junit.Assert.assertTrue;
14 import static org.mockito.ArgumentMatchers.any;
15 import static org.mockito.ArgumentMatchers.eq;
16 import static org.mockito.ArgumentMatchers.same;
17 import static org.mockito.Mockito.doNothing;
18 import static org.mockito.Mockito.doReturn;
19 import static org.mockito.Mockito.mock;
20 import static org.mockito.Mockito.never;
21 import static org.mockito.Mockito.reset;
22 import static org.mockito.Mockito.spy;
23 import static org.mockito.Mockito.timeout;
24 import static org.mockito.Mockito.verify;
25 import static org.opendaylight.netconf.api.xml.XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0;
27 import com.google.common.base.CharMatcher;
28 import com.google.common.base.Strings;
29 import com.google.common.collect.Sets;
30 import com.google.common.util.concurrent.ListenableFuture;
31 import io.netty.channel.ChannelFuture;
32 import io.netty.channel.EventLoopGroup;
33 import io.netty.channel.nio.NioEventLoopGroup;
34 import io.netty.util.HashedWheelTimer;
35 import io.netty.util.Timer;
36 import io.netty.util.concurrent.Future;
37 import io.netty.util.concurrent.GenericFutureListener;
38 import io.netty.util.concurrent.GlobalEventExecutor;
39 import java.io.ByteArrayInputStream;
40 import java.net.InetSocketAddress;
41 import java.util.ArrayList;
42 import java.util.Collection;
43 import java.util.Collections;
44 import java.util.UUID;
45 import java.util.concurrent.TimeUnit;
46 import java.util.concurrent.TimeoutException;
47 import javax.xml.parsers.ParserConfigurationException;
48 import org.junit.Before;
49 import org.junit.Test;
50 import org.junit.runner.RunWith;
51 import org.mockito.ArgumentCaptor;
52 import org.mockito.Mock;
53 import org.mockito.junit.MockitoJUnitRunner;
54 import org.opendaylight.netconf.api.NetconfMessage;
55 import org.opendaylight.netconf.api.NetconfTerminationReason;
56 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
57 import org.opendaylight.netconf.client.NetconfClientDispatcherImpl;
58 import org.opendaylight.netconf.client.NetconfClientSession;
59 import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
60 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration;
61 import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfigurationBuilder;
62 import org.opendaylight.netconf.nettyutil.ReconnectStrategy;
63 import org.opendaylight.netconf.nettyutil.TimedReconnectStrategy;
64 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.LoginPasswordHandler;
65 import org.opendaylight.netconf.sal.connect.api.RemoteDevice;
66 import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil;
67 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
68 import org.opendaylight.yangtools.util.xml.UntrustedXML;
69 import org.opendaylight.yangtools.yang.common.ErrorSeverity;
70 import org.opendaylight.yangtools.yang.common.ErrorTag;
71 import org.opendaylight.yangtools.yang.common.ErrorType;
72 import org.opendaylight.yangtools.yang.common.QName;
73 import org.opendaylight.yangtools.yang.common.RpcError;
74 import org.opendaylight.yangtools.yang.common.RpcResult;
75 import org.slf4j.Logger;
76 import org.slf4j.LoggerFactory;
77 import org.w3c.dom.Document;
78 import org.w3c.dom.Element;
80 @RunWith(MockitoJUnitRunner.StrictStubs.class)
81 public class NetconfDeviceCommunicatorTest {
83 private static final Logger LOG = LoggerFactory.getLogger(NetconfDeviceCommunicatorTest.class);
86 NetconfClientSession mockSession;
89 RemoteDevice<NetconfSessionPreferences, NetconfDeviceCommunicator> mockDevice;
91 NetconfDeviceCommunicator communicator;
94 public void setUp() throws Exception {
95 communicator = new NetconfDeviceCommunicator(
96 new RemoteDeviceId("test", InetSocketAddress.createUnresolved("localhost", 22)), mockDevice, 10);
100 doReturn(Collections.<String>emptySet()).when(mockSession).getServerCapabilities();
101 doNothing().when(mockDevice).onRemoteSessionUp(any(NetconfSessionPreferences.class),
102 any(NetconfDeviceCommunicator.class));
103 communicator.onSessionUp(mockSession);
106 private ListenableFuture<RpcResult<NetconfMessage>> sendRequest() throws Exception {
107 return sendRequest(UUID.randomUUID().toString(), true);
110 @SuppressWarnings("unchecked")
111 private ListenableFuture<RpcResult<NetconfMessage>> sendRequest(final String messageID,
112 final boolean doLastTest) throws Exception {
113 Document doc = UntrustedXML.newDocumentBuilder().newDocument();
114 Element element = doc.createElement("request");
115 element.setAttribute("message-id", messageID);
116 doc.appendChild(element);
117 NetconfMessage message = new NetconfMessage(doc);
119 ChannelFuture mockChannelFuture = mock(ChannelFuture.class);
120 doReturn(mockChannelFuture).when(mockChannelFuture)
121 .addListener(any(GenericFutureListener.class));
122 doReturn(mockChannelFuture).when(mockSession).sendMessage(same(message));
124 ListenableFuture<RpcResult<NetconfMessage>> resultFuture =
125 communicator.sendRequest(message, QName.create("", "mockRpc"));
127 assertNotNull("ListenableFuture is null", resultFuture);
133 public void testOnSessionUp() {
134 String testCapability = "urn:opendaylight:params:xml:ns:test?module=test-module&revision=2014-06-02";
135 Collection<String> serverCapabilities =
136 Sets.newHashSet(NetconfMessageTransformUtil.NETCONF_ROLLBACK_ON_ERROR_URI.toString(),
137 NetconfMessageTransformUtil.IETF_NETCONF_MONITORING.getNamespace().toString(),
139 doReturn(serverCapabilities).when(mockSession).getServerCapabilities();
141 ArgumentCaptor<NetconfSessionPreferences> netconfSessionPreferences =
142 ArgumentCaptor.forClass(NetconfSessionPreferences.class);
143 doNothing().when(mockDevice).onRemoteSessionUp(netconfSessionPreferences.capture(), eq(communicator));
145 communicator.onSessionUp(mockSession);
147 verify(mockSession).getServerCapabilities();
148 verify(mockDevice).onRemoteSessionUp(netconfSessionPreferences.capture(), eq(communicator));
150 NetconfSessionPreferences actualCapabilites = netconfSessionPreferences.getValue();
151 assertEquals("containsModuleCapability", true, actualCapabilites.containsNonModuleCapability(
152 NetconfMessageTransformUtil.NETCONF_ROLLBACK_ON_ERROR_URI.toString()));
153 assertEquals("containsModuleCapability", false, actualCapabilites.containsNonModuleCapability(testCapability));
154 assertEquals("getModuleBasedCaps", Sets.newHashSet(
155 QName.create("urn:opendaylight:params:xml:ns:test", "2014-06-02", "test-module")),
156 actualCapabilites.getModuleBasedCaps());
157 assertEquals("isRollbackSupported", true, actualCapabilites.isRollbackSupported());
158 assertEquals("isMonitoringSupported", true, actualCapabilites.isMonitoringSupported());
161 @SuppressWarnings("unchecked")
162 @Test(timeout = 5000)
163 public void testOnSessionDown() throws Exception {
166 ListenableFuture<RpcResult<NetconfMessage>> resultFuture1 = sendRequest();
167 final ListenableFuture<RpcResult<NetconfMessage>> resultFuture2 = sendRequest();
169 doNothing().when(mockDevice).onRemoteSessionDown();
171 communicator.onSessionDown(mockSession, new Exception("mock ex"));
173 verifyErrorRpcResult(resultFuture1.get(), ErrorType.TRANSPORT, ErrorTag.OPERATION_FAILED);
174 verifyErrorRpcResult(resultFuture2.get(), ErrorType.TRANSPORT, ErrorTag.OPERATION_FAILED);
176 verify(mockDevice).onRemoteSessionDown();
180 communicator.onSessionDown(mockSession, new Exception("mock ex"));
182 verify(mockDevice, never()).onRemoteSessionDown();
186 public void testOnSessionTerminated() throws Exception {
189 ListenableFuture<RpcResult<NetconfMessage>> resultFuture = sendRequest();
191 doNothing().when(mockDevice).onRemoteSessionDown();
193 String reasonText = "testing terminate";
194 NetconfTerminationReason reason = new NetconfTerminationReason(reasonText);
195 communicator.onSessionTerminated(mockSession, reason);
197 RpcError rpcError = verifyErrorRpcResult(resultFuture.get(), ErrorType.TRANSPORT, ErrorTag.OPERATION_FAILED);
198 assertEquals("RpcError message", reasonText, rpcError.getMessage());
200 verify(mockDevice).onRemoteSessionDown();
204 public void testClose() throws Exception {
205 communicator.close();
206 verify(mockDevice, never()).onRemoteSessionDown();
209 @SuppressWarnings({"rawtypes", "unchecked"})
211 public void testSendRequest() throws Exception {
214 NetconfMessage message = new NetconfMessage(UntrustedXML.newDocumentBuilder().newDocument());
215 QName rpc = QName.create("", "mockRpc");
217 ArgumentCaptor<GenericFutureListener> futureListener =
218 ArgumentCaptor.forClass(GenericFutureListener.class);
220 ChannelFuture mockChannelFuture = mock(ChannelFuture.class);
221 doReturn(mockChannelFuture).when(mockChannelFuture).addListener(futureListener.capture());
222 doReturn(mockChannelFuture).when(mockSession).sendMessage(same(message));
224 ListenableFuture<RpcResult<NetconfMessage>> resultFuture = communicator.sendRequest(message, rpc);
226 verify(mockSession).sendMessage(same(message));
228 assertNotNull("ListenableFuture is null", resultFuture);
230 verify(mockChannelFuture).addListener(futureListener.capture());
231 Future<Void> operationFuture = mock(Future.class);
232 doReturn(true).when(operationFuture).isSuccess();
233 futureListener.getValue().operationComplete(operationFuture);
236 resultFuture.get(1, TimeUnit.MILLISECONDS); // verify it's not cancelled or has an error set
237 } catch (TimeoutException e) {
238 LOG.info("Operation failed due timeout.");
243 public void testSendRequestWithNoSession() throws Exception {
244 NetconfMessage message = new NetconfMessage(UntrustedXML.newDocumentBuilder().newDocument());
245 QName rpc = QName.create("", "mockRpc");
247 ListenableFuture<RpcResult<NetconfMessage>> resultFuture = communicator.sendRequest(message, rpc);
249 assertNotNull("ListenableFuture is null", resultFuture);
251 // Should have an immediate result
252 RpcResult<NetconfMessage> rpcResult = resultFuture.get(3, TimeUnit.MILLISECONDS);
254 verifyErrorRpcResult(rpcResult, ErrorType.TRANSPORT, ErrorTag.OPERATION_FAILED);
257 private static NetconfMessage createSuccessResponseMessage(final String messageID)
258 throws ParserConfigurationException {
259 Document doc = UntrustedXML.newDocumentBuilder().newDocument();
261 doc.createElementNS(URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, XmlNetconfConstants.RPC_REPLY_KEY);
262 rpcReply.setAttribute("message-id", messageID);
263 Element element = doc.createElementNS("ns", "data");
264 element.setTextContent(messageID);
265 rpcReply.appendChild(element);
266 doc.appendChild(rpcReply);
268 return new NetconfMessage(doc);
271 @SuppressWarnings({ "rawtypes", "unchecked" })
273 public void testSendRequestWithWithSendFailure() throws Exception {
276 NetconfMessage message = new NetconfMessage(UntrustedXML.newDocumentBuilder().newDocument());
277 QName rpc = QName.create("", "mockRpc");
279 ArgumentCaptor<GenericFutureListener> futureListener =
280 ArgumentCaptor.forClass(GenericFutureListener.class);
282 ChannelFuture mockChannelFuture = mock(ChannelFuture.class);
283 doReturn(mockChannelFuture).when(mockChannelFuture).addListener(futureListener.capture());
284 doReturn(mockChannelFuture).when(mockSession).sendMessage(same(message));
286 ListenableFuture<RpcResult<NetconfMessage>> resultFuture = communicator.sendRequest(message, rpc);
288 assertNotNull("ListenableFuture is null", resultFuture);
290 verify(mockChannelFuture).addListener(futureListener.capture());
292 Future<Void> operationFuture = mock(Future.class);
293 doReturn(false).when(operationFuture).isSuccess();
294 doReturn(new Exception("mock error")).when(operationFuture).cause();
295 futureListener.getValue().operationComplete(operationFuture);
297 // Should have an immediate result
298 RpcResult<NetconfMessage> rpcResult = resultFuture.get(3, TimeUnit.MILLISECONDS);
300 RpcError rpcError = verifyErrorRpcResult(rpcResult, ErrorType.TRANSPORT, ErrorTag.OPERATION_FAILED);
301 assertEquals("RpcError message contains \"mock error\"", true,
302 rpcError.getMessage().contains("mock error"));
305 //Test scenario verifying whether missing message is handled
307 public void testOnMissingResponseMessage() throws Exception {
311 String messageID1 = UUID.randomUUID().toString();
312 ListenableFuture<RpcResult<NetconfMessage>> resultFuture1 = sendRequest(messageID1, true);
314 String messageID2 = UUID.randomUUID().toString();
315 ListenableFuture<RpcResult<NetconfMessage>> resultFuture2 = sendRequest(messageID2, true);
317 String messageID3 = UUID.randomUUID().toString();
318 ListenableFuture<RpcResult<NetconfMessage>> resultFuture3 = sendRequest(messageID3, true);
320 //response messages 1,2 are omitted
321 communicator.onMessage(mockSession, createSuccessResponseMessage(messageID3));
323 verifyResponseMessage(resultFuture3.get(), messageID3);
327 public void testOnSuccessfulResponseMessage() throws Exception {
330 String messageID1 = UUID.randomUUID().toString();
331 ListenableFuture<RpcResult<NetconfMessage>> resultFuture1 = sendRequest(messageID1, true);
333 String messageID2 = UUID.randomUUID().toString();
334 final ListenableFuture<RpcResult<NetconfMessage>> resultFuture2 = sendRequest(messageID2, true);
336 communicator.onMessage(mockSession, createSuccessResponseMessage(messageID1));
337 communicator.onMessage(mockSession, createSuccessResponseMessage(messageID2));
339 verifyResponseMessage(resultFuture1.get(), messageID1);
340 verifyResponseMessage(resultFuture2.get(), messageID2);
344 public void testOnResponseMessageWithError() throws Exception {
347 String messageID = UUID.randomUUID().toString();
348 ListenableFuture<RpcResult<NetconfMessage>> resultFuture = sendRequest(messageID, true);
350 communicator.onMessage(mockSession, createErrorResponseMessage(messageID));
352 RpcError rpcError = verifyErrorRpcResult(resultFuture.get(), ErrorType.RPC, ErrorTag.MISSING_ATTRIBUTE);
353 assertEquals("RpcError message", "Missing attribute", rpcError.getMessage());
355 String errorInfo = rpcError.getInfo();
356 assertNotNull("RpcError info is null", errorInfo);
357 assertTrue("Error info contains \"foo\"", errorInfo.contains("<bad-attribute>foo</bad-attribute>"));
358 assertTrue("Error info contains \"bar\"", errorInfo.contains("<bad-element>bar</bad-element>"));
362 public void testOnResponseMessageWithMultipleErrors() throws Exception {
365 String messageID = UUID.randomUUID().toString();
366 ListenableFuture<RpcResult<NetconfMessage>> resultFuture = sendRequest(messageID, true);
368 communicator.onMessage(mockSession, createMultiErrorResponseMessage(messageID));
370 RpcError rpcError = verifyErrorRpcResult(resultFuture.get(), ErrorType.PROTOCOL, ErrorTag.OPERATION_FAILED);
372 String errorInfo = rpcError.getInfo();
373 assertNotNull("RpcError info is null", errorInfo);
375 String errorInfoMessages = rpcError.getInfo();
376 String errMsg1 = "Number of member links configured, i.e [1], "
377 + "for interface [ae0]is lesser than the required minimum [2].";
378 String errMsg2 = "configuration check-out failed";
379 assertTrue(String.format("Error info contains \"%s\" or \"%s\'", errMsg1, errMsg2),
380 errorInfoMessages.contains(errMsg1) && errorInfoMessages.contains(errMsg2));
384 * Test whether reconnect is scheduled properly.
387 public void testNetconfDeviceReconnectInCommunicator() {
388 final RemoteDevice<NetconfSessionPreferences, NetconfDeviceCommunicator> device = mock(RemoteDevice.class);
390 final TimedReconnectStrategy timedReconnectStrategy =
391 new TimedReconnectStrategy(GlobalEventExecutor.INSTANCE, 10000, 0, 1.0, null, 100L, null);
392 final ReconnectStrategy reconnectStrategy = spy(new ReconnectStrategy() {
395 public int getConnectTimeout() throws Exception {
396 return timedReconnectStrategy.getConnectTimeout();
401 public Future<Void> scheduleReconnect(final Throwable cause) {
402 return timedReconnectStrategy.scheduleReconnect(cause);
407 public void reconnectSuccessful() {
408 timedReconnectStrategy.reconnectSuccessful();
412 final EventLoopGroup group = new NioEventLoopGroup();
413 final Timer time = new HashedWheelTimer();
415 final NetconfDeviceCommunicator listener = new NetconfDeviceCommunicator(
416 new RemoteDeviceId("test", InetSocketAddress.createUnresolved("localhost", 22)), device, 10);
417 final NetconfReconnectingClientConfiguration cfg = NetconfReconnectingClientConfigurationBuilder.create()
418 .withAddress(new InetSocketAddress("localhost", 65000))
419 .withReconnectStrategy(reconnectStrategy)
420 .withConnectStrategyFactory(() -> reconnectStrategy)
421 .withAuthHandler(new LoginPasswordHandler("admin", "admin"))
422 .withConnectionTimeoutMillis(10000)
423 .withProtocol(NetconfClientConfiguration.NetconfClientProtocol.SSH)
424 .withSessionListener(listener)
427 listener.initializeRemoteConnection(new NetconfClientDispatcherImpl(group, group, time), cfg);
429 verify(reconnectStrategy,
430 timeout(TimeUnit.MINUTES.toMillis(4)).times(101)).scheduleReconnect(any(Throwable.class));
433 group.shutdownGracefully();
438 public void testOnResponseMessageWithWrongMessageID() throws Exception {
441 String messageID = UUID.randomUUID().toString();
442 ListenableFuture<RpcResult<NetconfMessage>> resultFuture = sendRequest(messageID, true);
444 communicator.onMessage(mockSession, createSuccessResponseMessage(UUID.randomUUID().toString()));
446 RpcError rpcError = verifyErrorRpcResult(resultFuture.get(), ErrorType.PROTOCOL, ErrorTag.BAD_ATTRIBUTE);
447 assertFalse("RpcError message non-empty", Strings.isNullOrEmpty(rpcError.getMessage()));
449 String errorInfo = rpcError.getInfo();
450 assertNotNull("RpcError info is null", errorInfo);
451 assertTrue("Error info contains \"actual-message-id\"", errorInfo.contains("actual-message-id"));
452 assertTrue("Error info contains \"expected-message-id\"", errorInfo.contains("expected-message-id"));
456 public void testConcurrentMessageLimit() throws Exception {
458 ArrayList<String> messageID = new ArrayList<>();
460 for (int i = 0; i < 10; i++) {
461 messageID.add(UUID.randomUUID().toString());
462 ListenableFuture<RpcResult<NetconfMessage>> resultFuture = sendRequest(messageID.get(i), false);
463 assertEquals("ListenableFuture is null", true, resultFuture instanceof UncancellableFuture);
466 final String notWorkingMessageID = UUID.randomUUID().toString();
467 ListenableFuture<RpcResult<NetconfMessage>> resultFuture = sendRequest(notWorkingMessageID, false);
468 assertEquals("ListenableFuture is null", false, resultFuture instanceof UncancellableFuture);
470 communicator.onMessage(mockSession, createSuccessResponseMessage(messageID.get(0)));
472 resultFuture = sendRequest(messageID.get(0), false);
473 assertNotNull("ListenableFuture is null", resultFuture);
476 private static NetconfMessage createMultiErrorResponseMessage(final String messageID) throws Exception {
477 // multiple rpc-errors which simulate actual response like in NETCONF-666
478 String xmlStr = "<nc:rpc-reply xmlns:nc=\"urn:ietf:params:xml:ns:netconf:base:1.0\" xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\" xmlns:junos=\"http://xml.juniper.net/junos/18.4R1/junos\""
479 + " message-id=\"" + messageID + "\">"
481 + "<nc:error-type>protocol</nc:error-type>\n"
482 + "<nc:error-tag>operation-failed</nc:error-tag>\n"
483 + "<nc:error-severity>error</nc:error-severity>\n"
484 + "<source-daemon>\n"
486 + "</source-daemon>\n"
487 + "<nc:error-message>\n"
488 + "Number of member links configured, i.e [1], "
489 + "for interface [ae0]is lesser than the required minimum [2].\n"
490 + "</nc:error-message>\n"
491 + "</nc:rpc-error>\n"
493 + "<nc:error-type>protocol</nc:error-type>\n"
494 + "<nc:error-tag>operation-failed</nc:error-tag>\n"
495 + "<nc:error-severity>error</nc:error-severity>\n"
496 + "<nc:error-message>\n"
497 + "configuration check-out failed\n"
498 + "</nc:error-message>\n"
499 + "</nc:rpc-error>\n"
502 ByteArrayInputStream bis = new ByteArrayInputStream(xmlStr.getBytes());
503 Document doc = UntrustedXML.newDocumentBuilder().parse(bis);
504 return new NetconfMessage(doc);
507 private static NetconfMessage createErrorResponseMessage(final String messageID) throws Exception {
508 String xmlStr = "<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\""
509 + " message-id=\"" + messageID + "\">"
511 + " <error-type>rpc</error-type>"
512 + " <error-tag>missing-attribute</error-tag>"
513 + " <error-severity>error</error-severity>"
514 + " <error-message>Missing attribute</error-message>"
516 + " <bad-attribute>foo</bad-attribute>"
517 + " <bad-element>bar</bad-element>"
522 ByteArrayInputStream bis = new ByteArrayInputStream(xmlStr.getBytes());
523 Document doc = UntrustedXML.newDocumentBuilder().parse(bis);
524 return new NetconfMessage(doc);
527 private static void verifyResponseMessage(final RpcResult<NetconfMessage> rpcResult, final String dataText) {
528 assertNotNull("RpcResult is null", rpcResult);
529 assertTrue("isSuccessful", rpcResult.isSuccessful());
530 NetconfMessage messageResult = rpcResult.getResult();
531 assertNotNull("getResult", messageResult);
532 // List<SimpleNode<?>> nodes = messageResult.getSimpleNodesByName(
533 // QName.create( URI.create( "ns" ), null, "data" ) );
534 // assertNotNull( "getSimpleNodesByName", nodes );
535 // assertEquals( "List<SimpleNode<?>> size", 1, nodes.size() );
536 // assertEquals( "SimpleNode value", dataText, nodes.iterator().next().getValue() );
539 private static RpcError verifyErrorRpcResult(final RpcResult<NetconfMessage> rpcResult,
540 final ErrorType expErrorType, final ErrorTag expErrorTag) {
541 assertNotNull("RpcResult is null", rpcResult);
542 assertFalse("isSuccessful", rpcResult.isSuccessful());
543 assertNotNull("RpcResult errors is null", rpcResult.getErrors());
544 assertEquals("Errors size", 1, rpcResult.getErrors().size());
545 RpcError rpcError = rpcResult.getErrors().iterator().next();
546 assertEquals("getErrorSeverity", ErrorSeverity.ERROR, rpcError.getSeverity());
547 assertEquals("getErrorType", expErrorType, rpcError.getErrorType());
548 assertEquals("getErrorTag", expErrorTag, rpcError.getTag());
550 final String msg = rpcError.getMessage();
551 assertNotNull("getMessage is null", msg);
552 assertFalse("getMessage is empty", msg.isEmpty());
553 assertFalse("getMessage is blank", CharMatcher.whitespace().matchesAllOf(msg));