d364a70f1c552f7be7fd596d78762528fa40faa1
[yangtools.git] / integration-test / yang-runtime-tests / src / test / java / org / opendaylight / yangtools / it / yang / runtime / tests / Bug466EmptyAugmentationCodecs.java
1 package org.opendaylight.yangtools.it.yang.runtime.tests;
2
3 import static org.junit.Assert.assertNotNull;
4 import static org.junit.Assert.assertTrue;
5 import javassist.ClassPool;
6
7 import org.junit.Before;
8 import org.junit.Test;
9 import org.opendaylight.yang.gen.v1.urn.opendaylight.yang.test.regression.bug466.augmentation.empty.rev140226.Bug4661;
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.yang.test.regression.bug466.base.rev140226.Bug466;
11 import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
12 import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
13 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
14 import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
15 import org.opendaylight.yangtools.yang.data.impl.codec.DataContainerCodec;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
17
18 import com.google.common.base.Optional;
19
20 public class Bug466EmptyAugmentationCodecs {
21
22
23
24     private YangModuleInfo baseModuleInfo;
25     private YangModuleInfo augmentationModuleInfo;
26     private ModuleInfoBackedContext moduleInfoContext;
27     private RuntimeGeneratedMappingServiceImpl mappingService;
28     private Optional<SchemaContext> schemaContext;
29
30
31     @Before
32     public void setup()throws Exception {
33         baseModuleInfo = BindingReflections.getModuleInfo(Bug466.class);
34         augmentationModuleInfo = BindingReflections.getModuleInfo(Bug4661.class);
35
36         moduleInfoContext = ModuleInfoBackedContext.create();
37         moduleInfoContext.registerModuleInfo(baseModuleInfo);
38         moduleInfoContext.registerModuleInfo(augmentationModuleInfo);
39         schemaContext = moduleInfoContext.tryToCreateSchemaContext();
40         assertNotNull(schemaContext);
41         assertTrue(schemaContext.isPresent());
42
43         mappingService = new RuntimeGeneratedMappingServiceImpl(moduleInfoContext);
44         mappingService.setPool(ClassPool.getDefault());
45         mappingService.init();
46         mappingService.onGlobalContextUpdated(schemaContext.get());
47
48     }
49
50
51     @Test
52     public void proactiveGenerationOfAugmentationCodecs() {
53         DataContainerCodec<Bug466> codec = mappingService.getCodecRegistry().getCodecForDataObject(Bug466.class);
54         assertNotNull(codec);
55     }
56
57 }