FIXME test additions
This commit is contained in:
parent
3e6c1b435f
commit
e74da3fa73
|
|
@ -16,23 +16,33 @@
|
|||
|
||||
package org.springframework.boot.actuate.metrics;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.actuate.metrics.DefaultCounterService;
|
||||
import java.util.Date;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link DefaultCounterService}.
|
||||
*/
|
||||
@Ignore
|
||||
public class DefaultCounterServiceTests {
|
||||
|
||||
// FIXME
|
||||
private MetricRepository repository = mock(MetricRepository.class);
|
||||
|
||||
private DefaultCounterService service = new DefaultCounterService(this.repository);
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
fail("Not yet implemented");
|
||||
public void incrementPrependsCounter() {
|
||||
this.service.increment("foo");
|
||||
verify(this.repository).increment(eq("counter.foo"), eq(1), any(Date.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decrementPrependsCounter() {
|
||||
this.service.decrement("foo");
|
||||
verify(this.repository).increment(eq("counter.foo"), eq(-1), any(Date.class));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,23 +16,28 @@
|
|||
|
||||
package org.springframework.boot.actuate.metrics;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.actuate.metrics.DefaultGaugeService;
|
||||
import java.util.Date;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link DefaultGaugeService}.
|
||||
*/
|
||||
@Ignore
|
||||
public class DefaultGaugeServiceTests {
|
||||
|
||||
// FIXME
|
||||
private MetricRepository repository = mock(MetricRepository.class);
|
||||
|
||||
private DefaultGaugeService service = new DefaultGaugeService(this.repository);
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
fail("Not yet implemented");
|
||||
public void setPrependsGuager() {
|
||||
this.service.set("foo", 2.3);
|
||||
verify(this.repository).set(eq("gauge.foo"), eq(2.3), any(Date.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,23 +16,44 @@
|
|||
|
||||
package org.springframework.boot.actuate.security;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.actuate.security.AuthenticationAuditListener;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.access.ConfigAttribute;
|
||||
import org.springframework.security.access.SecurityConfig;
|
||||
import org.springframework.security.access.event.AuthorizationFailureEvent;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
|
||||
import static org.mockito.Matchers.anyObject;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link AuthenticationAuditListener}.
|
||||
*/
|
||||
@Ignore
|
||||
public class AuthorizationAuditListenerTests {
|
||||
|
||||
// FIXME
|
||||
private AuthorizationAuditListener listener = new AuthorizationAuditListener();
|
||||
|
||||
private ApplicationEventPublisher publisher = Mockito
|
||||
.mock(ApplicationEventPublisher.class);
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
this.listener.setApplicationEventPublisher(this.publisher);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
fail("Not yet implemented");
|
||||
public void testAuthenticationSuccess() {
|
||||
this.listener.onApplicationEvent(new AuthorizationFailureEvent(this, Arrays
|
||||
.<ConfigAttribute> asList(new SecurityConfig("USER")),
|
||||
new UsernamePasswordAuthenticationToken("user", "password"),
|
||||
new AccessDeniedException("Bad user")));
|
||||
verify(this.publisher).publishEvent((ApplicationEvent) anyObject());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue