85eeb30a07339c3b379bd756328f7ed96926fbc2
[controller.git] / opendaylight / netconf / netconf-util / src / test / java / org / opendaylight / controller / netconf / util / NetconfUtilTest.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.netconf.util;
9
10 import org.junit.Test;
11 import org.opendaylight.controller.netconf.api.NetconfMessage;
12 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
13 import org.w3c.dom.Document;
14
15 import static org.junit.Assert.assertThat;
16 import static org.junit.Assert.fail;
17 import static org.junit.matchers.JUnitMatchers.containsString;
18
19 public class NetconfUtilTest {
20
21     @Test
22     public void testConflictingVersionDetection() throws Exception {
23         Document document = XmlUtil.readXmlToDocument(getClass().getResourceAsStream("/netconfMessages/conflictingversion/conflictingVersionResponse.xml"));
24         try{
25             NetconfUtil.checkIsMessageOk(new NetconfMessage(document));
26             fail();
27         }catch(IllegalStateException e){
28             assertThat(e.getMessage(), containsString("Optimistic lock failed. Expected parent version 21, was 18"));
29         }
30     }
31 }