Skip to content

Commit 3c9def4

Browse files
Added unit tests
1 parent e9364a8 commit 3c9def4

File tree

2 files changed

+86
-8
lines changed

2 files changed

+86
-8
lines changed

pom.xml

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,59 +3,101 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>net.delirius</groupId>
55
<artifactId>jmeter.backendlistener.elasticsearch</artifactId>
6-
<version>1.5.3</version>
6+
<version>2.0.0</version>
77
<packaging>jar</packaging>
88
<name>jmeter.backendlistener.elasticsearch</name>
99
<url>http://maven.apache.org</url>
1010
<properties>
1111
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1212
<maven.compiler.source>1.8</maven.compiler.source>
1313
<maven.compiler.target>1.8</maven.compiler.target>
14+
<java.version>1.8</java.version>
15+
<junit.version>4.12</junit.version>
16+
<junit.jupiter.version>5.0.0</junit.jupiter.version>
17+
<junit.vintage.version>${junit.version}.0</junit.vintage.version>
18+
<junit.platform.version>1.0.0</junit.platform.version>
19+
<org.apache.jmeter.version>3.0</org.apache.jmeter.version>
20+
<org.apache.commons>3.4</org.apache.commons>
21+
<org.elasticsearch.client>5.5.2</org.elasticsearch.client>
1422
</properties>
1523
<dependencies>
1624
<dependency>
1725
<groupId>org.apache.jmeter</groupId>
1826
<artifactId>ApacheJMeter_config</artifactId>
19-
<version>3.0</version>
27+
<version>${org.apache.jmeter.version}</version>
2028
<scope>provided</scope>
2129
</dependency>
2230
<dependency>
2331
<groupId>org.apache.jmeter</groupId>
2432
<artifactId>ApacheJMeter_core</artifactId>
25-
<version>3.0</version>
33+
<version>${org.apache.jmeter.version}</version>
2634
<scope>provided</scope>
2735
</dependency>
2836
<dependency>
2937
<groupId>org.apache.jmeter</groupId>
3038
<artifactId>ApacheJMeter_components</artifactId>
31-
<version>3.0</version>
39+
<version>${org.apache.jmeter.version}</version>
3240
<scope>provided</scope>
3341
</dependency>
3442
<dependency>
3543
<groupId>org.apache.jmeter</groupId>
3644
<artifactId>jorphan</artifactId>
37-
<version>3.0</version>
45+
<version>${org.apache.jmeter.version}</version>
3846
<scope>provided</scope>
3947
</dependency>
4048
<dependency>
4149
<groupId>org.apache.commons</groupId>
4250
<artifactId>commons-lang3</artifactId>
43-
<version>3.4</version>
51+
<version>${org.apache.commons}</version>
4452
<scope>provided</scope>
4553
</dependency>
4654
<dependency>
4755
<groupId>org.elasticsearch.client</groupId>
4856
<artifactId>rest</artifactId>
49-
<version>5.5.2</version>
57+
<version>${org.elasticsearch.client}</version>
5058
</dependency>
5159
<dependency>
5260
<groupId>org.elasticsearch.client</groupId>
5361
<artifactId>transport</artifactId>
54-
<version>5.5.2</version>
62+
<version>${org.elasticsearch.client}</version>
63+
</dependency>
64+
<dependency>
65+
<groupId>junit</groupId>
66+
<artifactId>junit</artifactId>
67+
<version>${junit.version}</version>
68+
<scope>test</scope>
69+
</dependency>
70+
<dependency>
71+
<groupId>org.junit.platform</groupId>
72+
<artifactId>junit-platform-runner</artifactId>
73+
<version>${junit.platform.version}</version>
74+
<scope>test</scope>
75+
</dependency>
76+
<dependency>
77+
<groupId>org.junit.vintage</groupId>
78+
<artifactId>junit-vintage-engine</artifactId>
79+
<version>${junit.vintage.version}</version>
80+
<scope>test</scope>
5581
</dependency>
5682
</dependencies>
5783
<build>
5884
<plugins>
85+
<plugin>
86+
<artifactId>maven-surefire-plugin</artifactId>
87+
<version>2.19</version>
88+
<dependencies>
89+
<dependency>
90+
<groupId>org.junit.platform</groupId>
91+
<artifactId>junit-platform-surefire-provider</artifactId>
92+
<version>1.0.2</version>
93+
</dependency>
94+
<dependency>
95+
<groupId>org.junit.jupiter</groupId>
96+
<artifactId>junit-jupiter-engine</artifactId>
97+
<version>5.0.2</version>
98+
</dependency>
99+
</dependencies>
100+
</plugin>
59101
<plugin>
60102
<groupId>org.apache.maven.plugins</groupId>
61103
<artifactId>maven-compiler-plugin</artifactId>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package net.delirius.jmeter.backendlistener.elasticsearch;
2+
3+
import org.apache.jmeter.threads.JMeterContext;
4+
import org.apache.jmeter.threads.JMeterContextService;
5+
import org.junit.Before;
6+
import org.junit.Test;
7+
8+
import java.text.SimpleDateFormat;
9+
import java.util.Date;
10+
11+
import static org.junit.Assert.assertNotNull;
12+
import static org.junit.Assert.fail;
13+
14+
public class TestElasticSearchBackend {
15+
private DummyElasticSearchBackend instance = null;
16+
private JMeterContext context;
17+
18+
class DummyElasticSearchBackend extends ElasticsearchBackend {
19+
public DummyElasticSearchBackend() throws Exception {
20+
super();
21+
}
22+
}
23+
24+
@Before
25+
public void setUp() throws Exception {
26+
this.context = JMeterContextService.getContext();
27+
this.instance = new DummyElasticSearchBackend();
28+
}
29+
30+
@Test
31+
public void testGetElapsedTime() throws Exception {
32+
SimpleDateFormat sdf = new SimpleDateFormat("YYYY-mm-dd HH:mm:ss");
33+
Date testDate = this.instance.getElapsedDate();
34+
assertNotNull("testDate = " + sdf.format(testDate), sdf.format(testDate));
35+
}
36+
}

0 commit comments

Comments
 (0)