package com.orientechnologies.orient.server.distributed;

import com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage;
import com.orientechnologies.orient.core.storage.impl.memory.ODirectMemoryStorage;
import org.mockito.Mockito;
import org.testng.annotations.Test;

import com.orientechnologies.orient.server.OServer;

/**
 * @author <a href="mailto:enisher@gmail.com">Artem Orobets</a>
 */
public class ODistributedStorageTest {
  @Test
  public void testSupportedFreezeTrue() {
    OLocalPaginatedStorage storage = Mockito.mock(OLocalPaginatedStorage.class);
    ODistributedStorage ds = new ODistributedStorage(Mockito.mock(OServer.class), storage);

    ds.freeze(true);

    Mockito.verify(storage).freeze(true);
  }

  @Test
  public void testSupportedFreezeFalse() {
    OLocalPaginatedStorage storage = Mockito.mock(OLocalPaginatedStorage.class);
    ODistributedStorage ds = new ODistributedStorage(Mockito.mock(OServer.class), storage);

    ds.freeze(false);

    Mockito.verify(storage).freeze(false);
  }

  @Test(expectedExceptions = { UnsupportedOperationException.class })
  public void testUnsupportedFreeze() {
    ODistributedStorage ds = new ODistributedStorage(Mockito.mock(OServer.class), Mockito.mock(ODirectMemoryStorage.class));

    ds.freeze(false);
  }

  @Test
  public void testSupportedRelease() {
    OLocalPaginatedStorage storage = Mockito.mock(OLocalPaginatedStorage.class);
    ODistributedStorage ds = new ODistributedStorage(Mockito.mock(OServer.class), storage);

    ds.release();

    Mockito.verify(storage).release();
  }

  @Test(expectedExceptions = { UnsupportedOperationException.class })
  public void testUnsupportedRelease() {
    ODistributedStorage ds = new ODistributedStorage(Mockito.mock(OServer.class), Mockito.mock(ODirectMemoryStorage.class));

    ds.release();
  }
}

@@ -51,16 +51,65 @@
 buted;%0A%0A
+import com.orientechnologies.orient.core.Orient;%0A
 import c
@@ -190,24 +190,24 @@
 tedStorage;%0A
-
 import com.o
@@ -273,24 +273,25 @@
 oryStorage;%0A
+%0A
 import org.m
@@ -306,16 +306,60 @@
 ockito;%0A
+import org.testng.annotations.BeforeMethod;%0A
 import o
@@ -512,16 +512,16 @@
 /a%3E%0A */%0A
-
 public c
@@ -551,16 +551,144 @@
 eTest %7B%0A
+%0A  @BeforeMethod%0A  public void before() %7B%0A    if (Orient.instance().getTimer() == null)%0A      Orient.instance().startup();%0A  %7D%0A%0A
   @Test%0A

add check if orient instance is active in the distruted test.