diff --git a/azure-pipelines-1.yml b/azure-pipelines-1.yml new file mode 100644 index 000000000..e8f3d6f54 --- /dev/null +++ b/azure-pipelines-1.yml @@ -0,0 +1,22 @@ +# Maven +# Build your Java project and run tests with Apache Maven. +# Add steps that analyze code, save build artifacts, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/java + +trigger: +- main + +pool: + vmImage: ubuntu-latest + +steps: +- task: Maven@3 + inputs: + mavenPomFile: 'pom.xml' + mavenOptions: '-Xmx3072m' + javaHomeOption: 'JDKVersion' + jdkVersionOption: '1.11' + jdkArchitectureOption: 'x64' + publishJUnitResults: true + testResultsFiles: '**/surefire-reports/TEST-*.xml' + goals: 'package' diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 000000000..03ca7d3b8 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,23 @@ +# Maven +# Build your Java project and run tests with Apache Maven. +# Add steps that analyze code, save build artifacts, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/java + +trigger: +- main +- test + +pool: + vmImage: ubuntu-latest + +steps: +- task: Maven@4 + inputs: + mavenPomFile: 'pom.xml' + mavenOptions: '-Xmx3072m' + javaHomeOption: 'JDKVersion' + jdkVersionOption: '1.11' + jdkArchitectureOption: 'x64' + publishJUnitResults: true + testResultsFiles: '**/surefire-reports/TEST-*.xml' + goals: 'package' diff --git a/src/main/java/com/microsoft/demo/Pipeline_Test.java b/src/main/java/com/microsoft/demo/Pipeline_Test.java new file mode 100644 index 000000000..ca20b39a6 --- /dev/null +++ b/src/main/java/com/microsoft/demo/Pipeline_Test.java @@ -0,0 +1,59 @@ +package com.microsoft.demo; + +import java.util.Random; + +public class Pipeline_Test { + + public String MyTestPipeline(String s){ + String rev = ""; + char [] w = s.toCharArray(); + + for(int i = s.length()-1; i>=0; i--){ + rev = rev.concat(String.valueOf(w[i])); + } + return rev; + } + + public char[] random_password(int len) + { + System.out.println("Generating password using random function : "); + System.out.print("Your new password is : "); + + // A strong password has Cap_chars, Lower_chars, + // numeric value and symbols. So we are using all of + // them to generate our password + String Capital_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + String Small_chars = "abcdefghijklmnopqrstuvwxyz"; + String numbers = "0123456789"; + String symbols = "!@#$%^&*_=+-/.?<>)"; + + + String values = Capital_chars + Small_chars + + numbers + symbols; + + // Using random method + Random rndm_method = new Random(); + + char[] password = new char[len]; + + for (int i = 0; i < len; i++) + { + // Use of charAt() method : to get character value + // Use of nextInt() as it is scanning the value as int + password[i] = + values.charAt(rndm_method.nextInt(values.length())); + + } + return password; + } + +// public static void main(String[] args) { +// +// int length = 10; +// System.out.println(random_password(length)); +// } +} + + + + diff --git a/src/test/java/MyTest.java b/src/test/java/MyTest.java index 9e1d2abed..592272c13 100644 --- a/src/test/java/MyTest.java +++ b/src/test/java/MyTest.java @@ -1,7 +1,11 @@ import com.microsoft.demo.Demo; +import com.microsoft.demo.Pipeline_Test; import org.junit.Test; public class MyTest { + + Pipeline_Test pt = new Pipeline_Test(); + String s ="ABCDEFG"; @Test public void test_method_1() { Demo d = new Demo(); @@ -11,4 +15,26 @@ public void test_method_1() { @Test public void test_method_2() { } + + @Test + public void test_method_3(){ + String rev = pt.MyTestPipeline(s); + if (rev.length()==7) + System.out.println("Test Passed on Length"); + + } + + @Test + public void test_check_length(){ + String rev = pt.MyTestPipeline(s); + if (rev.length()<9) + System.out.println("Length Not Matching..!"); + } + + @Test + public void validateRandomPassword(){ + char [] password = pt.random_password(10); + if(password.length==10) + System.out.println("Password Length Matched..!"); + } } \ No newline at end of file