diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.MsgIdHandler.Test/JT808.Gateway.MsgIdHandler.Test.csproj b/src/JT808.Gateway.Tests/JT808.Gateway.MsgIdHandler.Test/JT808.Gateway.MsgIdHandler.Test.csproj deleted file mode 100644 index 7c471ef..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.MsgIdHandler.Test/JT808.Gateway.MsgIdHandler.Test.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - Exe - netcoreapp3.0 - - - - - - - - - - - - - - - Always - - - - diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.MsgIdHandler.Test/JT808DotNettyMsgIdHandlerDefaultImpl.cs b/src/JT808.Gateway.Tests/JT808.Gateway.MsgIdHandler.Test/JT808DotNettyMsgIdHandlerDefaultImpl.cs deleted file mode 100644 index 58ad123..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.MsgIdHandler.Test/JT808DotNettyMsgIdHandlerDefaultImpl.cs +++ /dev/null @@ -1,44 +0,0 @@ -using JT808.Gateway.BusinessServices.MsgIdHandler; -using JT808.Gateway.Configs.Kafka; -using JT808.Gateway.Kafka; -using JT808.Gateway.PubSub; -using JT808.Protocol; -using JT808.Protocol.Extensions; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace JT808.Gateway.MsgIdHandler.Test -{ - public class JT808DotNettyMsgIdHandlerDefaultImpl : IJT808MsgIdHandler - { - public readonly ILogger logger; - public JT808DotNettyMsgIdHandlerDefaultImpl(ILoggerFactory loggerFactory, - IServiceProvider serviceProvider) { - logger = loggerFactory.CreateLogger(); - Task.Run(()=> { - while (true) - { - Thread.Sleep(5000); - using (IJT808MsgProducer jT808MsgProducer = new JT808MsgProducer(new JT808MsgProducerConfig - { - BootstrapServers = "127.0.0.1:9092", - TopicName = "JT808Msg" - })) - { - jT808MsgProducer.ProduceAsync("123456", new byte[] { 0x7E, 0, 0x7E }).Wait(); - } - } - }); - } - - public void Processor((string TerminalNo, byte[] Data) parameter) - { - logger.LogDebug($"{parameter.TerminalNo}:{parameter.Data.ToHexString()}"); - } - } -} diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.MsgIdHandler.Test/Program.cs b/src/JT808.Gateway.Tests/JT808.Gateway.MsgIdHandler.Test/Program.cs deleted file mode 100644 index f96f9cd..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.MsgIdHandler.Test/Program.cs +++ /dev/null @@ -1,39 +0,0 @@ -using JT808.Gateway.BusinessServices.MsgIdHandler; -using JT808.Gateway.Kafka; -using JT808.Protocol; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using System; -using System.Threading.Tasks; - -namespace JT808.Gateway.MsgIdHandler.Test -{ - class Program - { - async static Task Main(string[] args) - { - var serverHostBuilder = new HostBuilder() - .UseEnvironment(args[0].Split('=')[1]) - .ConfigureAppConfiguration((hostingContext,config) => { - config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory); - config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) - .AddJsonFile($"appsettings.{ hostingContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true); - }) - .ConfigureLogging(configLogging => { - configLogging.AddConsole(); - configLogging.SetMinimumLevel(LogLevel.Trace); - }) - .ConfigureServices((hostContext, services) => { - services.AddSingleton(); - services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); - services.AddJT808Configure() - .AddJT808ClientKafka() - .AddMsgConsumer(hostContext.Configuration) - .AddJT808MsgIdHandler(); - }); - await serverHostBuilder.RunConsoleAsync(); - } - } -} diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.MsgLogging.Test/JT808.Gateway.MsgLogging.Test.csproj b/src/JT808.Gateway.Tests/JT808.Gateway.MsgLogging.Test/JT808.Gateway.MsgLogging.Test.csproj deleted file mode 100644 index 13142a7..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.MsgLogging.Test/JT808.Gateway.MsgLogging.Test.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - Exe - netcoreapp3.0 - - - - - - - - - - - - - - - - Always - - - - diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.MsgLogging.Test/JT808MsgLoggingImpl.cs b/src/JT808.Gateway.Tests/JT808.Gateway.MsgLogging.Test/JT808MsgLoggingImpl.cs deleted file mode 100644 index 033b8f1..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.MsgLogging.Test/JT808MsgLoggingImpl.cs +++ /dev/null @@ -1,52 +0,0 @@ -using JJT808.Gateway.Kafka; -using JT808.Gateway.BusinessServices.MsgLogging; -using JT808.Gateway.Configs.Kafka; -using JT808.Gateway.Kafka; -using JT808.Gateway.PubSub; -using JT808.Protocol.Extensions; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace JT808.Gateway.MsgLogging.Test -{ - public class JT808MsgLoggingImpl : IJT808MsgLogging - { - public readonly ILogger logger; - public JT808MsgLoggingImpl(ILoggerFactory loggerFactory) { - logger = loggerFactory.CreateLogger(); - Task.Run(() => { - while (true) - { - Thread.Sleep(5000); - using (IJT808MsgProducer jT808MsgProducer = new JT808MsgProducer(new JT808MsgProducerConfig - { - BootstrapServers = "127.0.0.1:9092", - TopicName = "JT808Msg" - })) - { - jT808MsgProducer.ProduceAsync("123456", new byte[] { 0x7E, 0,0,0,0, 0x7E }).Wait(); - } - - JT808MsgReplyProducerConfig JT808MsgProducerConfig = new JT808MsgReplyProducerConfig - { - TopicName = "JT808MsgReply", - BootstrapServers = "127.0.0.1:9092", - }; - using (IJT808MsgReplyProducer jT808MsgProducer = new JT808MsgReplyProducer(JT808MsgProducerConfig)) - { - jT808MsgProducer.ProduceAsync("123456", new byte[] { 0x7E,1,1,1,1, 0x7E }).Wait(); - } - } - }); - } - - public void Processor((string TerminalNo, byte[] Data) parameter, JT808MsgLoggingType jT808MsgLoggingType) - { - logger.LogDebug($"{parameter.TerminalNo}:{parameter.Data.ToHexString()},方向:{jT808MsgLoggingType.ToString()}"); - } - } -} diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.MsgLogging.Test/Program.cs b/src/JT808.Gateway.Tests/JT808.Gateway.MsgLogging.Test/Program.cs deleted file mode 100644 index 482e60f..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.MsgLogging.Test/Program.cs +++ /dev/null @@ -1,43 +0,0 @@ -using JT808.Gateway.BusinessServices.MsgLogging; -using JT808.Gateway.Kafka; -using JT808.Protocol; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Console; -using System; -using System.Threading.Tasks; - -namespace JT808.Gateway.MsgLogging.Test -{ - class Program - { - async static Task Main(string[] args) - { - var hostBuilder = new HostBuilder() - .UseEnvironment(args[0].Split('=')[1]) - .ConfigureAppConfiguration((hostContext,config)=> { - config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory); - config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) - .AddJsonFile($"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true); - }) - .ConfigureLogging((hostContext, configLogging) => { - configLogging.AddConsole(); - configLogging.SetMinimumLevel(LogLevel.Trace); - }) - .ConfigureServices((hostContext, services) => { - services.AddSingleton(); - services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); - services.AddJT808Configure() - .AddJT808ClientKafka() - .AddMsgConsumer(hostContext.Configuration) - .AddMsgReplyConsumer(hostContext.Configuration) - .AddJT808MsgLogging(); - }) - ; - - await hostBuilder.RunConsoleAsync(); - } - } -} diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.ReplyMessage.Test/JT808.Gateway.ReplyMessage.Test.csproj b/src/JT808.Gateway.Tests/JT808.Gateway.ReplyMessage.Test/JT808.Gateway.ReplyMessage.Test.csproj deleted file mode 100644 index da55908..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.ReplyMessage.Test/JT808.Gateway.ReplyMessage.Test.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - Exe - netcoreapp3.0 - - - - - - - - - - - - - - - - Always - - - - diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.ReplyMessage.Test/JT808DotNettyReplyMessageServiceInherited.cs b/src/JT808.Gateway.Tests/JT808.Gateway.ReplyMessage.Test/JT808DotNettyReplyMessageServiceInherited.cs deleted file mode 100644 index 4f400a8..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.ReplyMessage.Test/JT808DotNettyReplyMessageServiceInherited.cs +++ /dev/null @@ -1,48 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using JT808.Gateway.BusinessServices.ReplyMessage; -using JT808.Gateway.Configs.Kafka; -using JT808.Gateway.Kafka; -using JT808.Gateway.PubSub; -using JT808.Protocol; -using JT808.Protocol.Extensions; -using Microsoft.Extensions.Logging; - -namespace JT808.Gateway.ReplyMessage.Test -{ - public class JT808DotNettyReplyMessageServiceInherited : JT808ReplyMessageService - { - public readonly ILogger logger; - - public JT808DotNettyReplyMessageServiceInherited(IJT808Config jT808Config, - IJT808MsgReplyProducer jT808MsgReplyProducer, - ILoggerFactory loggerFactory) - : base(jT808Config, jT808MsgReplyProducer) - { - logger = loggerFactory.CreateLogger(); - Task.Run(() => { - while (true) - { - Thread.Sleep(5000); - using (IJT808MsgProducer jT808MsgProducer = new JT808MsgProducer(new JT808MsgProducerConfig - { - BootstrapServers = "127.0.0.1:9092", - TopicName = "JT808Msg" - })) - { - jT808MsgProducer.ProduceAsync("011111111111", "7E02000032011111111111012E00000000000C00000160E42506C30C82002C00000000180914142057010400001DC003020000250400000000300115310100977E".ToHexBytes()).Wait(); - } - } - }); - } - - public override void Processor((string TerminalNo, byte[] Data) parameter) - { - logger.LogDebug($"{parameter.TerminalNo}:{parameter.Data.ToHexString()}"); - base.Processor(parameter); - } - } -} diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.ReplyMessage.Test/Program.cs b/src/JT808.Gateway.Tests/JT808.Gateway.ReplyMessage.Test/Program.cs deleted file mode 100644 index eafa6a0..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.ReplyMessage.Test/Program.cs +++ /dev/null @@ -1,42 +0,0 @@ -using JT808.Gateway.BusinessServices.ReplyMessage; -using JT808.Gateway.Kafka; -using JT808.Protocol; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using System; -using System.Threading.Tasks; - -namespace JT808.Gateway.ReplyMessage.Test -{ - class Program - { - async static Task Main(string[] args) - { - var hostBuilder = new HostBuilder() - .UseEnvironment(args[0].Split('=')[1]) - .ConfigureAppConfiguration((hostContext, config) => { - config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory); - config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) - .AddJsonFile($"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true); - }) - .ConfigureLogging((hostContext, configLogging) => { - configLogging.AddConsole(); - configLogging.SetMinimumLevel(LogLevel.Trace); - }) - .ConfigureServices((hostContext, services) => { - services.AddSingleton(); - services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); - services.AddJT808Configure() - .AddJT808ClientKafka() - .AddMsgConsumer(hostContext.Configuration) - .AddMsgReplyProducer(hostContext.Configuration) - .AddInprocJT808ReplyMessage(); - }) - ; - - await hostBuilder.RunConsoleAsync(); - } - } -} diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.SessionNotice.Test/JT808.Gateway.SessionNotice.Test.csproj b/src/JT808.Gateway.Tests/JT808.Gateway.SessionNotice.Test/JT808.Gateway.SessionNotice.Test.csproj deleted file mode 100644 index c6b1507..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.SessionNotice.Test/JT808.Gateway.SessionNotice.Test.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - Exe - netcoreapp3.0 - - - - - - - - - - - - - - - Always - - - - diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.SessionNotice.Test/JT808DotNettySessionNoticeServiceInherited.cs b/src/JT808.Gateway.Tests/JT808.Gateway.SessionNotice.Test/JT808DotNettySessionNoticeServiceInherited.cs deleted file mode 100644 index 2c846c2..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.SessionNotice.Test/JT808DotNettySessionNoticeServiceInherited.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using JT808.Gateway.BusinessServices.SessionNotice; -using JT808.Gateway.Configs.Kafka; -using JT808.Gateway.Kafka; -using JT808.Gateway.PubSub; -using Microsoft.Extensions.Logging; - -namespace JT808.Gateway.SessionNotice.Test -{ - public class JT808DotNettySessionNoticeServiceInherited : JT808SessionNoticeService - { - public JT808DotNettySessionNoticeServiceInherited(ILoggerFactory loggerFactory) : base(loggerFactory) - { - Task.Run(()=> { - while (true) - { - Thread.Sleep(5000); - JT808SessionProducerConfig JT808ProducerConfig = new JT808SessionProducerConfig - { - TopicName = "JT808Session", - BootstrapServers = "127.0.0.1:9092" - }; - using (IJT808SessionProducer jT808MsgProducer = new JT808SessionProducer(JT808ProducerConfig)) - { - jT808MsgProducer.ProduceAsync("online", "123456").Wait(); - jT808MsgProducer.ProduceAsync("offline", "123457").Wait(); - } - } - }); - } - - public override void Processor((string Notice, string TerminalNo) parameter) - { - base.Processor(parameter); - } - } -} diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.SessionNotice.Test/Program.cs b/src/JT808.Gateway.Tests/JT808.Gateway.SessionNotice.Test/Program.cs deleted file mode 100644 index 24196a6..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.SessionNotice.Test/Program.cs +++ /dev/null @@ -1,41 +0,0 @@ -using JT808.Gateway.BusinessServices.SessionNotice; -using JT808.Gateway.Kafka; -using JT808.Protocol; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using System; -using System.Threading.Tasks; - -namespace JT808.Gateway.SessionNotice.Test -{ - class Program - { - async static Task Main(string[] args) - { - var hostBuilder = new HostBuilder() - .UseEnvironment(args[0].Split('=')[1]) - .ConfigureAppConfiguration((hostContext, config) => { - config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory); - config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) - .AddJsonFile($"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true); - }) - .ConfigureLogging((hostContext, configLogging) => { - configLogging.AddConsole(); - configLogging.SetMinimumLevel(LogLevel.Trace); - }) - .ConfigureServices((hostContext, services) => { - services.AddSingleton(); - services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); - services.AddJT808Configure() - .AddJT808ClientKafka() - .AddSessionConsumer(hostContext.Configuration) - .AddInprocJT808SessionNotice(); - }) - ; - - await hostBuilder.RunConsoleAsync(); - } - } -} diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.Test/JT808.Gateway.Test.csproj b/src/JT808.Gateway.Tests/JT808.Gateway.Test/JT808.Gateway.Test.csproj deleted file mode 100644 index 7745168..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.Test/JT808.Gateway.Test.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - - netcoreapp3.0 - - false - - - - - - - - - - - - - - - - - - - Always - - - Always - - - - diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.Test/Tcp/JT808SessionServiceTest.cs b/src/JT808.Gateway.Tests/JT808.Gateway.Test/Tcp/JT808SessionServiceTest.cs deleted file mode 100644 index 0339c36..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.Test/Tcp/JT808SessionServiceTest.cs +++ /dev/null @@ -1,94 +0,0 @@ -using JT808.Protocol; -using System; -using System.Collections.Generic; -using System.Net; -using System.Text; -using System.Threading; -using Microsoft.Extensions.DependencyInjection; -using JT808.Protocol.Extensions; -using Xunit; -using JT808.Gateway.Interfaces; -using JT808.Gateway.Session; -using JT808.Gateway.Simples; - -namespace JT808.Gateway.Test.Tcp -{ - public class JT808SessionServiceTest:TestBase,IDisposable - { - static IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 6565); - - JT808SimpleTcpClient SimpleTcpClient1; - JT808SimpleTcpClient SimpleTcpClient2; - JT808SimpleTcpClient SimpleTcpClient3; - JT808SimpleTcpClient SimpleTcpClient4; - JT808SimpleTcpClient SimpleTcpClient5; - - public JT808SessionServiceTest() - { - SimpleTcpClient1 = new JT808SimpleTcpClient(endPoint); - SimpleTcpClient2 = new JT808SimpleTcpClient(endPoint); - SimpleTcpClient3 = new JT808SimpleTcpClient(endPoint); - SimpleTcpClient4 = new JT808SimpleTcpClient(endPoint); - SimpleTcpClient5 = new JT808SimpleTcpClient(endPoint); - // 心跳会话包 - JT808Package jT808Package1 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789001"); - SimpleTcpClient1.WriteAsync(JT808Serializer.Serialize(jT808Package1)); - - // 心跳会话包 - JT808Package jT808Package2 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789002"); - SimpleTcpClient2.WriteAsync(JT808Serializer.Serialize(jT808Package2)); - - // 心跳会话包 - JT808Package jT808Package3 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789003"); - SimpleTcpClient3.WriteAsync(JT808Serializer.Serialize(jT808Package3)); - - // 心跳会话包 - JT808Package jT808Package4 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789004"); - SimpleTcpClient4.WriteAsync(JT808Serializer.Serialize(jT808Package4)); - - // 心跳会话包 - JT808Package jT808Package5 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789005"); - SimpleTcpClient5.WriteAsync(JT808Serializer.Serialize(jT808Package5)); - Thread.Sleep(1000); - } - - public void Dispose() - { - SimpleTcpClient1.Down(); - SimpleTcpClient2.Down(); - SimpleTcpClient3.Down(); - SimpleTcpClient4.Down(); - SimpleTcpClient5.Down(); - } - - [Fact] - public void Test1() - { - IJT808SessionService jT808SessionServiceDefaultImpl = ServiceProvider.GetService(); - var result = jT808SessionServiceDefaultImpl.GetTcpAll(); - Thread.Sleep(5000); - } - - [Fact] - public void Test2() - { - IJT808SessionService jT808SessionServiceDefaultImpl = ServiceProvider.GetService(); - var result1 = jT808SessionServiceDefaultImpl.GetTcpAll(); - var result2 = jT808SessionServiceDefaultImpl.RemoveByTerminalPhoneNo("123456789001"); - var result3 = jT808SessionServiceDefaultImpl.GetTcpAll(); - } - - [Fact] - public void Test3() - { - // 判断通道是否关闭 - IJT808SessionService jT808SessionServiceDefaultImpl = ServiceProvider.GetService(); - JT808SessionManager jT808TcpSessionManager = ServiceProvider.GetService(); - var result1 = jT808SessionServiceDefaultImpl.GetTcpAll(); - SimpleTcpClient1.Down(); - Thread.Sleep(5000); - var session = jT808TcpSessionManager.GetSessionByTerminalPhoneNo("123456789001"); - Thread.Sleep(100000); - } - } -} diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.Test/Tcp/JT808UnificationTcpSendServiceTest.cs b/src/JT808.Gateway.Tests/JT808.Gateway.Test/Tcp/JT808UnificationTcpSendServiceTest.cs deleted file mode 100644 index e5138a6..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.Test/Tcp/JT808UnificationTcpSendServiceTest.cs +++ /dev/null @@ -1,75 +0,0 @@ -using JT808.Protocol; -using System; -using System.Collections.Generic; -using System.Net; -using System.Text; -using System.Threading; -using Microsoft.Extensions.DependencyInjection; -using JT808.Protocol.Extensions; -using JT808.Protocol.MessageBody; -using JT808.Gateway.Interfaces; -using JT808.Gateway.Simples; -using Xunit; -using JT808.Gateway.Dtos; - -namespace JT808.Gateway.Test.Tcp -{ - public class JT808UnificationTcpSendServiceTest: TestBase - { - static IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 6565); - - private IJT808UnificationSendService jT808UnificationSendService; - private IJT808SessionService jT808SessionServiceDefaultImpl; - - public JT808UnificationTcpSendServiceTest() - { - - JT808SimpleTcpClient SimpleTcpClient1 = new JT808SimpleTcpClient(endPoint); - JT808SimpleTcpClient SimpleTcpClient2 = new JT808SimpleTcpClient(endPoint); - JT808SimpleTcpClient SimpleTcpClient3 = new JT808SimpleTcpClient(endPoint); - JT808SimpleTcpClient SimpleTcpClient4 = new JT808SimpleTcpClient(endPoint); - JT808SimpleTcpClient SimpleTcpClient5 = new JT808SimpleTcpClient(endPoint); - // 心跳会话包 - JT808Package jT808Package1 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789001"); - SimpleTcpClient1.WriteAsync(JT808Serializer.Serialize(jT808Package1)); - - // 心跳会话包 - JT808Package jT808Package2 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789002"); - SimpleTcpClient2.WriteAsync(JT808Serializer.Serialize(jT808Package2)); - - // 心跳会话包 - JT808Package jT808Package3 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789003"); - SimpleTcpClient3.WriteAsync(JT808Serializer.Serialize(jT808Package3)); - - // 心跳会话包 - JT808Package jT808Package4 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789004"); - SimpleTcpClient4.WriteAsync(JT808Serializer.Serialize(jT808Package4)); - - // 心跳会话包 - JT808Package jT808Package5 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789005"); - SimpleTcpClient5.WriteAsync(JT808Serializer.Serialize(jT808Package5)); - - Thread.Sleep(300); - } - - [Fact] - public void Test1() - { - jT808SessionServiceDefaultImpl = ServiceProvider.GetService(); - jT808UnificationSendService = ServiceProvider.GetService(); - jT808SessionServiceDefaultImpl.GetTcpAll(); - string no = "123456789001"; - // 文本信息包 - JT808Package jT808Package2 = JT808.Protocol.Enums.JT808MsgId.文本信息下发.Create(no, new JT808_0x8300 - { - TextFlag = 5, - TextInfo = "smallchi 518" - }); - var data = JT808Serializer.Serialize(jT808Package2); - JT808ResultDto jt808Result = jT808UnificationSendService.Send(no, data); - Thread.Sleep(1000); - Assert.Equal(200, jt808Result.Code); - Assert.True(jt808Result.Data); - } - } -} diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.Test/Tcp/TestBase.cs b/src/JT808.Gateway.Tests/JT808.Gateway.Test/Tcp/TestBase.cs deleted file mode 100644 index 2f9716f..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.Test/Tcp/TestBase.cs +++ /dev/null @@ -1,43 +0,0 @@ -using JT808.Gateway.Tcp; -using JT808.Protocol; -using JT808.Protocol.Interfaces; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace JT808.Gateway.Test.Tcp -{ - public class TestBase - { - public static IServiceProvider ServiceProvider; - public static JT808Serializer JT808Serializer; - static TestBase() - { - var serverHostBuilder = new HostBuilder() - .ConfigureAppConfiguration((hostingContext, config) => - { - config.SetBasePath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Tcp")); - config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); - }) - .ConfigureServices((hostContext, services) => - { - services.AddSingleton(); - services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); - services.AddJT808Configure() - .AddJT808Gateway(hostContext.Configuration) - .AddJT808GatewayTcpHost() - .Builder(); - //.Replace<>; - }); - var build = serverHostBuilder.Build(); - build.Start(); - ServiceProvider = build.Services; - JT808Serializer = ServiceProvider.GetRequiredService().GetSerializer(); - } - } -} diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.Test/Udp/JT808SessionServiceTest.cs b/src/JT808.Gateway.Tests/JT808.Gateway.Test/Udp/JT808SessionServiceTest.cs deleted file mode 100644 index dedf7c4..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.Test/Udp/JT808SessionServiceTest.cs +++ /dev/null @@ -1,92 +0,0 @@ -using JT808.Protocol; -using System; -using System.Collections.Generic; -using System.Net; -using System.Text; -using System.Threading; -using Microsoft.Extensions.DependencyInjection; -using JT808.Protocol.Extensions; -using Xunit; -using JT808.Gateway.Simples; -using JT808.Gateway.Interfaces; -using JT808.Gateway.Session; - -namespace JT808.Gateway.Test.Udp -{ - public class JT808SessionServiceTest:TestBase,IDisposable - { - static IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 818); - JT808SimpleUdpClient SimpleUdpClient1; - JT808SimpleUdpClient SimpleUdpClient2; - JT808SimpleUdpClient SimpleUdpClient3; - JT808SimpleUdpClient SimpleUdpClient4; - JT808SimpleUdpClient SimpleUdpClient5; - - public void Dispose() - { - SimpleUdpClient1.Down(); - SimpleUdpClient2.Down(); - SimpleUdpClient3.Down(); - SimpleUdpClient4.Down(); - SimpleUdpClient5.Down(); - } - - public JT808SessionServiceTest() - { - SimpleUdpClient1 = new JT808SimpleUdpClient(endPoint); - SimpleUdpClient2 = new JT808SimpleUdpClient(endPoint); - SimpleUdpClient3 = new JT808SimpleUdpClient(endPoint); - SimpleUdpClient4 = new JT808SimpleUdpClient(endPoint); - SimpleUdpClient5 = new JT808SimpleUdpClient(endPoint); - // 心跳会话包 - JT808Package jT808Package1 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789001"); - SimpleUdpClient1.WriteAsync(JT808Serializer.Serialize(jT808Package1)); - - // 心跳会话包 - JT808Package jT808Package2 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789002"); - SimpleUdpClient2.WriteAsync(JT808Serializer.Serialize(jT808Package2)); - - // 心跳会话包 - JT808Package jT808Package3 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789003"); - SimpleUdpClient3.WriteAsync(JT808Serializer.Serialize(jT808Package3)); - - // 心跳会话包 - JT808Package jT808Package4 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789004"); - SimpleUdpClient4.WriteAsync(JT808Serializer.Serialize(jT808Package4)); - - // 心跳会话包 - JT808Package jT808Package5 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789005"); - SimpleUdpClient5.WriteAsync(JT808Serializer.Serialize(jT808Package5)); - Thread.Sleep(1000); - } - - [Fact] - public void Test1() - { - IJT808SessionService jT808SessionServiceDefaultImpl = ServiceProvider.GetService(); - var result = jT808SessionServiceDefaultImpl.GetUdpAll(); - } - - [Fact] - public void Test2() - { - IJT808SessionService jT808SessionServiceDefaultImpl = ServiceProvider.GetService(); - var result1 = jT808SessionServiceDefaultImpl.GetUdpAll(); - var result2 = jT808SessionServiceDefaultImpl.RemoveByTerminalPhoneNo("123456789001"); - var result3 = jT808SessionServiceDefaultImpl.GetUdpAll(); - } - - [Fact] - public void Test3() - { - // 判断通道是否关闭 - IJT808SessionService jT808SessionServiceDefaultImpl = ServiceProvider.GetService(); - JT808SessionManager jT808UdpSessionManager = ServiceProvider.GetService(); - var result1 = jT808SessionServiceDefaultImpl.GetUdpAll(); - SimpleUdpClient1.Down(); - var session = jT808UdpSessionManager.GetSessionByTerminalPhoneNo("123456789001"); - var result3 = jT808UdpSessionManager.GetUdpAll(); - Thread.Sleep(100000); - } - } -} diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.Test/Udp/JT808UnificationUdpSendServiceTest.cs b/src/JT808.Gateway.Tests/JT808.Gateway.Test/Udp/JT808UnificationUdpSendServiceTest.cs deleted file mode 100644 index 0f3cf87..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.Test/Udp/JT808UnificationUdpSendServiceTest.cs +++ /dev/null @@ -1,76 +0,0 @@ -using JT808.Protocol; -using System; -using System.Collections.Generic; -using System.Net; -using System.Text; -using System.Threading; -using Microsoft.Extensions.DependencyInjection; -using JT808.Protocol.Extensions; -using JT808.Protocol.MessageBody; -using JT808.Gateway.Interfaces; -using JT808.Gateway.Simples; -using JT808.Gateway.Dtos; -using Xunit; - -namespace JT808.Gateway.Test.Udp -{ - - public class JT808UnificationUdpSendServiceTest : TestBase - { - static IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 818); - - private IJT808UnificationSendService jT808UnificationSendService; - private IJT808SessionService jT808SessionServiceDefaultImpl; - - public JT808UnificationUdpSendServiceTest() - { - JT808SimpleUdpClient SimpleUdpClient1 = new JT808SimpleUdpClient(endPoint); - JT808SimpleUdpClient SimpleUdpClient2 = new JT808SimpleUdpClient(endPoint); - JT808SimpleUdpClient SimpleUdpClient3 = new JT808SimpleUdpClient(endPoint); - JT808SimpleUdpClient SimpleUdpClient4 = new JT808SimpleUdpClient(endPoint); - JT808SimpleUdpClient SimpleUdpClient5 = new JT808SimpleUdpClient(endPoint); - // 心跳会话包 - JT808Package jT808Package1 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789001"); - SimpleUdpClient1.WriteAsync(JT808Serializer.Serialize(jT808Package1)); - - // 心跳会话包 - JT808Package jT808Package2 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789002"); - SimpleUdpClient2.WriteAsync(JT808Serializer.Serialize(jT808Package2)); - - // 心跳会话包 - JT808Package jT808Package3 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789003"); - SimpleUdpClient3.WriteAsync(JT808Serializer.Serialize(jT808Package3)); - - // 心跳会话包 - JT808Package jT808Package4 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789004"); - SimpleUdpClient4.WriteAsync(JT808Serializer.Serialize(jT808Package4)); - - // 心跳会话包 - JT808Package jT808Package5 = JT808.Protocol.Enums.JT808MsgId.终端心跳.Create("123456789005"); - SimpleUdpClient5.WriteAsync(JT808Serializer.Serialize(jT808Package5)); - - Thread.Sleep(300); - } - - [Fact] - public void Test1() - { - //"126 131 0 0 13 18 52 86 120 144 1 0 11 5 115 109 97 108 108 99 104 105 32 53 49 56 24 126" - jT808SessionServiceDefaultImpl = ServiceProvider.GetService(); - jT808UnificationSendService = ServiceProvider.GetService(); - jT808SessionServiceDefaultImpl.GetUdpAll(); - string no = "123456789001"; - // 文本信息包 - JT808Package jT808Package2 = JT808.Protocol.Enums.JT808MsgId.文本信息下发.Create(no, new JT808_0x8300 - { - TextFlag = 5, - TextInfo = "smallchi 518" - }); - var data = JT808Serializer.Serialize(jT808Package2); - JT808ResultDto jt808Result = jT808UnificationSendService.Send(no, data); - Thread.Sleep(1000); - Assert.Equal(200, jt808Result.Code); - Assert.True(jt808Result.Data); - } - } -} diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.Test/Udp/TestBase.cs b/src/JT808.Gateway.Tests/JT808.Gateway.Test/Udp/TestBase.cs deleted file mode 100644 index ecb1d9d..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.Test/Udp/TestBase.cs +++ /dev/null @@ -1,41 +0,0 @@ -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Text; -using JT808.Protocol; -using JT808.Protocol.Interfaces; -using JT808.Gateway.Udp; -using System.IO; - -namespace JT808.Gateway.Test.Udp -{ - public class TestBase - { - public static IServiceProvider ServiceProvider; - public static JT808Serializer JT808Serializer; - static TestBase() - { - var serverHostBuilder = new HostBuilder() - .ConfigureAppConfiguration((hostingContext, config) => - { - config.SetBasePath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"Udp")); - config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); - }) - .ConfigureServices((hostContext, services) => - { - services.AddSingleton(); - services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); - services.AddJT808Configure() - .AddJT808Gateway(hostContext.Configuration) - .AddJT808GatewayUdpHost(); - }); - var build = serverHostBuilder.Build(); - build.Start(); - ServiceProvider = build.Services; - JT808Serializer = ServiceProvider.GetRequiredService().GetSerializer(); - } - } -} diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.Traffic.Test/JT808.Gateway.Traffic.Test.csproj b/src/JT808.Gateway.Tests/JT808.Gateway.Traffic.Test/JT808.Gateway.Traffic.Test.csproj deleted file mode 100644 index c6b1507..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.Traffic.Test/JT808.Gateway.Traffic.Test.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - Exe - netcoreapp3.0 - - - - - - - - - - - - - - - Always - - - - diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.Traffic.Test/JT808DotNettyTrafficServiceTest.cs b/src/JT808.Gateway.Tests/JT808.Gateway.Traffic.Test/JT808DotNettyTrafficServiceTest.cs deleted file mode 100644 index 741c65f..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.Traffic.Test/JT808DotNettyTrafficServiceTest.cs +++ /dev/null @@ -1,40 +0,0 @@ -using JT808.Gateway.Configs.Kafka; -using JT808.Gateway.Kafka; -using JT808.Gateway.PubSub; -using JT808.Protocol.Extensions; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace JT808.Gateway.Traffic.Test -{ - public class JT808DotNettyTrafficServiceTest - { - private readonly CSRedis.CSRedisClient redisClien; - public readonly ILogger logger; - public JT808DotNettyTrafficServiceTest(ILoggerFactory loggerFactory) { - redisClien = new CSRedis.CSRedisClient("127.0.0.1:6379,password=smallchi"); - RedisHelper.Initialization(redisClien); - logger = loggerFactory.CreateLogger(); - Task.Run(() => { - while (true) - { - Thread.Sleep(5000); - using (IJT808MsgProducer jT808MsgProducer = new JT808MsgProducer(new JT808MsgProducerConfig - { - BootstrapServers = "127.0.0.1:9092", - TopicName = "JT808Msg" - })) - { - jT808MsgProducer.ProduceAsync("011111111111", "7E02000032011111111111012E00000000000C00000160E42506C30C82002C00000000180914142057010400001DC003020000250400000000300115310100977E".ToHexBytes()).Wait(); - } - var length= RedisHelper.HGet("011111111111", DateTime.Now.ToString("yyyyMMdd")); - logger.LogDebug($"{011111111111}:{length}"); - } - }); - } - } -} diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.Traffic.Test/Program.cs b/src/JT808.Gateway.Tests/JT808.Gateway.Traffic.Test/Program.cs deleted file mode 100644 index 8a3f615..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.Traffic.Test/Program.cs +++ /dev/null @@ -1,44 +0,0 @@ -using JT808.Gateway.BusinessServices.Traffic; -using JT808.Gateway.Kafka; -using JT808.Protocol; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using System; -using System.Threading.Tasks; - -namespace JT808.Gateway.Traffic.Test -{ - class Program - { - async static Task Main(string[] args) - { - var hostBuilder = new HostBuilder() - .UseEnvironment(args[0].Split('=')[1]) - .ConfigureAppConfiguration((hostContext, config) => { - config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory); - config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) - .AddJsonFile($"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true); - }) - .ConfigureLogging((hostContext, configLogging) => { - configLogging.AddConsole(); - configLogging.SetMinimumLevel(LogLevel.Trace); - }) - .ConfigureServices((hostContext, services) => { - services.AddSingleton(); - services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); - services.AddSingleton(); - services.AddJT808Configure() - .AddJT808ClientKafka() - .AddMsgConsumer(hostContext.Configuration) - .AddInprocJT808Traffic(); - - services.BuildServiceProvider().GetRequiredService(); - }) - ; - - await hostBuilder.RunConsoleAsync(); - } - } -} diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.Transmit.Test/JT808.Gateway.Transmit.Test.csproj b/src/JT808.Gateway.Tests/JT808.Gateway.Transmit.Test/JT808.Gateway.Transmit.Test.csproj deleted file mode 100644 index 37cd0df..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.Transmit.Test/JT808.Gateway.Transmit.Test.csproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - Exe - netcoreapp3.0 - - - - - - - - - - - - - - - Always - - - - diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.Transmit.Test/JT808DotNettyTransmitServiceTest.cs b/src/JT808.Gateway.Tests/JT808.Gateway.Transmit.Test/JT808DotNettyTransmitServiceTest.cs deleted file mode 100644 index d91df89..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.Transmit.Test/JT808DotNettyTransmitServiceTest.cs +++ /dev/null @@ -1,35 +0,0 @@ -using JT808.Gateway.Configs.Kafka; -using JT808.Gateway.Kafka; -using JT808.Gateway.PubSub; -using JT808.Protocol.Extensions; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace JT808.Gateway.Transmit.Test -{ - public class JT808DotNettyTransmitServiceTest - { - public readonly ILogger logger; - public JT808DotNettyTransmitServiceTest(ILoggerFactory loggerFactory) { - logger = loggerFactory.CreateLogger(); - Task.Run(() => { - while (true) - { - Thread.Sleep(5000); - using (IJT808MsgProducer jT808MsgProducer = new JT808MsgProducer(new JT808MsgProducerConfig - { - BootstrapServers = "127.0.0.1:9092", - TopicName = "JT808Msg" - })) - { - jT808MsgProducer.ProduceAsync("011111111111", "7E02000032011111111111012E00000000000C00000160E42506C30C82002C00000000180914142057010400001DC003020000250400000000300115310100977E".ToHexBytes()).Wait(); - } - } - }); - } - } -} diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.Transmit.Test/Program.cs b/src/JT808.Gateway.Tests/JT808.Gateway.Transmit.Test/Program.cs deleted file mode 100644 index d188fb1..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.Transmit.Test/Program.cs +++ /dev/null @@ -1,43 +0,0 @@ -using JT808.Gateway.BusinessServices.Transmit; -using JT808.Gateway.Kafka; -using JT808.Protocol; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using System; -using System.Threading.Tasks; - -namespace JT808.Gateway.Transmit.Test -{ - class Program - { - async static Task Main(string[] args) - { - var hostBuilder = new HostBuilder() - .UseEnvironment(args[0].Split('=')[1]) - .ConfigureAppConfiguration((hostContext, config) => { - config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory); - config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) - .AddJsonFile($"appsettings.{hostContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true); - }) - .ConfigureLogging((hostContext, configLogging) => { - configLogging.AddConsole(); - configLogging.SetMinimumLevel(LogLevel.Trace); - }) - .ConfigureServices((hostContext, services) => { - services.AddSingleton(); - services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); - services.AddSingleton(); - services.AddJT808Configure() - .AddJT808ClientKafka() - .AddMsgConsumer(hostContext.Configuration) - .AddInprocJT808Transmit(hostContext.Configuration); - services.BuildServiceProvider().GetRequiredService(); - }) - ; - - await hostBuilder.RunConsoleAsync(); - } - } -}