import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.testkit.JavaTestKit;
-import com.google.common.collect.Lists;
-import com.google.common.io.ByteSource;
-import java.io.IOException;
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 org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
/**
* Base class for RPC tests.
static final SchemaPath TEST_RPC_TYPE = SchemaPath.create(true, TEST_RPC);
- static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.create(new YangInstanceIdentifier.NodeIdentifier(TEST_RPC));
- static final DOMRpcIdentifier TEST_RPC_ID = DOMRpcIdentifier.create(TEST_RPC_TYPE, TEST_PATH);
+ static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.create(
+ new YangInstanceIdentifier.NodeIdentifier(TEST_RPC));
+ public static final DOMRpcIdentifier TEST_RPC_ID = DOMRpcIdentifier.create(TEST_RPC_TYPE, TEST_PATH);
static ActorSystem node1;
static ActorSystem node2;
@Before
public void setUp() throws Exception {
- final ByteSource byteSource = new ByteSource() {
- @Override
- public InputStream openStream() throws IOException {
- return AbstractRpcTest.this.getClass().getResourceAsStream("/test-rpc.yang");
- }
- };
-
- final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
- final ArrayList<ByteSource> sources = Lists.newArrayList(byteSource);
+ final List<InputStream> sources = Collections.singletonList(
+ AbstractRpcTest.this.getClass().getResourceAsStream("/test-rpc.yang"));
try {
- schemaContext = reactor.buildEffective(sources);
+ schemaContext = YangParserTestUtils.parseYangStreams(sources);
} catch (ReactorException e) {
throw new RuntimeException("Unable to build schema context from " + sources, e);
}
}
static void assertRpcErrorEquals(final RpcError rpcError, final ErrorSeverity severity,
- final ErrorType errorType, final String tag, final String message, final String applicationTag, final String info,
- final String causeMsg) {
+ final ErrorType errorType, final String tag, final String message, final String applicationTag,
+ final String info, final String causeMsg) {
assertEquals("getSeverity", severity, rpcError.getSeverity());
assertEquals("getErrorType", errorType, rpcError.getErrorType());
assertEquals("getTag", tag, rpcError.getTag());
assertEquals("getApplicationTag", applicationTag, rpcError.getApplicationTag());
assertEquals("getInfo", info, rpcError.getInfo());
- if(causeMsg == null) {
+ if (causeMsg == null) {
assertNull("Unexpected cause " + rpcError.getCause(), rpcError.getCause());
} else {
assertEquals("Cause message", causeMsg, rpcError.getCause().getMessage());
}
}
- static void assertCompositeNodeEquals(final NormalizedNode<? , ?> exp, final NormalizedNode<? , ? > actual) {
+ static void assertCompositeNodeEquals(final NormalizedNode<? , ?> exp, final NormalizedNode<? , ?> actual) {
assertEquals(exp, actual);
}
- static ContainerNode makeRPCInput(final String data) {
+ public static ContainerNode makeRPCInput(final String data) {
return Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(TEST_RPC_INPUT))
.withChild(ImmutableNodes.leafNode(TEST_RPC_INPUT_DATA, data)).build();
}
- static ContainerNode makeRPCOutput(final String data) {
+ public static ContainerNode makeRPCOutput(final String data) {
return Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(TEST_RPC_OUTPUT))
.withChild(ImmutableNodes.leafNode(TEST_RPC_OUTPUT, data)).build();
}
static void assertFailedRpcResult(final DOMRpcResult rpcResult, final ErrorSeverity severity,
- final ErrorType errorType, final String tag, final String message, final String applicationTag, final String info,
- final String causeMsg) {
-
+ final ErrorType errorType, final String tag, final String message, final String applicationTag,
+ final String info, final String causeMsg) {
assertNotNull("RpcResult was null", rpcResult);
final Collection<RpcError> rpcErrors = rpcResult.getErrors();
assertEquals("RpcErrors count", 1, rpcErrors.size());