mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-17 02:31:14 +01:00
Merge with 2.0.0-m3
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
package sonia.scm.api.v2.resources;
|
||||
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.apache.shiro.subject.support.SubjectThreadState;
|
||||
import org.apache.shiro.util.ThreadContext;
|
||||
import org.apache.shiro.util.ThreadState;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import sonia.scm.repository.BrowserResult;
|
||||
import sonia.scm.repository.FileObject;
|
||||
import sonia.scm.repository.NamespaceAndName;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.MockitoAnnotations.initMocks;
|
||||
|
||||
public class BrowserResultToBrowserResultDtoMapperTest {
|
||||
|
||||
private final URI baseUri = URI.create("http://example.com/base/");
|
||||
@SuppressWarnings("unused") // Is injected
|
||||
private final ResourceLinks resourceLinks = ResourceLinksMock.createMock(baseUri);
|
||||
|
||||
@Mock
|
||||
private FileObjectToFileObjectDtoMapper fileObjectToFileObjectDtoMapper;
|
||||
|
||||
@InjectMocks
|
||||
private BrowserResultToBrowserResultDtoMapper mapper;
|
||||
|
||||
private final Subject subject = mock(Subject.class);
|
||||
private final ThreadState subjectThreadState = new SubjectThreadState(subject);
|
||||
|
||||
private FileObject fileObject1 = new FileObject();
|
||||
private FileObject fileObject2 = new FileObject();
|
||||
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
initMocks(this);
|
||||
subjectThreadState.bind();
|
||||
ThreadContext.bind(subject);
|
||||
|
||||
fileObject1.setName("FO 1");
|
||||
fileObject1.setLength(100);
|
||||
fileObject1.setLastModified(0L);
|
||||
fileObject1.setPath("/path/object/1");
|
||||
fileObject1.setDescription("description of file object 1");
|
||||
fileObject1.setDirectory(false);
|
||||
|
||||
fileObject2.setName("FO 2");
|
||||
fileObject2.setLength(100);
|
||||
fileObject2.setLastModified(101L);
|
||||
fileObject2.setPath("/path/object/2");
|
||||
fileObject2.setDescription("description of file object 2");
|
||||
fileObject2.setDirectory(true);
|
||||
}
|
||||
|
||||
@After
|
||||
public void unbind() {
|
||||
ThreadContext.unbindSubject();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldMapAttributesCorrectly() {
|
||||
BrowserResult browserResult = createBrowserResult();
|
||||
|
||||
BrowserResultDto dto = mapper.map(browserResult, new NamespaceAndName("foo", "bar"));
|
||||
|
||||
assertEqualAttributes(browserResult, dto);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldDelegateToFileObjectsMapper() {
|
||||
BrowserResult browserResult = createBrowserResult();
|
||||
NamespaceAndName namespaceAndName = new NamespaceAndName("foo", "bar");
|
||||
|
||||
BrowserResultDto dto = mapper.map(browserResult, namespaceAndName);
|
||||
|
||||
verify(fileObjectToFileObjectDtoMapper).map(fileObject1, namespaceAndName, "Revision");
|
||||
verify(fileObjectToFileObjectDtoMapper).map(fileObject2, namespaceAndName, "Revision");
|
||||
}
|
||||
|
||||
private BrowserResult createBrowserResult() {
|
||||
BrowserResult browserResult = new BrowserResult();
|
||||
browserResult.setTag("Tag");
|
||||
browserResult.setRevision("Revision");
|
||||
browserResult.setBranch("Branch");
|
||||
browserResult.setFiles(createFileObjects());
|
||||
|
||||
return browserResult;
|
||||
}
|
||||
|
||||
private List<FileObject> createFileObjects() {
|
||||
List<FileObject> fileObjects = new ArrayList<>();
|
||||
|
||||
fileObjects.add(fileObject1);
|
||||
fileObjects.add(fileObject2);
|
||||
return fileObjects;
|
||||
}
|
||||
|
||||
private void assertEqualAttributes(BrowserResult browserResult, BrowserResultDto dto) {
|
||||
assertThat(dto.getTag()).isEqualTo(browserResult.getTag());
|
||||
assertThat(dto.getBranch()).isEqualTo(browserResult.getBranch());
|
||||
assertThat(dto.getRevision()).isEqualTo(browserResult.getRevision());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package sonia.scm.api.v2.resources;
|
||||
import com.github.sdorra.shiro.ShiroRule;
|
||||
import com.github.sdorra.shiro.SubjectAware;
|
||||
import com.google.common.io.Resources;
|
||||
import org.apache.shiro.util.ThreadContext;
|
||||
import org.jboss.resteasy.core.Dispatcher;
|
||||
import org.jboss.resteasy.mock.MockDispatcherFactory;
|
||||
import org.jboss.resteasy.mock.MockHttpRequest;
|
||||
@@ -21,7 +22,9 @@ import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.MockitoAnnotations.initMocks;
|
||||
|
||||
@SubjectAware(
|
||||
@@ -47,6 +50,13 @@ public class ConfigResourceTest {
|
||||
@InjectMocks
|
||||
private ScmConfigurationToConfigDtoMapperImpl configToDtoMapper;
|
||||
|
||||
public ConfigResourceTest() {
|
||||
// cleanup state that might have been left by other tests
|
||||
ThreadContext.unbindSecurityManager();
|
||||
ThreadContext.unbindSubject();
|
||||
ThreadContext.remove();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void prepareEnvironment() {
|
||||
initMocks(this);
|
||||
|
||||
@@ -108,17 +108,6 @@ public class ContentResourceTest {
|
||||
assertEquals("text/plain", response.getHeaderString("Content-Type"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldRecognizeShebangSourceCode() throws Exception {
|
||||
mockContentFromResource("someScript.sh");
|
||||
|
||||
Response response = contentResource.get(NAMESPACE, REPO_NAME, REV, "someScript.sh");
|
||||
assertEquals(200, response.getStatus());
|
||||
|
||||
assertEquals("PYTHON", response.getHeaderString("Language"));
|
||||
assertEquals("application/x-sh", response.getHeaderString("Content-Type"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldHandleRandomByteFile() throws Exception {
|
||||
mockContentFromResource("JustBytes");
|
||||
@@ -142,6 +131,17 @@ public class ContentResourceTest {
|
||||
assertTrue("stream has to be closed after reading head", stream.isClosed());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldHandleEmptyFile() throws Exception {
|
||||
mockContent("empty", new byte[]{});
|
||||
|
||||
Response response = contentResource.get(NAMESPACE, REPO_NAME, REV, "empty");
|
||||
assertEquals(200, response.getStatus());
|
||||
|
||||
assertFalse(response.getHeaders().containsKey("Language"));
|
||||
assertEquals("application/octet-stream", response.getHeaderString("Content-Type"));
|
||||
}
|
||||
|
||||
private void mockContentFromResource(String fileName) throws Exception {
|
||||
URL url = Resources.getResource(fileName);
|
||||
mockContent(fileName, Resources.toByteArray(url));
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
package sonia.scm.api.v2.resources;
|
||||
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.apache.shiro.subject.support.SubjectThreadState;
|
||||
import org.apache.shiro.util.ThreadContext;
|
||||
import org.apache.shiro.util.ThreadState;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import sonia.scm.repository.FileObject;
|
||||
import sonia.scm.repository.NamespaceAndName;
|
||||
import sonia.scm.repository.SubRepository;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.Silent.class)
|
||||
public class FileObjectToFileObjectDtoMapperTest {
|
||||
|
||||
private final URI baseUri = URI.create("http://example.com/base/");
|
||||
@SuppressWarnings("unused") // Is injected
|
||||
private final ResourceLinks resourceLinks = ResourceLinksMock.createMock(baseUri);
|
||||
|
||||
@InjectMocks
|
||||
private FileObjectToFileObjectDtoMapperImpl mapper;
|
||||
|
||||
private final Subject subject = mock(Subject.class);
|
||||
private final ThreadState subjectThreadState = new SubjectThreadState(subject);
|
||||
|
||||
private URI expectedBaseUri;
|
||||
|
||||
@Before
|
||||
public void init() {
|
||||
expectedBaseUri = baseUri.resolve(RepositoryRootResource.REPOSITORIES_PATH_V2 + "/");
|
||||
subjectThreadState.bind();
|
||||
ThreadContext.bind(subject);
|
||||
}
|
||||
|
||||
@After
|
||||
public void unbind() {
|
||||
ThreadContext.unbindSubject();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldMapAttributesCorrectly() {
|
||||
FileObject fileObject = createFileObject();
|
||||
FileObjectDto dto = mapper.map(fileObject, new NamespaceAndName("namespace", "name"), "revision");
|
||||
|
||||
assertEqualAttributes(fileObject, dto);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldHaveCorrectSelfLinkForDirectory() {
|
||||
FileObject fileObject = createDirectoryObject();
|
||||
FileObjectDto dto = mapper.map(fileObject, new NamespaceAndName("namespace", "name"), "revision");
|
||||
|
||||
assertThat(dto.getLinks().getLinkBy("self").get().getHref()).isEqualTo(expectedBaseUri.resolve("namespace/name/sources/revision/foo/bar").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldHaveCorrectContentLink() {
|
||||
FileObject fileObject = createFileObject();
|
||||
fileObject.setDirectory(false);
|
||||
FileObjectDto dto = mapper.map(fileObject, new NamespaceAndName("namespace", "name"), "revision");
|
||||
|
||||
assertThat(dto.getLinks().getLinkBy("self").get().getHref()).isEqualTo(expectedBaseUri.resolve("namespace/name/content/revision/foo/bar").toString());
|
||||
}
|
||||
|
||||
private FileObject createDirectoryObject() {
|
||||
FileObject fileObject = createFileObject();
|
||||
fileObject.setDirectory(true);
|
||||
return fileObject;
|
||||
}
|
||||
|
||||
private FileObject createFileObject() {
|
||||
FileObject fileObject = new FileObject();
|
||||
fileObject.setName("foo");
|
||||
fileObject.setDescription("bar");
|
||||
fileObject.setPath("foo/bar");
|
||||
fileObject.setDirectory(false);
|
||||
fileObject.setLength(100);
|
||||
fileObject.setLastModified(123L);
|
||||
|
||||
fileObject.setSubRepository(new SubRepository("repo.url"));
|
||||
return fileObject;
|
||||
}
|
||||
|
||||
private void assertEqualAttributes(FileObject fileObject, FileObjectDto dto) {
|
||||
assertThat(dto.getName()).isEqualTo(fileObject.getName());
|
||||
assertThat(dto.getDescription()).isEqualTo(fileObject.getDescription());
|
||||
assertThat(dto.getPath()).isEqualTo(fileObject.getPath());
|
||||
assertThat(dto.isDirectory()).isEqualTo(fileObject.isDirectory());
|
||||
assertThat(dto.getLength()).isEqualTo(fileObject.getLength());
|
||||
assertThat(dto.getLastModified().toEpochMilli()).isEqualTo((long) fileObject.getLastModified());
|
||||
assertThat(dto.getSubRepository().getBrowserUrl()).isEqualTo(fileObject.getSubRepository().getBrowserUrl());
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import org.jboss.resteasy.core.Dispatcher;
|
||||
import org.jboss.resteasy.mock.MockHttpRequest;
|
||||
import org.jboss.resteasy.mock.MockHttpResponse;
|
||||
import org.jboss.resteasy.spi.HttpRequest;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -141,6 +142,11 @@ public class PermissionRootResourceTest {
|
||||
ThreadContext.bind(subject);
|
||||
}
|
||||
|
||||
@After
|
||||
public void unbind() {
|
||||
ThreadContext.unbindSubject();
|
||||
}
|
||||
|
||||
@TestFactory
|
||||
@DisplayName("test endpoints on missing repository")
|
||||
Stream<DynamicTest> missedRepositoryTestFactory() {
|
||||
|
||||
@@ -135,8 +135,8 @@ public class ResourceLinksTest {
|
||||
|
||||
@Test
|
||||
public void shouldCreateCorrectBranchSourceUrl() {
|
||||
String url = resourceLinks.source().source("space", "name", "revision");
|
||||
assertEquals(BASE_URL + RepositoryRootResource.REPOSITORIES_PATH_V2 + "space/name/sources/revision", url);
|
||||
String url = resourceLinks.source().selfWithoutRevision("space", "name");
|
||||
assertEquals(BASE_URL + RepositoryRootResource.REPOSITORIES_PATH_V2 + "space/name/sources/", url);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -147,13 +147,18 @@ public class ResourceLinksTest {
|
||||
|
||||
@Test
|
||||
public void shouldCreateCorrectSourceCollectionUrl() {
|
||||
String url = resourceLinks.source().self("space", "repo");
|
||||
String url = resourceLinks.source().selfWithoutRevision("space", "repo");
|
||||
assertEquals(BASE_URL + RepositoryRootResource.REPOSITORIES_PATH_V2 + "space/repo/sources/", url);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldCreateCorrectSourceUrlWithFilename() {
|
||||
String url = resourceLinks.source().sourceWithPath("foo", "bar", "rev", "file");
|
||||
assertEquals(BASE_URL + RepositoryRootResource.REPOSITORIES_PATH_V2 + "foo/bar/sources/rev/file", url);
|
||||
}
|
||||
@Test
|
||||
public void shouldCreateCorrectPermissionCollectionUrl() {
|
||||
String url = resourceLinks.source().self("space", "repo");
|
||||
String url = resourceLinks.source().selfWithoutRevision("space", "repo");
|
||||
assertEquals(BASE_URL + RepositoryRootResource.REPOSITORIES_PATH_V2 + "space/repo/sources/", url);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
package sonia.scm.api.v2.resources;
|
||||
|
||||
import org.jboss.resteasy.core.Dispatcher;
|
||||
import org.jboss.resteasy.mock.MockDispatcherFactory;
|
||||
import org.jboss.resteasy.mock.MockHttpRequest;
|
||||
import org.jboss.resteasy.mock.MockHttpResponse;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
import sonia.scm.repository.BrowserResult;
|
||||
import sonia.scm.repository.FileObject;
|
||||
import sonia.scm.repository.NamespaceAndName;
|
||||
import sonia.scm.repository.RepositoryNotFoundException;
|
||||
import sonia.scm.repository.RevisionNotFoundException;
|
||||
import sonia.scm.repository.api.BrowseCommandBuilder;
|
||||
import sonia.scm.repository.api.RepositoryService;
|
||||
import sonia.scm.repository.api.RepositoryServiceFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
||||
@RunWith(MockitoJUnitRunner.Silent.class)
|
||||
public class SourceRootResourceTest {
|
||||
|
||||
private final Dispatcher dispatcher = MockDispatcherFactory.createDispatcher();
|
||||
private final URI baseUri = URI.create("/");
|
||||
private final ResourceLinks resourceLinks = ResourceLinksMock.createMock(baseUri);
|
||||
|
||||
@Mock
|
||||
private RepositoryServiceFactory serviceFactory;
|
||||
@Mock
|
||||
private RepositoryService service;
|
||||
@Mock
|
||||
private BrowseCommandBuilder browseCommandBuilder;
|
||||
|
||||
@Mock
|
||||
private FileObjectToFileObjectDtoMapper fileObjectToFileObjectDtoMapper;
|
||||
|
||||
@InjectMocks
|
||||
private BrowserResultToBrowserResultDtoMapper browserResultToBrowserResultDtoMapper;
|
||||
|
||||
|
||||
@Before
|
||||
public void prepareEnvironment() throws Exception {
|
||||
when(serviceFactory.create(new NamespaceAndName("space", "repo"))).thenReturn(service);
|
||||
when(service.getBrowseCommand()).thenReturn(browseCommandBuilder);
|
||||
|
||||
FileObjectDto dto = new FileObjectDto();
|
||||
dto.setName("name");
|
||||
dto.setLength(1024);
|
||||
|
||||
when(fileObjectToFileObjectDtoMapper.map(any(FileObject.class), any(NamespaceAndName.class), anyString())).thenReturn(dto);
|
||||
SourceRootResource sourceRootResource = new SourceRootResource(serviceFactory, browserResultToBrowserResultDtoMapper);
|
||||
RepositoryRootResource repositoryRootResource =
|
||||
new RepositoryRootResource(MockProvider.of(new RepositoryResource(null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
MockProvider.of(sourceRootResource),
|
||||
null,
|
||||
null)),
|
||||
null);
|
||||
|
||||
dispatcher.getRegistry().addSingletonResource(repositoryRootResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnSources() throws URISyntaxException, IOException, RevisionNotFoundException {
|
||||
BrowserResult result = createBrowserResult();
|
||||
when(browseCommandBuilder.getBrowserResult()).thenReturn(result);
|
||||
MockHttpRequest request = MockHttpRequest.get("/" + RepositoryRootResource.REPOSITORIES_PATH_V2 + "space/repo/sources");
|
||||
MockHttpResponse response = new MockHttpResponse();
|
||||
|
||||
dispatcher.invoke(request, response);
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getContentAsString()).contains("\"revision\":\"revision\"");
|
||||
assertThat(response.getContentAsString()).contains("\"tag\":\"tag\"");
|
||||
assertThat(response.getContentAsString()).contains("\"branch\":\"branch\"");
|
||||
assertThat(response.getContentAsString()).contains("\"files\":");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturn404IfRepoNotFound() throws URISyntaxException, RepositoryNotFoundException {
|
||||
when(serviceFactory.create(new NamespaceAndName("idont", "exist"))).thenThrow(RepositoryNotFoundException.class);
|
||||
MockHttpRequest request = MockHttpRequest.get("/" + RepositoryRootResource.REPOSITORIES_PATH_V2 + "idont/exist/sources");
|
||||
MockHttpResponse response = new MockHttpResponse();
|
||||
|
||||
dispatcher.invoke(request, response);
|
||||
assertThat(response.getStatus()).isEqualTo(404);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGetResultForSingleFile() throws URISyntaxException, IOException, RevisionNotFoundException {
|
||||
BrowserResult browserResult = new BrowserResult();
|
||||
browserResult.setBranch("abc");
|
||||
browserResult.setRevision("revision");
|
||||
browserResult.setTag("tag");
|
||||
FileObject fileObject = new FileObject();
|
||||
fileObject.setName("File Object!");
|
||||
|
||||
browserResult.setFiles(Arrays.asList(fileObject));
|
||||
|
||||
when(browseCommandBuilder.getBrowserResult()).thenReturn(browserResult);
|
||||
MockHttpRequest request = MockHttpRequest.get("/" + RepositoryRootResource.REPOSITORIES_PATH_V2 + "space/repo/sources/revision/fileabc");
|
||||
MockHttpResponse response = new MockHttpResponse();
|
||||
|
||||
dispatcher.invoke(request, response);
|
||||
assertThat(response.getStatus()).isEqualTo(200);
|
||||
assertThat(response.getContentAsString()).contains("\"revision\":\"revision\"");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldGet404ForSingleFileIfRepoNotFound() throws URISyntaxException, RepositoryNotFoundException {
|
||||
when(serviceFactory.create(new NamespaceAndName("idont", "exist"))).thenThrow(RepositoryNotFoundException.class);
|
||||
|
||||
MockHttpRequest request = MockHttpRequest.get("/" + RepositoryRootResource.REPOSITORIES_PATH_V2 + "idont/exist/sources/revision/fileabc");
|
||||
MockHttpResponse response = new MockHttpResponse();
|
||||
|
||||
dispatcher.invoke(request, response);
|
||||
assertThat(response.getStatus()).isEqualTo(404);
|
||||
}
|
||||
|
||||
private BrowserResult createBrowserResult() {
|
||||
return new BrowserResult("revision", "tag", "branch", createFileObjects());
|
||||
}
|
||||
|
||||
private List<FileObject> createFileObjects() {
|
||||
FileObject fileObject1 = new FileObject();
|
||||
fileObject1.setName("FO 1");
|
||||
fileObject1.setDirectory(false);
|
||||
fileObject1.setDescription("File object 1");
|
||||
fileObject1.setPath("/foo/bar/fo1");
|
||||
fileObject1.setLength(1024L);
|
||||
fileObject1.setLastModified(0L);
|
||||
|
||||
FileObject fileObject2 = new FileObject();
|
||||
fileObject2.setName("FO 2");
|
||||
fileObject2.setDirectory(true);
|
||||
fileObject2.setDescription("File object 2");
|
||||
fileObject2.setPath("/foo/bar/fo2");
|
||||
fileObject2.setLength(4096L);
|
||||
fileObject2.setLastModified(1234L);
|
||||
|
||||
return Arrays.asList(fileObject1, fileObject2);
|
||||
}
|
||||
}
|
||||
@@ -36,18 +36,26 @@ import com.github.sdorra.shiro.SubjectAware;
|
||||
import com.google.common.collect.Sets;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import org.apache.shiro.util.ThreadContext;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.*;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import static org.hamcrest.Matchers.isEmptyOrNullString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.anyString;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* Unit test for {@link JwtAccessTokenBuilder}.
|
||||
@@ -57,6 +65,10 @@ import org.mockito.junit.MockitoJUnitRunner;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class JwtAccessTokenBuilderTest {
|
||||
|
||||
{
|
||||
ThreadContext.unbindSubject();
|
||||
}
|
||||
|
||||
@Mock
|
||||
private KeyGenerator keyGenerator;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user