@@ -203,7 +203,7 @@ public void testCreateIndexWithLongName() {
203
203
204
204
try {
205
205
// Catch chars that are more than a single byte
206
- client ().prepareIndex (randomAsciiOfLength (MetaDataCreateIndexService .MAX_INDEX_NAME_BYTES -1 ).toLowerCase (Locale .ROOT ) +
206
+ client ().prepareIndex (randomAsciiOfLength (MetaDataCreateIndexService .MAX_INDEX_NAME_BYTES - 1 ).toLowerCase (Locale .ROOT ) +
207
207
"Ϟ" .toLowerCase (Locale .ROOT ),
208
208
"mytype" ).setSource ("foo" , "bar" ).get ();
209
209
fail ("exception should have been thrown on too-long index name" );
@@ -215,4 +215,22 @@ public void testCreateIndexWithLongName() {
215
215
// we can create an index of max length
216
216
createIndex (randomAsciiOfLength (MetaDataCreateIndexService .MAX_INDEX_NAME_BYTES ).toLowerCase (Locale .ROOT ));
217
217
}
218
+
219
+ public void testInvalidIndexName () {
220
+ try {
221
+ createIndex ("." );
222
+ fail ("exception should have been thrown on dot index name" );
223
+ } catch (InvalidIndexNameException e ) {
224
+ assertThat ("exception contains message about index name is dot " + e .getMessage (),
225
+ e .getMessage ().contains ("Invalid index name [.], must not be \' .\' or '..'" ), equalTo (true ));
226
+ }
227
+
228
+ try {
229
+ createIndex (".." );
230
+ fail ("exception should have been thrown on dot index name" );
231
+ } catch (InvalidIndexNameException e ) {
232
+ assertThat ("exception contains message about index name is dot " + e .getMessage (),
233
+ e .getMessage ().contains ("Invalid index name [..], must not be \' .\' or '..'" ), equalTo (true ));
234
+ }
235
+ }
218
236
}
0 commit comments