/**
 * Copyright (C) 2011 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.web.analytics.push;

import static org.mockito.Mockito.mock;

import java.util.Collections;

import org.testng.annotations.Test;

import com.opengamma.DataNotFoundException;
import com.opengamma.core.change.ChangeManager;
import com.opengamma.core.change.ChangeProvider;
import com.opengamma.id.UniqueId;
import com.opengamma.util.test.TestGroup;
import com.opengamma.util.test.Timeout;
import com.opengamma.web.analytics.rest.MasterType;

/**
 * Test.
 */
@Test(groups = TestGroup.UNIT)
public class ConnectionManagerImplTest {

  @Test(expectedExceptions = DataNotFoundException.class, invocationCount = 5, successPercentage = 19)
  public void timeout() throws InterruptedException {
    // update manager with non-default short timeouts
    final MasterChangeManager masterChangeManager = new MasterChangeManager(Collections.<MasterType, ChangeProvider>emptyMap());
    final ConnectionManagerImpl connectionManager = new ConnectionManagerImpl(mock(ChangeManager.class),
                                                                        masterChangeManager,
                                                                        new LongPollingConnectionManager(),
                                                                        Timeout.standardTimeoutMillis() / 2,
                                                                        Timeout.standardTimeoutMillis() / 4);
    // connection that will be allowed to time out
    final String clientId = connectionManager.clientConnected("userId");
    // should complete normally
    connectionManager.subscribe("userId", clientId, UniqueId.of("Tst", "123"), "url");
    // wait until timeout
    Thread.sleep(Timeout.standardTimeoutMillis());
    // connection should have timed out, exception will be thrown because clientId is unknown
    connectionManager.subscribe("userId", clientId, UniqueId.of("Tst", "1234"), "url");
  }
}

@@ -639,12 +639,19 @@
 oup.
-UNIT
+INTEGRATION
 )%0Apu
@@ -750,53 +750,8 @@
 lass
-, invocationCount = 5, successPercentage = 19
 )%0A  

Switch test to Integration