import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import java.lang.reflect.Field;
+import java.net.URI;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
import org.opendaylight.restconf.common.context.NormalizedNodeContext;
import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
+import org.opendaylight.restconf.common.util.SimpleUriInfo;
import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
import org.opendaylight.restconf.nb.rfc8040.handlers.DOMDataBrokerHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.NotificationServiceHandler;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
+@SuppressWarnings("deprecation")
public class RestconfStreamsSubscriptionServiceImplTest {
private static final String URI = "/restconf/18/data/ietf-restconf-monitoring:restconf-state/streams/stream/"
private SchemaContextHandler schemaHandler;
+ @SuppressWarnings("unchecked")
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
final Set<Entry<String, List<String>>> set = new HashSet<>();
Mockito.when(map.entrySet()).thenReturn(set);
Mockito.when(this.uriInfo.getQueryParameters()).thenReturn(map);
+ final UriBuilder baseUriBuilder = new LocalUriInfo().getBaseUriBuilder();
+ Mockito.when(uriInfo.getBaseUri()).thenReturn(baseUriBuilder.build());
+ Mockito.when(uriInfo.getBaseUriBuilder()).thenReturn(baseUriBuilder);
this.schemaHandler.onGlobalContextUpdated(
YangParserTestUtils.parseYangSources(TestRestconfUtils.loadFiles("/notifications")));
}
+ private static class LocalUriInfo extends SimpleUriInfo {
+
+ LocalUriInfo() {
+ super("/");
+ }
+
+ @Override
+ public URI getBaseUri() {
+ return UriBuilder.fromUri("http://localhost:8181").build();
+ }
+ }
+
@BeforeClass
public static void setUpBeforeTest() throws Exception {
final Map<String, ListenerAdapter> listenersByStreamNameSetter = new HashMap<>();
@Test
public void testSubscribeToStream() throws Exception {
final UriBuilder uriBuilder = UriBuilder.fromUri(URI);
- final ListenerAdapter createListener = Notificator.createListener(
+ Notificator.createListener(
IdentifierCodec.deserialize("toaster:toaster/toasterStatus", this.schemaHandler.get()),
"data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE",
NotificationOutputType.XML);
"data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE",
this.uriInfo);
assertEquals(
- "ws://:8181/data-change-event-subscription/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE",
+ "ws://localhost:8181/data-change-event-subscription"
+ + "/toaster:toaster/toasterStatus/datastore=OPERATIONAL/scope=ONE",
response.getNewHeaders().get("Location").toString());
}