Skip to content
This repository has been archived by the owner on Jul 13, 2020. It is now read-only.

Commit

Permalink
intro RESTCONF Version DRAFT_02 vs DRAFT_18
Browse files Browse the repository at this point in the history
use DRAFT_02 by default (instead of previous DRAFT_18)

un-comment the test which now passes!
  • Loading branch information
vorburger committed Oct 30, 2018
1 parent d2fafc4 commit fea97cc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
10 changes: 10 additions & 0 deletions src/main/java/org/opendaylight/restconf/simple/RestConfConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,14 @@ static RestConfConfigBuilder builder() {
default String contextPath() {
return "/restconf";
}

default Version version() {
return Version.DRAFT_02;
}

enum Version {
// TODO Confirm what are appropriate names for these versions?
DRAFT_18, // RFC_8040 ?
DRAFT_02
}
}
19 changes: 16 additions & 3 deletions src/main/java/org/opendaylight/restconf/simple/RestConfWiring.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl;
import org.opendaylight.netconf.sal.restconf.impl.RestconfProviderImpl;
import org.opendaylight.netconf.sal.restconf.impl.StatisticsRestconfServiceWrapper;
import org.opendaylight.restconf.nb.rfc8040.RestconfApplication;
import org.opendaylight.restconf.nb.rfc8040.handlers.DOMDataBrokerHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.DOMMountPointServiceHandler;
import org.opendaylight.restconf.nb.rfc8040.handlers.NotificationServiceHandler;
Expand Down Expand Up @@ -99,8 +98,22 @@ public RestConfWiring(RestConfConfig config, WebServer webServer, ServletSupport

// This is currently hard-coded to DRAFT_18; if we ever actually need to support the
// older DRAFT_02 for anything, then (only) add it to the RestConfConfig and switch here
Application application = new RestconfApplication(schemaCtxHandler,
domMountPointServiceHandler, servicesWrapper);
Application application;
switch (config.version()) {
case DRAFT_02:
application = new org.opendaylight.netconf.sal.rest.impl.RestconfApplication(
controllerContext, stats);
break;

case DRAFT_18:
application = new org.opendaylight.restconf.nb.rfc8040.RestconfApplication(
schemaCtxHandler, domMountPointServiceHandler, servicesWrapper);
break;

default:
throw new UnsupportedOperationException(config.version().name());
}

HttpServlet servlet = jaxRS.createHttpServletBuilder(application).build();
this.webContext = WebContext.builder().contextPath(config.contextPath())
.addServlet(ServletDetails.builder().addUrlPattern("/*").servlet(servlet).build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*/
package org.opendaylight.restconf.simple.test;

import static com.google.common.truth.Truth.assertThat;
import static org.opendaylight.infrautils.testutils.TestHttpClient.Method.GET;

import java.io.IOException;
import javax.inject.Inject;
import org.junit.Rule;
Expand Down Expand Up @@ -35,7 +38,7 @@ public class RestConfModuleTest extends AbstractSimpleDistributionTest {
@Inject TestHttpClient http;

@Test public void testRestConf() throws IOException {
// TODO assertThat(http.responseCode(GET, "/restconf/modules/")).isEqualTo(200);
assertThat(http.responseCode(GET, "/restconf/modules/")).isEqualTo(200);

// TODO test security; add auth support to TestHttpClient, check that w.o. auth it's 401
}
Expand Down

0 comments on commit fea97cc

Please sign in to comment.