package com.orientechnologies.orient.test.server.network.http;

import com.orientechnologies.orient.core.record.impl.ODocument;
import org.apache.http.HttpResponse;
import org.junit.Assert;
import org.junit.Test;

public class HttpServerTest extends BaseHttpDatabaseTest {
  @Test
  public void testGetServer() throws Exception {
    HttpResponse res = get("server").getResponse();
    Assert.assertEquals(res.getStatusLine().getStatusCode(), 200);

    ODocument payload = new ODocument().fromJSON(res.getEntity().getContent());

    Assert.assertTrue(payload.containsField("connections"));
  }

  @Test
  public void testGetConnections() throws Exception {
    HttpResponse res =
        setUserName("root").setUserPassword("root").get("connections/").getResponse();
    Assert.assertEquals(res.getStatusLine().getStatusCode(), 200);

    ODocument payload = new ODocument().fromJSON(res.getEntity().getContent());

    Assert.assertTrue(payload.containsField("connections"));
  }

  @Override
  protected String getDatabaseName() {
    return "server";
  }
}

@@ -207,16 +207,45 @@
 .Test;%0A%0A
+import java.io.IOException;%0A%0A
 public c
@@ -1006,16 +1006,670 @@
 );%0A  %7D%0A%0A
+  @Test%0A  public void testCreateDatabase() throws IOException %7B%0A    String dbName = getClass().getSimpleName()+%22testCreateDatabase%22;%0A    HttpResponse res =%0A            setUserName(%22root%22)%0A                    .setUserPassword(%22root%22)%0A                    .post(%22servercommand%22)%0A                    .payload(%22%7B%5C%22command%5C%22:%5C%22create database %22+dbName+%22 plocal%5C%22 %7D%22, CONTENT.JSON)%0A                    .getResponse();%0A    System.out.println(res.getStatusLine().getReasonPhrase());%0A    Assert.assertEquals(res.getStatusLine().getStatusCode(), 200);%0A%0A    Assert.assertTrue(getServer().getContext().exists(dbName));%0A    getServer().getContext().drop(dbName);%0A  %7D%0A%0A
   @Overr

Add test cases for HTTP server-level commands