X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fconfig-netconf-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fconfignetconfconnector%2Fosgi%2FNetconfOperationServiceImplTest.java;h=a063f5786a8f4796d95023849fbc6243e873fa01;hb=94b968f7454a2d677b1ac8fc4a81c10ecca03fa3;hp=0d459cfb865904fee47d19f0831aa62b8f795fa0;hpb=576aa6018e48dfca8f223b7ac929139a32135201;p=controller.git diff --git a/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImplTest.java b/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImplTest.java index 0d459cfb86..a063f5786a 100644 --- a/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImplTest.java +++ b/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImplTest.java @@ -14,21 +14,31 @@ import org.junit.Assert; import org.junit.Test; import org.junit.matchers.JUnitMatchers; import org.opendaylight.controller.config.api.LookupRegistry; -import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot; import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry; import org.opendaylight.yangtools.yang.common.QName; import java.net.URI; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; import java.util.Set; +import static org.junit.Assert.fail; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; public class NetconfOperationServiceImplTest { - private Date date = new Date(0); + private static final Date date1970_01_01; + + static { + try { + date1970_01_01 = new SimpleDateFormat("yyyy-MM-dd").parse("1970-01-01"); + } catch (ParseException e) { + throw new IllegalStateException(e); + } + } @Test public void testCheckConsistencyBetweenYangStoreAndConfig_ok() throws Exception { @@ -51,22 +61,22 @@ public class NetconfOperationServiceImplTest { mockYangStoreSnapshot()); } - @Test(expected = IllegalStateException.class) + @Test public void testCheckConsistencyBetweenYangStoreAndConfig_yangStoreMore() throws Exception { try { NetconfOperationServiceImpl.checkConsistencyBetweenYangStoreAndConfig(mockJmxClient("qname1"), mockYangStoreSnapshot("qname2", "qname1")); + fail("An exception of type " + IllegalStateException.class + " was expected"); } catch (IllegalStateException e) { String message = e.getMessage(); Assert.assertThat( message, JUnitMatchers - .containsString(" missing from config subsystem but present in yangstore: [(namespace?revision=1970-01-01)qname2]")); + .containsString("missing from config subsystem but present in yangstore: [(namespace?revision=1970-01-01)qname2]")); Assert.assertThat( message, JUnitMatchers .containsString("All modules present in config: [(namespace?revision=1970-01-01)qname1]")); - throw e; } } @@ -97,7 +107,7 @@ public class NetconfOperationServiceImplTest { } private QName getQName(String qname) { - return new QName(URI.create("namespace"), date, qname); + return new QName(URI.create("namespace"), date1970_01_01, qname); } private LookupRegistry mockJmxClient(String... visibleQNames) {