Skip to content

Commit

Permalink
Adding tests for dotnet database
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulkj committed Jul 1, 2024
1 parent 7847069 commit 4ee95f3
Show file tree
Hide file tree
Showing 15 changed files with 1,242 additions and 53 deletions.
98 changes: 85 additions & 13 deletions csa-app/tests/test-cases/data_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@ category:
assert: true
assert-count: 4
assert-value: "null"
- name: "JAVA MSMQ - Code"
rule-name: java-messaging
test-filename: java-messaging-msmq-code_test-sample.java
assert: true
assert-count: 7
assert-value: "null"
- name: "PYTHON ActiveMQ - Code"
rule-name: python-messaging
test-filename: python-messaging-activemq-code_test-code.py
assert: true
assert-count: 2
assert-value: "null"
- name: "DOTNET - Caching - Apache Geode - Code"
rule-name: dotnet-cache
test-filename: dotnet-caching-apache-geode-code_test-sample.cs
Expand All @@ -42,7 +30,7 @@ category:
rule-name: dotnet-rdbms-database
test-filename: dotnet-database-postgresql-code_test-sample.cs
assert: true
assert-count: 6
assert-count: 4
assert-value: "null"
- name: "DOTNET - Databases - PostgreSQL - Package"
rule-name: dotnet-rdbms-database
Expand Down Expand Up @@ -331,4 +319,88 @@ category:
test-filename: mongodb.xml
assert: true
assert-count: 1
assert-value: "null"
- name: "JAVA MSMQ - Code"
rule-name: java-messaging
test-filename: java-messaging-msmq-code_test-sample.java
assert: true
assert-count: 7
assert-value: "null"
- name: "PYTHON ActiveMQ - Code"
rule-name: python-messaging
test-filename: python-messaging-activemq-code_test-code.py
assert: true
assert-count: 2
assert-value: "null"
- name: "DOTNET RDBMS - ConnectionStrings - Code"
rule-name: dotnet-rdbms-database
test-filename: dotnet-db_con.cs
assert: true
assert-count: 2
assert-value: "null"
- name: "DOTNET RDBMS - connectionStrings - Code"
rule-name: dotnet-rdbms-database
test-filename: dotnet-connectionstrings.config
assert: true
assert-count: 2
assert-value: "null"
- name: "DOTNET RDBMS - IBM DB2 - Code"
rule-name: dotnet-rdbms-database
test-filename: dotnet-db2.cs
assert: true
assert-count: 1
assert-value: "null"
- name: "DOTNET RDBMS - SqlServer - Code"
rule-name: dotnet-rdbms-database
test-filename: dotnet-sqlserver.cs
assert: true
assert-count: 4
assert-value: "null"
- name: "DOTNET RDBMS - MySQL - Code"
rule-name: dotnet-rdbms-database
test-filename: dotnet-mysql.cs
assert: true
assert-count: 2
assert-value: "null"
- name: "DOTNET RDBMS - Oracle - Code"
rule-name: dotnet-rdbms-database
test-filename: dotnet-oracle.cs
assert: true
assert-count: 3
assert-value: "null"
- name: "DOTNET RDBMS - Postgres - Code"
rule-name: dotnet-rdbms-database
test-filename: dotnet-postgres.cs
assert: true
assert-count: 6
assert-value: "null"
- name: "DOTNET RDBMS - ElasticSearch - Code"
rule-name: dotnet-rdbms-database
test-filename: dotnet-elasticsearch.cs
assert: true
assert-count: 1
assert-value: "null"
- name: "DOTNET NOSQL - Apache Ignite - Code"
rule-name: dotnet-nosql-database
test-filename: dotnet-apache-ignite.cs
assert: true
assert-count: 5
assert-value: "null"
- name: "DOTNET NOSQL - Cassandra - Code"
rule-name: dotnet-nosql-database
test-filename: dotnet-cassandra.cs
assert: true
assert-count: 5
assert-value: "null"
- name: "DOTNET NOSQL - GraphQL - Code"
rule-name: dotnet-nosql-database
test-filename: dotnet-graphql.cs
assert: true
assert-count: 3
assert-value: "null"
- name: "DOTNET NOSQL - MongoDB - Code"
rule-name: dotnet-nosql-database
test-filename: dotnet-mongodb.cs
assert: true
assert-count: 3
assert-value: "null"
148 changes: 148 additions & 0 deletions csa-app/tests/test-samples/dotnet-apache-ignite.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Apache.Ignite
{
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading;
using Apache.Ignite.Config;
using Apache.Ignite.Core;
using Apache.Ignite.Service;

/// <summary>
/// Runner class.
/// </summary>
public static class IgniteRunner
{
/** Help commands. */
private static readonly IList<string> Help = new List<string> { "/help", "-help", "--help" };

/** Argument meaning that this is service call. */
public const string Svc = "/service";

/** Service install command. */
public const string SvcInstall = "/install";

/** Service uninstall command. */
public const string SvcUninstall = "/uninstall";

/// <summary>
/// Application entry point.
/// </summary>
[SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "Reviewed")]
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
Justification = "Main method catches all exceptions to report them.")]
internal static void Main(string[] args)
{
bool svc = false;
bool install = false;

try
{
// Check for special cases.
if (args.Length > 0)
{
string first = args[0].ToLowerInvariant();

if (Help.Contains(first))
{
ConsoleUtils.PrintHelp("Apache.Ignite.exe", true);

return;
}

if (Svc.Equals(first, StringComparison.Ordinal))
{
args = RemoveFirstArg(args);

svc = true;
}

else if (SvcInstall.Equals(first, StringComparison.Ordinal))
{
args = RemoveFirstArg(args);

install = true;
}
else if (SvcUninstall.Equals(first, StringComparison.Ordinal))
{
IgniteService.Uninstall();

return;
}
}

if (!svc)
{
// Pick application configuration first, command line arguments second.
var allArgs = AppSettingsConfigurator.GetArgs(ConfigurationManager.AppSettings)
.Concat(ArgsConfigurator.GetArgs(args))
.ToArray();

if (install)
IgniteService.DoInstall(allArgs);
else
{
// Load assemblies before instantiating IgniteConfiguration,
// it can reference types from those assemblies.
allArgs = allArgs.LoadAssemblies().ToArray();

using (var ignite = Ignition.Start(Configurator.GetConfiguration(allArgs)))
{
// Wait until stopped.
using (var evt = new ManualResetEventSlim(false))
{
// ReSharper disable AccessToDisposedClosure
ignite.Stopped += (s, a) => evt.Set();
Console.CancelKeyPress += (s, a) => evt.Set();
evt.Wait();
// ReSharper restore AccessToDisposedClosure
}
}
}

return;
}
}
catch (Exception e)
{
Console.WriteLine("ERROR: " + e);

Environment.Exit(-1);
}

// If we are here, then this is a service call.
// Use only arguments, not app.config.
var cfg = Configurator.GetConfiguration(ArgsConfigurator.GetArgs(args).ToArray());
IgniteService.Run(cfg);
}

/// <summary>
/// Remove the first argument.
/// </summary>
/// <param name="args">Arguments.</param>
/// <returns>New arguments.</returns>
private static string[] RemoveFirstArg(string[] args)
{
return args.Skip(1).ToArray();
}
}
}
Loading

0 comments on commit 4ee95f3

Please sign in to comment.