2 * Copyright (c) 2016 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;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil.getRevisionFormat;
14 import java.text.ParseException;
15 import java.util.Date;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.opendaylight.yangtools.yang.model.api.Module;
20 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
21 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
23 public class Bug6491Test {
27 public void setup() throws ParseException {
28 date = getRevisionFormat().parse("2016-01-01");
32 public void tetststs() throws Exception {
33 testRevision("withoutRevision", null, null);
34 testRevision("withRevision", date, date);
35 testRevision("importedModuleRevisionOnly", null, date);
36 testRevision("moduleRevisionOnly", date, null);
39 private static void testRevision(final String path, final Date moduleRevision, final Date importedRevision)
41 final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6491/".concat(path));
42 assertNotNull(context);
43 final Module module = context.findModule("bar", moduleRevision).get();
44 final Set<ModuleImport> imports = module.getImports();
45 assertNotNull(imports);
46 assertEquals(1, imports.size());
47 assertEquals(importedRevision, imports.iterator().next().getRevision());