import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import java.net.URI;
-import java.text.ParseException;
import org.jaxen.Context;
import org.jaxen.Function;
import org.jaxen.FunctionCallException;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
private static JaxenSchemaContextFactory jaxenSchemaContextFactory;
private static QNameModule barModule;
- private static QName myContainer;
+ private static QName myContainer;
private static QName myList;
private static QName keyLeaf;
private static QName idrefLeaf;
private static QName idC2Identity;
@BeforeClass
- public static void setup() throws ParseException {
+ public static void setup() {
jaxenSchemaContextFactory = new JaxenSchemaContextFactory();
- barModule = QNameModule.create(URI.create("bar-ns"),
- SimpleDateFormatUtil.getRevisionFormat().parse("2017-04-03"));
+ barModule = QNameModule.create(URI.create("bar-ns"), Revision.valueOf("2017-04-03"));
myContainer = QName.create(barModule, "my-container");
myList = QName.create(barModule, "my-list");
keyLeaf = QName.create(barModule, "key-leaf");
@Test
public void testDerivedFromFunction() throws Exception {
// also includes test for derived-from-or-self function
- final SchemaContext schemaContext = YangParserTestUtils.parseYangSources(ImmutableList.of(
+ final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(DerivedFromXPathFunctionTest.class,
"/yang-xpath-functions-test/derived-from-function/foo.yang",
- "/yang-xpath-functions-test/derived-from-function/bar.yang"));
+ "/yang-xpath-functions-test/derived-from-function/bar.yang");
assertNotNull(schemaContext);
final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
@Test
public void testInvalidTypeOfCorrespondingSchemaNode() throws Exception {
- final SchemaContext schemaContext = YangParserTestUtils.parseYangSource(
+ final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(DerivedFromXPathFunctionTest.class,
"/yang-xpath-functions-test/derived-from-function/bar-invalid.yang");
assertNotNull(schemaContext);
@Test
public void testInvalidNormalizedNodeValueType() throws Exception {
- final SchemaContext schemaContext = YangParserTestUtils.parseYangSources(ImmutableList.of(
+ final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(DerivedFromXPathFunctionTest.class,
"/yang-xpath-functions-test/derived-from-function/foo.yang",
- "/yang-xpath-functions-test/derived-from-function/bar.yang"));
+ "/yang-xpath-functions-test/derived-from-function/bar.yang");
assertNotNull(schemaContext);
final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
@Test
public void shouldFailOnUnknownPrefixOfIdentity() throws Exception {
- final SchemaContext schemaContext = YangParserTestUtils.parseYangSources(ImmutableList.of(
+ final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(DerivedFromXPathFunctionTest.class,
"/yang-xpath-functions-test/derived-from-function/foo.yang",
- "/yang-xpath-functions-test/derived-from-function/bar.yang"));
+ "/yang-xpath-functions-test/derived-from-function/bar.yang");
assertNotNull(schemaContext);
final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
getDerivedFromResult(derivedFromFunction, normalizedNodeContext, "unknown-prefix:id-a3");
fail("Function call should have failed on unresolved prefix of the identity argument.");
} catch (IllegalArgumentException ex) {
- assertEquals("Cannot resolve prefix 'unknown-prefix' from identity 'unknown-prefix:id-a3'.", ex.getMessage());
+ assertEquals("Cannot resolve prefix 'unknown-prefix' from identity 'unknown-prefix:id-a3'.",
+ ex.getMessage());
}
}
@Test
public void shouldFailOnMalformedIdentityArgument() throws Exception {
- final SchemaContext schemaContext = YangParserTestUtils.parseYangSources(ImmutableList.of(
+ final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(DerivedFromXPathFunctionTest.class,
"/yang-xpath-functions-test/derived-from-function/foo.yang",
- "/yang-xpath-functions-test/derived-from-function/bar.yang"));
+ "/yang-xpath-functions-test/derived-from-function/bar.yang");
assertNotNull(schemaContext);
final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
@Test
public void shouldFailOnUnknownIdentityArgument() throws Exception {
- final SchemaContext schemaContext = YangParserTestUtils.parseYangSources(ImmutableList.of(
+ final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(DerivedFromXPathFunctionTest.class,
"/yang-xpath-functions-test/derived-from-function/foo.yang",
- "/yang-xpath-functions-test/derived-from-function/bar.yang"));
+ "/yang-xpath-functions-test/derived-from-function/bar.yang");
assertNotNull(schemaContext);
final XPathSchemaContext jaxenSchemaContext = jaxenSchemaContextFactory.createContext(schemaContext);
fail("Function call should have failed on unknown identity argument.");
} catch (IllegalArgumentException ex) {
assertTrue(ex.getMessage().startsWith(
- "Identity (foo-ns?revision=2017-04-03)id-a333 does not have a corresponding identity schema " +
- "node in the module"));
+ "Identity (foo-ns?revision=2017-04-03)id-a333 does not have a corresponding identity schema "
+ + "node in the module"));
}
}
.node(new NodeIdentifierWithPredicates(myList, keys)).node(idrefLeaf);
return path;
}
-}
\ No newline at end of file
+}