2018-08-23 11:48:42 +02:00
|
|
|
package sonia.scm;
|
|
|
|
|
|
2018-09-10 14:52:32 +02:00
|
|
|
import com.google.inject.util.Providers;
|
2018-08-23 11:48:42 +02:00
|
|
|
import org.assertj.core.api.Assertions;
|
|
|
|
|
import org.junit.After;
|
|
|
|
|
import org.junit.Test;
|
2018-09-10 14:52:32 +02:00
|
|
|
import org.junit.runner.RunWith;
|
|
|
|
|
import org.mockito.Mock;
|
|
|
|
|
import org.mockito.junit.MockitoJUnitRunner;
|
|
|
|
|
import sonia.scm.template.TemplateEngine;
|
2018-08-23 11:48:42 +02:00
|
|
|
|
2018-09-10 14:52:32 +02:00
|
|
|
@RunWith(MockitoJUnitRunner.class)
|
2018-08-23 11:48:42 +02:00
|
|
|
public class PushStateDispatcherProviderTest {
|
|
|
|
|
|
2018-09-10 14:52:32 +02:00
|
|
|
@Mock
|
|
|
|
|
private TemplateEngine templateEngine;
|
|
|
|
|
|
|
|
|
|
private PushStateDispatcherProvider provider = new PushStateDispatcherProvider(
|
|
|
|
|
Providers.of(new TemplatingPushStateDispatcher(templateEngine))
|
|
|
|
|
);
|
2018-08-23 11:48:42 +02:00
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetProxyPushStateWithPropertySet() {
|
|
|
|
|
System.setProperty(PushStateDispatcherProvider.PROPERTY_TARGET, "http://localhost:9966");
|
|
|
|
|
PushStateDispatcher dispatcher = provider.get();
|
|
|
|
|
Assertions.assertThat(dispatcher).isInstanceOf(ProxyPushStateDispatcher.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testGetProxyPushStateWithoutProperty() {
|
|
|
|
|
PushStateDispatcher dispatcher = provider.get();
|
2018-09-10 14:52:32 +02:00
|
|
|
Assertions.assertThat(dispatcher).isInstanceOf(TemplatingPushStateDispatcher.class);
|
2018-08-23 11:48:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@After
|
|
|
|
|
public void cleanupSystemProperty() {
|
|
|
|
|
System.clearProperty(PushStateDispatcherProvider.PROPERTY_TARGET);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|