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.junit.Assert.assertNotNull;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
16 import org.opendaylight.yangtools.yang.parser.builder.api.TypeDefinitionBuilder;
17 import org.opendaylight.yangtools.yang.parser.builder.impl.CopyUtils;
18 import org.opendaylight.yangtools.yang.parser.builder.impl.IdentityrefTypeBuilder;
19 import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleBuilder;
22 * NPE is rised during use of CopyUtils.copy operation for IdentityrefTypeBuilder.
23 * NPE occours in private getData method in CopyUtils.java during QName.create.
25 * The reason for exception is the old.getQName returns null since IdentityrefTypeBuilder.getQName()
26 * by implementation returns always null.
29 public class Bug2219Test {
31 private ModuleBuilder moduleBuilder;
35 moduleBuilder = new ModuleBuilder("test-module", "somePath");
39 public void testCopyIdentityrefTypeBuilder() {
40 final String typedefLocalName = "identity-ref-test-type";
41 final QName typedefQname = QName.create(moduleBuilder.getNamespace(), moduleBuilder.getRevision(), typedefLocalName);
42 final SchemaPath typedefPath = SchemaPath.create(true, typedefQname);
43 final IdentityrefTypeBuilder typeBuilder = new IdentityrefTypeBuilder(moduleBuilder.getModuleName(), 12,
44 "base:parent-identity", typedefPath);
46 final TypeDefinitionBuilder copy = CopyUtils.copy(typeBuilder, moduleBuilder, true);