Scott Baker | 14c8f18 | 2019-05-22 18:05:29 -0700 | [diff] [blame] | 1 | // Portions copyright 2019-present Open Networking Foundation |
| 2 | // Original copyright 2019-present Ciena Corporation |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | const {createMockServer} = require("grpc-mock"); |
| 14 | const options = { |
| 15 | keepCase: true, |
| 16 | enum: "String", |
| 17 | defaults: true, |
| 18 | oneofs: true, |
| 19 | includeDirs: ["/xos/v1"], |
| 20 | address: "0.0.0.0:50051"} |
| 21 | const mockServer = createMockServer({ |
| 22 | protoPath: "xos.proto", |
| 23 | packageName: "xos", |
| 24 | serviceName: "xos", |
| 25 | options: options, |
| 26 | rules: require('/xos/data.json') |
| 27 | }); |
| 28 | |
| 29 | // add xos.utility protos to server |
| 30 | mockServer.addProtos({ |
| 31 | protoPath: "utility.proto", |
| 32 | packageName: "xos", |
| 33 | serviceName: "utility", |
| 34 | options: options}); |
| 35 | |
| 36 | // add xos.dynamicload protos to server |
| 37 | mockServer.addProtos({ |
| 38 | protoPath: "dynamicload.proto", |
| 39 | packageName: "xos", |
| 40 | serviceName: "dynamicload", |
| 41 | options: options}); |
| 42 | |
| 43 | // add xos.filetransfer protos to server |
| 44 | mockServer.addProtos({ |
| 45 | protoPath: "filetransfer.proto", |
| 46 | packageName: "xos", |
| 47 | serviceName: "filetransfer", |
| 48 | options: options}); |
| 49 | |
| 50 | process.on('SIGINT', function() { |
| 51 | console.log("Caught interrupt signal"); |
| 52 | process.exit(); |
| 53 | }); |
| 54 | mockServer.listen("0.0.0.0:50051"); |
| 55 | console.log("Listening for requests\n") |