<dependency>
<groupId>org.kohsuke.metainf-services</groupId>
<artifactId>metainf-services</artifactId>
- <optional>true</optional>
</dependency>
<dependency>
- <groupId>javax.inject</groupId>
+ <groupId>com.guicedee.services</groupId>
<artifactId>javax.inject</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
</dependencies>
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
+import org.opendaylight.mdsal.eos.dom.simple.SimpleDOMEntityOwnershipService;
+
+module org.opendaylight.mdsal.eos.dom.simple {
+ exports org.opendaylight.mdsal.eos.dom.simple.di;
+
+ requires org.opendaylight.yangtools.concepts;
+ requires org.opendaylight.mdsal.eos.dom.api;
+ requires org.slf4j;
+
+ provides DOMEntityOwnershipService with SimpleDOMEntityOwnershipService;
+
+ // Annotations
+ requires static com.github.spotbugs.annotations;
+ requires static org.eclipse.jdt.annotation;
+ requires static org.checkerframework.checker.qual;
+ requires static javax.inject;
+ requires static metainf.services;
+ requires static org.osgi.service.component.annotations;
+}
import java.util.Collection;
import java.util.Optional;
import java.util.UUID;
-import javax.inject.Singleton;
import org.checkerframework.checker.lock.qual.GuardedBy;
import org.kohsuke.MetaInfServices;
import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- * Simple {@link DOMEntityOwnershipService} operating as an isolated island. It has no awareness of the world outside
- * of itself.
- *
- * @author Robert Varga
- */
@MetaInfServices
-@Singleton
@Component(immediate = true)
-public final class SimpleDOMEntityOwnershipService implements DOMEntityOwnershipService {
+public class SimpleDOMEntityOwnershipService implements DOMEntityOwnershipService {
private static final Logger LOG = LoggerFactory.getLogger(SimpleDOMEntityOwnershipService.class);
@GuardedBy("entities")
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.mdsal.eos.dom.simple.di;
+
+import com.google.common.annotations.Beta;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
+import org.opendaylight.mdsal.eos.dom.simple.SimpleDOMEntityOwnershipService;
+
+/**
+ * Simple {@link DOMEntityOwnershipService} operating as an isolated island. It has no awareness of the world outside
+ * of itself.
+ *
+ * @author Robert Varga
+ */
+@Beta
+@Singleton
+public class LocalDOMEntityOwnershipService extends SimpleDOMEntityOwnershipService {
+ @Inject
+ public LocalDOMEntityOwnershipService() {
+ // Exposed for DI
+ }
+}
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
import java.util.Optional;
import java.util.UUID;
-import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.mdsal.eos.common.api.CandidateAlreadyRegisteredException;
import org.opendaylight.mdsal.eos.common.api.EntityOwnershipChangeState;
import org.opendaylight.mdsal.eos.common.api.EntityOwnershipState;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipListenerRegistration;
import org.opendaylight.mdsal.eos.dom.api.DOMEntityOwnershipService;
+@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class SimpleDOMEntityOwnershipServiceTest {
- private static final String FOO_TYPE = "foo";
- private static final String BAR_TYPE = "bar";
+ public static final String FOO_TYPE = "foo";
+ public static final String BAR_TYPE = "bar";
- private static final DOMEntity FOO_FOO_ENTITY = new DOMEntity(FOO_TYPE, "foo");
- private static final DOMEntity FOO_BAR_ENTITY = new DOMEntity(FOO_TYPE, "bar");
+ public static final DOMEntity FOO_FOO_ENTITY = new DOMEntity(FOO_TYPE, "foo");
+ public static final DOMEntity FOO_BAR_ENTITY = new DOMEntity(FOO_TYPE, "bar");
- private DOMEntityOwnershipService service;
-
- @Before
- public void setUp() {
- service = new SimpleDOMEntityOwnershipService();
- }
+ public final DOMEntityOwnershipService service = new SimpleDOMEntityOwnershipService();
@Test
public void testNonExistingEntity() {
// Mismatched type, not triggered
final DOMEntityOwnershipListener barListener = mock(DOMEntityOwnershipListener.class);
- doNothing().when(barListener).ownershipChanged(any(DOMEntityOwnershipChange.class));
final DOMEntityOwnershipListenerRegistration barReg = service.registerListener(BAR_TYPE, barListener);
- verifyZeroInteractions(barListener);
// Matching type should be triggered
final DOMEntityOwnershipListener fooListener = mock(DOMEntityOwnershipListener.class);
reset(fooListener);
doNothing().when(fooListener).ownershipChanged(any(DOMEntityOwnershipChange.class));
entityReg.close();
- verifyZeroInteractions(barListener);
verify(fooListener).ownershipChanged(fooCaptor.capture());
fooChange = fooCaptor.getValue();
assertEquals(FOO_FOO_ENTITY, fooChange.getEntity());