2 * Copyright (c) 2014 Cisco 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.yangtools.yang.stmt.retest;
10 import static org.mockito.Mockito.doReturn;
12 import java.net.URISyntaxException;
13 import java.text.ParseException;
14 import java.util.Collections;
15 import java.util.Date;
17 import org.junit.Before;
18 import org.mockito.Mock;
19 import org.mockito.MockitoAnnotations;
20 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
21 import org.opendaylight.yangtools.yang.model.api.Module;
22 import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
23 //import org.opendaylight.yangtools.yang.parser.impl.SchemaContextImpl;
25 public class SchemaContextTest {
27 private Module oldModule;
30 private Module newModule;
32 private Map<ModuleIdentifier, String> sources;
39 public void setUp() throws ParseException, URISyntaxException {
40 MockitoAnnotations.initMocks(this);
42 ns = new URI("http://abc");
43 oldDate = SimpleDateFormatUtil.getRevisionFormat().parse("2014-07-20");
44 newDate = SimpleDateFormatUtil.getRevisionFormat().parse("2014-07-22");
46 doReturn("abc").when(oldModule).getName();
47 doReturn(oldDate).when(oldModule).getRevision();
48 doReturn(ns).when(oldModule).getNamespace();
49 doReturn("abc").when(newModule).getName();
50 doReturn(newDate).when(newModule).getRevision();
51 doReturn(ns).when(newModule).getNamespace();
53 sources = Collections.emptyMap();
57 // public void testModuleOrdering() {
61 // sc = SchemaContextImpl(ImmutableSet.of(newModule, oldModule), sources);
62 // m = sc.findModuleByName("abc", null);
63 // assertEquals(newDate, m.getRevision());
64 // m = sc.findModuleByNamespaceAndRevision(ns, null);
65 // assertEquals(newDate, m.getRevision());
67 // sc = new SchemaContextImpl(ImmutableSet.of(oldModule, newModule), sources);
68 // m = sc.findModuleByName("abc", null);
69 // assertEquals(newDate, m.getRevision());
70 // m = sc.findModuleByNamespaceAndRevision(ns, null);
71 // assertEquals(newDate, m.getRevision());