├── README.md
├── pom.xml
└── src
├── main
├── java
│ └── org
│ │ └── easetech
│ │ └── easytest
│ │ ├── annotation
│ │ ├── Converters.java
│ │ ├── DataLoader.java
│ │ ├── Display.java
│ │ ├── Duration.java
│ │ ├── Format.java
│ │ ├── Intercept.java
│ │ ├── Parallel.java
│ │ ├── ParallelSuite.java
│ │ ├── Param.java
│ │ ├── PreserveContext.java
│ │ ├── Provided.java
│ │ ├── Repeat.java
│ │ ├── Report.java
│ │ ├── TestBean.java
│ │ ├── TestConfigProvider.java
│ │ ├── TestPolicy.java
│ │ ├── TestProperties.java
│ │ └── package-info.java
│ │ ├── converter
│ │ ├── AbstractConverter.java
│ │ ├── BaseConverter.java
│ │ ├── CollectionConverter.java
│ │ ├── ConversionDelegator.java
│ │ ├── Converter.java
│ │ ├── ConverterManager.java
│ │ ├── ConverterSupport.java
│ │ ├── DataAlreadyConvertedConverter.java
│ │ ├── JSONDataConverter.java
│ │ ├── MapConverter.java
│ │ ├── ParamAwareConverter.java
│ │ ├── ParamConstructorConverter.java
│ │ ├── PropertyEditorCollectionConverter.java
│ │ ├── PropertyEditorConverter.java
│ │ ├── StandardObjectCollectionConverter.java
│ │ ├── StandardObjectConverter.java
│ │ ├── UserDefinedCollectionConverter.java
│ │ ├── UserDefinedConverter.java
│ │ └── package-info.java
│ │ ├── exceptions
│ │ ├── ParamAssertionError.java
│ │ └── package-info.java
│ │ ├── interceptor
│ │ ├── CommonProxyInterceptor.java
│ │ ├── DefaultMethodIntercepter.java
│ │ ├── Empty.java
│ │ ├── InternalInterceptor.java
│ │ ├── InternalInvocationhandler.java
│ │ ├── MethodIntercepter.java
│ │ └── package-info.java
│ │ ├── internal
│ │ ├── DateTimeFormat.java
│ │ ├── EasyAssignments.java
│ │ ├── EasyParamSignature.java
│ │ ├── SystemProperties.java
│ │ └── package-info.java
│ │ ├── io
│ │ ├── ClasspathResource.java
│ │ ├── EmptyResource.java
│ │ ├── FileSystemResource.java
│ │ ├── Resource.java
│ │ ├── ResourceLoader.java
│ │ ├── ResourceLoaderStrategy.java
│ │ ├── UrlResource.java
│ │ └── package-info.java
│ │ ├── loader
│ │ ├── CSVDataLoader.java
│ │ ├── DataConverter.java
│ │ ├── DataLoaderUtil.java
│ │ ├── EmptyLoader.java
│ │ ├── ExcelDataLoader.java
│ │ ├── Loader.java
│ │ ├── LoaderFactory.java
│ │ ├── LoaderType.java
│ │ ├── XMLDataLoader.java
│ │ └── package-info.java
│ │ ├── reports
│ │ ├── data
│ │ │ ├── Duration.java
│ │ │ ├── DurationObserver.java
│ │ │ ├── ImageBean.java
│ │ │ ├── MethodDurationReportBean.java
│ │ │ ├── MethodUnderTestDuration.java
│ │ │ ├── ReportDataContainer.java
│ │ │ ├── ReportParametersBean.java
│ │ │ ├── ReportTotalsBean.java
│ │ │ ├── TestMethodDuration.java
│ │ │ ├── TestResultBean.java
│ │ │ └── package-info.java
│ │ ├── impl
│ │ │ ├── ReportBuilder.java
│ │ │ ├── ReportExporter.java
│ │ │ ├── ReportRunner.java
│ │ │ └── package-info.java
│ │ └── utils
│ │ │ ├── ChartUtils.java
│ │ │ ├── PieChartColorRendererHelper.java
│ │ │ └── package-info.java
│ │ ├── runner
│ │ ├── BaseSuite.java
│ │ ├── DataDrivenTestRunner.java
│ │ ├── EasyFrameworkMethod.java
│ │ ├── EasyTestRunListener.java
│ │ ├── EasyTestSuite.java
│ │ ├── InternalParameterizedStatement.java
│ │ ├── RunnerUtil.java
│ │ ├── TestConfigUtil.java
│ │ ├── TestPolicyHandler.java
│ │ ├── TestRunDurationListener.java
│ │ └── package-info.java
│ │ ├── strategy
│ │ ├── ParallelScheduler.java
│ │ ├── SchedulerStrategy.java
│ │ ├── SerialScheduler.java
│ │ └── package-info.java
│ │ └── util
│ │ ├── CommonUtils.java
│ │ ├── ConfigContext.java
│ │ ├── DataContext.java
│ │ ├── GeneralUtil.java
│ │ ├── RunAftersWithOutputData.java
│ │ ├── TestInfo.java
│ │ └── package-info.java
└── resources
│ ├── reports
│ ├── MainReport_pdf.jrxml
│ ├── MainReport_xls.jrxml
│ ├── MethodDurationReport_pdf.jrxml
│ └── MethodDurationReport_xls.jrxml
│ └── testDataSchema.xsd
└── test
├── java
└── org
│ └── easetech
│ └── easytest
│ ├── conditions
│ └── TestConditionsSupportedByDataDrivenTest.java
│ ├── example
│ ├── ComparableObject.java
│ ├── ComparableObjectConverter.java
│ ├── CustomCSVDataLoader.java
│ ├── CustomObjectDataLoader.java
│ ├── DelayedObject.java
│ ├── DelayedObjectConverter.java
│ ├── DequeConverter.java
│ ├── EnumConverter.java
│ ├── EnumObject.java
│ ├── Item.java
│ ├── ItemAndLocation.java
│ ├── ItemConverter.java
│ ├── ItemId.java
│ ├── ItemService.java
│ ├── LibraryId.java
│ ├── Location.java
│ ├── LocationId.java
│ ├── RealItemService.java
│ ├── TemperatureConverter.java
│ ├── TestBeanProviderFunctionality.java
│ ├── TestBorderConditions.java
│ ├── TestCombinedLoadingAndWriting.java
│ ├── TestConfigProviderClass.java
│ ├── TestConstructorFunctionality.java
│ ├── TestConverters.java
│ ├── TestConvertersForSuite.java
│ ├── TestDates.java
│ ├── TestDatesPolicy.java
│ ├── TestDifferentConditionsSupportedByParam.java
│ ├── TestDuration.java
│ ├── TestErrorCollector.java
│ ├── TestExcelDataLoader.java
│ ├── TestExcelDataLoaderPolicy.java
│ ├── TestJSON.java
│ ├── TestMethodInjection.java
│ ├── TestMultipleFileDataLoadedExample.java
│ ├── TestSuiteFunctionality.java
│ ├── TestTemperatureConverter.java
│ └── TestXMLDataLoader.java
│ └── interceptor
│ └── CGLIBEnhancerTest.java
└── resources
├── MultipleFileDataExampleData1.csv
├── MultipleFileDataExampleData2.csv
├── TestExcelDataLoader.csv
├── anotherConfig.properties
├── borderConditions.csv
├── borderConditions.xls
├── borderConditions.xml
├── config.properties
├── getDDTData.csv
├── getItemsData.csv
├── getItemsDataCustom.csv
├── input-data-mod-again.xml
├── input-data-mod.xml
├── input-data.xml
├── jsonBasedData.csv
├── jsonBasedData.xls
├── org
└── easetech
│ └── data
│ ├── test-combined.xls
│ ├── test-update.xls
│ ├── testExcelData.xls
│ ├── testExcelData1.xls
│ └── testExcelData2.xls
├── overrideExcelData.csv
├── paramTestConditions.csv
├── sample.xls
├── tcd.csv
└── testExcelData-update.xls
/src/main/java/org/easetech/easytest/annotation/Converters.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Inherited;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 | import org.easetech.easytest.converter.Converter;
9 |
10 | /**
11 | * Annotation to be used for declaring the converters either on a test Class or on a test method.
12 | * See {@link Converter} for more details on what Converters are and how can they be used.
13 | *
14 | * @author Anuj Kumar
15 | *
16 | */
17 | @Retention(RetentionPolicy.RUNTIME)
18 | @Target({ElementType.METHOD , ElementType.TYPE})
19 | @Inherited
20 | public @interface Converters {
21 |
22 | /**
23 | * An array of {@link Converter} classes to be registered with the EasyTest framework
24 | * @return an array of {@link Converter}s
25 | */
26 | Class extends Converter>[] value() ;
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/annotation/Display.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Annotation that defines what all fields(input attributes of the test method)
10 | * should be used in the display name of the test method.
11 | * EasyTest shows the input test data as part of the test method name in the IDE.
12 | * But sometimes the input test data is too much to be displayed and a mechanism was required
13 | * to restrict the input fields appearing in the test method name. Display annotation is that mechanism.
14 | * A user can say in the {@link #fields()} attribute what all fields should be part of the test method name.
15 | * Note that if the input test data does not contain any field specified by the {@link #fields()} attribute, EasyTest will
16 | * default back to its original behaviour, which is showing all the input fields as part of test method name.
17 | *
18 | *@author Anuj Kumar
19 | */
20 | @Retention(RetentionPolicy.RUNTIME)
21 | @Target({ElementType.METHOD , ElementType.TYPE})
22 | public @interface Display {
23 |
24 | /**
25 | * The input fields that should be part of the test method display name
26 | */
27 | String[] fields();
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/annotation/Duration.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 | import net.sf.cglib.proxy.MethodInterceptor;
8 | import org.easetech.easytest.interceptor.DefaultMethodIntercepter;
9 | import org.easetech.easytest.interceptor.Empty;
10 | import org.easetech.easytest.interceptor.MethodIntercepter;
11 |
12 | /**
13 | * Duration is similar to {@link Intercept} annotation in that it intercepts the call to the methods
14 | * of the Class annotated with Duration annotation. But it has got extra attributes for the user to specify the
15 | * maximum duration a method under test should take to execute.
16 | * If the total time taken by the method exceeds the time specified (using the attribute timeInMillis ),
17 | * the test method will fail.
18 | *
19 | * This annotation can be used both at the FIELD level as well as the METHOD level
20 | *
21 | * Usage at Field Level:
22 | *
23 | *
{@code}class TestClass {
24 | *
25 | * {@literal @}Duration(timeInMillis=100)
26 | * private ItemService testSubject;
27 | * }
28 | *
29 | * OR , in case the user also needs to specify its custom {@link MethodIntercepter} :
30 | * {@code}class TestClass {
31 | *
32 | * {@literal @}Duration(timeInMillis=100 , interceptor=MyCustomInterceptor.class)
33 | * private ItemService testSubject;
34 | * }
35 | *
36 | * In both the above cases, EasyTest will measure the time taken by each method of ItemService.
37 | * If the time taken by the method is more than the time specified, the test will fail with appropriate failure reason.
38 | *
39 | * Usage at Test Method Level
40 | *
41 | *
42 | * {@code} class TestClass {
43 | *
44 | * private ItemService testSubject;
45 | *
46 | * {@literal @}Test
47 | * {@literal @}Duration(forClass=ItemService.class , timeInMillis=50)
48 | * private Item testGetItem({@literal @}Param(name='itemId') String itemId) {
49 | * return testSubject.getItem(itemId);
50 | * }
51 | * }
52 | *
53 | * In this case, EasyTest will compare the time taken, by the method under test, with the time specified in the Duration annotation,
54 | * only for this test method.
55 | *
56 | * Special case : When the Duration annotation is specified both at the field level and at the method level
57 | *
58 | * {@code} class TestClass {
59 | * {@literal @}Duration(timeInMillis=100)
60 | * private ItemService testSubject;
61 | *
62 | * {@literal @}Test
63 | * {@literal @}Duration(forClass=ItemService.class , timeInMillis=50)
64 | * private Item testGetItem({@literal @}Param(name='itemId') String itemId) {
65 | * return testSubject.getItem(itemId);
66 | * }
67 | * }
68 | * In this case, EasyTest will override the timeInMillis value supplied at the field level, with the value supplied at the method level.
69 | * Once the method is finished, it will revert back to the original value specified at the field level. Thus if you have second test method
70 | * that does not have Duration annotation, then the measure of time taken by the method will be 100 milliseconds and not 50 ms.
71 | *
72 | * @author Anuj Kumar
73 | *
74 | */
75 | @Target({ ElementType.FIELD, ElementType.METHOD})
76 | @Retention(RetentionPolicy.RUNTIME)
77 | public @interface Duration {
78 |
79 | /** The time in milliseconds. This is the maximum time a method under test should take to execute */
80 | long timeInMillis();
81 |
82 | /** The Class that should be proxied to provide the time comparison functionality.
83 | * Only required in case the Duration annotation is specified at the test method level.
84 | * Its value will be ignored in case it is specified when the annotation is used at the field level
85 | */
86 | Class> forClass() default Empty.class;
87 |
88 | /**
89 | * The {@link MethodInterceptor} to use to intercept method calls.
90 | */
91 | Class extends MethodIntercepter> interceptor() default DefaultMethodIntercepter.class;
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/annotation/Format.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Annotation that can be used by the user to specify various formating options to be used by EasyTest while
10 | * converting the raw data to a specific object. Currently user has the option to specify the format of date, time and datetime type fields.
11 | *
12 | * @author Anuj Kumar
13 | */
14 | @Retention(RetentionPolicy.RUNTIME)
15 | @Target({ElementType.METHOD , ElementType.TYPE})
16 | public @interface Format {
17 |
18 | /**
19 | * The date formats to be used
20 | */
21 | String[] date() default "dd/MM/yyyy";
22 |
23 | /** The date time formats to be used*/
24 | String[] dateTime() default "dd/MM/yyyy HH:MM:SS";
25 |
26 | /** The time formats to be used*/
27 | String[] time() default "HH:MM:SS";
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/annotation/Intercept.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.annotation;
3 |
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 | import net.sf.cglib.proxy.MethodInterceptor;
9 | import org.easetech.easytest.interceptor.DefaultMethodIntercepter;
10 | import org.easetech.easytest.interceptor.MethodIntercepter;
11 |
12 | /**
13 | *
14 | * A field level annotation that can be used to intercept calls to methods within the subject under test. A user can
15 | * specify the interceptor it wants to use to intercept the call to the test subject's method. The interceptor should
16 | * implement {@link MethodIntercepter}. The default interceptor is {@link DefaultMethodIntercepter} that simply prints
17 | * the time taken in nano seconds by the test method on the console.
18 | * Look here for a simple example :
19 | * https://github.com/EaseTech/easytest-core/blob/master/src/test/java/org/easetech/easytest
20 | * /example/TestExcelDataLoader.java
21 | *
22 | * @author Anuj Kumar
23 | *
24 | */
25 | @Retention(RetentionPolicy.RUNTIME)
26 | @Target({ ElementType.FIELD })
27 | public @interface Intercept {
28 | /**
29 | * The {@link MethodInterceptor} to use to intercept method calls.
30 | */
31 | Class extends MethodIntercepter> interceptor() default DefaultMethodIntercepter.class;
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/annotation/Parallel.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Inherited;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 | import java.util.concurrent.Executors;
9 |
10 | /**
11 | * Class level Annotation that is used
12 | * to run tests in Parallel.
13 | * A user can use the annotation as it is without specifying
14 | * any threads value in which case {@link Executors#newCachedThreadPool()} method is used
15 | * to create a Thread Pool.
16 | * In case the value of threads attribute is specified and it is greater than 0,
17 | * {@link Executors#newFixedThreadPool(int)} method is used to create a fixed thread pool
18 | *
19 | *@author Anuj Kumar
20 | */
21 | @Retention(RetentionPolicy.RUNTIME)
22 | @Target({ElementType.TYPE})
23 | @Inherited
24 | public @interface Parallel {
25 |
26 | /** Number of threads to start while executing the test methods in the given class
27 | * If the value is ZERO or a NEGATIVE number, {@link Executors#newCachedThreadPool()} is used
28 | * to create thread pools else {@link Executors#newFixedThreadPool(int)} is used with the supplied thread count*/
29 | int threads() default 0;
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/annotation/ParallelSuite.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Inherited;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 | import java.util.concurrent.Executors;
9 | import org.junit.runners.Suite;
10 |
11 | /**
12 | * {@link Suite} level Annotation that is used
13 | * to run test classes defined in Suite, in Parallel.
14 | * A user can use the annotation as it is without specifying
15 | * any threads value in which case {@link Executors#newCachedThreadPool()} method is used
16 | * to create a Thread Pool.
17 | * In case the value of threads attribute is specified and it is greater than 0,
18 | * {@link Executors#newFixedThreadPool(int)} method is used to create a fixed thread pool
19 | *
20 | *@author Anuj Kumar
21 | */
22 | @Retention(RetentionPolicy.RUNTIME)
23 | @Target({ElementType.TYPE})
24 | @Inherited
25 | public @interface ParallelSuite {
26 |
27 | /** Number of threads to start while executing the test classes in the given suite class
28 | * If the value is ZERO or a NEGATIVE number, {@link Executors#newCachedThreadPool()} is used
29 | * to create thread pools else {@link Executors#newFixedThreadPool(int)} is used with the supplied thread count*/
30 | int threads() default 0;
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/annotation/PreserveContext.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | @Retention(RetentionPolicy.RUNTIME)
9 | @Target({ElementType.METHOD})
10 | public @interface PreserveContext {
11 |
12 | boolean value() default true;
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/annotation/Provided.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.annotation;
2 |
3 | import javax.inject.Inject;
4 |
5 | import java.lang.annotation.ElementType;
6 | import java.lang.annotation.Retention;
7 | import java.lang.annotation.RetentionPolicy;
8 | import java.lang.annotation.Target;
9 |
10 | /**
11 | * A field level annotation that can be used in the test classes
12 | * to load the values from outside the test class, for example from
13 | * a configuration file. The configuration file is provided to the test class using the
14 | * {@link TestConfigProvider} annotation at the class level.
15 | * The Test Config Provider class should have methods annotated with {@link TestBean} annotations and
16 | * should be public. It is a convenient annotation to support IoC. A user can also use {@link Inject} annotation
17 | * to achieve the same behavior.
18 | *
19 | * @author Anuj Kumar
20 | *
21 | */
22 | @Retention(RetentionPolicy.RUNTIME)
23 | @Target({ElementType.FIELD})
24 | public @interface Provided {
25 |
26 | /** The OPTIONAL name of the bean that should be loaded. If not
27 | * provided then EasyTest framework tries to load the bean using
28 | * the field's type. If the bean with Type is also not found,
29 | * then the framework searches for bean which has the same name as the name of the field
30 | */
31 | String value() default "";
32 |
33 | //Class extends FieldProvider> providerClass() default null;
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/annotation/Repeat.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Annotation to repeat the test method 'n' times where 'n' is identified by the attribute {@link #times()}
10 | * This annotation can be applied at the test method level and will
11 | * repeat a given test the number of times as specified by the times attribute.
12 | * The test will be executed with exactly the same set of parameters as specified for a single run of the test.
13 | * Note that in case you have specified 3 different input sets for the same test method and also have a Repeat annotation
14 | * on that test method with the {@link #times()} attribute set to 5, then the test will be executed for a total of 15(3 * 5) times.
15 | *
16 | * Currently, there is no way to specify the repeat for a given set of test input.
17 | *
18 | *@author Anuj Kumar
19 | */
20 | @Retention(RetentionPolicy.RUNTIME)
21 | @Target({ElementType.METHOD})
22 | public @interface Repeat {
23 |
24 | /** The number of times a given test method must be repeated*/
25 | int times();
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/annotation/Report.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Inherited;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | /**
10 | * A test class level annotation providing reporting parameters.
11 | *
12 | * @author Christiaan Mol
13 | *
14 | */
15 | @Retention(RetentionPolicy.RUNTIME)
16 | @Target({ ElementType.TYPE })
17 | @Inherited
18 | public @interface Report {
19 |
20 | public enum EXPORT_FORMAT {
21 | PDF, HTML, XLS
22 | }
23 |
24 | public enum REPORT_TYPE {
25 | DEFAULT, METHOD_DURATION //ALL, PERFORMANCE
26 | }
27 |
28 | /**
29 | * The output path where the reports should be written to. prefix with file:
30 | * will output to filesystem's directory prefix with classpath: will output
31 | * to target classpath
32 | */
33 | String outputLocation() default "";
34 |
35 | /** The output format. Defaults to PDF. */
36 | EXPORT_FORMAT[] outputFormats() default { EXPORT_FORMAT.PDF };
37 |
38 | /** The default report to be outputted */
39 | REPORT_TYPE[] reportTypes() default { REPORT_TYPE.DEFAULT };
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/annotation/TestBean.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * A Method level annotation to identify a test bean.
10 | * Since EasyTest supports Inversion of Control, A user can specify
11 | * his test beans in a config class and use the Injection mechanism of easytest to inject these test beans in the test classes.
12 | * Look at {@link Provided} annotation for details. These beans should be defined in the class that is identified by the {@link TestConfigProvider}
13 | *
14 | * @author Anuj Kumar
15 | *
16 | */
17 | @Retention(RetentionPolicy.RUNTIME)
18 | @Target({ElementType.METHOD})
19 | public @interface TestBean {
20 | /**
21 | * Optional name of the bean. If not provided, then
22 | * the return type of the method is used to identify the bean.
23 | * @return the name of the bean
24 | */
25 | String value() default "";
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/annotation/TestConfigProvider.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Inherited;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | /**
10 | * A Class level annotation used to identify the Test Configuration provider class.
11 | * This annotation is used right at the place where RunWith annotation is used.
12 | *
13 | *@author Anuj Kumar
14 | */
15 | @Retention(RetentionPolicy.RUNTIME)
16 | @Target({ElementType.TYPE})
17 | @Inherited
18 | public @interface TestConfigProvider {
19 |
20 | /**
21 | * An array of Class objects identifying the test config provider class
22 | * @return An array of Class objects identifying the test config provider class
23 | */
24 | Class>[] value();
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/annotation/TestPolicy.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Inherited;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | /**
10 | * An extremely useful annotation to define a test class policy.
11 | * A policy of the test class is basically its behavior that drives the test.
12 | * Currently , in EasyTest World, the Test Policy consists of the following annotations :
13 | * {@link Parallel}
14 | * {@link TestConfigProvider}
15 | * {@link Display}
16 | * {@link DataLoader}
17 | * {@link Report}
18 | * {@link Format}
19 | *
20 | *
21 | * Thus a user can define all the above annotation is a separate class and annotate the test class with {@link TestPolicy}
22 | * annotation and define all the class level annotations in the class referenced by the {@link TestPolicy} annotation.
23 | *
24 | * Note that a user can always override the policy specific annotation by defining the individual
25 | * annotations at the test class level. If the annotation is present both in the class referenced in {@link TestPolicy}
26 | * annotation as well as at the test class level, then the annotation at the test class level takes priority over policy level annotation.
27 | *
28 | * @author Anuj Kumar
29 | */
30 | @Retention(RetentionPolicy.RUNTIME)
31 | @Target({ElementType.TYPE})
32 | @Inherited
33 | public @interface TestPolicy {
34 |
35 | /** The class that identifies the Policy associated with the test class */
36 | Class> value();
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/annotation/TestProperties.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.annotation;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 | import java.util.Properties;
8 |
9 | /**
10 | * A Class level annotation that is applied of Config classes that defines the {@link TestBean}s.
11 | * This annotation is used to load the configuration properties, if any, for the test configuration.
12 | * This annotation can be used both on the Config classes as well as on the actual Test classes.
13 | * When you use this annotation, be sure to provide a field of type {@link Properties}
14 | * in the class on which the annotation is used. This property will be provided the value of the loaded Properties
15 | * at runtime by the framework.
16 | *
17 | * NOTE: For the moment the annotation does not work properly at the class level. This is a known bug and will be fixed in a future release.
18 | *
19 | *
20 | *@author Anuj Kumar
21 | */
22 | @Retention(RetentionPolicy.RUNTIME)
23 | @Target({ElementType.TYPE , ElementType.FIELD})
24 | public @interface TestProperties {
25 |
26 | /**
27 | * The array of file paths from where to load the resource.
28 | *
29 | */
30 | String[] value();
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/annotation/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Package containing EasyTest specific annotations.
3 | *
4 | *
5 | */
6 |
7 | package org.easetech.easytest.annotation;
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/converter/BaseConverter.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.converter;
2 |
3 |
4 | /**
5 | *
6 | * A base Converter for all the converters in EasyTest.
7 | *
8 | * @param the data to convert from
9 | * @param the data to convert to
10 | *
11 | * @author Anuj Kumar
12 | */
13 | public interface BaseConverter {
14 |
15 | /**
16 | * Constant for Empty String
17 | */
18 | public static final String EMPTY_STRING = "";
19 |
20 |
21 |
22 | public static final String COLON = ":";
23 |
24 | /**
25 | * Convert the passed object into a user defined data.
26 | * @param convertFrom the object to convert from
27 | * @return the object to convert to
28 | */
29 | TO convert(FROM convertFrom);
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/converter/Converter.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.converter;
2 |
3 | import java.util.Map;
4 |
5 | /**
6 | *
7 | * A generic interface responsible for converting a Map object into a user defined object.
8 | * The Map object is of type Map<String,List<Map<String,Object>>>
9 | * It can be read as Map of MethodName as KEY and List of Map of MethodAttributes/MethodAttributeValues as Value.
10 | * Users should normally extend {@link AbstractConverter} instead of implementing this interface as the abstract converter
11 | * has implementation to methods {@link #convertTo()} and {@link #instanceOfType()}
12 | *
13 | * For an example of writing a converter, look at :
14 | * https://github.com/EaseTech/easytest-core/blob/master/src/test/java/org/easetech/easytest/example/ItemConverter.java
15 | *
16 | * @param the type of object to convert to from a map.
17 | *
18 | * @author Anuj Kumar
19 | */
20 | public interface Converter extends BaseConverter, TO>{
21 |
22 | /**
23 | * The class of the generic type argument to which the data should be converted to.
24 | * @return the class of the object to convert to
25 | */
26 | Class convertTo();
27 |
28 | /**
29 | * Convert the Map into a user defined object.
30 | * @param convertFrom the {@link Map} to convert from
31 | * @return the object to convert to identified by {@link #convertTo()} class.
32 | */
33 | TO convert(Map convertFrom);
34 |
35 | /**
36 | * Method responsible for returning an instance of the provided Generic Type argument.
37 | * Look at {@link AbstractConverter#instanceOfType()} methods Javadoc for details on the default implementation.
38 | * @return an instance of the provided Generic Type argument.
39 | */
40 | TO instanceOfType();
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/converter/ConverterManager.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.converter;
3 |
4 | import java.util.HashSet;
5 | import java.util.Iterator;
6 | import java.util.Set;
7 |
8 | /**
9 | * A class that manages the registered Converters and makes them available to the framework.
10 | * This class can be used to locate a {@link Converter} for any given type name.
11 | *
12 | * @author Anuj Kumar
13 | *
14 | */
15 | @SuppressWarnings("rawtypes")
16 | public class ConverterManager {
17 |
18 | /**
19 | * A thread local variable that will hold the set of {@link Converter} for easy consumption by the test cases.
20 | */
21 | public static final InheritableThreadLocal> converters = new InheritableThreadLocal>();
22 |
23 | /**
24 | * Find the registered Converter for the given class type
25 | *
26 | * @param targetType the class type to find teh converter for.
27 | * @return an instance of registered converter or Null if not found.
28 | */
29 | public static Converter> findConverter(Class> targetType) {
30 |
31 | Set cnvrtrs = converters.get();
32 | Converter result = null;
33 | if (cnvrtrs != null) {
34 | Iterator itr = cnvrtrs.iterator();
35 |
36 | while (itr.hasNext()) {
37 | Converter converter = itr.next();
38 | if (converter.convertTo().equals(targetType)) {
39 | result = converter;
40 | break;
41 | }
42 | }
43 | }
44 |
45 | return result;
46 | }
47 |
48 | /**
49 | * Register the converter with the ConverterManager
50 | *
51 | * @param converterClass the class object identifying the concrete {@link Converter} class.
52 | */
53 | public static void registerConverter(Class converterClass) {
54 | Set cnvrtrs = converters.get();
55 | if (cnvrtrs == null) {
56 | cnvrtrs = new HashSet();
57 | }
58 | if (converterClass != null && Converter.class.isAssignableFrom(converterClass)) {
59 | Converter converter = null;
60 | try {
61 | converter = (Converter) converterClass.newInstance();
62 | cnvrtrs.add(converter);
63 | converters.set(cnvrtrs);
64 | } catch (InstantiationException e) {
65 | throw new RuntimeException(
66 | "InstantiationException occured while trying to register a converter with class : "
67 | + converterClass, e);
68 | } catch (IllegalAccessException e) {
69 | throw new RuntimeException(
70 | "IllegalAccessException occured while trying to register a converter with class : "
71 | + converterClass, e);
72 | }
73 |
74 | } else {
75 | throw new RuntimeException("Could not register the converter for " + converterClass
76 | + " . Either the passed argument is NULL or the passed class does not extend the "
77 | + AbstractConverter.class.getSimpleName() + " abstract class or implement the "
78 | + Converter.class.getSimpleName() + " interface.");
79 | }
80 |
81 | }
82 |
83 | /**
84 | * Clean the thread local variable
85 | */
86 | public static void cleanConverters() {
87 | converters.remove();
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/converter/ConverterSupport.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.converter;
2 |
3 | import org.easetech.easytest.internal.DateTimeFormat;
4 |
5 | /**
6 | * A convenient support class that gives users access to various defined
7 | * parameters that may be useful during data conversion
8 | */
9 | public class ConverterSupport {
10 |
11 | /** The name of the parameter to which this converter is serving */
12 | private String paramName;
13 |
14 | /**
15 | * Whether empty values should be converted to Null values or not
16 | */
17 | private Boolean convertEmptyToNull;
18 |
19 | /**
20 | * The user specified date time format to use
21 | */
22 | private DateTimeFormat dateTimeFormat;
23 |
24 | /**
25 | * The name of the parameter to which this converter is serving
26 | * @return the paramName
27 | */
28 | public String getParamName() {
29 | return paramName;
30 | }
31 |
32 | /**
33 | * The name of the parameter to which this converter is serving
34 | * @param paramName the paramName to set
35 | */
36 | public void setParamName(String paramName) {
37 | this.paramName = paramName;
38 | }
39 |
40 | /**
41 | * Whether empty values should be converted to Null values or not
42 | * @return the convertEmptyToNull
43 | */
44 | public Boolean getConvertEmptyToNull() {
45 | return convertEmptyToNull;
46 | }
47 |
48 | /**
49 | * Whether empty values should be converted to Null values or not
50 | * @param convertEmptyToNull the convertEmptyToNull to set
51 | */
52 | public void setConvertEmptyToNull(Boolean convertEmptyToNull) {
53 | this.convertEmptyToNull = convertEmptyToNull;
54 | }
55 |
56 | /**
57 | * The user specified date time format to use
58 | * @return the dateTimeFormat
59 | */
60 | public DateTimeFormat getDateTimeFormat() {
61 | return dateTimeFormat;
62 | }
63 |
64 | /**
65 | * The user specified date time format to use
66 | * @param dateTimeFormat the dateTimeFormat to set
67 | */
68 | public void setDateTimeFormat(DateTimeFormat dateTimeFormat) {
69 | this.dateTimeFormat = dateTimeFormat;
70 | }
71 |
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/converter/DataAlreadyConvertedConverter.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.converter;
3 |
4 | import org.slf4j.Logger;
5 | import org.slf4j.LoggerFactory;
6 |
7 | import java.util.ArrayList;
8 | import org.easetech.easytest.util.GeneralUtil;
9 |
10 | import java.util.List;
11 | import java.util.Map;
12 | import org.junit.experimental.theories.PotentialAssignment;
13 |
14 | /**
15 | *
16 | * An instance of {@link BaseConverter} that is responsible for getting the already converted data and
17 | * creating a list of {@link PotentialAssignment}s that is understood by EasyTest Framework.
18 | *
19 | * @author Anuj Kumar
20 | *
21 | */
22 | public class DataAlreadyConvertedConverter implements
23 | BaseConverter>, List> {
24 |
25 | /**
26 | * Logger
27 | */
28 | private static final Logger LOG = LoggerFactory.getLogger(DataAlreadyConvertedConverter.class);
29 |
30 | /**
31 | * The type of parameter to convert the raw data to
32 | */
33 | private final Class> parameterType;
34 |
35 | /**
36 | * The name of the parameter that is being converted
37 | */
38 | private final String paramName;
39 |
40 | /**
41 | * Whether empty values should be converted to Null values or not
42 | */
43 | private final Boolean convertEmptyToNull;
44 |
45 | /**
46 | *
47 | * Construct a new DataAlreadyConvertedConverter
48 | * @param parameterType The type of parameter to convert the raw data to
49 | * @param paramName The name of the parameter that is being converted
50 | * @param convertEmptyToNull Whether empty values should be converted to Null values or not
51 | */
52 | public DataAlreadyConvertedConverter(Class> parameterType, String paramName, Boolean convertEmptyToNull) {
53 | super();
54 | this.parameterType = parameterType;
55 | this.paramName = paramName;
56 | this.convertEmptyToNull = convertEmptyToNull;
57 | }
58 |
59 | /**
60 | * Handle the data that has already been converted by the user.
61 | * @param convertFrom the data to handle
62 | * @return the list of PotentialAssignemnts
63 | */
64 | public List convert(List> convertFrom) {
65 | LOG.debug("Trying to verify whether the data has already been converted by the user or not");
66 | List potentialAssignments = null;
67 | if (GeneralUtil.dataAlreadyConverted(parameterType, convertFrom, paramName)) {
68 | LOG.debug("Data is converted by the user. Filling it up");
69 | potentialAssignments = new ArrayList();
70 | Object value = null;
71 | for (Map object : convertFrom) {
72 | if (String.class.isAssignableFrom(parameterType)) {
73 | if (convertEmptyToNull) {
74 | if (object.get(paramName) != null && "".equals(object.get(paramName).toString())) {
75 | potentialAssignments.add(PotentialAssignment.forValue(EMPTY_STRING, value));
76 | } else {
77 | potentialAssignments.add(PotentialAssignment.forValue(EMPTY_STRING, object.get(paramName)));
78 | }
79 | } else {
80 | potentialAssignments.add(PotentialAssignment.forValue(EMPTY_STRING, object.get(paramName)));
81 | }
82 | } else {
83 | potentialAssignments.add(PotentialAssignment.forValue(EMPTY_STRING, object.get(paramName)));
84 | }
85 |
86 | }
87 | }
88 | return potentialAssignments;
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/converter/JSONDataConverter.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.converter;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.Map;
6 | import org.easetech.easytest.util.GeneralUtil;
7 | import org.junit.experimental.theories.PotentialAssignment;
8 | import org.slf4j.Logger;
9 | import org.slf4j.LoggerFactory;
10 |
11 | /**
12 | *
13 | * An instance of {@link BaseConverter} that is responsible for converting the raw JSON data in to auser defined type instance
14 | *
15 | * @author Anuj Kumar
16 | *
17 | */
18 | public class JSONDataConverter implements BaseConverter>, List> {
19 |
20 | /**
21 | * The type of parameter to convert to
22 | */
23 | private final Class> parameterType;
24 |
25 | /**
26 | * The name of the parameter that is being converted
27 | */
28 | private final String paramName;
29 |
30 | /**
31 | * Logger
32 | */
33 | private static final Logger LOG = LoggerFactory.getLogger(JSONDataConverter.class);
34 |
35 | /**
36 | *
37 | * Construct a new JSONDataConverter
38 | * @param parameterType The type of parameter to convert to
39 | * @param paramName The name of the parameter that is being converted
40 | */
41 | public JSONDataConverter(Class> parameterType, String paramName) {
42 | this.parameterType = parameterType;
43 | this.paramName = paramName;
44 | }
45 |
46 | /**
47 | * Convert the raw data into a list of {@link PotentialAssignment} instance
48 | * that EasyTest uses to provide the right set of test data to the test method
49 | * @param convertFrom the raw data to convert from
50 | * @return the list of {@link PotentialAssignment} instances
51 | */
52 | public List convert(List> convertFrom) {
53 | LOG.debug("Trying to see if the provided data is JSON Data. ");
54 | List potentialAssignments = new ArrayList();
55 | Boolean populated = GeneralUtil.populateJSONData(parameterType , convertFrom, potentialAssignments, paramName);
56 | if(!populated) {
57 | potentialAssignments = null;
58 | }
59 | return potentialAssignments;
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/converter/MapConverter.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.converter;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import java.util.Map;
6 | import org.junit.experimental.theories.PotentialAssignment;
7 | import org.slf4j.Logger;
8 | import org.slf4j.LoggerFactory;
9 |
10 | /**
11 | *
12 | * An instance of {@link BaseConverter} that is responsible for converting the raw data in to a user defined Map type instance
13 | *
14 | * @author Anuj Kumar
15 | *
16 | */
17 | public class MapConverter implements BaseConverter> , List> {
18 |
19 | /**
20 | * Logger
21 | */
22 | private static final Logger LOG = LoggerFactory.getLogger(MapConverter.class);
23 |
24 | /**
25 | * The type of Map to convert to
26 | */
27 | private final Class> mapType;
28 |
29 | /**
30 | *
31 | * Construct a new MapConverter
32 | * @param mapType the type of map to convert to
33 | */
34 | public MapConverter(Class> mapType) {
35 | this.mapType = mapType;
36 | }
37 |
38 |
39 | /**
40 | * Convert the given list of raw data to a list of map instance
41 | * @param convertFrom the data to convert from
42 | * @return the list of {@link PotentialAssignment}
43 | */
44 | @SuppressWarnings("unchecked")
45 | public List convert(List> convertFrom) {
46 | List potentialAssignments = null;
47 | if (Map.class.isAssignableFrom(mapType)) {
48 | potentialAssignments = new ArrayList();
49 | for (Map map : convertFrom) {
50 | if (mapType.isInterface()) {
51 | potentialAssignments.add(PotentialAssignment.forValue(EMPTY_STRING, map));
52 | } else {
53 | Map dataValues;
54 | try {
55 | dataValues = (Map) mapType.newInstance();
56 | } catch (Exception e) {
57 | LOG.error(
58 | "Exception occured while trying to convert the data to Map(using newInstance() method). "
59 | + "The type of Map passed as input parameter is :" + mapType, e);
60 | throw new RuntimeException(e);
61 | }
62 | dataValues.putAll(map);
63 | potentialAssignments.add(PotentialAssignment.forValue(EMPTY_STRING, dataValues));
64 | }
65 |
66 | }
67 | }
68 |
69 | return potentialAssignments;
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/converter/ParamAwareConverter.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.converter;
2 |
3 | import java.util.Map;
4 |
5 | /**
6 | * Decorator of {@link Converter} to provide the name of the parameter
7 | * to the implementing class. Users who are extending from {@link AbstractConverter}
8 | * will have no effect on their existing converters. On top of that they will now
9 | * have access to the parameter name using the {@link AbstractConverter#getParamName()} method.
10 | * Users who are directly implementing {@link Converter} interface will have to switch to either
11 | * {@link ParamAwareConverter} or {@link AbstractConverter} to get the parameter name.
12 | *
13 | * @param the type of object to convert to from a map.
14 | *
15 | * @author Anuj Kumar
16 | */
17 | public interface ParamAwareConverter extends Converter {
18 |
19 | /**
20 | * Convert the Map into a user defined object and also expect the param name
21 | * @param convertFrom the {@link Map} to convert from
22 | * @param paramName the name of the parameter for which this converter is called
23 | * @return the object to convert to identified by {@link #convertTo()} class.
24 | */
25 | Type convert(Map convertFrom , String paramName);
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/converter/ParamConstructorConverter.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.converter;
2 |
3 | import org.easetech.easytest.internal.DateTimeFormat;
4 |
5 | import java.util.ArrayList;
6 | import java.util.Collection;
7 | import java.util.List;
8 | import java.util.Map;
9 | import org.easetech.easytest.util.GeneralUtil;
10 | import org.junit.experimental.theories.PotentialAssignment;
11 | import org.slf4j.Logger;
12 | import org.slf4j.LoggerFactory;
13 |
14 | /**
15 | *
16 | * An instance of {@link BaseConverter} that is responsible for converting the raw data in to a user defined type instance
17 | * using the type's constructor
18 | *
19 | * @author Anuj Kumar
20 | *
21 | */
22 | public class ParamConstructorConverter implements BaseConverter>, List> {
23 |
24 | /**
25 | * The type of parameter to convert to
26 | */
27 | private final Class> parameterType;
28 |
29 | /**
30 | * The name of the parameter that is being converted
31 | */
32 | private final String paramName;
33 |
34 | /**
35 | * The optional collection instance in case of Collection type parameter
36 | */
37 | private final Collection collection;
38 |
39 | /**
40 | * Whether empty values should be converted to null or not
41 | */
42 | private final Boolean convertEmptyToNull;
43 |
44 | /**
45 | * the user specified date time format to use
46 | */
47 | private final DateTimeFormat dateTimeFormat;
48 |
49 | /**
50 | * Logger
51 | */
52 | private static final Logger LOG = LoggerFactory.getLogger(JSONDataConverter.class);
53 |
54 | /**
55 | *
56 | * Construct a new ParamConstructorConverter
57 | * @param parameterType The type of parameter to convert to
58 | * @param paramName The name of the parameter that is being converted
59 | * @param collection The optional collection instance in case of Collection type parameter
60 | * @param convertEmptyToNull whether empty string be converted to null or not
61 | * @param dateTimeFormat the user specified date time format to use
62 | */
63 | public ParamConstructorConverter(Class> parameterType, String paramName, Collection collection, Boolean convertEmptyToNull , DateTimeFormat dateTimeFormat) {
64 | this.parameterType = parameterType;
65 | this.paramName = paramName;
66 | this.collection = collection;
67 | this.convertEmptyToNull = convertEmptyToNull;
68 | this.dateTimeFormat = dateTimeFormat;
69 | }
70 |
71 | /**
72 | * Convert the raw data into a list of {@link PotentialAssignment} instance
73 | * that EasyTest uses to provide the right set of test data to the test method
74 | * @param convertFrom the raw data to convert from
75 | * @return the list of {@link PotentialAssignment} instances
76 | */
77 | public List convert(List> convertFrom) {
78 | LOG.debug("Trying to call the constructor, if any of the class {} to populate the data" , parameterType);
79 | List potentialAssignments = new ArrayList();
80 | Boolean populated = false;
81 | try {
82 | populated = GeneralUtil.fillDataUsingConstructor(parameterType, convertFrom, potentialAssignments, paramName, collection , convertEmptyToNull , dateTimeFormat);
83 | } catch (Exception e) {
84 | LOG.debug("Exception occured while trying to populate the data by instantiating the parameter object" , e);
85 | potentialAssignments = null;
86 | }
87 | if(!populated) {
88 | potentialAssignments = null;
89 | }
90 | return potentialAssignments;
91 |
92 | }
93 |
94 | }
95 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/converter/PropertyEditorCollectionConverter.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.converter;
2 |
3 | import java.beans.PropertyEditor;
4 | import java.beans.PropertyEditorManager;
5 | import java.util.ArrayList;
6 | import java.util.Collection;
7 | import java.util.List;
8 | import java.util.Map;
9 | import org.easetech.easytest.internal.EasyParamSignature;
10 | import org.easetech.easytest.util.GeneralUtil;
11 | import org.junit.experimental.theories.PotentialAssignment;
12 | import org.slf4j.Logger;
13 | import org.slf4j.LoggerFactory;
14 |
15 | /**
16 | *
17 | * An instance of {@link BaseConverter} that is responsible for converting the raw data in to a user defined type instance
18 | * using any registered Property Editors
19 | *
20 | * @author Anuj Kumar
21 | *
22 | */
23 | public class PropertyEditorCollectionConverter implements BaseConverter>, List> {
24 |
25 | /**
26 | * an instance of {@link EasyParamSignature}
27 | */
28 | private final EasyParamSignature signature;
29 |
30 | /**
31 | * The name of the parameter that is being converted
32 | */
33 | private final String paramName;
34 |
35 | /**
36 | * The collection instance in case of Collection type parameter
37 | */
38 | private final Collection collection;
39 |
40 |
41 | /**
42 | * Logger
43 | */
44 | private static final Logger LOG = LoggerFactory.getLogger(PropertyEditorCollectionConverter.class);
45 |
46 | /**
47 | *
48 | * Construct a new PropertyEditorCollectionConverter
49 | * @param signature an instance of {@link EasyParamSignature}
50 | * @param paramName The name of the parameter that is being converted
51 | * @param collection The collection instance in case of Collection type parameter
52 | */
53 | public PropertyEditorCollectionConverter(EasyParamSignature signature, String paramName, Collection collection) {
54 | super();
55 | this.signature = signature;
56 | this.paramName = paramName;
57 | this.collection = collection;
58 | }
59 |
60 | /**
61 | * Convert the raw data into a list of {@link PotentialAssignment} instance
62 | * that EasyTest uses to provide the right set of test data to the test method
63 | * @param convertFrom the raw data to convert from
64 | * @return the list of {@link PotentialAssignment} instances
65 | */
66 | @SuppressWarnings("unchecked")
67 | public List convert(List> convertFrom) {
68 | List potentialAssignments = null;
69 | Class> genericType = signature.getIsGenericParameter() ? signature.getGenericParameterArgType()
70 | : Object.class;
71 | PropertyEditor editor = PropertyEditorManager.findEditor(genericType);
72 | if (editor != null) {
73 | potentialAssignments = new ArrayList();
74 | LOG.debug("Editor for class {} found", genericType);
75 | for (Map object : convertFrom) {
76 | String strValue;
77 | if (paramName != null && !EMPTY_STRING.equals(paramName)) {
78 | strValue = GeneralUtil.getStringValue(paramName, object);
79 | } else {
80 | strValue = GeneralUtil.getStringValue(genericType.getSimpleName(), object);
81 | }
82 | if (strValue != null) {
83 | String[] values = strValue.split(COLON);
84 | for (int i = 0; i < values.length; i++) {
85 | editor.setAsText(values[i]);
86 | if (editor.getValue() != null) {
87 | collection.add(editor.getValue());
88 | }
89 | }
90 | }
91 | potentialAssignments.add(PotentialAssignment.forValue(EMPTY_STRING, collection));
92 | }
93 |
94 | }
95 | return potentialAssignments;
96 | }
97 |
98 |
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/converter/PropertyEditorConverter.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.converter;
2 |
3 | import java.beans.PropertyEditor;
4 | import java.beans.PropertyEditorManager;
5 | import java.util.ArrayList;
6 | import java.util.List;
7 | import java.util.Map;
8 | import org.easetech.easytest.util.GeneralUtil;
9 | import org.junit.experimental.theories.PotentialAssignment;
10 | import org.slf4j.Logger;
11 | import org.slf4j.LoggerFactory;
12 |
13 | /**
14 | *
15 | * An instance of {@link BaseConverter} that is responsible for converting the raw data in to a user defined type instance
16 | * using any registered Property Editors
17 | *
18 | * @author Anuj Kumar
19 | *
20 | */
21 | public class PropertyEditorConverter implements BaseConverter>, List> {
22 |
23 | /**
24 | * Logger
25 | */
26 | private static final Logger LOG = LoggerFactory.getLogger(PropertyEditorConverter.class);
27 |
28 | /**
29 | * The type of parameter to convert the raw data to
30 | */
31 | private final Class> parameterType;
32 |
33 | /**
34 | * The name of the parameter that is being converted
35 | */
36 | private final String paramName;
37 |
38 | /**
39 | *
40 | * Construct a new PropertyEditorConverter
41 | * @param parameterType The type of parameter to convert the raw data to
42 | * @param paramName The name of the parameter that is being converted
43 | */
44 | public PropertyEditorConverter(Class> parameterType, String paramName) {
45 | this.parameterType = parameterType;
46 | this.paramName = paramName;
47 | }
48 |
49 | /**
50 | * Convert the raw data into a list of {@link PotentialAssignment} instance
51 | * that EasyTest uses to provide the right set of test data to the test method
52 | * @param convertFrom the raw data to convert from
53 | * @return the list of {@link PotentialAssignment} instances
54 | */
55 | public List convert(List> convertFrom) {
56 | LOG.debug("Trying to convert the data using any registered Property Editors. The class responsible for conversion is {}" , PropertyEditorConverter.class.getSimpleName());
57 | List potentialAssignments = null;
58 | PropertyEditor editor = PropertyEditorManager.findEditor(parameterType);
59 | if (editor != null) {
60 | potentialAssignments = new ArrayList();
61 | LOG.debug("Editor for class {} found", parameterType);
62 | for (Map object : convertFrom) {
63 | if (paramName != null && !EMPTY_STRING.equals(paramName)) {
64 | if (GeneralUtil.getStringValue(paramName, object) != null) {
65 | editor.setAsText(GeneralUtil.getStringValue(paramName, object));
66 | }
67 |
68 | } else {
69 | if(GeneralUtil.getStringValue(parameterType.getSimpleName(), object) != null){
70 | editor.setAsText(GeneralUtil.getStringValue(parameterType.getSimpleName(), object));
71 | }
72 | }
73 | // add data to PotentialAssignment even if it is null
74 | potentialAssignments.add(PotentialAssignment.forValue(EMPTY_STRING, editor.getValue()));
75 |
76 | }
77 |
78 | }
79 | return potentialAssignments;
80 | }
81 |
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/converter/StandardObjectCollectionConverter.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.converter;
2 |
3 | import org.easetech.easytest.internal.DateTimeFormat;
4 |
5 | import java.util.ArrayList;
6 | import java.util.Collection;
7 | import java.util.List;
8 | import java.util.Map;
9 | import org.easetech.easytest.internal.EasyParamSignature;
10 | import org.easetech.easytest.util.GeneralUtil;
11 | import org.junit.experimental.theories.PotentialAssignment;
12 | import org.slf4j.Logger;
13 | import org.slf4j.LoggerFactory;
14 |
15 | /**
16 | *
17 | * An instance of {@link BaseConverter} that is responsible for converting the raw data in to a user defined type instance
18 | * using any jav standard object
19 | *
20 | * @author Anuj Kumar
21 | *
22 | */
23 | public class StandardObjectCollectionConverter implements BaseConverter>, List> {
24 |
25 | /**
26 | * The collection instance in case of Collection type parameter
27 | */
28 | private final Collection collection;
29 |
30 | /**
31 | * an instance of {@link EasyParamSignature}
32 | */
33 | private final EasyParamSignature signature;
34 |
35 | /**
36 | * The name of the parameter that is being converted
37 | */
38 | private final String paramName;
39 |
40 | /**
41 | * Whether empty values should be converted to Null values or not
42 | */
43 | private final Boolean convertEmptyToNull;
44 |
45 | /**
46 | * User specified date time format to use
47 | */
48 | private final DateTimeFormat dateTimeFormat;
49 |
50 | /**
51 | *
52 | * Construct a new StandardObjectCollectionConverter
53 | * @param collection The collection instance in case of Collection type parameter
54 | * @param signature an instance of {@link EasyParamSignature}
55 | * @param paramName The name of the parameter that is being converted
56 | * @param convertEmptyToNull whether empty values be converted to null or not
57 | * @param dateTimeFormat user specified date time format
58 | */
59 | public StandardObjectCollectionConverter(Collection collection, EasyParamSignature signature, String paramName , Boolean convertEmptyToNull , DateTimeFormat dateTimeFormat) {
60 | super();
61 | this.collection = collection;
62 | this.signature = signature;
63 | this.paramName = paramName;
64 | this.convertEmptyToNull = convertEmptyToNull;
65 | this.dateTimeFormat = dateTimeFormat;
66 | }
67 |
68 | /**
69 | * Logger
70 | */
71 | private static final Logger LOG = LoggerFactory.getLogger(StandardObjectCollectionConverter.class);
72 |
73 | /**
74 | * Convert the raw data into a list of {@link PotentialAssignment} instance
75 | * that EasyTest uses to provide the right set of test data to the test method
76 | * @param convertFrom the raw data to convert from
77 | * @return the list of {@link PotentialAssignment} instances
78 | */
79 | @SuppressWarnings({ "unchecked" })
80 | public List convert(List> convertFrom) {
81 | List potentialAssignments = null;
82 | Class> genericType = signature.getIsGenericParameter() ? signature.getGenericParameterArgType()
83 | : Object.class;
84 | if (GeneralUtil.isStandardObjectInstance(genericType)) {
85 | potentialAssignments = new ArrayList();
86 | LOG.debug(
87 | "parameter to the collection is a Standard Java Class {} . Using Internal Editors to resolve values",
88 | genericType);
89 |
90 | for (Map object : convertFrom) {
91 | String[] strValues = ((String) object.get(paramName)).split(COLON);
92 | for (int i = 0; i < strValues.length; i++) {
93 | collection.add(GeneralUtil.convertToTargetType(genericType, strValues[i], convertEmptyToNull , dateTimeFormat));
94 | }
95 | potentialAssignments.add(PotentialAssignment.forValue(EMPTY_STRING, collection));
96 | }
97 | }
98 | return potentialAssignments;
99 |
100 | }
101 |
102 | }
103 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/converter/StandardObjectConverter.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.converter;
3 |
4 | import org.easetech.easytest.internal.DateTimeFormat;
5 |
6 | import java.util.ArrayList;
7 | import java.util.List;
8 | import java.util.Map;
9 | import org.easetech.easytest.util.GeneralUtil;
10 | import org.junit.experimental.theories.PotentialAssignment;
11 | import org.slf4j.Logger;
12 | import org.slf4j.LoggerFactory;
13 |
14 | /**
15 | *
16 | * An instance of {@link BaseConverter} that is responsible for converting the raw data in to a user defined type instance
17 | * using any java standard object
18 | *
19 | * @author Anuj Kumar
20 | *
21 | */
22 | public class StandardObjectConverter implements BaseConverter>, List> {
23 |
24 | /**
25 | * The type of parameter to convert the raw data to
26 | */
27 | private final Class> parameterType;
28 |
29 | /**
30 | * The name of the parameter that is being converted
31 | */
32 | private final String paramName;
33 |
34 | /**
35 | * Whether empty values should be converted to Null values or not
36 | */
37 | private final Boolean convertEmptyToNull;
38 |
39 | /**
40 | * The user specified date time format to use
41 | */
42 | private final DateTimeFormat dateTimeFormat;
43 |
44 | /**
45 | * Logger
46 | */
47 | private static final Logger LOG = LoggerFactory.getLogger(StandardObjectConverter.class);
48 |
49 | /**
50 | *
51 | * Construct a new StandardObjectConverter
52 | * @param parameterType The type of parameter to convert the raw data to
53 | * @param paramName The name of the parameter that is being converted
54 | * @param convertEmptyToNull Whether empty values should be converted to Null values or not
55 | * @param dateTimeFormat The user specified date time format to use
56 | */
57 | public StandardObjectConverter(Class> parameterType, String paramName , Boolean convertEmptyToNull , DateTimeFormat dateTimeFormat) {
58 | this.parameterType = parameterType;
59 | this.paramName = paramName;
60 | this.convertEmptyToNull = convertEmptyToNull;
61 | this.dateTimeFormat = dateTimeFormat;
62 | }
63 |
64 | /**
65 | * Convert the raw data into a list of {@link PotentialAssignment} instance
66 | * that EasyTest uses to provide the right set of test data to the test method
67 | * @param convertFrom the raw data to convert from
68 | * @return the list of {@link PotentialAssignment} instances
69 | */
70 | public List convert(List> convertFrom) {
71 | LOG.debug("Trying to convert the data to a standard Object instance using {}" , StandardObjectConverter.class.getSimpleName());
72 | List potentialAssignments = null;
73 | if (GeneralUtil.isStandardObjectInstance(parameterType)) {
74 | potentialAssignments = new ArrayList();
75 | for (Map object : convertFrom) {
76 | potentialAssignments.add(PotentialAssignment.forValue(EMPTY_STRING,
77 | GeneralUtil.convertToTargetType(parameterType, object.get(paramName) , convertEmptyToNull, dateTimeFormat)));
78 | }
79 | }
80 |
81 | return potentialAssignments;
82 | }
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/converter/UserDefinedCollectionConverter.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.converter;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Collection;
5 | import java.util.HashMap;
6 | import java.util.List;
7 | import java.util.Map;
8 | import org.easetech.easytest.internal.EasyParamSignature;
9 | import org.junit.experimental.theories.PotentialAssignment;
10 | import org.slf4j.Logger;
11 | import org.slf4j.LoggerFactory;
12 |
13 | /**
14 | *
15 | * An instance of {@link BaseConverter} that is responsible for converting the raw data in to a user defined type instance
16 | * using any user defined converter
17 | *
18 | * @author Anuj Kumar
19 | *
20 | */
21 | public class UserDefinedCollectionConverter implements BaseConverter>, List> {
22 |
23 |
24 | /**
25 | * The collection instance in case of Collection type parameter
26 | */
27 | private final Collection collection;
28 |
29 | /**
30 | * an instance of {@link EasyParamSignature}
31 | */
32 | private final EasyParamSignature signature;
33 |
34 | /**
35 | * The name of the parameter that is being converted
36 | */
37 | private final String paramName;
38 |
39 |
40 | /**
41 | *
42 | * Construct a new UserDefinedCollectionConverter
43 | * @param signature an instance of {@link EasyParamSignature}
44 | * @param paramName The name of the parameter that is being converted
45 | * @param collection The collection instance in case of Collection type parameter
46 | */
47 | public UserDefinedCollectionConverter(EasyParamSignature signature, String paramName, Collection collection) {
48 | super();
49 | this.signature = signature;
50 | this.paramName = paramName;
51 | this.collection = collection;
52 | }
53 |
54 | /**
55 | * Logger
56 | */
57 | private static final Logger LOG = LoggerFactory.getLogger(UserDefinedCollectionConverter.class);
58 |
59 | /**
60 | * Convert the raw data into a list of {@link PotentialAssignment} instance
61 | * that EasyTest uses to provide the right set of test data to the test method
62 | * @param convertFrom the raw data to convert from
63 | * @return the list of {@link PotentialAssignment} instances
64 | */
65 | @SuppressWarnings("unchecked")
66 | public List convert(List> convertFrom) {
67 |
68 | List potentialAssignments = null;
69 | Class> genericType = signature.getIsGenericParameter() ? signature.getGenericParameterArgType()
70 | : Object.class;
71 | LOG.debug("Editor for class {} not found. Trying to find converter.", genericType);
72 | Converter> converter = ConverterManager.findConverter(genericType);
73 | if (converter != null) {
74 | potentialAssignments = new ArrayList();
75 | LOG.debug("Converter for class {} found ", genericType);
76 | for (Map object : convertFrom) {
77 | Map tempMap = new HashMap();
78 | String values = (String) object.get(paramName);
79 | String[] splitValues = values.split(COLON);
80 | for (int i = 0; i < splitValues.length; i++) {
81 | tempMap.put(paramName, splitValues[i]);
82 | Object value;
83 | if(converter instanceof ParamAwareConverter) {
84 | value = ((ParamAwareConverter)converter).convert(tempMap, paramName);
85 | } else {
86 | value = converter.convert(tempMap);
87 | }
88 | collection.add(value);
89 | }
90 | potentialAssignments.add(PotentialAssignment.forValue(EMPTY_STRING, collection));
91 | }
92 | }
93 | return potentialAssignments;
94 | }
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/converter/UserDefinedConverter.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.converter;
2 |
3 | import org.easetech.easytest.internal.DateTimeFormat;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 | import java.util.Map;
8 | import org.junit.experimental.theories.PotentialAssignment;
9 | import org.slf4j.Logger;
10 | import org.slf4j.LoggerFactory;
11 |
12 | /**
13 | *
14 | * An instance of {@link BaseConverter} that is responsible for converting the raw data in to a user defined type instance
15 | * using any user defined converter
16 | *
17 | * @author Anuj Kumar
18 | *
19 | */
20 | public class UserDefinedConverter implements BaseConverter>, List> {
21 |
22 | /**
23 | * The type of parameter to convert the raw data to
24 | */
25 | private final Class> parameterType;
26 |
27 | /**
28 | * The name of the parameter that is being converted
29 | */
30 | private final String paramName;
31 |
32 | /**
33 | * Whether empty values should be converted to Null values or not
34 | */
35 | private final Boolean convertEmptyToNull;
36 |
37 | /**
38 | * The user specified date time format to use
39 | */
40 | private final DateTimeFormat dateTimeFormat;
41 |
42 | /**
43 | * Logger
44 | */
45 | private static final Logger LOG = LoggerFactory.getLogger(UserDefinedConverter.class);
46 |
47 | /**
48 | *
49 | * Construct a new UserDefinedConverter
50 | * @param parameterType The type of parameter to convert the raw data to
51 | * @param paramName The name of the parameter that is being converted
52 | * @param convertEmptyToNull
53 | * @param dateTimeFormat
54 | */
55 | public UserDefinedConverter(Class> parameterType, String paramName , Boolean convertEmptyToNull, DateTimeFormat dateTimeFormat) {
56 | this.parameterType = parameterType;
57 | this.paramName = paramName;
58 | this.convertEmptyToNull = convertEmptyToNull;
59 | this.dateTimeFormat = dateTimeFormat;
60 | }
61 |
62 | /**
63 | * Convert the raw data into a list of {@link PotentialAssignment} instance
64 | * that EasyTest uses to provide the right set of test data to the test method
65 | * @param convertFrom the raw data to convert from
66 | * @return the list of {@link PotentialAssignment} instances
67 | */
68 | @SuppressWarnings("unchecked")
69 | public List convert(List> convertFrom) {
70 | List potentialAssignments = null;
71 | LOG.debug("Trying to find a registerd converter for class {}", parameterType);
72 | // Try to find the Converter
73 | Converter> converter = ConverterManager.findConverter(parameterType);
74 | if (converter != null) {
75 | if(converter instanceof AbstractConverter) {
76 | ConverterSupport converterSupport = new ConverterSupport();
77 | converterSupport.setConvertEmptyToNull(convertEmptyToNull);
78 | converterSupport.setDateTimeFormat(dateTimeFormat);
79 | converterSupport.setParamName(paramName);
80 | ((AbstractConverter) converter).setConverterSupport(converterSupport);
81 | }
82 |
83 | potentialAssignments = new ArrayList();
84 | LOG.debug("Converter for class {} found.", parameterType);
85 | for (Map object : convertFrom) {
86 | Object value;
87 | //TODO: This logic should be removed in future versions of EasyTest
88 | if (converter instanceof ParamAwareConverter) {
89 | value = ((ParamAwareConverter)converter).convert(object, paramName);
90 | } else {
91 | value = converter.convert(object);
92 | }
93 | potentialAssignments.add(PotentialAssignment.forValue(EMPTY_STRING, value));
94 | }
95 | }
96 | return potentialAssignments;
97 | }
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/converter/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Package containing various data converters part of the EasyTest framework.
3 | *
4 | *
5 | */
6 |
7 | package org.easetech.easytest.converter;
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/exceptions/ParamAssertionError.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.exceptions;
2 |
3 | import java.util.Arrays;
4 | import java.util.Collection;
5 | import java.util.Iterator;
6 |
7 | /**
8 | *
9 | * An extension of {@link RuntimeException} class that handles {@link ParamAssertionError}
10 | *
11 | * @author Anuj Kumar
12 | *
13 | */
14 | public class ParamAssertionError extends RuntimeException {
15 |
16 | private static final long serialVersionUID = 1L;
17 |
18 | public ParamAssertionError(Throwable targetException,
19 | String methodName, Object... params) {
20 | super(String.format("%s(%s)", methodName, join(", ", params)),
21 | targetException);
22 | }
23 |
24 | public boolean equals(Object obj) {
25 | return toString().equals(obj.toString());
26 | }
27 |
28 | public static String join(String delimiter, Object... params) {
29 | return join(delimiter, Arrays.asList(params));
30 | }
31 |
32 | public static String join(String delimiter,
33 | Collection values) {
34 | StringBuilder buffer = new StringBuilder();
35 | Iterator iter = values.iterator();
36 | while (iter.hasNext()) {
37 | Object next = iter.next();
38 | buffer.append(stringValueOf(next));
39 | if (iter.hasNext()) {
40 | buffer.append(delimiter);
41 | }
42 | }
43 | return buffer.toString();
44 | }
45 |
46 | private static String stringValueOf(Object next) {
47 | try {
48 | return String.valueOf(next);
49 | } catch (Throwable e) {
50 | return "[toString failed]";
51 | }
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/exceptions/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Package containing exception classes part of the EasyTest framework.
3 | *
4 | *
5 | */
6 |
7 | package org.easetech.easytest.exceptions;
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/interceptor/DefaultMethodIntercepter.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.interceptor;
2 |
3 | import java.lang.reflect.Method;
4 | import org.slf4j.Logger;
5 | import org.slf4j.LoggerFactory;
6 |
7 | /**
8 | * A default implementation of {@link MethodIntercepter} to log the time taken by a method
9 | *
10 | * @author Anuj Kumar
11 | *
12 | */
13 | public class DefaultMethodIntercepter implements MethodIntercepter {
14 |
15 | /** Logger implementation*/
16 | protected static final Logger LOG = LoggerFactory.getLogger(DefaultMethodIntercepter.class);
17 |
18 | /**
19 | * Intercept the method invocation for logging the time taken by the method.
20 | * @param methodToIntercept the method to intercept the call for
21 | * @param targetInstance the target class on which the method will be called
22 | * @param methodArgs the arguments to the method
23 | * @return the object that is returned after method invocation
24 | * @throws Throwable if any exception occurs
25 | */
26 | public Object intercept(Method methodToIntercept, Object targetInstance, Object[] methodArgs) throws Throwable{
27 | return methodToIntercept.invoke(targetInstance, methodArgs);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/interceptor/Empty.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.interceptor;
2 |
3 | public final class Empty {
4 |
5 | private Empty() {
6 | //Do Nothing
7 | }
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/interceptor/InternalInterceptor.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.interceptor;
3 |
4 | import java.lang.reflect.Method;
5 | import net.sf.cglib.proxy.MethodInterceptor;
6 | import net.sf.cglib.proxy.MethodProxy;
7 |
8 | /**
9 | *
10 | * An internal intercepter implementation of the CGLIB provided {@link MethodInterceptor} interface, that
11 | * actually calls the {@link MethodIntercepter#intercept(Method, Object, Object[])} method internally.
12 | * This is done so as to hide the implementation details of intercepting method calls from the user.
13 | * A user can extend this class to modify the behavior of the default
14 | * {@link MethodInterceptor#intercept(Object, Method, Object[], MethodProxy)} method implementation
15 | *
16 | * @author Anuj Kumar
17 | *
18 | */
19 | public class InternalInterceptor extends CommonProxyInterceptor implements MethodInterceptor {
20 |
21 | /**
22 | * Intercept the method with the advice
23 | * @param object the object on which to invoke the method
24 | * @param method the method to invoke
25 | * @param args arguments to the method
26 | * @param methodProxy the method proxy
27 | * @return returned value
28 | * @throws Throwable
29 | */
30 | public Object intercept(Object object, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {
31 | return intercept(method, args);
32 | }
33 |
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/interceptor/InternalInvocationhandler.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.interceptor;
2 |
3 | import java.lang.reflect.InvocationHandler;
4 | import java.lang.reflect.Method;
5 | import org.easetech.easytest.annotation.Provided;
6 |
7 | /**
8 | * Implementation of the {@link InvocationHandler} interface for internal usage.
9 | * This is used when the user has {@link Provided} annotation on a field whose type is an Interface.
10 | * EasyTest uses JDK dynamic proxies to intercept calls to the method on Interface type fields.
11 | * For Concrete classes, EasyTest uses CGLIB.
12 | *
13 | * @author Anuj Kumar
14 | *
15 | */
16 | public class InternalInvocationhandler extends CommonProxyInterceptor implements InvocationHandler {
17 |
18 |
19 |
20 | /**
21 | * Invoke the method on the provided {@link #getTargetInstance}.
22 | * {@link #getUserIntercepter}'s intercept method is invoked with the right arguments.
23 | * Note that this implementation does not use the proxy instance passed to this method.
24 | * @param proxy NOT USED
25 | * @param method the method to invoke
26 | * @param args the arguments to the method
27 | * @return object
28 | * @throws Throwable if any exception occurs
29 | */
30 | public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
31 | return intercept(method, args);
32 | }
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/interceptor/MethodIntercepter.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.interceptor;
2 |
3 | import java.lang.reflect.Method;
4 | import org.easetech.easytest.annotation.Intercept;
5 | import org.easetech.easytest.runner.DataDrivenTestRunner;
6 |
7 | /**
8 | * Interface that provides the users with the ability to intercept
9 | * methods on class instances that are marked with {@link Intercept} annotations.
10 | * The user can provide the implementation of this interface as attribute to the {@link Intercept} annotation.
11 | * Note: If you are using {@link DataDrivenTestRunner}, then CGLib is being used to intercept method invocation behind the scene.
12 | * Look at {@link InternalInterceptor} class for more detail.
13 | * If you are using SpringTestRunner from the easytest-spring module,
14 | * then Spring AOP is being used to intercept method invocation behind the scene.You can look at SpringInternalIntercepter class
15 | * in the easytest-spring module for more detail.
16 | *
17 | * @author Anuj Kumar
18 | *
19 | */
20 | public interface MethodIntercepter {
21 |
22 | /**
23 | * Intercept the method invocation on the target class.
24 | * To be used for providing before and after advice when a given method is executed.
25 | * @param methodToIntercept the method to intercept
26 | * @param targetInstance the target instance on which to call the method
27 | * @param methodArgs the arguments to the method
28 | * @return object
29 | * @throws Throwable if any exception occurs
30 | */
31 | public Object intercept(Method methodToIntercept , Object targetInstance , Object[] methodArgs ) throws Throwable;
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/interceptor/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Package containing various interceptors part of the EasyTest framework.
3 | * Interceptors can be used to intercept calls to the class that is being tested by the test method.
4 | * It gives convenience and control to the end user. For example, using the method interceptors, a user can know how much time did a test method take.
5 | * A user can also decide to fail the test method in case it takes more than the specified amount of time.
6 | *
7 | *
8 | */
9 |
10 | package org.easetech.easytest.interceptor;
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/internal/DateTimeFormat.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.internal;
2 |
3 | import org.easetech.easytest.annotation.Format;
4 |
5 | /**
6 | * The date time formats to be used to convert raw data into date/time objects.
7 | * The class is instantiated with the date and time formats specified by the user using {@link Format}
8 | * annotation. If the user does not specify any format, then the default formats are used.
9 | * The default formats for date type object are :
10 | *
11 | * dd/MM/yy
12 | * dd/MM/yyyy
13 | * dd-MM-yy
14 | * dd-MM-yyyy
15 | *
16 | *The default format for time type object is :
17 | *
20 | *The default formats for date time type objetcs are :
21 | *
22 | * dd/MM/yy HH:MM:SS
23 | * dd/MM/yyyy HH:MM:SS
24 | * dd-MM-yy HH:MM:SS
25 | * dd-MM-yyyy HH:MM:SS
26 | *
27 | *
28 | * @author Anuj Kumar
29 | */
30 | public class DateTimeFormat {
31 |
32 | /**
33 | * The date formats to use as specified by the user or the default formats
34 | */
35 | private String[] dateFormat = {"dd/MM/yy" , "dd/MM/yyyy", "dd-MM-yy" , "dd-MM-yyyy"};
36 |
37 | /**
38 | * The time formats to use as specified by the user or the default formats
39 | */
40 | private String[] timeFormat = {"HH:MM:SS"};
41 |
42 | /**
43 | * The date/time formats to use as specified by the user or the default formats
44 | */
45 | private String[] dateTimeFormat = {"dd/MM/yy HH:MM:SS" ,"dd/MM/yyyy HH:MM:SS", "dd-MM-yy HH:MM:SS", "dd-MM-yyyy HH:MM:SS"};
46 |
47 | /**
48 | * Get the date formats to use as specified by the user or the default formats
49 | * @return the dateFormat
50 | */
51 | public String[] getDateFormat() {
52 | return dateFormat;
53 | }
54 |
55 | /**
56 | * Set the date formats to use as specified by the user or the default formats
57 | * @param dateFormat the dateFormat to set
58 | */
59 | public void setDateFormat(String[] dateFormat) {
60 | this.dateFormat = dateFormat;
61 | }
62 |
63 | /**
64 | * Get the time formats to use as specified by the user or the default formats
65 | * @return the timeFormat
66 | */
67 | public String[] getTimeFormat() {
68 | return timeFormat;
69 | }
70 |
71 | /**
72 | * Set the time formats to use as specified by the user or the default formats
73 | * @param timeFormat the timeFormat to set
74 | */
75 | public void setTimeFormat(String[] timeFormat) {
76 | this.timeFormat = timeFormat;
77 | }
78 |
79 | /**
80 | * Get the date/time formats to use as specified by the user or the default formats
81 | * @return the dateTimeFormat
82 | */
83 | public String[] getDateTimeFormat() {
84 | return dateTimeFormat;
85 | }
86 |
87 | /**
88 | * Set the date/time formats to use as specified by the user or the default formats
89 | * @param dateTimeFormat the dateTimeFormat to set
90 | */
91 | public void setDateTimeFormat(String[] dateTimeFormat) {
92 | this.dateTimeFormat = dateTimeFormat;
93 | }
94 |
95 | /**
96 | * Override toString
97 | * @return toString representation
98 | */
99 | @Override
100 | public String toString() {
101 | return "DateTimeFormat [dateFormat=" + dateFormat + ", timeFormat=" + timeFormat + ", dateTimeFormat="
102 | + dateTimeFormat + "]";
103 | }
104 |
105 |
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/internal/SystemProperties.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.internal;
2 |
3 | import javax.xml.bind.annotation.XmlRootElement;
4 |
5 | /**
6 | *
7 | * A convenient class to define all the system properties that EasyTest expects.
8 | *
9 | * @author Anuj Kumar
10 | *
11 | */
12 | @XmlRootElement
13 | public enum SystemProperties {
14 |
15 | /**
16 | * System Property that a user can set at runtime using the -D option, to provide
17 | * test data file paths at runtime.
18 | */
19 | TEST_DATA_FILES("test.dataFiles"),
20 |
21 | /**
22 | * System Property that a user can set at runtime using the -D option,
23 | * to specify whether reports should be generated or not.
24 | */
25 | GENERATE_REPORT("reports.generate"),
26 |
27 | /**
28 | * System Property that a user can set at runtime using the -D option,
29 | * to specify the report format.
30 | */
31 | REPORT_FORMAT("reports.format"),
32 |
33 | /**
34 | * System Property that a user can set at runtime using the -D option,
35 | * to specify the report type (main report, method duration report)
36 | */
37 | REPORT_TYPE("reports.type"),
38 |
39 | /**
40 | * System Property that a user can set at runtime using the -D option,
41 | * to specify the report location.
42 | */
43 | REPORT_LOCATION("reports.location"),
44 |
45 | /**
46 | * System Property that a user can set at runtime using the -D option,
47 | * to specify the report package.
48 | */
49 | REPORT_PACKAGES("reports.package"),
50 |
51 | /**
52 | * System Property to be used for specifying the number of times
53 | * a test should be repeated
54 | */
55 | REPEAT_COUNT("test.repeatCount"),
56 |
57 | /**
58 | * System property to specify the number of threads to run in parallel
59 | */
60 | PARALLEL_THREAD_COUNT("test.parallelThreads"),
61 |
62 | /**
63 | * System property to specify whethere the data should be written back to the file or not
64 | */
65 | WRITE_DATA("easytest.writeData");
66 |
67 | /**
68 | * the actual value of the system property
69 | */
70 | private String value;
71 |
72 | /**
73 | *
74 | * Construct a new SystemProperties
75 | * @param value
76 | */
77 | private SystemProperties(String value) {
78 | this.value = value;
79 | }
80 |
81 | /**
82 | * Get the system property value
83 | * @return
84 | */
85 | public String getValue() {
86 | return value;
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/internal/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Package containing various internal classes part of the EasyTest framework.
3 | *
4 | *
5 | */
6 |
7 | package org.easetech.easytest.internal;
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/io/EmptyResource.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.io;
2 |
3 | import java.io.File;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 | import java.io.OutputStream;
7 | import java.net.URL;
8 |
9 | /**
10 | *
11 | * An empty implementation of the resource, useful in cases where the user loads the data from Java Class
12 | * and thus does not require to load a resource explicitly
13 | *
14 | * @author Anuj Kumar
15 | *
16 | */
17 | public class EmptyResource implements Resource {
18 |
19 | public boolean exists() {
20 |
21 | return false;
22 | }
23 |
24 | public InputStream getInputStream() throws IOException {
25 |
26 | return null;
27 | }
28 |
29 | public OutputStream getOutputStream() throws IOException {
30 |
31 | return null;
32 | }
33 |
34 | public URL getURL() {
35 |
36 | return null;
37 | }
38 |
39 | public File getFile() throws Exception {
40 |
41 | return null;
42 | }
43 |
44 | public String getResourceName() {
45 |
46 | return null;
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/io/FileSystemResource.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.io;
3 |
4 | import java.io.File;
5 | import java.io.FileInputStream;
6 | import java.io.FileNotFoundException;
7 | import java.io.FileOutputStream;
8 | import java.io.InputStream;
9 | import java.io.OutputStream;
10 | import java.net.MalformedURLException;
11 | import java.net.URL;
12 | import org.easetech.easytest.annotation.DataLoader;
13 | import org.easetech.easytest.util.CommonUtils;
14 | import org.junit.Assert;
15 |
16 | /**
17 | * A FileSystem based {@link Resource} implementation.
18 | * The {@link ResourceLoaderStrategy} will auto instantiate this class if the {@link DataLoader}
19 | * annotation specifies the filePaths attribute to contain a FileSystem resource. For eg.
20 | * @DataLoader(filePahts={C:\\myComputer\\testData.csv})
21 | *
22 | *@author Anuj Kuamr
23 | */
24 | public class FileSystemResource implements Resource {
25 |
26 | /**
27 | * The path associated with the resource
28 | */
29 | private String path;
30 |
31 | /**
32 | * The {@link File} object representing the resource
33 | */
34 | private File file;
35 |
36 |
37 | /**
38 | *
39 | * Construct a new FileSystemResource from the provided simple path
40 | * @param path the path where the file system resource resides
41 | */
42 | public FileSystemResource(String path) {
43 | if(path == null || path.length() <= 0){
44 | Assert.fail("The supplied path must be a non empty and Not Null value");
45 | }
46 | this.path = CommonUtils.cleanPath(path);
47 | this.file = new File(path);
48 | }
49 |
50 | /**
51 | *
52 | * Construct a new FileSystemResource from the provided File instance
53 | * @param file representing the file system resource
54 | */
55 | public FileSystemResource(File file){
56 | if(file == null || file.exists()){
57 | Assert.fail("The supplied file must be not be empty and should exist.");
58 | }
59 | this.path = CommonUtils.cleanPath(file.getPath());
60 | this.file = file;
61 | }
62 |
63 |
64 | /**
65 | * @return the path
66 | */
67 | public String getPath() {
68 | return path;
69 | }
70 |
71 | /**
72 | * Identifies whether the resource represented by this instance exists or not
73 | * @return boolean
74 | */
75 | public boolean exists() {
76 | return this.file.exists();
77 | }
78 |
79 | /**
80 | * Get the input stream represented by this resource
81 | * @return {@link InputStream}
82 | */
83 | public InputStream getInputStream() {
84 | try {
85 | return new FileInputStream(this.file);
86 | } catch (FileNotFoundException e) {
87 | throw new RuntimeException(e);
88 | }
89 | }
90 |
91 | /**
92 | * Gwet the URL represented by this resource
93 | * @return URL instance
94 | */
95 | public URL getURL() {
96 | try {
97 | return this.file.toURI().toURL();
98 | } catch (MalformedURLException e) {
99 | throw new RuntimeException(e);
100 | }
101 | }
102 |
103 | /**
104 | * Get the File object instance represented by this Resource
105 | * @return File instance
106 | */
107 | public File getFile() {
108 | return this.file;
109 | }
110 |
111 | /**
112 | * Return the name of the resource
113 | * @return resource name
114 | */
115 | public String getResourceName() {
116 | return this.file.getPath();
117 | }
118 |
119 | /**
120 | * Get the {@link OutputStream} for the given resource
121 | * @return {@link OutputStream}
122 | */
123 | public OutputStream getOutputStream() {
124 | try {
125 | return new FileOutputStream(this.file);
126 | } catch (FileNotFoundException e) {
127 | throw new RuntimeException(e);
128 | }
129 | }
130 |
131 | /**
132 | * @return
133 | */
134 | public String toString() {
135 | return "FileSystemResource [path=" + path + ", file=" + file + "]";
136 | }
137 |
138 |
139 |
140 | }
141 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/io/Resource.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.io;
2 |
3 |
4 | import java.io.File;
5 | import java.io.IOException;
6 | import java.io.InputStream;
7 | import java.io.OutputStream;
8 | import java.net.URL;
9 |
10 | /**
11 | * Interface representing a generic Resource to be used by the EasyTest framework.
12 | * Three implementations exists for this interface in the EasyTest framework:
13 | * {@link ClasspathResource} - Resources that exists in the Classpath
14 | * {@link FileSystemResource} - Resources that exists in the FileSystem
15 | * {@link UrlResource} - Resource that exists as a URL(http , ftp) etc
16 | *
17 | * @author Anuj Kumar
18 | */
19 | public interface Resource {
20 |
21 | /**
22 | * Indicates whether the resource exists or not
23 | * @return boolean
24 | */
25 | boolean exists();
26 |
27 | /**
28 | * Get the {@link InputStream} associated with the resource
29 | * @return {@link InputStream}
30 | * @throws IOException if an IOException occurs
31 | */
32 | InputStream getInputStream() throws IOException;
33 |
34 | /**
35 | * Get the {@link OutputStream} associated with the resource
36 | * @return {@link OutputStream}
37 | * @throws IOException if an IOException occurs
38 | */
39 | OutputStream getOutputStream() throws IOException;
40 |
41 | /**
42 | * get the {@link URL} associated with the resource
43 | * @return {@link URL}
44 | */
45 | URL getURL();
46 |
47 | /**
48 | * Get the {@link File} associated with the resource
49 | * @return {@link File}
50 | * @throws Exception
51 | */
52 | File getFile() throws Exception;
53 |
54 | /**
55 | * Get the resource name
56 | * @return String
57 | */
58 | String getResourceName();
59 |
60 |
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/io/ResourceLoader.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.io;
2 |
3 | /**
4 | *
5 | * ResourceLoader interface consisting of methods to get hold of a {@link Resource} object.
6 | * @see ResourceLoaderStrategy
7 | *
8 | * @author Anuj Kumar
9 | *
10 | */
11 | public interface ResourceLoader {
12 |
13 | /**
14 | * The classpath prefix
15 | */
16 | String CLASSPATH_PREFIX = "classpath:";
17 |
18 | /**
19 | * The file prefix
20 | */
21 | String FILE_PREFIX = "file:";
22 |
23 | /**
24 | * The URL prefix
25 | */
26 | String URL_PREFIX = "url:";
27 |
28 | /**
29 | * Get the {@link Resource} instance based on the location
30 | * @param location the location of the resource
31 | * @return {@link Resource} instance
32 | */
33 | Resource getResource(String location);
34 |
35 | /**
36 | * Get the class loader associated with the Resource Loader
37 | * @return the class loader associated with the Resource Loader
38 | */
39 | ClassLoader getClassLoader();
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/io/UrlResource.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.io;
2 |
3 | import java.io.File;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 | import java.io.OutputStream;
7 | import java.net.HttpURLConnection;
8 | import java.net.MalformedURLException;
9 | import java.net.URI;
10 | import java.net.URL;
11 | import java.net.URLConnection;
12 | import org.easetech.easytest.util.CommonUtils;
13 | import org.jfree.util.Log;
14 | import org.junit.Assert;
15 |
16 | /**
17 | * A {@link Resource} implementation for the URL based resources.
18 | *
19 | * @author Anuj Kumar
20 | *
21 | */
22 | public class UrlResource implements Resource {
23 |
24 | /**
25 | * The path of the resource
26 | */
27 | private String path;
28 |
29 | /**
30 | * The URL of the resource
31 | */
32 | private URL url;
33 |
34 | /**
35 | *
36 | * Construct a new UrlResource from the given path
37 | * @param path
38 | * @throws MalformedURLException
39 | */
40 | public UrlResource(String path) throws MalformedURLException {
41 | if (path == null || path.length() <= 0) {
42 | Assert.fail("The supplied path must be a non empty and Not Null value");
43 | }
44 | this.path = path;
45 | this.url = new URL(path);
46 | }
47 |
48 | /**
49 | *
50 | * Construct a new UrlResource from the given URL
51 | * @param url
52 | */
53 | public UrlResource(URL url) {
54 | if (url == null || url.toString().length() <= 0) {
55 | Assert.fail("The supplied path must be a non empty and Not Null value");
56 | }
57 | this.path = url.getPath();
58 | this.url = url;
59 | }
60 |
61 |
62 |
63 | /**
64 | * @return the path
65 | */
66 | public String getPath() {
67 | return path;
68 | }
69 |
70 |
71 | /**
72 | * Checks whether the URL resource exists or not.
73 | *
74 | * @return true if exists, false otherwise
75 | */
76 | public boolean exists() {
77 | try {
78 | HttpURLConnection.setFollowRedirects(false);
79 | HttpURLConnection con = (HttpURLConnection) url.openConnection();
80 | con.setRequestMethod("HEAD");
81 | return con.getResponseCode() == HttpURLConnection.HTTP_OK;
82 | } catch (Exception e) {
83 | Log.debug("Exception occured while trying to find whether the resource exists or not ", e);
84 | return false;
85 | }
86 | }
87 |
88 | /**
89 | * Get the input stream associated with the resource
90 | * @return input stream associated with the resource
91 | * @throws IOException
92 | */
93 | public InputStream getInputStream() throws IOException{
94 | URLConnection con = this.url.openConnection();
95 | con.setUseCaches(false);
96 | return con.getInputStream();
97 |
98 | }
99 |
100 | /**
101 | * Get the URL associated with the resource
102 | * @return the URL associated with the resource
103 | */
104 | public URL getURL() {
105 | return url;
106 | }
107 |
108 | /**
109 | * Get the File associated with the resource
110 | * @return the File associated with the resource
111 | * @throws Exception
112 | */
113 | public File getFile() throws Exception {
114 | URI uri = CommonUtils.toURI(getURL());
115 | File file;
116 | if (uri != null) {
117 | file = CommonUtils.getFile(uri, uri.toString());
118 | } else {
119 | file = CommonUtils.getFile(getURL(), null);
120 | }
121 | return file;
122 | }
123 |
124 | /**
125 | * Get the resource name
126 | * @return
127 | */
128 | public String getResourceName(){
129 | try {
130 | return getFile().getName();
131 | } catch (Exception e) {
132 | Log.debug("Exception occured while trying to get the name of the resource",e);
133 | return this.path;
134 | }
135 | }
136 |
137 | /**
138 | * Get the {@link OutputStream} associated with the resource
139 | */
140 | public OutputStream getOutputStream() throws IOException{
141 | URLConnection con = this.url.openConnection();
142 | con.setUseCaches(false);
143 | return con.getOutputStream();
144 | }
145 |
146 | /**
147 | * @return
148 | */
149 | public String toString() {
150 | return "UrlResource [path=" + path + ", URL=" + url + "]";
151 | }
152 |
153 | }
154 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/io/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The I/O package of EasyTest for easy Resource Loading strategies
3 | *
4 | *
5 | */
6 |
7 | package org.easetech.easytest.io;
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/loader/DataConverter.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.loader;
3 |
4 | import java.util.Collections;
5 | import java.util.HashMap;
6 | import java.util.List;
7 | import java.util.Map;
8 | import org.easetech.easytest.runner.DataDrivenTestRunner;
9 | import org.easetech.easytest.util.DataContext;
10 |
11 | /**
12 | *
13 | * A Utility class that helps {@link DataDrivenTestRunner} and {@link DataContext} classes to store the input test data in a
14 | * format that is easy to display to the user as well as easy to interpret.
15 | *
16 | * @author Anuj Kumar
17 | *
18 | */
19 | public final class DataConverter {
20 |
21 | private DataConverter(){
22 | //private constructor
23 | }
24 |
25 | /**
26 | * Converts/normalize the input test data such that the name of the method is: prepended with the name of the
27 | * Class that the method is associated with, and appended with the input test data that the method will take.
28 | *
29 | * @param from the original input test data
30 | * @param currentTestClass the class of the methods that this input test data belongs to
31 | * @return a Normalized input test data.
32 | */
33 | public static Map>> convert(Map>> from,
34 | Class> currentTestClass) {
35 | Map>> result = new HashMap>>();
36 | for (String method : from.keySet()) {
37 | List> value = from.get(method);
38 | for (Map singleTestMethod : value) {
39 | result.put(getFullyQualifiedTestName(method, currentTestClass).concat(singleTestMethod.toString()),
40 | Collections.singletonList(singleTestMethod));
41 | }
42 |
43 | }
44 | return result;
45 | }
46 |
47 | /**
48 | * Returns the fully qualified name of the test method such that: if the input testClass is null, return the
49 | * test method name, else prepend the test method name with the name of the class and return.
50 | *
51 | * @param testMethod the name of the test method. Cannot be null
52 | * @param testClass the name of the test class, can be null.
53 | * @return Fully qualified test method name
54 | */
55 | public static String getFullyQualifiedTestName(String testMethod, Class testClass) {
56 | return testClass == null ? testMethod : testClass.getName().concat(":").concat(testMethod);
57 | }
58 |
59 | /**
60 | * Get truncated method name such that: if the testMethod name starts with the testClass name, remove the name
61 | * of the class and return the result, else return the test method
62 | *
63 | * @param testMethod the name of the test method. Cannot be null
64 | * @param testClass the name of the test class, can be null.
65 | * @return the truncated method name
66 | */
67 | public static String getTruncatedMethodName(String testMethod, Class testClass) {
68 | return testMethod.startsWith(testClass.getName()) ? testMethod.replaceAll(testClass.getName(), "") : testMethod;
69 |
70 | }
71 |
72 | /**
73 | * Prepend the className to the name of the method
74 | *
75 | * @param from the input test data
76 | * @param currentTestClass the currently executing test class
77 | * @return the converted test data
78 | */
79 | public static Map>> appendClassName(Map>> from,
80 | Class> currentTestClass) {
81 | Map>> result = new HashMap>>();
82 | for (String method : from.keySet()) {
83 | result.put(getFullyQualifiedTestName(method, currentTestClass), from.get(method));
84 | }
85 | return result;
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/loader/EmptyLoader.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.loader;
3 |
4 | import junit.framework.Assert;
5 |
6 | import java.util.List;
7 | import java.util.Map;
8 | import org.easetech.easytest.io.Resource;
9 |
10 | /**
11 | *
12 | * An empty loader implementation
13 | *
14 | */
15 | public class EmptyLoader implements Loader {
16 |
17 | public Map>> loadData(Resource resource) {
18 | Assert.fail("There is no loader configured to handle loading of the resource :" + resource.getResourceName()+
19 | "Please provide either file with extensions : " +
20 | "xsl, csv, xml or provide your own custom data loader implementation for the resource.");
21 | return null;
22 | }
23 |
24 | public void writeData(Resource resource, Map>> actualData, String... methodNames) {
25 | Assert.fail("There is no loader configured to handle writing of the resource :" + resource.getResourceName()+
26 | "Please provide either file with extensions : " +
27 | "xsl, csv, xml or provide your own custom data loader implementation for the resource.");
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/loader/Loader.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.loader;
2 |
3 | import java.util.List;
4 | import java.util.Map;
5 | import org.easetech.easytest.annotation.DataLoader;
6 | import org.easetech.easytest.io.Resource;
7 |
8 | /**
9 | * An interface for different types of loader.
10 | * This would ultimately be used by the users of EasyTest as well to provide their custom Loaders.
11 | * Currently, EasyTest supports three Loaders internally :
12 | * {@link ExcelDataLoader} - To load data from XLS files
13 | * {@link XMLDataLoader} - To load data from XML files. Look at the Schema for XML at :
14 | * https://github.com/EaseTech/easytest-core/blob/master/src/main/resources/testDataSchema.xsd
15 | * {@link CSVDataLoader} - To load data from a CSV file
16 | *
17 | * In addition users can define their own custom Loaders and use them in their test
18 | * classes by specifying the {@link LoaderType#CUSTOM} loader type in their {@link DataLoader} annotation
19 | *
20 | * @author Anuj Kumar
21 | *
22 | */
23 | public interface Loader {
24 | /**
25 | * The key identifying the actual output result that needs to be written to the file.
26 | */
27 | String ACTUAL_RESULT = "ActualResult";
28 |
29 | /**
30 | * The key identifying the expected output that needs to be compared with actual result
31 | */
32 | String EXPECTED_RESULT = "ExpectedResult";
33 |
34 | /**
35 | * Constant for empty string
36 | */
37 | String EMPTY_STRING = " ";
38 |
39 | /**
40 | * Double Quote String
41 | */
42 | String DOUBLE_QUOTE = "\"";
43 |
44 | /**
45 | * Single Quote
46 | */
47 | String SINGLE_QUOTE = "'";
48 |
49 | /**
50 | * The ampersand sign
51 | */
52 | String AMPERSAND = "&";
53 |
54 | /**
55 | * Comma
56 | */
57 | String COMMA = ",";
58 | /**
59 | * The key identifying the Test Status either PASSED/FAILED
60 | * determined after comparing expected and actual results, and written to the file.
61 | */
62 | String TEST_STATUS = "TestStatus";
63 |
64 | /**
65 | * The key identifying the Test Duration in milli seconds
66 | */
67 | String DURATION = "Duration(ms)";
68 |
69 | /**
70 | * The constants for test status PASSED/FAILED
71 | */
72 | final String TEST_PASSED = "PASSED";
73 | final String TEST_FAILED = "FAILED";
74 |
75 | /**
76 | * Method responsible to Load the test data from the {@link Resource} instance passed as parameter
77 | * @param resource from which to load the data
78 | * @return a Map consisting of the methodName as key and a List of Key/value pairs as the value of the Map.
79 | * This is currently not a user friendly way of exposing the test data.
80 | */
81 | Map>> loadData(Resource resource);
82 |
83 | /**
84 | * Method responsible for writing the test data and actual result back to the file
85 | * @param resource the resource to which data needs to be written
86 | * @param methodNames the names of the method to write the data for
87 | * @param actualData a Map consisting of the methodName as key and a List of Key/value pairs as the value of the Map.
88 | * This Map contains the input as well as output data
89 | * This is currently not a user friendly way of exposing the test data.
90 | */
91 | void writeData(Resource resource, Map>> actualData, String... methodNames);
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/loader/LoaderFactory.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.loader;
2 |
3 | import junit.framework.Assert;
4 |
5 |
6 | /**
7 | * A factory class responsible for churning out Loader instances based on the type of {@link LoaderType} to load the data from.
8 | * @author Anuj kumar
9 | *
10 | */
11 | public class LoaderFactory {
12 |
13 | /**
14 | * Return an instance of {@link Loader} based on the type of file or return null.
15 | * @param loaderType the type of the loader
16 | * @return an instance of {@link Loader} or null if no loader is found.
17 | */
18 | public static Loader getLoader(LoaderType loaderType){
19 | Loader loader = null;
20 | if(LoaderType.CSV.equals(loaderType)){
21 | loader = new CSVDataLoader();
22 | }else if(LoaderType.EXCEL.equals(loaderType)){
23 | loader = new ExcelDataLoader();
24 | }else if(LoaderType.XML.equals(loaderType)){
25 | loader = new XMLDataLoader();
26 | }else{
27 | Assert.fail("The framework currently does not support the specified Loader type. " +
28 | "You can provide the custom Loader by choosing LoaderType.CUSTOM in TestData " +
29 | "annotation and providing your custom loader using DataLoader annotation." );
30 | }
31 | return loader;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/loader/LoaderType.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.loader;
2 |
3 | import org.easetech.easytest.annotation.DataLoader;
4 |
5 | /**
6 | *
7 | * An Enum identifying the type of loader to be used for loading the data.
8 | * A loader type can identify a loader to be framework based loader(CSV , Excel or XML)
9 | * or it can identify the loader to be user defined loader(CUSTOM).
10 | * Note that a user can provide a loader whose loaderType is already
11 | * supported by the framework and still choose to mark it CUSTOM. In such a scenario, the framework
12 | * will use the Loader provided by the user to load the test data.
13 | *
14 | */
15 | public enum LoaderType {
16 |
17 | /**
18 | * Identifies that the type of file is a framework based CSV file.
19 | * This file should support the structure as identified in {@link CSVDataLoader}
20 | */
21 | CSV ,
22 | /**
23 | * Identifies that the type of file is a framework based XML file.
24 | * This is currently just a place holder and will be supported in future.
25 | */
26 | XML,
27 | /**
28 | * Identifies that the type of file is a framework based EXCEL file.
29 | * This is currently just a place holder and will be supported in future.
30 | */
31 | EXCEL,
32 | /**
33 | * Identifies that the type of file is a user defined custom type.
34 | * This option is used in conjunction with {@link DataLoader} annotation.
35 | *
36 | */
37 | CUSTOM,
38 | /**
39 | * Identifies that the user has not specified any specific loader type.
40 | * The framework should identify the type of file from its extension.
41 | * If the file type is any one of the available standard types(XML, Excel, XLS)
42 | * appropriate loaders will be called. Else the framework will assume the file to be loaded by
43 | * the custom loader. In such a case, a custom loader implementation should be provided as
44 | * part of the {@link DataLoader}'s loader attribute declaration.
45 | */
46 | NONE
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/loader/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * package containing various Loaders part of the easytest framework and related classes
3 | *
4 | *
5 | */
6 |
7 | package org.easetech.easytest.loader;
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/reports/data/Duration.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.reports.data;
2 |
3 | import java.io.Serializable;
4 |
5 | public class Duration implements Serializable, Comparable {
6 |
7 | private static final long serialVersionUID = 6732313448995436466L;
8 |
9 | /**
10 | * Item name
11 | */
12 | private String method = "";
13 |
14 | /**
15 | * Minimum value
16 | */
17 | private int min = 0;
18 |
19 | /**
20 | * Maximum value
21 | */
22 | private int max = 0;
23 |
24 | /**
25 | * Average of all the values
26 | */
27 | private int avg = 0;
28 |
29 | /**
30 | * The total number of method calls
31 | */
32 | private int count = 0;
33 |
34 | /**
35 | * Constructor
36 | * @param item item name
37 | */
38 | public Duration(String item) {
39 | this.method = item;
40 | }
41 |
42 | /**
43 | * Constructor
44 | * @param method method call
45 | * @param min minimum value
46 | * @param max maximum value
47 | * @param avg average value
48 | * @param count total number of items
49 | */
50 | public Duration(String method, int min, int max, int avg, int count) {
51 | this(method);
52 | this.min = min;
53 | this.max = max;
54 | this.avg = avg;
55 | this.count = count;
56 | }
57 |
58 | public String getMethod() {
59 | return method;
60 | }
61 |
62 | public void setMethod(String method) {
63 | this.method = method;
64 | }
65 |
66 | public int getMin() {
67 | return min;
68 | }
69 |
70 | public void setMin(int min) {
71 | this.min = min;
72 | }
73 |
74 | public int getMax() {
75 | return max;
76 | }
77 |
78 | public void setMax(int max) {
79 | this.max = max;
80 | }
81 |
82 | public int getAvg() {
83 | return avg;
84 | }
85 |
86 | public void setAvg(int avg) {
87 | this.avg = avg;
88 | }
89 |
90 | public int getCount() {
91 | return count;
92 | }
93 |
94 | public void setCount(int count) {
95 | this.count = count;
96 | }
97 |
98 | @Override
99 | public String toString() {
100 | return "Duration [method=" + method + ", min=" + min + ", max=" + max
101 | + ", avg=" + avg + ", count=" + count + "]";
102 | }
103 |
104 | public int compareTo(String o) {
105 | return this.method.compareTo(o);
106 | }
107 |
108 | }
109 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/reports/data/DurationObserver.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.reports.data;
2 |
3 |
4 |
5 | import java.util.ArrayList;
6 | import java.util.Collections;
7 | import java.util.List;
8 | import java.util.Observable;
9 | import java.util.Observer;
10 |
11 | /**
12 | * The {@link Observer} implementation to observe the method under test and the time it took to run as well as the expected time, if any
13 | * This class is instantiated during the initialization phase of the EasyTest's runner.
14 | * It has a synchronized list in which data is added for each run of the test method.
15 | * Thus in case of parallel execution of tests multiple threads can try to add the data at the same time, thus the synchronized list.
16 | * A user of this list should take care of synchronizing the iteration process on this list if multiple threads are involved.
17 | *
18 | * @author Anuj Kumar
19 | *
20 | */
21 | public class DurationObserver implements Observer {
22 |
23 | /**
24 | * A synchronized list in which data is added for each run of the test method.
25 | */
26 | private final List durationList = Collections.synchronizedList(new ArrayList());
27 |
28 | /**
29 | * Method responsible for updating the duration list and adding an instance of {@link MethodUnderTestDuration}
30 | * for each execution of the test.
31 | * @param o the observable instance
32 | * @param obj an instance of {@link MethodUnderTestDuration}
33 | */
34 | public void update(Observable o, Object obj) {
35 | if(obj instanceof MethodUnderTestDuration) {
36 | MethodUnderTestDuration data = (MethodUnderTestDuration)obj;
37 | durationList.add(data);
38 | }
39 |
40 | }
41 |
42 | /**
43 | * Return the List of {@link MethodUnderTestDuration}
44 | * @return the durationBeanList
45 | */
46 | public List getDurationList() {
47 | return durationList;
48 | }
49 |
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/reports/data/ImageBean.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.reports.data;
2 |
3 | import java.awt.image.BufferedImage;
4 | import java.io.Serializable;
5 |
6 | /**
7 | * this class holds the image and description data
8 | * @author gpcmol
9 | *
10 | */
11 | public class ImageBean implements Serializable {
12 |
13 | private static final long serialVersionUID = 4057076384657248894L;
14 |
15 | /**
16 | * Chart of the totals
17 | */
18 | private BufferedImage image;
19 |
20 | /**
21 | * Name
22 | */
23 | private String name;
24 |
25 | /**
26 | * Description
27 | */
28 | private String description;
29 |
30 | /**
31 | * Constructor
32 | *
33 | * @param totalsGraph
34 | * @param name
35 | * @param description
36 | */
37 | public ImageBean(BufferedImage image, String name, String description) {
38 | super();
39 | this.image = image;
40 | this.name = name;
41 | this.description = description;
42 | }
43 |
44 | public BufferedImage getImage() {
45 | return image;
46 | }
47 |
48 | public void setImage(BufferedImage image) {
49 | this.image = image;
50 | }
51 |
52 | public String getName() {
53 | return name;
54 | }
55 |
56 | public void setName(String name) {
57 | this.name = name;
58 | }
59 |
60 | public String getDescription() {
61 | return description;
62 | }
63 |
64 | public void setDescription(String description) {
65 | this.description = description;
66 | }
67 |
68 | @Override
69 | public String toString() {
70 | return "ImageBean [image=" + image + ", name=" + name
71 | + ", description=" + description + "]";
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/reports/data/MethodDurationReportBean.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.reports.data;
2 |
3 | import java.io.Serializable;
4 | import java.util.List;
5 |
6 | /**
7 | * Method duration report bean that hold the duration bean data and the graph
8 | * @author gpcmol
9 | *
10 | */
11 | public class MethodDurationReportBean implements Serializable {
12 |
13 | private static final long serialVersionUID = 7045417311960242599L;
14 |
15 | /**
16 | * The bean that hold the image data
17 | */
18 | private ImageBean imageBean;
19 |
20 | /**
21 | * This list of duration beans
22 | */
23 | private List durations;
24 |
25 | /**
26 | * Constructor
27 | */
28 | public MethodDurationReportBean() {
29 | // empty constructor
30 | }
31 |
32 | public ImageBean getImageBean() {
33 | return imageBean;
34 | }
35 |
36 | public void setImageBean(ImageBean imageBean) {
37 | this.imageBean = imageBean;
38 | }
39 |
40 | public List getDurations() {
41 | return durations;
42 | }
43 |
44 | public void setDurations(List durations) {
45 | this.durations = durations;
46 | }
47 |
48 | @Override
49 | public String toString() {
50 | return "MethodDurationReportBean [imageBean=" + imageBean
51 | + ", durations=" + durations + "]";
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/reports/data/ReportDataContainer.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.reports.data;
2 |
3 | import java.util.ArrayList;
4 | import java.util.Date;
5 | import java.util.LinkedHashMap;
6 | import java.util.List;
7 | import java.util.Map;
8 |
9 | /**
10 | * Accumulates all the test results during a test run. Results are used as input
11 | * for the TestReportHelper
12 | *
13 | * @author gpcmol
14 | *
15 | */
16 | public class ReportDataContainer {
17 |
18 | /**
19 | * The tested class
20 | */
21 | private Class> testClass;
22 |
23 | /**
24 | * Holds all the test results
25 | */
26 | private volatile List testResults;
27 |
28 | /**
29 | * Holds the test results for method. Key is test method name, value is a
30 | * list of test results
31 | */
32 | private volatile Map> methodTestResults;
33 |
34 | /**
35 | * The synchronized list of {@link MethodUnderTestDuration} instances that can be used
36 | * for various report generations
37 | */
38 | private List durationList;
39 |
40 | /**
41 | * Private constructor Initializes the report data structures
42 | */
43 | private ReportDataContainer() {
44 | this.testResults = new ArrayList();
45 | this.methodTestResults = new LinkedHashMap>();
46 | }
47 |
48 | /**
49 | * Constructor
50 | *
51 | * @param testClass
52 | */
53 | public ReportDataContainer(Class> testClass) {
54 | this();
55 | this.testClass = testClass;
56 | }
57 |
58 | /**
59 | * Creates a TestResultBean which contains all the test result data and adds
60 | * it to the report data structures
61 | *
62 | * @param method
63 | * @param input
64 | * @param output
65 | * @param passed
66 | * @param result
67 | * @param exception
68 | * @param exceptionResult
69 | */
70 | public void addTestResult(String method, Map input,
71 | Object output, Boolean passed, String result, Boolean exception,
72 | String exceptionResult) {
73 | TestResultBean testResultBean = new TestResultBean(method, input,
74 | output, passed, result, exception, exceptionResult, new Date());
75 | this.addTestResult(testResultBean);
76 | }
77 |
78 | public void addTestResult(TestResultBean testResult) {
79 | synchronized (this) {
80 | String key = testResult.getMethod();
81 | List list = this.methodTestResults.get(key);
82 |
83 | if (list == null) {
84 | list = new ArrayList();
85 | this.methodTestResults.put(key, list);
86 | }
87 | list.add(testResult);
88 |
89 | this.testResults.add(testResult);
90 | }
91 | }
92 |
93 | public List getTestResults() {
94 | return testResults;
95 | }
96 |
97 | public Map> getMethodTestResults() {
98 | return methodTestResults;
99 | }
100 |
101 | public String getClassName() {
102 | return getTestClass().getName();
103 | }
104 |
105 | public Class> getTestClass() {
106 | return testClass;
107 | }
108 |
109 | /**
110 | * @return the durationList
111 | */
112 | public List getDurationList() {
113 | return durationList;
114 | }
115 |
116 | /**
117 | * @param durationList the durationList to set
118 | */
119 | public void setDurationList(List durationList) {
120 | this.durationList = durationList;
121 | }
122 |
123 | @Override
124 | public String toString() {
125 | return "ReportDataContainer [testClass=" + testClass + ", testResults="
126 | + testResults + ", methodTestResults=" + methodTestResults
127 | + ", durationList=" + durationList + "]";
128 | }
129 |
130 | }
131 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/reports/data/ReportTotalsBean.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.reports.data;
2 |
3 | import java.awt.image.BufferedImage;
4 | import java.io.Serializable;
5 | import org.easetech.easytest.util.CommonUtils;
6 |
7 | /**
8 | * This class contains the totals of a set of tests
9 | *
10 | * @author gpcmol
11 | *
12 | */
13 | public class ReportTotalsBean implements Serializable {
14 |
15 | private static final long serialVersionUID = 2033649257986672921L;
16 |
17 | /**
18 | * Can be a test method name, servicename or class name etc.
19 | */
20 | private String item;
21 |
22 | /**
23 | * # of tests passed
24 | */
25 | private Long passed = 0L;
26 |
27 | /**
28 | * # of tests failed
29 | */
30 | private Long failed = 0L;
31 |
32 | /**
33 | * # of tests has exception
34 | */
35 | private Long exception = 0L;
36 |
37 | /**
38 | * Chart of the totals
39 | */
40 | private BufferedImage totalsGraph;
41 |
42 | public String getItem() {
43 | return item;
44 | }
45 |
46 | public void setItem(String item) {
47 | this.item = item;
48 | }
49 |
50 | public Long getPassed() {
51 | return passed;
52 | }
53 |
54 | public void setPassed(Long passed) {
55 | this.passed = passed;
56 | }
57 |
58 | public void addPassed() {
59 | this.passed++;
60 | }
61 |
62 | public void addPassed(long passed) {
63 | this.passed += passed;
64 | }
65 |
66 | public Long getFailed() {
67 | return failed;
68 | }
69 |
70 | public void setFailed(Long failed) {
71 | this.failed = failed;
72 | }
73 |
74 | public void addFailed() {
75 | this.failed++;
76 | }
77 |
78 | public void addFailed(long failed) {
79 | this.failed += failed;
80 | }
81 |
82 | public Long getException() {
83 | return exception;
84 | }
85 |
86 | public void setException(Long exception) {
87 | this.exception = exception;
88 | }
89 |
90 | public void addException() {
91 | this.exception++;
92 | }
93 |
94 | public void addException(long exception) {
95 | this.exception += exception;
96 | }
97 |
98 | public BufferedImage getTotalsGraph() {
99 | return totalsGraph;
100 | }
101 |
102 | public void setTotalsGraph(BufferedImage totalsGraph) {
103 | this.totalsGraph = totalsGraph;
104 | }
105 |
106 | /**
107 | * passed + failed + exception
108 | */
109 | public Long getTotal() {
110 | return this.passed + this.failed + this.exception;
111 | }
112 |
113 | /**
114 | * Percentage of tests passed
115 | *
116 | * @return
117 | */
118 | public Double getPercentagePassed() {
119 | return CommonUtils.getRounded(
120 | ((double) this.passed / this.getTotal()) * 100, 2);
121 | }
122 |
123 | /**
124 | * Percentage of tests failed
125 | *
126 | * @return
127 | */
128 | public Double getPercentageFailed() {
129 | return CommonUtils.getRounded(
130 | ((double) this.failed / this.getTotal()) * 100, 2);
131 | }
132 |
133 | /**
134 | * Percentage of tests exception
135 | *
136 | * @return
137 | */
138 | public Double getPercentageException() {
139 | return CommonUtils.getRounded(
140 | ((double) this.exception / this.getTotal()) * 100, 2);
141 | }
142 |
143 | @Override
144 | public String toString() {
145 | return "ReportTotalsBean [getItem()=" + getItem() + ", getPassed()="
146 | + getPassed() + ", getFailed()=" + getFailed()
147 | + ", getException()=" + getException() + ", getTotal()="
148 | + getTotal() + ", getPercentagePassed()="
149 | + getPercentagePassed() + ", getPercentageFailed()="
150 | + getPercentageFailed() + ", getPercentageException()="
151 | + getPercentageException() + "]";
152 | }
153 |
154 | }
155 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/reports/data/TestMethodDuration.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.reports.data;
2 |
3 | import java.io.Serializable;
4 | import java.math.BigDecimal;
5 |
6 | /**
7 | * Class encapsulating the information about the test methods exact executiopn time.
8 | * This class is actually used by the Reports functionality to provide useful reports
9 | * information to the end user.
10 | *
11 | * @author gpcmol
12 | *
13 | */
14 | public class TestMethodDuration implements Serializable {
15 |
16 | private static final long serialVersionUID = -6175933760799880386L;
17 |
18 | public static final long NANO_TO_MILLI = 1000000L;
19 |
20 | /**
21 | * Item, e.g. intercepted method call
22 | */
23 | private String item;
24 |
25 | /**
26 | * Start system time in nano
27 | */
28 | private long startInNano;
29 |
30 | /**
31 | * End system time in nano
32 | */
33 | private long endInNano;
34 |
35 | /**
36 | * Constructor
37 | */
38 | public TestMethodDuration() {
39 | // empty constructor
40 | }
41 |
42 | /**
43 | * Constructor
44 | *
45 | * @param item
46 | * e.g. method call
47 | * @param startInNano
48 | * start system time in nano
49 | * @param endInNano
50 | * end system time in nano
51 | */
52 | public TestMethodDuration(String item, long startInNano, long endInNano) {
53 | this();
54 | this.item = item;
55 | this.startInNano = startInNano;
56 | this.endInNano = endInNano;
57 | }
58 |
59 | public String getItem() {
60 | return item;
61 | }
62 |
63 | public void setItem(String item) {
64 | this.item = item;
65 | }
66 |
67 | public long getStartInNano() {
68 | return startInNano;
69 | }
70 |
71 | public void setStartInNano(long startInNano) {
72 | this.startInNano = startInNano;
73 | }
74 |
75 | public long getEndInNano() {
76 | return endInNano;
77 | }
78 |
79 | public void setEndInNano(long endInNano) {
80 | this.endInNano = endInNano;
81 | }
82 |
83 | /**
84 | * Time difference in nano seconds
85 | *
86 | * @return Time difference in nano seconds
87 | */
88 | public long getNanoDifference() {
89 | return this.endInNano - this.startInNano;
90 | }
91 |
92 | /**
93 | * Returns the difference end - start in milli seconds
94 | *
95 | * @return difference in ms
96 | */
97 | public long getMsDifference() {
98 | return getNanoDifference() / NANO_TO_MILLI;
99 | }
100 |
101 | /**
102 | * Returns rounded milli seconds
103 | * @return rounded difference in ms
104 | */
105 | public BigDecimal getRoundedMsDifference() {
106 | return BigDecimal.valueOf((double) getMsDifference());
107 | }
108 |
109 | @Override
110 | public String toString() {
111 | return "TestItemDurationBean [getItem()=" + getItem()
112 | + ", getStartInNano()=" + getStartInNano()
113 | + ", getEndInNano()=" + getEndInNano() + ", getMsDifference()="
114 | + getMsDifference() + "]";
115 | }
116 |
117 | }
118 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/reports/data/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Package containing classes that are responsible for gathering data for the reporting module of Easytest.
3 | *
4 | *
5 | */
6 |
7 | package org.easetech.easytest.reports.data;
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/reports/impl/ReportRunner.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.reports.impl;
2 |
3 | import java.io.IOException;
4 | import java.util.HashMap;
5 | import java.util.Map;
6 | import java.util.concurrent.Callable;
7 |
8 | import net.sf.jasperreports.engine.JRDataSource;
9 | import net.sf.jasperreports.engine.JRException;
10 | import org.easetech.easytest.annotation.Report.EXPORT_FORMAT;
11 | import org.easetech.easytest.annotation.Report.REPORT_TYPE;
12 | import org.easetech.easytest.reports.data.ReportDataContainer;
13 | import org.slf4j.Logger;
14 | import org.slf4j.LoggerFactory;
15 |
16 | /**
17 | * This class receives the preprared data from the ReportBuilder and runs the
18 | * reports
19 | *
20 | * @author gpcmol
21 | *
22 | */
23 | public class ReportRunner implements Callable {
24 | private static final Logger LOG = LoggerFactory.getLogger(ReportRunner.class);
25 |
26 | private ReportBuilder reportBuilder;
27 | private ReportExporter reportExporter;
28 | private ReportDataContainer testReportContainer;
29 |
30 | private EXPORT_FORMAT[] formats;
31 |
32 | private REPORT_TYPE[] types;
33 |
34 | private String destinationLocation;
35 |
36 | /**
37 | * Constructor
38 | * @param testReportContainer report container
39 | * @param formats format types
40 | * @param types report types (main or method duration report)
41 | * @param destinationLocation destination
42 | */
43 | public ReportRunner(ReportDataContainer testReportContainer, EXPORT_FORMAT formats[], REPORT_TYPE[] types, String destinationLocation) {
44 | this.testReportContainer = testReportContainer;
45 | this.formats = formats;
46 | this.types = types;
47 | this.destinationLocation = destinationLocation;
48 | this.reportBuilder = new ReportBuilder(testReportContainer);
49 | this.reportExporter = new ReportExporter();
50 | }
51 |
52 | /**
53 | * Prepares the report and calls the print method
54 | */
55 | public Boolean call() throws Exception {
56 | Map reportParameters = new HashMap();
57 |
58 | JRDataSource reportDataSource;
59 |
60 | Boolean returnValue = true;
61 |
62 | for (REPORT_TYPE type: types) {
63 | if (returnValue == false) {
64 | return false;
65 | }
66 | switch (type) {
67 | case DEFAULT:
68 | reportDataSource = reportBuilder.buildDefaultTestReport(reportParameters);
69 | break;
70 | case METHOD_DURATION:
71 | reportDataSource = reportBuilder.buildTestMethodDurationReport(reportParameters);
72 | break;
73 | default:
74 | return false;
75 | }
76 | returnValue = printReportForType(reportParameters, reportDataSource, type);
77 | }
78 | return returnValue;
79 | }
80 |
81 | /**
82 | * Print report for type (main report or method dureation report)
83 | * @param reportParameters report parameters
84 | * @param reportDataSource datasource
85 | * @param type report type
86 | * @return true if succeeded, false otherwise
87 | */
88 | private boolean printReportForType(Map reportParameters, JRDataSource reportDataSource, REPORT_TYPE type) {
89 | String className = testReportContainer.getClassName();
90 | reportParameters.put("TEST_CLASS_NAME", className);
91 |
92 | try {
93 | reportExporter.printReport(reportDataSource, reportParameters, destinationLocation, className,
94 | formats, type);
95 | } catch (JRException e) {
96 | System.out.println(e);
97 | e.printStackTrace();
98 | LOG.error("JRException occurred during generation of report", e);
99 | return false;
100 | } catch (IOException e) {
101 | System.out.println(e);
102 | LOG.error("IOException occurred during generation of report", e);
103 | return false;
104 | } catch (Exception e) {
105 | System.out.println(e);
106 | LOG.error("Exception occurred during generation of report", e);
107 | return false;
108 | }
109 |
110 | return true;
111 | }
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/reports/impl/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Package containing the Report module classes
3 | *
4 | *
5 | */
6 |
7 | package org.easetech.easytest.reports.impl;
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/reports/utils/PieChartColorRendererHelper.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.reports.utils;
2 |
3 | import java.awt.Color;
4 | import java.util.List;
5 | import org.jfree.chart.plot.PiePlot;
6 | import org.jfree.data.general.DefaultPieDataset;
7 |
8 | /**
9 | * Class for rendering customized colors for the purpose of PieChart
10 | * @author gpcmol
11 | *
12 | */
13 | public class PieChartColorRendererHelper {
14 | private Color[] color;
15 |
16 | /**
17 | * Constructor
18 | * @param color colors array
19 | */
20 | public PieChartColorRendererHelper(Color[] color) {
21 | this.color = color;
22 | }
23 |
24 | /**
25 | * Sets the color for dataset (ordered on index)
26 | * @param plot
27 | * @param dataset
28 | */
29 | @SuppressWarnings("rawtypes")
30 | public void setColor(PiePlot plot, DefaultPieDataset dataset) {
31 | @SuppressWarnings("unchecked")
32 | List keys = dataset.getKeys();
33 |
34 | for (int i = 0; i < keys.size(); i++) {
35 | plot.setSectionPaint(keys.get(i), this.color[i]);
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/reports/utils/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Util package
3 | *
4 | *
5 | */
6 |
7 | package org.easetech.easytest.reports.utils;
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/runner/EasyTestRunListener.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************************************************
2 | *
3 | * Copyright (c) 2012 OCLC, Inc. All Rights Reserved.
4 | *
5 | * OCLC proprietary information: the enclosed materials contain
6 | * proprietary information of OCLC, Inc. and shall not be disclosed in whole or in
7 | * any part to any third party or used by any person for any purpose, without written
8 | * consent of OCLC, Inc. Duplication of any portion of these materials shall include this notice.
9 | *
10 | ******************************************************************************************************************/
11 |
12 | package org.easetech.easytest.runner;
13 |
14 | import org.junit.internal.AssumptionViolatedException;
15 | import org.junit.runner.Description;
16 | import org.junit.runner.Result;
17 | import org.junit.runner.notification.Failure;
18 | import org.junit.runner.notification.RunListener;
19 | import org.slf4j.Logger;
20 | import org.slf4j.LoggerFactory;
21 |
22 | /**
23 | * Currently just a placeholder class that will be used later to factor out some common logic from the Runner class.
24 | *
25 | * @author Anuj Kumar
26 | *
27 | */
28 | public class EasyTestRunListener extends RunListener {
29 |
30 | /**
31 | * An instance of logger associated with the test framework.
32 | */
33 | protected static final Logger LOG = LoggerFactory.getLogger(EasyTestRunListener.class);
34 |
35 | /**
36 | * Called before any tests have been run.
37 | * @param description describes the tests to be run
38 | */
39 |
40 | public void testRunStarted(Description description) throws Exception {
41 | LOG.debug("testRunStarted with Description : " + description);
42 | }
43 |
44 | /**
45 | * Called when all tests have finished
46 | * @param result the summary of the test run, including all the tests that failed
47 | */
48 |
49 | public void testRunFinished(Result result) throws Exception {
50 | LOG.debug("testRunStarted with Result : " + result);
51 | }
52 |
53 | /**
54 | * Called when an atomic test is about to be started.
55 | * @param description the description of the test that is about to be run
56 | * (generally a class and method name)
57 | */
58 |
59 | public void testStarted(Description description) throws Exception {
60 | LOG.debug("testStarted with Description : " + description);
61 | }
62 |
63 | /**
64 | * Called when an atomic test has finished, whether the test succeeds or fails.
65 | * @param description the description of the test that just ran
66 | */
67 |
68 | public void testFinished(Description description) throws Exception {
69 | LOG.debug("testFinished with Description : " + description);
70 | }
71 |
72 | /**
73 | * Called when an atomic test fails.
74 | * @param failure describes the test that failed and the exception that was thrown
75 | */
76 |
77 | public void testFailure(Failure failure) throws Exception {
78 | LOG.debug("testFailure with Failure : " + failure);
79 | }
80 |
81 | /**
82 | * Called when an atomic test flags that it assumes a condition that is
83 | * false
84 | *
85 | * @param failure
86 | * describes the test that failed and the
87 | * {@link AssumptionViolatedException} that was thrown
88 | */
89 |
90 | public void testAssumptionFailure(Failure failure) {
91 | LOG.debug("testAssumptionFailure with Failure : " + failure);
92 | }
93 |
94 | /**
95 | * Called when a test will not be run, generally because a test method is annotated
96 | * with {@link org.junit.Ignore}.
97 | *
98 | * @param description describes the test that will not be run
99 | */
100 |
101 | public void testIgnored(Description description) throws Exception {
102 | LOG.debug("testIgnored with Description : " + description);
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/runner/EasyTestSuite.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.runner;
2 |
3 | import org.easetech.easytest.annotation.Parallel;
4 | import org.easetech.easytest.internal.SystemProperties;
5 | import org.easetech.easytest.strategy.SchedulerStrategy;
6 | import org.junit.internal.builders.AllDefaultPossibilitiesBuilder;
7 | import org.junit.runners.Suite;
8 | import org.junit.runners.model.InitializationError;
9 |
10 | /**
11 | * Extended Suite class for EasyTest.
12 | * This Suite class gives the users ability to run the Suite classes in Parallel.
13 | * It also provides a convenient place to define parallel threads per test class
14 | *
15 | */
16 | public class EasyTestSuite extends Suite {
17 |
18 | /**
19 | *
20 | * Construct a new EasyTestSuite
21 | * @param klass
22 | * @throws InitializationError
23 | */
24 | public EasyTestSuite(Class> klass) throws InitializationError {
25 | super(klass , new AllDefaultPossibilitiesBuilder(true));
26 | setSchedulingStrategy();
27 | setScheduler(SchedulerStrategy.getSchedulerForSuite(klass));
28 | }
29 |
30 | /**
31 | * Set whether the tests should be run in parallel or serial.
32 | */
33 | protected void setSchedulingStrategy() {
34 | Class> testClass = getTestClass().getJavaClass();
35 | super.setScheduler(SchedulerStrategy.getScheduler(testClass , false));
36 | Parallel parallelAnnotation = testClass.getAnnotation(Parallel.class);
37 | if(parallelAnnotation != null) {
38 | int threads = parallelAnnotation.threads();
39 | System.setProperty(SystemProperties.PARALLEL_THREAD_COUNT.getValue(), String.valueOf(threads));
40 | }
41 |
42 |
43 | }
44 |
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/runner/TestPolicyHandler.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.runner;
2 |
3 | public class TestPolicyHandler {
4 |
5 | }
6 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/runner/TestRunDurationListener.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.runner;
2 |
3 | import org.junit.runner.Description;
4 |
5 | /**
6 | * This listener measures the time of the test execution
7 | * @author gpcmol
8 | *
9 | */
10 | public class TestRunDurationListener extends EasyTestRunListener {
11 |
12 | private long startInNano = 0L;
13 | private long endInNano = 0L;
14 |
15 |
16 |
17 | public void testFinished(Description description) throws Exception {
18 | endInNano = System.nanoTime();
19 | }
20 |
21 | public void testStarted(Description description) throws Exception {
22 | startInNano = System.nanoTime();
23 | }
24 |
25 | public long getStartInNano() {
26 | return startInNano;
27 | }
28 |
29 | public long getEndInNano() {
30 | return endInNano;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/runner/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Package containing the EasyTest runner implementation and various other supporting classes.
3 | * {@link org.easetech.easytest.runner.DataDrivenTestRunner} is the main class that a user uses to enable EasyTest support.
4 | *
5 | *
6 | */
7 |
8 | package org.easetech.easytest.runner;
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/strategy/ParallelScheduler.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.strategy;
3 |
4 | import java.util.concurrent.ExecutorService;
5 | import java.util.concurrent.Executors;
6 | import java.util.concurrent.TimeUnit;
7 | import org.junit.runners.model.RunnerScheduler;
8 |
9 | /**
10 | * {@link RunnerScheduler} implementation to run tests in Parallel.
11 | * @author Anuj Kumar
12 | *
13 | */
14 | public class ParallelScheduler implements RunnerScheduler {
15 |
16 | /**
17 | * An instance of {@link ExecutorService} to run tests in Parallel
18 | */
19 | private final ExecutorService executorService;
20 |
21 | /**
22 | * Construct a new ParallelScheduler.
23 | * This creates a Cached Thread Pool Executor Service
24 | */
25 | public ParallelScheduler() {
26 | this.executorService = Executors.newCachedThreadPool();
27 | }
28 |
29 | /**
30 | *
31 | * Construct a new ParallelScheduler
32 | * This creates a fixed thread pool executor Service,
33 | * where the user passes the number of threads he wants to start
34 | * @param threadsToStart the number of threads in the thread pool
35 | */
36 | public ParallelScheduler(int threadsToStart) {
37 | this.executorService = Executors.newFixedThreadPool(threadsToStart);
38 | }
39 |
40 | /**
41 | * Schedule a Runnable {@link org.junit.runners.model.Statement}
42 | * @param childStatement a runnable implementation
43 | */
44 | public void schedule(Runnable childStatement) {
45 | executorService.submit(childStatement);
46 |
47 | }
48 |
49 | /**
50 | * Method called when all the test methods have been executed
51 | * by the {@link ExecutorService} instance.
52 | * This method is used to shutdown and await for termination of all threads.
53 | */
54 | public void finished() {
55 | try {
56 | executorService.shutdown();
57 | executorService.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
58 | } catch (InterruptedException e) {
59 | e.printStackTrace(System.err);
60 | }
61 |
62 | }
63 |
64 | /**
65 | *
66 | * @return the executorService
67 | */
68 | public ExecutorService getExecutorService() {
69 | return executorService;
70 | }
71 |
72 |
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/strategy/SchedulerStrategy.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.strategy;
3 |
4 | import org.easetech.easytest.annotation.Parallel;
5 | import org.easetech.easytest.annotation.ParallelSuite;
6 | import org.easetech.easytest.annotation.TestPolicy;
7 | import org.easetech.easytest.internal.SystemProperties;
8 | import org.junit.runners.model.RunnerScheduler;
9 |
10 | /**
11 | * A simple Strategy class that decides the Scheduler to use to run the tests. Scheduler at the moment can be serial or
12 | * parallel.
13 | * A user can specify {@link Parallel} annotation at the class level to run tests in that class in parallel. If the
14 | * Parallel annotation is not specified then the scheduler is not overridden and JUnits strategy is used to run the
15 | * tests.
16 | *
17 | * @author Anuj Kumar
18 | *
19 | */
20 | public class SchedulerStrategy {
21 |
22 | /**
23 | * Get the correct Scheduler requested by the user based on the {@link Parallel} annotation.
24 | *
25 | * @param testClass the Class under test
26 | * @param policyApplied Identifies whether a test Policy identified by {@link TestPolicy} annotation has been applied or not
27 | * @return an implementation of {@link RunnerScheduler}
28 | */
29 | public static RunnerScheduler getScheduler(Class> testClass , Boolean policyApplied) {
30 | Parallel parallelAnnotation = testClass.getAnnotation(Parallel.class);
31 | String parallelThreadsStr = System.getProperty(SystemProperties.PARALLEL_THREAD_COUNT.getValue());
32 | Integer parallelThreads = null;
33 | if (parallelThreadsStr != null) {
34 | parallelThreads = Integer.valueOf(parallelThreadsStr);
35 | }
36 |
37 | if (parallelThreads != null) {
38 | if (parallelThreads <= 0) {
39 | return new ParallelScheduler();
40 | } else {
41 | return new ParallelScheduler(parallelThreads);
42 | }
43 | } else {
44 | if (parallelAnnotation != null) {
45 | if (parallelAnnotation.threads() <= 0) {
46 | return new ParallelScheduler();
47 | } else {
48 | return new ParallelScheduler(parallelAnnotation.threads());
49 | }
50 |
51 | }
52 | }
53 | if(policyApplied) {
54 | return null;
55 | }
56 | return new SerialScheduler();
57 |
58 | }
59 |
60 | /**
61 | * Utility method to get the Scheduler for Suite class
62 | * @param suiteClass the suiteClass
63 | * @return an instance of {@link RunnerScheduler}
64 | */
65 | public static RunnerScheduler getSchedulerForSuite(Class> suiteClass) {
66 | ParallelSuite parallelSuite = suiteClass.getAnnotation(ParallelSuite.class);
67 | if(parallelSuite != null) {
68 | if(parallelSuite.threads() <=0) {
69 | return new ParallelScheduler();
70 | } else {
71 | return new ParallelScheduler(parallelSuite.threads());
72 | }
73 | }
74 | return new SerialScheduler();
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/strategy/SerialScheduler.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.strategy;
2 |
3 | import org.junit.runners.model.RunnerScheduler;
4 |
5 | /**
6 | * A simple Scheduler that runs all the test methods in Serial Order
7 | *
8 | */
9 | public class SerialScheduler implements RunnerScheduler {
10 |
11 | /**
12 | * Schedule the execution of a test method, which in this case is immediate
13 | * @param childStatement the statement to execute
14 | */
15 | public void schedule(Runnable childStatement) {
16 | childStatement.run();
17 |
18 | }
19 |
20 | /**
21 | * Method called after all the test methods have been executed.
22 | * In case of Serial execution, nothing extra is required.
23 | */
24 | public void finished() {
25 | // TODO Auto-generated method stub
26 |
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/strategy/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Package containing classes responsible for deciding the scheduling strategy to use while running test methods
3 | *
4 | *
5 | */
6 |
7 | package org.easetech.easytest.strategy;
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/util/ConfigContext.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.util;
3 |
4 | import java.util.HashMap;
5 | import java.util.Map;
6 | import org.easetech.easytest.annotation.TestBean;
7 | import org.easetech.easytest.annotation.TestConfigProvider;
8 |
9 | /**
10 | * A context class for holding the Configuration beans declared by the user. This class provides a utility for the
11 | * EasyTest framework to identify a test bean declared using {@link TestBean} annotations inside a class that is
12 | * declared in the test class using {@link TestConfigProvider}
13 | *
14 | * @author Anuj Kumar
15 | */
16 | public final class ConfigContext {
17 |
18 | private ConfigContext() {
19 | // do nothing
20 | }
21 |
22 | /**
23 | * The threadlocal variable that is responsible for containing the bean name to object instance mapping
24 | */
25 | public static final InheritableThreadLocal> beansByName = new InheritableThreadLocal>();
26 |
27 | /**
28 | * The threadlocal variable that is responsible for containing the bean type to object instance mapping
29 | */
30 | public static final InheritableThreadLocal> beansByType = new InheritableThreadLocal>();
31 |
32 | /**
33 | * Set the test bean in the thread local variable by name
34 | *
35 | * @param beanName the name of the bean
36 | * @param beanInstance the instance to set
37 | */
38 | public static void setTestBeanByName(String beanName, Object beanInstance) {
39 | Map beanNamesMap = beansByName.get();
40 | if (beanNamesMap == null) {
41 | beanNamesMap = new HashMap();
42 | }
43 | beanNamesMap.put(beanName, beanInstance);
44 | beansByName.set(beanNamesMap);
45 |
46 | }
47 |
48 | /**
49 | * Set the test bean in the threadlocal variable by type
50 | *
51 | * @param beanType the type of the bean
52 | * @param beanInstance the instance to set
53 | */
54 | public static void setTestBeanByType(Class beanType, Object beanInstance) {
55 | Map beanTypesMap = beansByType.get();
56 | if (beanTypesMap == null) {
57 | beanTypesMap = new HashMap();
58 | }
59 | beanTypesMap.put(beanType, beanInstance);
60 | beansByType.set(beanTypesMap);
61 | }
62 |
63 | /**
64 | * Get the test bean by name.
65 | *
66 | * @param beanName the name of the bean to get value for
67 | * @return the bean instance or null if not found
68 | */
69 | public static Object getBeanByName(String beanName) {
70 | Map beanNamesMap = beansByName.get();
71 | if (beanNamesMap == null) {
72 | return null;
73 | }
74 | return beanNamesMap.get(beanName);
75 | }
76 |
77 | /**
78 | * Get the test bean by type
79 | *
80 | * @param beanType the type of bean to get
81 | * @return the instance of the bean
82 | */
83 | public static Object getBeanByType(Class beanType) {
84 | Map beanTypesMap = beansByType.get();
85 | if (beanTypesMap == null) {
86 | return null;
87 | }
88 | return beanTypesMap.get(beanType);
89 | }
90 |
91 | public static void cleanConfigContext() {
92 | beansByName.remove();
93 | beansByType.remove();
94 | }
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/util/TestInfo.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.util;
3 |
4 | import java.util.Arrays;
5 | import org.easetech.easytest.loader.Loader;
6 | import org.junit.runners.model.TestClass;
7 |
8 | /**
9 | *
10 | * TestInfo class encapsulates the information about a given test method that could be used by various parties to get
11 | * the runtime information about the given test method. This class is currently being used by the
12 | * {@link RunAftersWithOutputData} to find and call the right Loader to write the data for a given method.
13 | *
14 | */
15 | public class TestInfo {
16 |
17 | /**
18 | * An instance of {@link TestClass} associated with the given test method info
19 | */
20 | private TestClass testClass;
21 |
22 | /**
23 | * The loader used by the method to load the data
24 | */
25 | private Loader dataLoader;
26 |
27 | /**
28 | * The files associated with the method's data
29 | */
30 | private String[] filePaths;
31 |
32 | /**
33 | * The name of the method
34 | */
35 | private String methodName;
36 |
37 | /**
38 | * Write the data back to the file
39 | */
40 | private Boolean writeData;
41 |
42 | /**
43 | * whether to write data back to the file or not
44 | * @return the writeData whether to write data back to the file or not
45 | */
46 | public Boolean getWriteData() {
47 | return writeData;
48 | }
49 |
50 | /**
51 | * whether to write data back to the file or not
52 | * @param writeData the writeData to set
53 | */
54 | public void setWriteData(Boolean writeData) {
55 | this.writeData = writeData;
56 | }
57 |
58 | /**
59 | *
60 | * Construct a new TestInfo
61 | * @param testClass an instance of {@link TestClass}
62 | */
63 | public TestInfo(TestClass testClass) {
64 | this.testClass = testClass;
65 |
66 | }
67 |
68 | /**
69 | * Get Test Class instance
70 | * @return Test Class instance
71 | */
72 | public TestClass getTestClass() {
73 | return testClass;
74 | }
75 |
76 | /**
77 | * Get associated Data Loader
78 | * @return associated Data Loader
79 | */
80 | public Loader getDataLoader() {
81 | return dataLoader;
82 | }
83 |
84 | /**
85 | * Set associated Data Loader
86 | * @param dataLoader associated Data Loader
87 | */
88 | public void setDataLoader(Loader dataLoader) {
89 | this.dataLoader = dataLoader;
90 | }
91 |
92 | /**
93 | * Get filePaths
94 | * @return filePaths
95 | */
96 | public String[] getFilePaths() {
97 | return filePaths;
98 | }
99 |
100 | /**
101 | * Set filePaths
102 | * @param filePaths filePaths
103 | */
104 | public void setFilePaths(String[] filePaths) {
105 | this.filePaths = filePaths;
106 | }
107 |
108 | /**
109 | * Get method name
110 | * @return method name
111 | */
112 | public String getMethodName() {
113 | return methodName;
114 | }
115 |
116 | /**
117 | * Set method name
118 | * @param methodName method name
119 | */
120 | public void setMethodName(String methodName) {
121 | this.methodName = methodName;
122 | }
123 |
124 | /**
125 | * @return the overridden toString
126 | */
127 | @Override
128 | public String toString() {
129 | return "TestInfo [testClass=" + testClass + ", dataLoader=" + dataLoader + ", filePaths="
130 | + Arrays.toString(filePaths) + ", methodName=" + methodName + "]";
131 | }
132 |
133 |
134 |
135 | }
--------------------------------------------------------------------------------
/src/main/java/org/easetech/easytest/util/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Util Package
3 | *
4 | *
5 | */
6 |
7 | package org.easetech.easytest.util;
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/conditions/TestConditionsSupportedByDataDrivenTest.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.conditions;
2 |
3 |
4 |
5 | import java.sql.Date;
6 | import java.util.LinkedList;
7 | import java.util.Map;
8 | import java.util.TreeMap;
9 | import org.easetech.easytest.annotation.DataLoader;
10 | import org.easetech.easytest.annotation.Param;
11 | import org.easetech.easytest.converter.ConverterManager;
12 | import org.easetech.easytest.example.CustomObjectDataLoader;
13 | import org.easetech.easytest.example.ItemConverter;
14 | import org.easetech.easytest.example.ItemId;
15 | import org.easetech.easytest.runner.DataDrivenTestRunner;
16 | import org.junit.AfterClass;
17 | import org.junit.BeforeClass;
18 | import org.junit.Test;
19 | import org.junit.runner.RunWith;
20 |
21 | /**
22 | *
23 | * An example test class that tries to list different scenarios of using {@link DataDrivenTestRunner} and its supports
24 | * annotations and classes. We are loading the test data at the class level, but the user can override the data at the
25 | * method level as well.
26 | *
27 | */
28 | @RunWith(DataDrivenTestRunner.class)
29 | @DataLoader(filePaths = { "getDDTData.csv" })
30 | public class TestConditionsSupportedByDataDrivenTest {
31 |
32 | @Test
33 | public void testBug(@Param(name="className") String name, @Param(name="dateDebut")Date dateDebut , @Param(name="dateFin")Date dateFin){
34 | System.out.println("Class Name :" + name + " DateDebut : " + dateDebut + " dateFin :" + dateFin);
35 | }
36 |
37 |
38 | /**
39 | * Example showing the usage of propertyEditors for getting custom object.
40 | */
41 | @BeforeClass
42 | public static void setUpGone() {
43 | System.out.println("Should be printed only once");
44 | //PropertyEditorManager.registerEditor(LibraryId.class, LibraryIdEditor.class);
45 | ConverterManager.registerConverter(ItemConverter.class);
46 | }
47 |
48 | @AfterClass
49 | public static void tearDown() {
50 | System.out.println("Should ALSO be printed only once");
51 |
52 | }
53 |
54 |
55 |
56 | /**
57 | * Test DDT runner with a generic MAP parameter
58 | *
59 | * @param inputData
60 | */
61 | @Test
62 | public void testDDTGetItem(
63 | Map inputData) {
64 | System.out.print("Executing testDDTGetItem :");
65 | System.out.println("library Id : " + inputData.get("LibraryId") + " and item type : "
66 | + inputData.get("itemType") + " and search text array :" + inputData.get("searchText"));
67 |
68 | }
69 |
70 |
71 | /**
72 | * Test case showing the use of {@link DataLoader} annotation. This example can also be used as a test to using
73 | * PropertyEditors that are registered by the test class itself.
74 | *
75 | * @param inputData
76 | */
77 | @Test
78 | @DataLoader(loader = CustomObjectDataLoader.class)
79 | public void testDDTGetItemsWithCustomLoader(
80 | TreeMap inputData) {
81 | System.out.print("Executing testDDTGetItemsWithCustomLoader :");
82 | System.out.println("library Id : " + inputData.get("LibraryId"));
83 |
84 | }
85 |
86 | /**
87 | * Test case that uses {@link ItemConverter} to convert from a Hashmap to an Item object instance.
88 | *
89 | * @param item an instance of Item object that is automatically converted from a map to an Item instance.
90 | */
91 | @Test
92 | public String testDDTConverter(@Param(name="items")LinkedList items) {
93 | System.out.print("Executing testDDTConverter :");
94 | for(ItemId itemId : items){
95 | System.out.println("Item Id is:" + itemId);
96 | }
97 | return "Sample";
98 | // Assert.assertNotNull(item);
99 | // System.out.println(item.getDescription() + item.getItemId() + item.getItemType());
100 |
101 | }
102 |
103 | @Test
104 | public String testMethodWithNoParameter(){
105 | return "Empty Value";
106 | }
107 |
108 |
109 | }
110 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/ComparableObject.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | public class ComparableObject implements Comparable {
4 |
5 | private Long item;
6 |
7 |
8 |
9 | /**
10 | * Construct a new ComparableObject
11 | * @param item
12 | */
13 | public ComparableObject(Long item) {
14 | super();
15 | this.item = item;
16 | }
17 |
18 |
19 |
20 | @Override
21 | public String toString() {
22 | return "ComparableObject [item=" + item + "]";
23 | }
24 |
25 |
26 |
27 | public Long getItem() {
28 | return item;
29 | }
30 |
31 |
32 |
33 | public void setItem(Long item) {
34 | this.item = item;
35 | }
36 |
37 |
38 |
39 | /**
40 | * @param o
41 | * @return
42 | */
43 | public int compareTo(ComparableObject o) {
44 | return 1;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/ComparableObjectConverter.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import java.util.Map;
4 | import org.easetech.easytest.converter.AbstractConverter;
5 |
6 | public class ComparableObjectConverter extends AbstractConverter {
7 |
8 | /**
9 | * @param convertFrom
10 | * @return
11 | */
12 | public ComparableObject convert(Map convertFrom) {
13 | System.out.println("Param name is :" + getParamName());
14 | String items = (String)convertFrom.get("items");
15 | return new ComparableObject(Long.valueOf(items));
16 |
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/CustomObjectDataLoader.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.example;
3 |
4 | import java.util.ArrayList;
5 | import java.util.HashMap;
6 | import java.util.List;
7 | import java.util.Map;
8 | import org.easetech.easytest.io.Resource;
9 | import org.easetech.easytest.loader.Loader;
10 |
11 | /**
12 | *
13 | * A Custom Data Loader that simply provides data from the class itself without reading any external files.
14 | *
15 | */
16 | public class CustomObjectDataLoader implements Loader {
17 |
18 |
19 | public Map>> loadData(Resource resource) {
20 | Map>> result = new HashMap>>();
21 | List> list = new ArrayList>();
22 | Map map1 = new HashMap();
23 | Map map2 = new HashMap();
24 | Item item1 = new Item (1, "Item1");
25 | Item item2= new Item (1, "Item2");
26 | map1.put("Item", item1);
27 | map2.put("Item", item2);
28 | list.add(map1);
29 | list.add(map2);
30 | result.put("testGetItemsWithCustomLoader", list);
31 | return result;
32 | }
33 |
34 | public void writeData(Resource resource, Map>> actualData, String... methodName) {
35 | // TODO Auto-generated method stub
36 |
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/DelayedObject.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import java.util.concurrent.Delayed;
4 | import java.util.concurrent.TimeUnit;
5 |
6 | public class DelayedObject implements Delayed {
7 |
8 | private Long value;
9 |
10 |
11 | @Override
12 | public String toString() {
13 | return "DelayedObject [value=" + value + "]";
14 | }
15 |
16 | public Long getValue() {
17 | return value;
18 | }
19 |
20 | public void setValue(Long value) {
21 | this.value = value;
22 | }
23 |
24 | /**
25 | * Construct a new DelayedObject
26 | * @param value
27 | */
28 | public DelayedObject(Long value) {
29 | super();
30 | this.value = value;
31 | }
32 |
33 | public int compareTo(Delayed o) {
34 |
35 | return 1;
36 | }
37 |
38 | public long getDelay(TimeUnit unit) {
39 |
40 | return 0;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/DelayedObjectConverter.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import java.util.Map;
4 | import org.easetech.easytest.converter.AbstractConverter;
5 |
6 | public class DelayedObjectConverter extends AbstractConverter{
7 |
8 | /**
9 | * @param convertFrom
10 | * @return
11 | */
12 | public DelayedObject convert(Map convertFrom) {
13 | System.out.println("The parameter passed is :" + getParamName());
14 |
15 | return new DelayedObject(Long.valueOf((String)convertFrom.get("items")));
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/DequeConverter.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import java.util.Map;
4 | import java.util.concurrent.LinkedBlockingQueue;
5 | import org.easetech.easytest.converter.AbstractConverter;
6 |
7 | public class DequeConverter extends AbstractConverter {
8 |
9 | /**
10 | * @param convertFrom
11 | * @return
12 | */
13 | public LinkedBlockingQueue convert(Map convertFrom) {
14 | // TODO Auto-generated method stub
15 | return null;
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/EnumConverter.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import java.util.Map;
4 | import org.easetech.easytest.converter.AbstractConverter;
5 | import org.easetech.easytest.example.EnumObject.Workingday;
6 |
7 | public class EnumConverter extends AbstractConverter {
8 |
9 | /**
10 | * @param convertFrom
11 | * @return
12 | */
13 | public Workingday convert(Map convertFrom) {
14 |
15 | return Workingday.valueOf((String)convertFrom.get("items"));
16 |
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/EnumObject.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import java.util.EnumSet;
4 |
5 | public class EnumObject{
6 |
7 | public enum Workingday {
8 | Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday;
9 | public static final EnumSet Workdays = EnumSet.range(
10 | Monday, Friday);
11 | public final boolean isWorkday() {
12 | return Workdays.contains(this);
13 | }
14 | public static final EnumSet WHOLE_WEEK = EnumSet.allOf(Workingday.class);
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/Item.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.example;
3 |
4 | public class Item {
5 |
6 | private String description;
7 |
8 | private String itemType;
9 |
10 | private ItemId itemId;
11 |
12 | public Item() {
13 |
14 | }
15 |
16 | public Item(long itemId , String itemType) {
17 | this.itemId = new ItemId(itemId);
18 | this.itemType = itemType;
19 | }
20 |
21 | /**
22 | * @return the description
23 | */
24 | public String getDescription() {
25 | return description;
26 | }
27 |
28 | /**
29 | * @param description the description to set
30 | */
31 | public void setDescription(String description) {
32 | this.description = description;
33 | }
34 |
35 | /**
36 | * @return the itemType
37 | */
38 | public String getItemType() {
39 | return itemType;
40 | }
41 |
42 | /**
43 | * @param itemType the itemType to set
44 | */
45 | public void setItemType(String itemType) {
46 | this.itemType = itemType;
47 | }
48 |
49 | /**
50 | * @return the itemId
51 | */
52 | public ItemId getItemId() {
53 | return itemId;
54 | }
55 |
56 | /**
57 | * @param itemId the itemId to set
58 | */
59 | public void setItemId(ItemId itemId) {
60 | this.itemId = itemId;
61 | }
62 |
63 | @Override
64 | public String toString() {
65 | return "Item [description=" + description + ", itemType=" + itemType + ", itemId=" + itemId + "]";
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/ItemAndLocation.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | public class ItemAndLocation {
4 |
5 | private Item item;
6 |
7 | private Location location;
8 |
9 | private Integer id;
10 |
11 | /**
12 | * @return the item
13 | */
14 | public Item getItem() {
15 | return item;
16 | }
17 |
18 | /**
19 | * @param item the item to set
20 | */
21 | public void setItem(Item item) {
22 | this.item = item;
23 | }
24 |
25 | /**
26 | * @return the location
27 | */
28 | public Location getLocation() {
29 | return location;
30 | }
31 |
32 | /**
33 | * @param location the location to set
34 | */
35 | public void setLocation(Location location) {
36 | this.location = location;
37 | }
38 |
39 | /**
40 | * @return the id
41 | */
42 | public Integer getId() {
43 | return id;
44 | }
45 |
46 | /**
47 | * @param id the id to set
48 | */
49 | public void setId(Integer id) {
50 | this.id = id;
51 | }
52 |
53 |
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/ItemConverter.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.example;
3 |
4 | import java.util.Map;
5 | import org.easetech.easytest.converter.AbstractConverter;
6 |
7 | public class ItemConverter extends AbstractConverter- {
8 |
9 | public Item convert(Map
convertFrom) {
10 | Item item = null;
11 | System.out.println("Param Name is : " + getParamName());
12 |
13 | if (convertFrom != null) {
14 | item = new Item();
15 | item.setDescription((String) convertFrom.get("itemDescription"));
16 | System.out.println(convertFrom.get("itemId"));
17 | item.setItemId(new ItemId(Long.valueOf((String) convertFrom.get("itemId"))));
18 | item.setItemType((String) convertFrom.get("itemType"));
19 | }
20 | return item;
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/ItemId.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.example;
3 |
4 | /**
5 | *
6 | * An example of user defined Strongly typed object
7 | *
8 | */
9 | public class ItemId {
10 |
11 | /**
12 | * The id
13 | */
14 | private Long id;
15 |
16 | /**
17 | *
18 | * Construct a new ItemId
19 | *
20 | * @param id theid
21 | */
22 | public ItemId(Long id) {
23 | this.id = id;
24 | }
25 |
26 | public ItemId() {
27 | }
28 |
29 | /**
30 | * @return the toString representation
31 | */
32 | @Override
33 | public String toString() {
34 | return "ItemId [id=" + id + "]";
35 | }
36 |
37 | /**
38 | * @return the id
39 | */
40 | public Long getId() {
41 | return id;
42 | }
43 |
44 | /**
45 | * @param id the id to set
46 | */
47 | public void setId(Long id) {
48 | this.id = id;
49 | }
50 |
51 |
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/ItemService.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.example;
3 |
4 | import java.util.List;
5 |
6 | public interface ItemService {
7 |
8 | /**
9 | *
10 | * @param libraryId
11 | * @param searchText
12 | * @param itemType
13 | * @return
14 | */
15 | public List- getItems(LibraryId libraryId, String searchText, String itemType);
16 |
17 | public Item findItem(LibraryId libraryId, ItemId itemId);
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/LibraryId.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.example;
3 |
4 | /**
5 | *
6 | * An example of user defined Strongly typed object
7 | *
8 | */
9 | public class LibraryId {
10 |
11 | /**
12 | * The id
13 | */
14 | private Long id;
15 |
16 | /**
17 | *
18 | * Construct a new LibraryId
19 | *
20 | * @param id the id
21 | */
22 | public LibraryId(Long id) {
23 | this.id = id;
24 | }
25 |
26 |
27 |
28 | /**
29 | * @return the id
30 | */
31 | public Long getId() {
32 | return id;
33 | }
34 |
35 |
36 |
37 | /**
38 | * @return the toString representation
39 | */
40 | @Override
41 | public String toString() {
42 | return "LibraryId [id=" + id + "]";
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/Location.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | public class Location {
4 |
5 | private String locationName;
6 |
7 | private LocationId locationId;
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/LocationId.java:
--------------------------------------------------------------------------------
1 | /****************************************************************************************************************
2 | *
3 | * Copyright (c) 2013 OCLC, Inc. All Rights Reserved.
4 | *
5 | * OCLC proprietary information: the enclosed materials contain
6 | * proprietary information of OCLC, Inc. and shall not be disclosed in whole or in
7 | * any part to any third party or used by any person for any purpose, without written
8 | * consent of OCLC, Inc. Duplication of any portion of these materials shall include this notice.
9 | *
10 | ******************************************************************************************************************/
11 |
12 | package org.easetech.easytest.example;
13 |
14 | /**
15 | * TODO Describe me
16 | *
17 | */
18 | public class LocationId {
19 |
20 | private Integer locId;
21 |
22 | public LocationId(Integer locId){
23 | this.locId = locId;
24 | }
25 |
26 | /**
27 | * @return the locId
28 | */
29 | public Integer getLocId() {
30 | return locId;
31 | }
32 |
33 |
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/RealItemService.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.example;
3 |
4 | import java.util.ArrayList;
5 | import java.util.Collections;
6 | import java.util.Iterator;
7 | import java.util.List;
8 |
9 | public class RealItemService implements ItemService {
10 |
11 | public String testString;
12 |
13 | @SuppressWarnings("unchecked")
14 | public List
- getItems(LibraryId libraryId, String searchText, String itemType) {
15 | System.out.println("getItems Called");
16 | return Collections.EMPTY_LIST;
17 | }
18 |
19 | public Item findItem(LibraryId libraryId, ItemId itemId) {
20 |
21 | System.out.println("findItems Called");
22 | Item item = new Item();
23 | item.setDescription("Item Description Modified Again");
24 | item.setItemId(itemId== null ? null : itemId);
25 | item.setItemType("BOOK");
26 | return item;
27 | }
28 |
29 | public static void main(String[] args) {
30 | ArrayList
stringList = new ArrayList();
31 | stringList.add(null);
32 | Iterator strItr = stringList.iterator();
33 | while (strItr.hasNext()) {
34 | System.out.println(strItr.next());
35 | }
36 | for (String str : stringList) {
37 | System.out.println(str);
38 | }
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TemperatureConverter.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | public class TemperatureConverter {
4 |
5 | public int toCelsius(int fahrenheit) {
6 | return (fahrenheit - 32) * 5 / 9;
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TestBeanProviderFunctionality.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import javax.inject.Inject;
4 | import javax.inject.Named;
5 | import org.easetech.easytest.annotation.DataLoader;
6 | import org.easetech.easytest.annotation.Param;
7 | import org.easetech.easytest.annotation.TestConfigProvider;
8 | import org.easetech.easytest.runner.DataDrivenTestRunner;
9 | import org.junit.Assert;
10 | import org.junit.Test;
11 | import org.junit.runner.RunWith;
12 | import org.slf4j.Logger;
13 | import org.slf4j.LoggerFactory;
14 |
15 | @RunWith(DataDrivenTestRunner.class)
16 | @TestConfigProvider({TestConfigProviderClass.class})
17 | public class TestBeanProviderFunctionality {
18 |
19 | @Inject
20 | @Named("itemService")
21 | public ItemService testSubject;
22 |
23 | /**
24 | * An instance of logger associated with the test framework.
25 | */
26 | protected static final Logger LOG = LoggerFactory.getLogger(TestExcelDataLoader.class);
27 |
28 |
29 | @Test
30 | @DataLoader(filePaths={"classpath:overrideExcelData.csv"})
31 | public Item getExcelTestDataWithDouble(@Param(name="libraryId")
32 | Double libraryId, @Param(name="itemId")
33 | Double itemId) {
34 | Assert.assertNotNull(testSubject);
35 | System.out.print("Executing getExcelTestDataWithDouble :");
36 | // if(itemId.equals(11568.0D)){
37 | // Assert.fail("ItemId is 11568 but should be 2");
38 | // }
39 | System.out.println("LibraryId Anuj is :" + libraryId + " and Item Id is :" + itemId);
40 | //itemService.testString = "String";
41 | Item item = testSubject.findItem(new LibraryId(Long.valueOf(libraryId.longValue())),
42 | new ItemId(Long.valueOf(itemId.longValue())));
43 | return item;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TestBorderConditions.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import org.easetech.easytest.annotation.DataLoader;
4 | import org.easetech.easytest.annotation.Param;
5 | import org.easetech.easytest.runner.DataDrivenTestRunner;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 |
9 | /**
10 | * Test that checks for NULL, 0 and negative values as part of the Test Data
11 | *
12 | */
13 | @RunWith(DataDrivenTestRunner.class)
14 | @DataLoader(filePaths={"borderConditions.csv"})
15 | public class TestBorderConditions {
16 |
17 | public static void before(){
18 | //PropertyEditorManager.registerEditor(ItemId.class, ItemIdEditor.class);
19 | }
20 |
21 | private ItemService itemService = new RealItemService();
22 |
23 | @Test
24 | public void checkForNull(@Param(name="itemId") ItemId itemId){
25 | System.out.println("CSV Item Id is :" + itemId);
26 | itemService.findItem(null, itemId);
27 | }
28 |
29 | @Test
30 | public void checkForNullWithTypedParam(@Param(name="itemId") ItemId itemId){
31 | System.out.println("CSV Item Id is :" + itemId);
32 | itemService.findItem(null, itemId);
33 | }
34 |
35 | @DataLoader(filePaths={"borderConditions.xls"})
36 | @Test
37 | public void checkForNullWithExcel(@Param(name="itemId") Long itemId){
38 | System.out.println("Excel Item Id is :" + itemId);
39 | itemService.findItem(null, new ItemId(itemId));
40 | }
41 |
42 | @DataLoader(filePaths={"borderConditions.xls"})
43 | @Test
44 | public void checkForNullTypedParamWithExcel(@Param(name="itemId") ItemId itemId){
45 | System.out.println("Excel Item Id is :" + itemId);
46 | itemService.findItem(null, itemId);
47 | }
48 |
49 | @DataLoader(filePaths={"borderConditions.xml"})
50 | @Test
51 | public void checkForNullWithXML(@Param(name="itemId") Long itemId){
52 | System.out.println("XML Item Id is :" + itemId);
53 | itemService.findItem(null, new ItemId(itemId));
54 | }
55 |
56 | @Test
57 | public void checkForNullTypedParameterWithXML(@Param(name="itemId") ItemId itemId){
58 | System.out.println("XML Item Id is :" + itemId);
59 | itemService.findItem(null, itemId);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TestCombinedLoadingAndWriting.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import org.easetech.easytest.annotation.DataLoader;
4 | import org.easetech.easytest.annotation.Param;
5 | import org.easetech.easytest.runner.DataDrivenTestRunner;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 |
9 | @RunWith(DataDrivenTestRunner.class)
10 | public class TestCombinedLoadingAndWriting {
11 |
12 | @Test
13 | @DataLoader(filePaths = { "input-data-mod-again.xml" })
14 | public Item getItemsDataFromXMLLoaderModified(@Param(name="libraryId")
15 | String libraryId, @Param(name="itemId")
16 | String itemId, @Param(name="itemType")
17 | String itemType, @Param(name="expectedItems")
18 | String expectedItems) {
19 | System.out.print("Executing TestCombinedLoadingAndWriting#getItemsDataFromXMLLoaderModified :");
20 | System.out.println("LibraryId :" + libraryId + " itemId : " + itemId + " itemType :" + itemType
21 | + " expectedItems :" + expectedItems);
22 | Item item= new Item();
23 | item.setDescription("Description Modified Once Again");
24 | item.setItemId(new ItemId(Long.valueOf(itemId)));
25 | item.setItemType(itemType);
26 | return item;
27 | }
28 |
29 | @Test
30 | @DataLoader(filePaths = { "org/easetech/data/test-combined.xls" })
31 | public Item getExcelTestDataWithReturnType(@Param(name="libraryId")
32 | Float libraryId, @Param(name="itemId")
33 | Float itemId) {
34 | System.out.print("Executing TestCombinedLoadingAndWriting#getExcelTestDataWithReturnType : ");
35 | ItemService itemService = new RealItemService();
36 | if(libraryId == null || itemId == null){
37 | return null;
38 | }
39 | Item item = itemService.findItem(new LibraryId(Long.valueOf(libraryId.longValue())),
40 | new ItemId(Long.valueOf(itemId.longValue())));
41 | return item;
42 | }
43 |
44 | @Test
45 | public void getExcelTestDataWithReturnTypeFail() {
46 | System.out.println("print");
47 | // Assert.fail("Failed");
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TestConfigProviderClass.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import java.util.Properties;
4 | import org.easetech.easytest.annotation.TestBean;
5 | import org.easetech.easytest.annotation.TestProperties;
6 | import org.junit.Ignore;
7 |
8 | @Ignore
9 |
10 | public class TestConfigProviderClass {
11 |
12 | @TestProperties({"config.properties", "anotherConfig.properties"})
13 | private Properties props;
14 |
15 | @TestBean("itemService") public RealItemService itemService(){
16 | String propValue = props.getProperty("simple.property");
17 | System.out.println(propValue);
18 | return new RealItemService();
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TestConstructorFunctionality.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import javax.inject.Inject;
4 | import javax.inject.Named;
5 | import org.easetech.easytest.annotation.DataLoader;
6 | import org.easetech.easytest.annotation.Param;
7 | import org.easetech.easytest.annotation.TestConfigProvider;
8 | import org.easetech.easytest.runner.DataDrivenTestRunner;
9 | import org.junit.Test;
10 | import org.junit.runner.RunWith;
11 |
12 | @RunWith(DataDrivenTestRunner.class)
13 | @TestConfigProvider({TestConfigProviderClass.class})
14 | public class TestConstructorFunctionality {
15 |
16 | @Inject
17 | @Named("itemService")
18 | public ItemService testSubject;
19 |
20 | @Test
21 | @DataLoader(filePaths = { "classpath:org/easetech/data/test-update.xls" })
22 | public Item getExcelTestDataWithReturnType(@Param(name="libraryId")
23 | LibraryId libraryId, @Param(name="itemId")
24 | ItemId itemId) {
25 | System.out.println("Executing getExcelTestDataWithReturnType : ");
26 |
27 | if(libraryId == null){
28 | return null;
29 | }
30 | if(itemId == null){
31 | return null;
32 | }
33 | Item item = testSubject.findItem(libraryId, itemId);
34 |
35 |
36 | // Boolean test = Boolean.FALSE;
37 | //
38 | // Assert.assertTrue( "test TRUE expected" ,test);
39 | return item;
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TestConverters.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import org.easetech.easytest.annotation.Converters;
4 | import org.easetech.easytest.annotation.DataLoader;
5 | import org.easetech.easytest.runner.DataDrivenTestRunner;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 |
9 | @RunWith(DataDrivenTestRunner.class)
10 | @DataLoader(filePaths = { "getDDTData.csv" })
11 | @Converters({ItemConverter.class})
12 | public class TestConverters {
13 |
14 | @Test
15 | public String testDDTConverter(Item item) {
16 | System.out.println("Item is :" + item);
17 | return item.toString();
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TestConvertersForSuite.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import org.easetech.easytest.annotation.Converters;
4 | import org.easetech.easytest.annotation.DataLoader;
5 | import org.easetech.easytest.runner.DataDrivenTestRunner;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 |
9 | @RunWith(DataDrivenTestRunner.class)
10 | @DataLoader(filePaths = { "getItemsData.csv" })
11 | @Converters({ItemConverter.class})
12 | public class TestConvertersForSuite {
13 |
14 | @Test
15 | public void testConverter(Item item) {
16 | System.out.println("Item value is :" + item.toString());
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TestDates.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import java.sql.Date;
4 | import org.easetech.easytest.annotation.Param;
5 | import org.easetech.easytest.annotation.TestPolicy;
6 | import org.easetech.easytest.runner.DataDrivenTestRunner;
7 | import org.junit.Assert;
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | @RunWith(DataDrivenTestRunner.class)
12 | @TestPolicy(TestDatesPolicy.class)
13 | public class TestDates {
14 |
15 | @Test
16 | public void testDatesFormating(@Param(name="date") Date date){
17 | Assert.assertNotNull(date);
18 | System.out.println("testDatesFormating : "+date);
19 | }
20 |
21 | @Test
22 | public void testEmptyInteger(@Param(name="day") Integer day , @Param(name="str")String str , @Param(name="long")Long longVal, @Param(name="Double")Double doubleVal){
23 | System.out.print("day = " + day + ",");
24 | System.out.print("str = " + str + ",");
25 | System.out.print("long = " + longVal + ",");
26 | System.out.println("Double = " + doubleVal);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TestDatesPolicy.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import org.junit.Ignore;
4 |
5 | import org.easetech.easytest.annotation.DataLoader;
6 | import org.easetech.easytest.annotation.Format;
7 |
8 | @Ignore
9 | @DataLoader(filePaths={"paramTestConditions.csv"} , writeData=false)
10 | @Format(date={"dd-MM-yyyy", "dd/MM/yy"})
11 | public class TestDatesPolicy {
12 | //do nothing
13 | }
14 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TestDuration.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import javax.inject.Inject;
4 | import org.easetech.easytest.annotation.DataLoader;
5 | import org.easetech.easytest.annotation.Duration;
6 | import org.easetech.easytest.annotation.Param;
7 | import org.easetech.easytest.annotation.Repeat;
8 | import org.easetech.easytest.annotation.TestConfigProvider;
9 | import org.easetech.easytest.runner.DataDrivenTestRunner;
10 | import org.junit.Before;
11 | import org.junit.Test;
12 | import org.junit.runner.RunWith;
13 | import org.slf4j.Logger;
14 | import org.slf4j.LoggerFactory;
15 |
16 | @RunWith(DataDrivenTestRunner.class)
17 | @DataLoader(filePaths = { "classpath:org/easetech/data/testExcelData.xls" })
18 | @TestConfigProvider({TestConfigProviderClass.class})
19 | public class TestDuration {
20 |
21 | @Duration(timeInMillis=10)
22 | @Inject
23 | private RealItemService itemService;
24 |
25 | /**
26 | * An instance of logger associated with the test framework.
27 | */
28 | protected static final Logger LOG = LoggerFactory.getLogger(TestExcelDataLoader.class);
29 |
30 | @Before
31 | public void before(){
32 | System.out.println("BEFORE");
33 | }
34 |
35 | @Test
36 | @Duration(timeInMillis=3000 , forClass= RealItemService.class)
37 | public Item testNoData() throws InterruptedException{
38 | System.out.println("Executing testNoData");
39 | return itemService.findItem(new LibraryId(Long.valueOf(1)), new ItemId(2L));
40 | }
41 |
42 | @Test
43 | @Repeat(times=2)
44 | public void a() {
45 | System.out.println("A Called");
46 | itemService.findItem(new LibraryId(1L), new ItemId(2L));
47 | }
48 |
49 | @Test
50 | @Repeat(times=3)
51 | public Item getExcelTestData(@Param(name="libraryId")
52 | Long libraryId, @Param(name="itemId")
53 | Long itemId) {
54 | return itemService.findItem(new LibraryId(libraryId), new ItemId(itemId));
55 |
56 | }
57 |
58 |
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TestErrorCollector.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import javax.inject.Inject;
4 | import org.easetech.easytest.annotation.DataLoader;
5 | import org.easetech.easytest.annotation.Intercept;
6 | import org.easetech.easytest.annotation.Param;
7 | import org.easetech.easytest.annotation.TestConfigProvider;
8 | import org.easetech.easytest.runner.DataDrivenTestRunner;
9 | import org.junit.Ignore;
10 | import org.junit.Rule;
11 | import org.junit.Test;
12 | import org.junit.rules.ErrorCollector;
13 | import org.junit.runner.RunWith;
14 |
15 | /**
16 | *
17 | * Test case for testing ErrorCollector functionality.
18 | * Uncomment the Ignore annotation
19 | *
20 | */
21 |
22 |
23 | @RunWith(DataDrivenTestRunner.class)
24 | @DataLoader(filePaths = { "classpath:org/easetech/data/testExcelData.xls" })
25 | @TestConfigProvider({TestConfigProviderClass.class})
26 | @Ignore
27 | public class TestErrorCollector {
28 |
29 | @Rule
30 | public ErrorCollector collector = new ErrorCollector();
31 |
32 | @Intercept
33 | @Inject
34 | private ItemService itemService;
35 |
36 | @Test
37 |
38 | public void getExcelTestData(@Param(name="libraryId")
39 | Float libraryId, @Param(name="itemId")
40 | Float itemId) {
41 | collector.addError(new Throwable("first thing went wrong"));
42 | collector.addError(new Throwable("second thing went wrong"));
43 | System.out.println("Executing getExcelTestData :");
44 |
45 | }
46 |
47 | @Test
48 | public void testSimpleTest() {
49 | collector.addError(new Throwable("third thing went wrong"));
50 | collector.addError(new Throwable("fourth thing went wrong"));
51 | System.out.println("Executing getExcelTestData :");
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TestExcelDataLoader.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.example;
3 |
4 | import javax.inject.Inject;
5 | import junit.framework.Assert;
6 | import org.easetech.easytest.annotation.DataLoader;
7 | import org.easetech.easytest.annotation.Display;
8 | import org.easetech.easytest.annotation.Intercept;
9 | import org.easetech.easytest.annotation.Param;
10 | import org.easetech.easytest.annotation.TestPolicy;
11 | import org.easetech.easytest.runner.DataDrivenTestRunner;
12 | import org.junit.After;
13 | import org.junit.Before;
14 | import org.junit.Test;
15 | import org.junit.runner.RunWith;
16 | import org.slf4j.Logger;
17 | import org.slf4j.LoggerFactory;
18 |
19 |
20 | @RunWith(DataDrivenTestRunner.class)
21 | @DataLoader(filePaths = { "classpath:org/easetech/data/testExcelData.xls" })
22 | public class TestExcelDataLoader {
23 |
24 | @Intercept
25 | @Inject
26 | private ItemService itemService;
27 |
28 | /**
29 | * An instance of logger associated with the test framework.
30 | */
31 | protected static final Logger LOG = LoggerFactory.getLogger(TestExcelDataLoader.class);
32 |
33 | @Before
34 | public void before(){
35 | System.out.println("BEFORE");
36 | }
37 |
38 | @After
39 | public void after(){
40 | System.out.println("AFTER");
41 | }
42 |
43 | // @Test
44 | // public void testException(){
45 | // throw new RuntimeException("Failed");
46 | // }
47 |
48 | @Test
49 | public void getExcelTestData(@Param(name="libraryId")
50 | Float libraryId, @Param(name="itemId")
51 | Float itemId) {
52 | System.out.print("Executing getExcelTestData :");
53 | System.out.println("LibraryId is :" + libraryId + " and Item Id is :" + itemId);
54 | }
55 |
56 |
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TestExcelDataLoaderPolicy.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import org.easetech.easytest.annotation.DataLoader;
4 | import org.easetech.easytest.annotation.Display;
5 | import org.easetech.easytest.annotation.Parallel;
6 | import org.easetech.easytest.annotation.Report;
7 | import org.easetech.easytest.annotation.TestConfigProvider;
8 | import org.junit.Ignore;
9 |
10 | @Ignore
11 | @DataLoader(filePaths = { "classpath:org/easetech/data/testExcelData.xls" } , writeData=false)
12 | @Report
13 | @TestConfigProvider({TestConfigProviderClass.class})
14 | @Parallel(threads=8)
15 | @Display(fields={"Description"})
16 | public class TestExcelDataLoaderPolicy {
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TestJSON.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import org.easetech.easytest.annotation.PreserveContext;
4 |
5 | import org.junit.After;
6 |
7 | import org.junit.Before;
8 |
9 | import org.easetech.easytest.annotation.DataLoader;
10 | import org.easetech.easytest.annotation.Param;
11 | import org.easetech.easytest.annotation.Repeat;
12 | import org.easetech.easytest.runner.DataDrivenTestRunner;
13 | import org.junit.Test;
14 | import org.junit.runner.RunWith;
15 |
16 | @RunWith(DataDrivenTestRunner.class)
17 | @DataLoader(filePaths="jsonBasedData.csv")
18 | public class TestJSON {
19 |
20 | private int count = 1;
21 |
22 | @Before
23 | public void before() {
24 | count = count + 1;
25 | //System.out.println("BEFOREEEEEEEEE");
26 | }
27 |
28 | @After
29 | public void after() {
30 | count = count - 1;
31 | System.out.println(count);
32 | }
33 |
34 | @Test
35 | @PreserveContext
36 | //@Repeat(times=3)
37 | public void testJSONObjectCSV(@Param(name="Item")Item item , LibraryId libId){
38 | System.out.println(item);
39 | //System.out.println(libId);
40 | }
41 |
42 |
43 | @Test
44 | @PreserveContext
45 | //@Repeat(times=3)
46 | @DataLoader(filePaths="jsonBasedData.xls")
47 | public void testJSONObject(@Param(name="Item")Item item , LibraryId libId){
48 | System.out.println(item);
49 | //System.out.println(libId);
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TestMethodInjection.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import javax.inject.Inject;
4 | import junit.framework.Assert;
5 | import org.easetech.easytest.annotation.TestPolicy;
6 | import org.easetech.easytest.runner.DataDrivenTestRunner;
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | @RunWith(DataDrivenTestRunner.class)
11 | @TestPolicy(TestExcelDataLoaderPolicy.class)
12 | public class TestMethodInjection {
13 |
14 | @Test
15 | @Inject
16 | public void testInjectData( RealItemService itemService){
17 | Assert.assertNotNull(itemService);
18 |
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TestMultipleFileDataLoadedExample.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import org.junit.Test;
4 |
5 | import org.easetech.easytest.annotation.DataLoader;
6 | import org.easetech.easytest.annotation.Param;
7 | import org.easetech.easytest.loader.LoaderType;
8 | import org.easetech.easytest.runner.DataDrivenTestRunner;
9 | import org.junit.runner.RunWith;
10 |
11 | @RunWith(DataDrivenTestRunner.class)
12 | @DataLoader(appendData=true, filePaths={"MultipleFileDataExampleData1.csv","MultipleFileDataExampleData2.csv"}, loaderType=LoaderType.CSV , writeData=true)
13 | public class TestMultipleFileDataLoadedExample {
14 |
15 | @Test
16 | public void multipleTestDataTest(@Param(name="libraryId")String libraryId , @Param(name="itemId")Integer itemId) {
17 | System.out.println("Lib Id : " + libraryId);
18 | System.out.println("Item Id : " + itemId);
19 | }
20 |
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TestSuiteFunctionality.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import org.easetech.easytest.annotation.Parallel;
4 | import org.easetech.easytest.annotation.ParallelSuite;
5 | import org.easetech.easytest.runner.EasyTestSuite;
6 | import org.junit.runner.RunWith;
7 | import org.junit.runners.Suite.SuiteClasses;
8 |
9 | /**
10 | * Test Parallel Suite functionality
11 | *
12 | *
13 | */
14 | @RunWith(EasyTestSuite.class)
15 | @SuiteClasses({TestConverters.class , TestConvertersForSuite.class, TestExcelDataLoader.class,TestCombinedLoadingAndWriting.class, TestBeanProviderFunctionality.class})
16 | @ParallelSuite
17 | @Parallel
18 | public class TestSuiteFunctionality {
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TestTemperatureConverter.java:
--------------------------------------------------------------------------------
1 | package org.easetech.easytest.example;
2 |
3 | import org.easetech.easytest.annotation.DataLoader;
4 | import org.easetech.easytest.annotation.Param;
5 | import org.easetech.easytest.annotation.Report;
6 | import org.easetech.easytest.runner.DataDrivenTestRunner;
7 | import org.junit.Assert;
8 | import org.junit.Before;
9 | import org.junit.Test;
10 | import org.junit.runner.RunWith;
11 |
12 | @RunWith(DataDrivenTestRunner.class)
13 | @DataLoader(filePaths = { "tcd.csv" })
14 | @Report(outputFormats={Report.EXPORT_FORMAT.PDF}, outputLocation="classpath:org/easytech/easytest/output")
15 | public class TestTemperatureConverter {
16 |
17 | private TemperatureConverter subject;
18 |
19 | @Before
20 | public void setup() {
21 | subject = new TemperatureConverter();
22 | }
23 |
24 | @Test
25 | public void testToCelsiusConverter(@Param(name = "fahrenheit") int fahrenheit, @Param(name = "celsius") int celsiusResult) {
26 | // execute the business method
27 | int celsius = subject.toCelsius(fahrenheit);
28 |
29 | System.out.println(fahrenheit + " Fahrenheit = " + celsius + " Celsius");
30 |
31 | // asserts the result from the business method with the celsius result that comes from the input data file
32 | // Assert.assertEquals(celsiusResult, celsius);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/example/TestXMLDataLoader.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.example;
3 |
4 | import org.easetech.easytest.annotation.Report;
5 |
6 | import org.junit.BeforeClass;
7 |
8 | import java.util.Properties;
9 | import org.easetech.easytest.annotation.DataLoader;
10 | import org.easetech.easytest.annotation.Param;
11 | import org.easetech.easytest.annotation.TestProperties;
12 | import org.easetech.easytest.runner.DataDrivenTestRunner;
13 | import org.junit.Assert;
14 | import org.junit.Test;
15 | import org.junit.runner.RunWith;
16 |
17 | @RunWith(DataDrivenTestRunner.class)
18 | @DataLoader(filePaths = { "input-data.xml" })
19 | //@TestProperties({ "config.properties" })
20 | @Report(outputFormats={Report.EXPORT_FORMAT.PDF, Report.EXPORT_FORMAT.HTML}, reportTypes={Report.REPORT_TYPE.DEFAULT, Report.REPORT_TYPE.METHOD_DURATION},outputLocation="file:/Users/anuj/reports")
21 | public class TestXMLDataLoader {
22 |
23 | /**
24 | * Automatically provided by the Framework with properties from files part of {@link TestProperties} annotation
25 | */
26 | @TestProperties({ "anotherConfig.properties" })
27 | private Properties loadedProperties;
28 |
29 | private static Properties prop;
30 |
31 | @BeforeClass
32 | public static void beforeClass() {
33 | prop = new Properties();
34 | prop.setProperty("key", "value");
35 | }
36 |
37 | @Test
38 | public Item getItemsDataFromXMLLoader(@Param(name = "libraryId")
39 | String libraryId, @Param(name = "itemId")
40 | String itemId, @Param(name = "itemType")
41 | String itemType, @Param(name = "globalParam")
42 | String globalParam, @Param(name = "expectedItems")
43 | String expectedItems) {
44 | Assert.assertNotNull(prop);
45 | System.out.println("Print Property :" + loadedProperties.getProperty("simple.property"));
46 | System.out.print("Executing getItemsDataFromXMLLoader :");
47 | System.out.println("LibraryId :" + libraryId + " itemId : " + itemId + " itemType :" + itemType
48 | + " globalParam : " + globalParam + " expectedItems :" + expectedItems);
49 |
50 | // assert global param is used / overridden
51 |
52 | Assert.assertEquals("globalParamValue", globalParam);
53 | Assert.assertNotSame("-1", libraryId);
54 |
55 | Item item = new Item();
56 | item.setDescription("Description Modified");
57 | item.setItemId(new ItemId(Long.valueOf(itemId)));
58 | item.setItemType(itemType);
59 | return item;
60 | }
61 |
62 | @Test
63 | @DataLoader(filePaths = { "input-data-mod.xml" })
64 | public Item getItemsDataFromXMLLoaderModified(@Param(name = "libraryId")
65 | String libraryId, @Param(name = "itemId")
66 | String itemId, @Param(name = "itemType")
67 | String itemType, @Param(name = "expectedItems")
68 | String expectedItems) {
69 | System.out.print("Executing getItemsDataFromXMLLoaderModified :");
70 | System.out.println("LibraryId :" + libraryId + " itemId : " + itemId + " itemType :" + itemType
71 | + " expectedItems :" + expectedItems);
72 | Item item = new Item();
73 | item.setDescription("Description Modified");
74 | item.setItemId(new ItemId(Long.valueOf(itemId)));
75 | item.setItemType(itemType);
76 | return item;
77 | }
78 |
79 | /**
80 | * UNCOMMENT to test feature when the expected is not the same as actual
81 | * @param libraryId
82 | * @param itemId
83 | * @param itemType
84 | */
85 | // @Test
86 | // @DataLoader(filePaths = { "input-data-mod.xml" })
87 | // public Long getDataWithExpectedResultSet(@Param(name = "libraryId")
88 | // String libraryId, @Param(name = "itemId")
89 | // Long itemId, @Param(name = "itemType")
90 | // String itemType) {
91 | // return itemId;
92 | // }
93 |
94 | @Test
95 | @DataLoader(filePaths = { "input-data-mod.xml" })
96 | public void methodReturningNoData(@Param(name = "libraryId")
97 | String libraryId, @Param(name = "itemId")
98 | Long itemId, @Param(name = "itemType")
99 | String itemType){
100 | System.out.println("methodReturningNoData called. Only Duration should be written");
101 | }
102 |
103 | @Test
104 | @DataLoader(filePaths = { "input-data-mod.xml" })
105 | public Long methodTakingNoData(){
106 | System.out.println("methodTakingNoData called.");
107 | return 21L;
108 | }
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/src/test/java/org/easetech/easytest/interceptor/CGLIBEnhancerTest.java:
--------------------------------------------------------------------------------
1 |
2 | package org.easetech.easytest.interceptor;
3 |
4 | import org.easetech.easytest.example.ItemId;
5 | import org.easetech.easytest.example.LibraryId;
6 | import org.easetech.easytest.example.RealItemService;
7 | import org.easetech.easytest.runner.DataDrivenTestRunner;
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | @RunWith(DataDrivenTestRunner.class)
12 | public class CGLIBEnhancerTest {
13 |
14 | public static RealItemService itemService = new RealItemService();
15 |
16 | @Test
17 | public void testGetItemEnh() {
18 | System.out.println("testGetItemEnh called");
19 | itemService.findItem(new LibraryId(1L), new ItemId(2L));
20 |
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/test/resources/MultipleFileDataExampleData1.csv:
--------------------------------------------------------------------------------
1 | multipleTestDataTest,libraryId,itemId
,1,2
,3,4
,5,6
--------------------------------------------------------------------------------
/src/test/resources/MultipleFileDataExampleData2.csv:
--------------------------------------------------------------------------------
1 | multipleTestDataTest,libraryId,itemId
,7,8
,9,10
,11,12
--------------------------------------------------------------------------------
/src/test/resources/TestExcelDataLoader.csv:
--------------------------------------------------------------------------------
1 | getTestDataWithDouble,libraryId,itemId
2 | ,1,2
3 | ,3,4
4 | ,5,6
5 |
--------------------------------------------------------------------------------
/src/test/resources/anotherConfig.properties:
--------------------------------------------------------------------------------
1 | simple.property=ComplexProperty Again!!!!
--------------------------------------------------------------------------------
/src/test/resources/borderConditions.csv:
--------------------------------------------------------------------------------
1 | checkForNull,itemId
2 | ,null
3 | , 0
4 | , -1
5 | checkForNullWithTypedParam,itemId
6 | ,null
7 | , 0
8 | , -1
9 | checkForNullTypedParameterWithXML,itemId
10 | ,null
11 | , 0
12 | , -1
--------------------------------------------------------------------------------
/src/test/resources/borderConditions.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EaseTech/easytest-core/faba9e0d8f161bb2eec570a8b160afcc95b9c011/src/test/resources/borderConditions.xls
--------------------------------------------------------------------------------
/src/test/resources/borderConditions.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 | The method with name GetItemsData will be executed 3
9 | times by the EasyTest framework,
10 | once each for the given TestRecord.
11 |
12 |
13 | This test tries to capture the scenario when the data is
14 | available in the DB
15 | for the given set of input parameters. In this
16 | case the expectedItems
17 | should be 2.
18 |
19 |
20 |
21 |
22 |
23 |
24 | This test tries to capture the scenario when the data is
25 | available in the DB
26 | for the given set of input parameters. In this
27 | case the expectedItems
28 | should be 1.
29 |
30 |
31 |
32 |
33 |
34 |
35 | This test tries to capture the scenario when the data is
36 | available in the DB
37 | for the given set of input parameters. In this
38 | case the expectedItems
39 | should be 0.
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | The method with name GetItemsData will be executed 3
49 | times by the EasyTest framework,
50 | once each for the given TestRecord.
51 |
52 |
53 | This test tries to capture the scenario when the data is
54 | available in the DB
55 | for the given set of input parameters. In this
56 | case the expectedItems
57 | should be 2.
58 |
59 |
60 |
61 |
62 |
63 |
64 | This test tries to capture the scenario when the data is
65 | available in the DB
66 | for the given set of input parameters. In this
67 | case the expectedItems
68 | should be 1.
69 |
70 |
71 |
72 |
73 |
74 |
75 | This test tries to capture the scenario when the data is
76 | available in the DB
77 | for the given set of input parameters. In this
78 | case the expectedItems
79 | should be 0.
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/src/test/resources/config.properties:
--------------------------------------------------------------------------------
1 | simple.property=complexValue
--------------------------------------------------------------------------------
/src/test/resources/getDDTData.csv:
--------------------------------------------------------------------------------
1 | testDDTGetItem,LibraryId,itemType,searchText
2 | ,4,journal,batman
3 | ,1,ebook,potter
4 | ,0,ebook,potrey
5 | ,null,something,extra
6 | testDDTGetItemsWithCustomLoader,LibraryId,itemType,searchText
7 | ,10,book,catwoman
8 | ,2,journal,spiderman
9 | testMethodWithNoParameter
10 | testDDTConverter,itemDescription,itemId,itemType,items
11 | ,item Description 1, 1212, ebook,1:2:3
12 | ,item Description 2, 3434, journal,4:5:6
13 | testBug,className,dateDebut,dateFin
14 | ,model.class1.ServiceName,08/12/2012,09/12/2013
15 | ,model1.Class1.ServiceName,10/12/2012,11/12/2013
16 | ,model2.Class1.ServiceName,10/12/2012,11/12/2013
17 | ,model3.Class1.ServiceName,10/12/2012,11/12/2013
18 | ,model4.Class1.ServiceName,10/12/2013,11/12/2013
19 | ,model4.Class1.ServiceName,10/12/2012,11/12/2013
20 | ,model5.Class1.ServiceName,10/12/2012,11/12/2013
21 | ,model6.Class1.ServiceName,10/12/2012,11/12/2013
22 |
--------------------------------------------------------------------------------
/src/test/resources/getItemsData.csv:
--------------------------------------------------------------------------------
1 | testGetItems,LibraryId,itemType,searchText
2 | ,4,journal,batman
3 | ,1,ebook,potter
4 | testGetItemsWithoutFileType,LibraryId,itemType,searchText
5 | ,10,book,catwoman
6 | ,2,journal,spiderman
7 | testGetItemsWithCustomLoader,LibraryId,itemType,searchText
8 | ,10,cd,a beautiful mind
9 | ,20,dvd,rambo
10 | testConverter,itemDescription,itemId,itemType
11 | ,item Description 1, 1212, ebook
12 | ,item Description 2, 3434, journal
13 |
--------------------------------------------------------------------------------
/src/test/resources/getItemsDataCustom.csv:
--------------------------------------------------------------------------------
1 | testGetItemsWithCustomLoader,LibraryId,itemType,searchText
2 | ,101,journal,custom beautiful mind
3 | ,201,blueray,custom rambo
4 |
--------------------------------------------------------------------------------
/src/test/resources/input-data-mod-again.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 | The method with name GetItemsData will be executed 3
9 | times by the EasyTest framework,
10 | once each for the given TestRecord.
11 |
12 |
13 | This test tries to capture the scenario when the data is
14 | available in the DB
15 | for the given set of input parameters. In this
16 | case the expectedItems
17 | should be 2.
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | This test tries to capture the scenario when the data is
28 | available in the DB
29 | for the given set of input parameters. In this
30 | case the expectedItems
31 | should be 1.
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | This test tries to capture the scenario when the data is
42 | available in the DB
43 | for the given set of input parameters. In this
44 | case the expectedItems
45 | should be 0.
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/src/test/resources/input-data.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 | The method with name GetItemsData will be executed 3
9 | times by the EasyTest framework,
10 | once each for the given TestRecord.
11 |
12 |
13 |
14 |
15 |
16 |
17 | This test tries to capture the scenario when the data is
18 | available in the DB
19 | for the given set of input parameters. In this
20 | case the expectedItems
21 | should be 2.
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | This test tries to capture the scenario when the data is
32 | available in the DB
33 | for the given set of input parameters. In this
34 | case the expectedItems
35 | should be 1.
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | This test tries to capture the scenario when the data is
46 | available in the DB
47 | for the given set of input parameters. In this
48 | case the expectedItems
49 | should be 0.
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/src/test/resources/jsonBasedData.csv:
--------------------------------------------------------------------------------
1 | testJSONObjectCSV,Item,LibraryId,Purpose
,{'itemId':{'id':23}&'itemType':'BOOK'&'description':'batMAN'},34,testJSONDAta
,{'itemId':{'id':24}&'itemType':'BOOK1'&'description':'batMAN1'},34,testJSONDAta1
--------------------------------------------------------------------------------
/src/test/resources/jsonBasedData.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EaseTech/easytest-core/faba9e0d8f161bb2eec570a8b160afcc95b9c011/src/test/resources/jsonBasedData.xls
--------------------------------------------------------------------------------
/src/test/resources/org/easetech/data/test-combined.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EaseTech/easytest-core/faba9e0d8f161bb2eec570a8b160afcc95b9c011/src/test/resources/org/easetech/data/test-combined.xls
--------------------------------------------------------------------------------
/src/test/resources/org/easetech/data/test-update.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EaseTech/easytest-core/faba9e0d8f161bb2eec570a8b160afcc95b9c011/src/test/resources/org/easetech/data/test-update.xls
--------------------------------------------------------------------------------
/src/test/resources/org/easetech/data/testExcelData.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EaseTech/easytest-core/faba9e0d8f161bb2eec570a8b160afcc95b9c011/src/test/resources/org/easetech/data/testExcelData.xls
--------------------------------------------------------------------------------
/src/test/resources/org/easetech/data/testExcelData1.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EaseTech/easytest-core/faba9e0d8f161bb2eec570a8b160afcc95b9c011/src/test/resources/org/easetech/data/testExcelData1.xls
--------------------------------------------------------------------------------
/src/test/resources/org/easetech/data/testExcelData2.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EaseTech/easytest-core/faba9e0d8f161bb2eec570a8b160afcc95b9c011/src/test/resources/org/easetech/data/testExcelData2.xls
--------------------------------------------------------------------------------
/src/test/resources/overrideExcelData.csv:
--------------------------------------------------------------------------------
1 | getExcelTestDataWithDouble,libraryId,itemId
2 | ,0009,0008
3 | ,9998,88887
4 | ,5555,4444
5 | getTestingData,libraryId,itemId
6 | ,1,2
7 | ,3,4
8 |
--------------------------------------------------------------------------------
/src/test/resources/paramTestConditions.csv:
--------------------------------------------------------------------------------
1 | testNonGenericListInterface,items,,,
, 1:2:3,,,
,4:05:06,,,
testGenericListInterface,items,,,
,11:22:33,,,
,44:55:66,,,
testGenericListImplementation,items,,,
,111:222:333,,,
,444:555:666,,,
testNonGenericListImplementation,items,,,
,112:223:334,,,
,445:556:667,,,
testGenericSetInterface,dates,,,
,10/12/2012:11/12/2013,,,
,11/12/2012:11/12/2013,,,
,12/12/2012:11/12/2013,,,
testNonGenericSetInterface,items,,,
,1.2:2.3:3.4,,,
testNonGenericSetImplementation,items,,,
,3.4:4.5:5.6,,,
testGenericSetImplementation,items,,,
,90:100:200,,,
testGenericQueueInterface,items,,,
, 1:2:35,,,
testNonGenericQueueImplementation,items,,,
,34:00:09,,,
testGenericQueueImplementation,items,,,
, 20:30:40,,,
testNonGenericQueueInterface,items,,,
, 1:2:3,,,
testNonGenericBlockingQueueImplementation,items,,,
, 45:90:57,,,
testNonGenericDequeImplementation,items,,,
, 999:222:1899,,,
testAbstractCollection,items,,,
,0.066319444,,,
testAbstractList,items,,,
,0.066319444,,,
testAbstractQueue,items,,,
, 20:30:40,,,
testAbstractSequentialList,items,,,
,12:23:34,,,
testAbstractSet,items,,,
,90:100:200,,,
testArrayBlockingQueue,items,,,
,12:2.3:3.4,,,
testArrayDeque,items,,,
,34:00:09,,,
testArrayList,items,,,
, 20:30:40,,,
testAttributeList,items,,,
, 999:222:1899,,,
testConcurrentLinkedQueue,items,,,
, 45:90:57,,,
testConcurrentSkipListSet,items,,,
, 1:2:35,,,
testCopyOnWriteArrayList,items,,,
,34:45:56,,,
testCopyOnWriteArraySet,items,,,
, 20:30:40,,,
testEnumSet,items,,,
,Monday:Wednesday:Sunday,,,
testLinkedBlockingDeque,items,,,
, 999:222:1899,,,
testLinkedBlockingQueue,items,,,
, 1:2:3,,,
testLinkedHashSet,items,,,
,34:45:56,,,
testPriorityBlockingQueue,items,,,
,34:45:56,,,
testPriorityQueue,items,,,
,90:100:200,,,
testRoleList,items,,,
, 999:222:1899,,,
testRoleUnresolvedList,items,,,
, 20:30:40,,,
testStack,items,,,
,34:45:56,,,
testSynchronousQueue,items,,,
,1,,,
testVector,items,,,
,34:45:56,,,
testDatesFormating,date,,,
,20/12/2012,,,
,31-12-2013,,,
,1/12/13,,,
testEmptyInteger,day,str,long,Double
,,,,
,null,null,null,null
,1,,null,2
,null,,,
--------------------------------------------------------------------------------
/src/test/resources/sample.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EaseTech/easytest-core/faba9e0d8f161bb2eec570a8b160afcc95b9c011/src/test/resources/sample.xls
--------------------------------------------------------------------------------
/src/test/resources/tcd.csv:
--------------------------------------------------------------------------------
1 | testToCelsiusConverter,fahrenheit,celsius
,9,-13
--------------------------------------------------------------------------------
/src/test/resources/testExcelData-update.xls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/EaseTech/easytest-core/faba9e0d8f161bb2eec570a8b160afcc95b9c011/src/test/resources/testExcelData-update.xls
--------------------------------------------------------------------------------