package io.searchbox.indices;


import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertTrue;
import static junit.framework.Assert.fail;
import io.searchbox.client.JestResult;
import io.searchbox.core.AbstractIntegrationTest;

import java.io.IOException;

import org.junit.Test;

/**
 * @author asierdelpozo
 */

public class PutTemplateIntegrationTest extends AbstractIntegrationTest {

    @Test
    public void testPutTemplate() {
    	PutTemplate putTemplate = new PutTemplate("new_template_1", 
    		"{	" +
    			"\"template\" : \"*\","+
    			"\"order\" : 0,"+
    			"\"settings\" : {"+
    			"	\"number_of_shards\" : 1"+
    			"},"+
    			"\"mappings\" : {"+
    			"	\"type1\" : {"+
    			"		\"_source\" : { \"enabled\" : false }"+
    			"	}"+
    			"}"+
    		"}");
        try {
            JestResult result = client.execute(putTemplate);
            assertNotNull(result);
            assertTrue(result.isSucceeded());
            
            GetTemplate getTemplate = new GetTemplate("new_template_1");
            result = client.execute(getTemplate);
            assertNotNull(result);
            assertTrue(result.isSucceeded());  
        } catch (IOException e) {
            fail("Test failed while executing creating index with default settings");
        }
    }
  
}

@@ -36,143 +36,157 @@
 ort 
-static junit.framework.Assert.assertNotNull;%0Aimport static junit.framework.Assert.assertTrue;%0Aimport static junit.framework.Assert.fail
+com.github.tlrx.elasticsearch.test.annotations.ElasticsearchNode;%0Aimport com.github.tlrx.elasticsearch.test.support.junit.runners.ElasticsearchRunner
 ;%0Aim
@@ -271,16 +271,72 @@
 ionTest;
+%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;
 %0A%0Aimport
@@ -365,30 +365,47 @@
 %0Aimport 
-org.junit.Test
+static junit.framework.Assert.*
 ;%0A%0A/**%0A 
@@ -432,16 +432,71 @@
 zo%0A */%0A%0A
+@RunWith(ElasticsearchRunner.class)%0A@ElasticsearchNode%0A
 public c
@@ -612,17 +612,20 @@
 ) %7B%0A    
-%09
+    
 PutTempl
@@ -679,30 +679,56 @@
 _1%22,
- %0A    %09%09%22%7B%09%22 +%0A    %09%09%09
+%0A                %22%7B%09%22 +%0A                        
 %22%5C%22t
@@ -746,25 +746,43 @@
  %5C%22*%5C%22,%22
+ 
 +%0A    
-%09%09%09
+                    
 %22%5C%22order
@@ -789,25 +789,43 @@
 %5C%22 : 0,%22
+ 
 +%0A    
-%09%09%09
+                    
 %22%5C%22setti
@@ -830,33 +830,51 @@
 tings%5C%22 : %7B%22
+ 
 +%0A    
-%09%09%09
+                    
 %22%09%5C%22number_o
@@ -892,30 +892,66 @@
 : 1%22
+ 
 +%0A    
-%09%09%09
+                    
 %22%7D,%22
+ 
 +%0A    
-%09%09%09
+                    
 %22%5C%22m
@@ -964,25 +964,43 @@
 s%5C%22 : %7B%22
+ 
 +%0A    
-%09%09%09
+                    
 %22%09%5C%22type
@@ -1007,25 +1007,43 @@
 1%5C%22 : %7B%22
+ 
 +%0A    
-%09%09%09
+                    
 %22%09%09%5C%22_so
@@ -1079,41 +1079,96 @@
 e %7D%22
+ 
 +%0A    
-%09%09%09
+                    
 %22%09%7D%22
+ 
 +%0A    
-%09%09%09
+                    
 %22%7D%22
+ 
 +%0A    
-%09%09
+                    
 %22%7D%22)
@@ -1325,28 +1325,16 @@
 ded());%0A
-            
 %0A       
@@ -1529,18 +1529,16 @@
 eded());
-  
 %0A       
@@ -1666,13 +1666,11 @@
 %7D%0A    %7D%0A
-  
 %0A%7D%0A

test runner