Skip to content

Commit 741baf6

Browse files
committed
Move tests to JUnit
Closes #14.
1 parent 7f26d6d commit 741baf6

File tree

3 files changed

+115
-25
lines changed

3 files changed

+115
-25
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
/.project
99
/.classpath
1010
/.settings
11+
/.local-execution-hints.log

pom.xml

Lines changed: 108 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
<properties>
3434
<elasticsearch.version>0.90.8</elasticsearch.version>
3535
<lucene.version>4.6.0</lucene.version>
36+
<tests.jvms>1</tests.jvms>
37+
<tests.shuffle>true</tests.shuffle>
38+
<tests.output>onerror</tests.output>
39+
<tests.client.ratio></tests.client.ratio>
40+
<es.logger.level>INFO</es.logger.level>
3641
</properties>
3742

3843
<repositories>
@@ -43,6 +48,19 @@
4348
</repositories>
4449

4550
<dependencies>
51+
<dependency>
52+
<groupId>org.hamcrest</groupId>
53+
<artifactId>hamcrest-all</artifactId>
54+
<version>1.3</version>
55+
<scope>test</scope>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.apache.lucene</groupId>
59+
<artifactId>lucene-test-framework</artifactId>
60+
<version>${lucene.version}</version>
61+
<scope>test</scope>
62+
</dependency>
63+
4664
<dependency>
4765
<groupId>org.elasticsearch</groupId>
4866
<artifactId>elasticsearch</artifactId>
@@ -65,23 +83,10 @@
6583
</dependency>
6684

6785
<dependency>
68-
<groupId>org.testng</groupId>
69-
<artifactId>testng</artifactId>
70-
<version>6.3.1</version>
71-
<scope>test</scope>
72-
</dependency>
73-
74-
<dependency>
75-
<groupId>org.hamcrest</groupId>
76-
<artifactId>hamcrest-core</artifactId>
77-
<version>1.3.RC2</version>
78-
<scope>test</scope>
79-
</dependency>
80-
81-
<dependency>
82-
<groupId>org.hamcrest</groupId>
83-
<artifactId>hamcrest-library</artifactId>
84-
<version>1.3.RC2</version>
86+
<groupId>org.elasticsearch</groupId>
87+
<artifactId>elasticsearch</artifactId>
88+
<version>${elasticsearch.version}</version>
89+
<type>test-jar</type>
8590
<scope>test</scope>
8691
</dependency>
8792
</dependencies>
@@ -98,13 +103,95 @@
98103
</configuration>
99104
</plugin>
100105
<plugin>
106+
<groupId>com.carrotsearch.randomizedtesting</groupId>
107+
<artifactId>junit4-maven-plugin</artifactId>
108+
<version>2.0.12</version>
109+
<executions>
110+
<execution>
111+
<id>tests</id>
112+
<phase>test</phase>
113+
<goals>
114+
<goal>junit4</goal>
115+
</goals>
116+
<configuration>
117+
<heartbeat>20</heartbeat>
118+
<jvmOutputAction>pipe,warn</jvmOutputAction>
119+
<leaveTemporary>true</leaveTemporary>
120+
<listeners>
121+
<report-ant-xml mavenExtensions="true"
122+
dir="${project.build.directory}/surefire-reports"/>
123+
<report-text
124+
showThrowable="true"
125+
showStackTraces="true"
126+
showOutput="${tests.output}"
127+
showStatusOk="false"
128+
showStatusError="true"
129+
showStatusFailure="true"
130+
showStatusIgnored="true"
131+
showSuiteSummary="true"
132+
timestamps="false"/>
133+
<report-execution-times file="${basedir}/.local-execution-hints.log"/>
134+
</listeners>
135+
<assertions>
136+
<enable/>
137+
</assertions>
138+
<parallelism>${tests.jvms}</parallelism>
139+
<balancers>
140+
<execution-times>
141+
<fileset dir="${basedir}" includes=".local-execution-hints.log"/>
142+
</execution-times>
143+
</balancers>
144+
<includes>
145+
<include>**/*Tests.class</include>
146+
<include>**/*Test.class</include>
147+
</includes>
148+
<excludes>
149+
<exclude>**/Abstract*.class</exclude>
150+
<exclude>**/*StressTest.class</exclude>
151+
</excludes>
152+
<jvmArgs>
153+
<param>-Xmx512m</param>
154+
<param>-XX:MaxDirectMemorySize=512m</param>
155+
<param>-Des.logger.prefix=</param>
156+
</jvmArgs>
157+
<shuffleOnSlave>${tests.shuffle}</shuffleOnSlave>
158+
<sysouts>${tests.verbose}</sysouts>
159+
<seed>${tests.seed}</seed>
160+
<haltOnFailure>${tests.failfast}</haltOnFailure>
161+
<systemProperties>
162+
<!-- RandomizedTesting library system properties -->
163+
<tests.iters>${tests.iters}</tests.iters>
164+
<tests.maxfailures>${tests.maxfailures}</tests.maxfailures>
165+
<tests.failfast>${tests.failfast}</tests.failfast>
166+
<tests.class>${tests.class}</tests.class>
167+
<tests.method>${tests.method}</tests.method>
168+
<tests.nightly>${tests.nightly}</tests.nightly>
169+
<tests.badapples>${tests.badapples}</tests.badapples>
170+
<tests.weekly>${tests.weekly}</tests.weekly>
171+
<tests.slow>${tests.slow}</tests.slow>
172+
<tests.awaitsfix>${tests.awaitsfix}</tests.awaitsfix>
173+
<tests.slow>${tests.slow}</tests.slow>
174+
<tests.timeoutSuite>${tests.timeoutSuite}</tests.timeoutSuite>
175+
<tests.showSuccess>${tests.showSuccess}</tests.showSuccess>
176+
<tests.integration>${tests.integration}</tests.integration>
177+
<tests.cluster_seed>${tests.cluster_seed}</tests.cluster_seed>
178+
<tests.client.ratio>${tests.client.ratio}</tests.client.ratio>
179+
<es.node.local>${env.ES_TEST_LOCAL}</es.node.local>
180+
<es.node.mode>${es.node.mode}</es.node.mode>
181+
<es.logger.level>${es.logger.level}</es.logger.level>
182+
<java.awt.headless>true</java.awt.headless>
183+
</systemProperties>
184+
</configuration>
185+
</execution>
186+
</executions>
187+
</plugin>
188+
<plugin>
189+
<!-- we skip surefire to work with randomized testing above -->
101190
<groupId>org.apache.maven.plugins</groupId>
102191
<artifactId>maven-surefire-plugin</artifactId>
103-
<version>2.12</version>
192+
<version>2.15</version>
104193
<configuration>
105-
<includes>
106-
<include>**/*Tests.java</include>
107-
</includes>
194+
<skipTests>true</skipTests>
108195
</configuration>
109196
</plugin>
110197
<plugin>

src/test/java/org/elasticsearch/index/analysis/SimplePhoneticAnalysisTests.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import org.elasticsearch.common.inject.Injector;
44
import org.elasticsearch.common.inject.ModulesBuilder;
5-
import static org.elasticsearch.common.settings.ImmutableSettings.*;
65
import org.elasticsearch.common.settings.Settings;
76
import org.elasticsearch.common.settings.SettingsModule;
87
import org.elasticsearch.env.Environment;
@@ -12,13 +11,16 @@
1211
import org.elasticsearch.index.settings.IndexSettingsModule;
1312
import org.elasticsearch.indices.analysis.IndicesAnalysisModule;
1413
import org.elasticsearch.indices.analysis.IndicesAnalysisService;
14+
import org.elasticsearch.test.ElasticsearchTestCase;
1515
import org.hamcrest.MatcherAssert;
16-
import static org.hamcrest.Matchers.*;
17-
import org.testng.annotations.Test;
16+
import org.junit.Test;
17+
18+
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
19+
import static org.hamcrest.Matchers.instanceOf;
1820

1921
/**
2022
*/
21-
public class SimplePhoneticAnalysisTests {
23+
public class SimplePhoneticAnalysisTests extends ElasticsearchTestCase {
2224

2325
@Test
2426
public void testPhoneticTokenFilterFactory() {

0 commit comments

Comments
 (0)