2 * Copyright (c) 2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package io.fd.honeycomb.vppioam.impl;
19 import static org.hamcrest.CoreMatchers.is;
20 import static org.hamcrest.CoreMatchers.not;
21 import static org.hamcrest.Matchers.empty;
22 import static org.junit.Assert.assertNotNull;
23 import static org.junit.Assert.assertThat;
24 import static org.mockito.Mockito.mock;
25 import static org.mockito.MockitoAnnotations.initMocks;
27 import com.google.inject.Guice;
28 import com.google.inject.Inject;
29 import com.google.inject.Provider;
30 import com.google.inject.name.Named;
31 import com.google.inject.testing.fieldbinder.Bind;
32 import com.google.inject.testing.fieldbinder.BoundFieldModule;
33 import io.fd.honeycomb.translate.impl.write.registry.FlatWriterRegistryBuilder;
34 import io.fd.honeycomb.translate.write.WriterFactory;
35 import java.util.HashSet;
37 import org.junit.Before;
38 import org.junit.Test;
39 import org.mockito.Mock;
40 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
42 import io.fd.vpp.jvpp.ioamtrace.future.FutureJVppIoamtraceFacade;
43 import io.fd.vpp.jvpp.JVppRegistry;
46 public class VppIoamModuleTest {
48 @Named("honeycomb-context")
51 private DataBroker honeycombContext;
53 @Named("honeycomb-initializer")
56 private DataBroker honeycombInitializer;
60 private JVppRegistry registry;
63 private Set<WriterFactory> writerFactories = new HashSet<>();
66 public void setUp() throws Exception {
70 Guice.createInjector(new VppIoamModule(MockJVppIoamProvider.class), BoundFieldModule.of(this)).injectMembers(this);
74 public void testWriterFactories() throws Exception {
75 assertThat(writerFactories, is(not(empty())));
77 final FlatWriterRegistryBuilder registryBuilder = new FlatWriterRegistryBuilder();
78 writerFactories.forEach(factory -> factory.init(registryBuilder));
79 assertNotNull(registryBuilder.build());
82 private static final class MockJVppIoamProvider implements Provider<FutureJVppIoamtraceFacade> {
85 public FutureJVppIoamtraceFacade get() {
86 return mock(FutureJVppIoamtraceFacade.class);