import com.google.common.io.ByteSource;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
-import java.io.InputStream;
import java.net.URI;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.custommonkey.xmlunit.DetailedDiff;
return doc;
}
- private final DOMRpcService rpcServiceVoidInvoke = new DOMRpcService() {
+ private static final DOMRpcService RPC_SERVICE_VOID_INVOKER = new DOMRpcService() {
@Nonnull
@Override
public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(
}
};
- private final DOMRpcService rpcServiceFailedInvocation = new DOMRpcService() {
+ private static final DOMRpcService RPC_SERVICE_FAILED_INVOCATION = new DOMRpcService() {
@Nonnull
@Override
public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(
}
};
- private final DOMRpcService rpcServiceSuccesfullInvocation = new DOMRpcService() {
+ private final DOMRpcService rpcServiceSuccessfulInvocation = new DOMRpcService() {
@Nonnull
@Override
public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(
@Nonnull final SchemaPath type, @Nullable final NormalizedNode<?, ?> input) {
final Collection<DataContainerChild<? extends PathArgument, ?>> children =
(Collection<DataContainerChild<? extends PathArgument, ?>>) input.getValue();
- final Module module = schemaContext.findModuleByNamespaceAndRevision(
- type.getLastComponent().getNamespace(), null);
+ final Module module = schemaContext.findModule(type.getLastComponent().getNamespace()).orElse(null);
final RpcDefinition rpcDefinition = getRpcDefinitionFromModule(
module, module.getNamespace(), type.getLastComponent().getLocalName());
final ContainerSchemaNode outputSchemaNode = rpcDefinition.getOutput();
@Nonnull
@Override
public <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(
- @Nonnull final T listener) {
+ @Nonnull final T lsnr) {
return null;
}
};
}).when(sourceProvider).getSource(any(SourceIdentifier.class));
- this.schemaContext = YangParserTestUtils.parseYangStreams(getYangSchemas());
+ this.schemaContext = YangParserTestUtils.parseYangResource("/yang/mdsal-netconf-rpc-test.yang");
this.currentSchemaContext = new CurrentSchemaContext(schemaService, sourceProvider);
}
@Test
public void testVoidOutputRpc() throws Exception {
- final RuntimeRpc rpc = new RuntimeRpc(SESSION_ID_FOR_REPORTING, currentSchemaContext, rpcServiceVoidInvoke);
+ final RuntimeRpc rpc = new RuntimeRpc(SESSION_ID_FOR_REPORTING, currentSchemaContext, RPC_SERVICE_VOID_INVOKER);
final Document rpcDocument = XmlFileLoader.xmlFileToDocument("messages/mapping/rpcs/rpc-void-output.xml");
final HandlingPriority priority = rpc.canHandle(rpcDocument);
@Test
public void testSuccesfullNonVoidInvocation() throws Exception {
final RuntimeRpc rpc = new RuntimeRpc(
- SESSION_ID_FOR_REPORTING, currentSchemaContext, rpcServiceSuccesfullInvocation);
+ SESSION_ID_FOR_REPORTING, currentSchemaContext, rpcServiceSuccessfulInvocation);
final Document rpcDocument = XmlFileLoader.xmlFileToDocument("messages/mapping/rpcs/rpc-nonvoid.xml");
final HandlingPriority priority = rpc.canHandle(rpcDocument);
@Test
public void testSuccesfullContainerInvocation() throws Exception {
final RuntimeRpc rpc = new RuntimeRpc(
- SESSION_ID_FOR_REPORTING, currentSchemaContext, rpcServiceSuccesfullInvocation);
+ SESSION_ID_FOR_REPORTING, currentSchemaContext, rpcServiceSuccessfulInvocation);
final Document rpcDocument = XmlFileLoader.xmlFileToDocument("messages/mapping/rpcs/rpc-container.xml");
final HandlingPriority priority = rpc.canHandle(rpcDocument);
@Test
public void testFailedInvocation() throws Exception {
final RuntimeRpc rpc = new RuntimeRpc(
- SESSION_ID_FOR_REPORTING, currentSchemaContext, rpcServiceFailedInvocation);
+ SESSION_ID_FOR_REPORTING, currentSchemaContext, RPC_SERVICE_FAILED_INVOCATION);
final Document rpcDocument = XmlFileLoader.xmlFileToDocument("messages/mapping/rpcs/rpc-nonvoid.xml");
final HandlingPriority priority = rpc.canHandle(rpcDocument);
@Test
public void testVoidInputOutputRpc() throws Exception {
- final RuntimeRpc rpc = new RuntimeRpc(SESSION_ID_FOR_REPORTING, currentSchemaContext, rpcServiceVoidInvoke);
+ final RuntimeRpc rpc = new RuntimeRpc(SESSION_ID_FOR_REPORTING, currentSchemaContext, RPC_SERVICE_VOID_INVOKER);
final Document rpcDocument = XmlFileLoader.xmlFileToDocument("messages/mapping/rpcs/rpc-void-input-output.xml");
final HandlingPriority priority = rpc.canHandle(rpcDocument);
@Test
public void testBadNamespaceInRpc() throws Exception {
- final RuntimeRpc rpc = new RuntimeRpc(SESSION_ID_FOR_REPORTING, currentSchemaContext, rpcServiceVoidInvoke);
+ final RuntimeRpc rpc = new RuntimeRpc(SESSION_ID_FOR_REPORTING, currentSchemaContext, RPC_SERVICE_VOID_INVOKER);
final Document rpcDocument = XmlFileLoader.xmlFileToDocument("messages/mapping/rpcs/rpc-bad-namespace.xml");
try {
return null;
}
-
- private List<InputStream> getYangSchemas() {
- final List<String> schemaPaths = Collections.singletonList("/yang/mdsal-netconf-rpc-test.yang");
- final List<InputStream> schemas = new ArrayList<>();
-
- for (final String schemaPath : schemaPaths) {
- final InputStream resourceAsStream = getClass().getResourceAsStream(schemaPath);
- schemas.add(resourceAsStream);
- }
-
- return schemas;
- }
-}
\ No newline at end of file
+}