Our CLA is based on the Apache Software Foundation’s CLA and in it, contributors state that the contributions are their original work and grant Pivotal a copyright and patent license to include their contributions in the project.
In return, Pivotal and the open source communities we serve are able to distribute and build upon such contributions.
This means that if any legal issues arise in the future about our rights to distribute the code, we can show them these forms.
- It also ensures that the contributors cannot withdraw permission to the contributions at some point in the future.
+ It also ensures that the contributors cannot withdraw permission to the contributions at some point in the future.
Both individuals and large enterprises use code from our open source projects, and in our experience, they need to be sure about the origins and rights to use the code.
diff --git a/src/main/resources/templates/admin/cla/form.html b/src/main/resources/templates/admin/cla/form.html
index 52002526..fc379619 100644
--- a/src/main/resources/templates/admin/cla/form.html
+++ b/src/main/resources/templates/admin/cla/form.html
@@ -1,6 +1,6 @@
+ layout:decorate="layouts/main" th:with="isEditCla=${claForm.id != null}">
Create CLA
diff --git a/src/main/resources/templates/admin/cla/index.html b/src/main/resources/templates/admin/cla/index.html
index af33cfb2..d91eb0a2 100644
--- a/src/main/resources/templates/admin/cla/index.html
+++ b/src/main/resources/templates/admin/cla/index.html
@@ -1,6 +1,6 @@
+ layout:decorate="layouts/main">
Manage CLAs
diff --git a/src/main/resources/templates/admin/cla/link.html b/src/main/resources/templates/admin/cla/link.html
index a98e99c7..d7e3c71e 100644
--- a/src/main/resources/templates/admin/cla/link.html
+++ b/src/main/resources/templates/admin/cla/link.html
@@ -1,5 +1,5 @@
-
+
Link to CLA
diff --git a/src/main/resources/templates/admin/cla/sign/icla.html b/src/main/resources/templates/admin/cla/sign/icla.html
index 178c3fb8..2734dea5 100644
--- a/src/main/resources/templates/admin/cla/sign/icla.html
+++ b/src/main/resources/templates/admin/cla/sign/icla.html
@@ -1,6 +1,6 @@
+ layout:decorate="layouts/main">
Sign ICLA
diff --git a/src/main/resources/templates/admin/help/index.html b/src/main/resources/templates/admin/help/index.html
index fdeb6634..d68a6b9b 100644
--- a/src/main/resources/templates/admin/help/index.html
+++ b/src/main/resources/templates/admin/help/index.html
@@ -1,6 +1,6 @@
+ layout:decorate="layouts/main">
Admin Help
diff --git a/src/main/resources/templates/admin/help/migrate.html b/src/main/resources/templates/admin/help/migrate.html
index 4c213cb4..15ed3698 100644
--- a/src/main/resources/templates/admin/help/migrate.html
+++ b/src/main/resources/templates/admin/help/migrate.html
@@ -1,6 +1,6 @@
+ layout:decorate="layouts/main">
Migrating
diff --git a/src/main/resources/templates/admin/lookup/index.html b/src/main/resources/templates/admin/lookup/index.html
index a56ff6c7..c56dd20d 100644
--- a/src/main/resources/templates/admin/lookup/index.html
+++ b/src/main/resources/templates/admin/lookup/index.html
@@ -1,6 +1,6 @@
+ layout:decorate="layouts/main">
Lookup Signature
diff --git a/src/main/resources/templates/cla/ccla/sign.html b/src/main/resources/templates/cla/ccla/sign.html
index 936808c3..68dcbaaa 100644
--- a/src/main/resources/templates/cla/ccla/sign.html
+++ b/src/main/resources/templates/cla/ccla/sign.html
@@ -1,6 +1,6 @@
+ layout:decorate="layouts/main">
Sign CCLA
diff --git a/src/main/resources/templates/cla/ccla/view.html b/src/main/resources/templates/cla/ccla/view.html
index e229ee4c..b7e47a79 100644
--- a/src/main/resources/templates/cla/ccla/view.html
+++ b/src/main/resources/templates/cla/ccla/view.html
@@ -1,6 +1,6 @@
+ layout:decorate="layouts/main">
Sign CCLA
diff --git a/src/main/resources/templates/cla/icla/sign.html b/src/main/resources/templates/cla/icla/sign.html
index f77795ea..35685eac 100644
--- a/src/main/resources/templates/cla/icla/sign.html
+++ b/src/main/resources/templates/cla/icla/sign.html
@@ -1,6 +1,6 @@
+ layout:decorate="layouts/main">
Sign ICLA
diff --git a/src/main/resources/templates/cla/icla/view.html b/src/main/resources/templates/cla/icla/view.html
index 726e810c..46a868b7 100644
--- a/src/main/resources/templates/cla/icla/view.html
+++ b/src/main/resources/templates/cla/icla/view.html
@@ -1,6 +1,6 @@
+ layout:decorate="layouts/main">
View ICLA
diff --git a/src/main/resources/templates/error.html b/src/main/resources/templates/error.html
index df9a2fd5..705814ca 100644
--- a/src/main/resources/templates/error.html
+++ b/src/main/resources/templates/error.html
@@ -1,4 +1,4 @@
-
+
Error
diff --git a/src/main/resources/templates/error/403.html b/src/main/resources/templates/error/403.html
index 303434cc..f79f9764 100644
--- a/src/main/resources/templates/error/403.html
+++ b/src/main/resources/templates/error/403.html
@@ -1,4 +1,4 @@
-
+
Access Denied
diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html
index 8593c2e8..280fdad6 100644
--- a/src/main/resources/templates/index.html
+++ b/src/main/resources/templates/index.html
@@ -1,4 +1,4 @@
-
+
Home
diff --git a/src/main/resources/templates/layouts/main.html b/src/main/resources/templates/layouts/main.html
index 2209c1b6..bc28fdfb 100644
--- a/src/main/resources/templates/layouts/main.html
+++ b/src/main/resources/templates/layouts/main.html
@@ -8,7 +8,7 @@
- Pivotal CLA
+ Pivotal CLA
diff --git a/src/main/resources/templates/sync/form.html b/src/main/resources/templates/sync/form.html
index 044df3b0..68b2d3db 100644
--- a/src/main/resources/templates/sync/form.html
+++ b/src/main/resources/templates/sync/form.html
@@ -1,6 +1,6 @@
+ layout:decorate="layouts/main">
Sync Pull Request
diff --git a/src/test/java/io/pivotal/cla/MocksConfig.java b/src/test/java/io/pivotal/cla/MocksConfig.java
index 3a2487cf..9f98497c 100644
--- a/src/test/java/io/pivotal/cla/MocksConfig.java
+++ b/src/test/java/io/pivotal/cla/MocksConfig.java
@@ -15,14 +15,14 @@
*/
package io.pivotal.cla;
+import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
-@Configuration
-@Profile("test")
+@TestConfiguration
public class MocksConfig {
@Controller
diff --git a/src/test/java/io/pivotal/cla/TestPivotalClaApplication.java b/src/test/java/io/pivotal/cla/TestPivotalClaApplication.java
new file mode 100644
index 00000000..a962d1f6
--- /dev/null
+++ b/src/test/java/io/pivotal/cla/TestPivotalClaApplication.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2002-2024 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.pivotal.cla;
+
+import io.pivotal.cla.data.repository.MysqlConfiguration;
+import org.springframework.boot.SpringApplication;
+import org.springframework.test.context.ActiveProfiles;
+
+@ActiveProfiles("local")
+public class TestPivotalClaApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.from(PivotalClaApplication::main)
+ .with(MysqlConfiguration.class)
+ .run(args);
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/io/pivotal/cla/config/ClaOAuthConfigTests.java b/src/test/java/io/pivotal/cla/config/ClaOAuthConfigTests.java
index d00f3bca..2288f286 100644
--- a/src/test/java/io/pivotal/cla/config/ClaOAuthConfigTests.java
+++ b/src/test/java/io/pivotal/cla/config/ClaOAuthConfigTests.java
@@ -17,10 +17,8 @@
import static org.assertj.core.api.Assertions.assertThat;
-import java.lang.reflect.Modifier;
-
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
/**
@@ -30,7 +28,7 @@
public class ClaOAuthConfigTests {
ClaOAuthConfig config;
- @Before
+ @BeforeEach
public void setup() {
config = new ClaOAuthConfig();
}
diff --git a/src/test/java/io/pivotal/cla/data/repository/CorporateSignatureRepositoryTests.java b/src/test/java/io/pivotal/cla/data/repository/CorporateSignatureRepositoryTests.java
index 77d0b829..487e89f4 100644
--- a/src/test/java/io/pivotal/cla/data/repository/CorporateSignatureRepositoryTests.java
+++ b/src/test/java/io/pivotal/cla/data/repository/CorporateSignatureRepositoryTests.java
@@ -19,17 +19,20 @@
import io.pivotal.cla.data.CorporateSignature;
import io.pivotal.cla.data.DataUtils;
import io.pivotal.cla.data.User;
-import io.pivotal.cla.junit.JpaTests;
-import io.pivotal.cla.test.context.SystemDataActiveProfiles;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.boot.test.context.TestConfiguration;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Import;
import org.springframework.data.domain.PageRequest;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.testcontainers.containers.MySQLContainer;
+import org.testcontainers.junit.jupiter.Testcontainers;
+import org.testcontainers.utility.DockerImageName;
import java.util.Arrays;
import java.util.Collections;
@@ -40,11 +43,11 @@
* @author Rob Winch
*
*/
-@RunWith(SpringJUnit4ClassRunner.class)
@DataJpaTest
+@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
@TestPropertySource(locations="/application-test.properties")
-@SystemDataActiveProfiles
-@Category(JpaTests.class)
+@Testcontainers
+@Import(MysqlConfiguration.class)
public class CorporateSignatureRepositoryTests {
@Autowired
@@ -61,7 +64,7 @@ public class CorporateSignatureRepositoryTests {
User user;
- @Before
+ @BeforeEach
public void setup() {
user = DataUtils.createUser();
@@ -227,4 +230,5 @@ private static CorporateSignature createSignature(ContributorLicenseAgreement cl
signature.setEmail(user.getEmails().iterator().next());
return signature;
}
+
}
diff --git a/src/test/java/io/pivotal/cla/data/repository/IndividualSignatureRepositoryTests.java b/src/test/java/io/pivotal/cla/data/repository/IndividualSignatureRepositoryTests.java
index b3faca5f..2b95605c 100644
--- a/src/test/java/io/pivotal/cla/data/repository/IndividualSignatureRepositoryTests.java
+++ b/src/test/java/io/pivotal/cla/data/repository/IndividualSignatureRepositoryTests.java
@@ -19,18 +19,18 @@
import io.pivotal.cla.data.DataUtils;
import io.pivotal.cla.data.IndividualSignature;
import io.pivotal.cla.data.User;
-import io.pivotal.cla.junit.JpaTests;
import io.pivotal.cla.service.ClaService;
-import io.pivotal.cla.test.context.SystemDataActiveProfiles;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
+import io.pivotal.cla.service.github.GitHubApi;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.context.annotation.Import;
import org.springframework.data.domain.PageRequest;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.testcontainers.junit.jupiter.Testcontainers;
import java.util.Collections;
@@ -40,11 +40,11 @@
* @author Rob Winch
*
*/
-@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest
+@DataJpaTest
+@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
@TestPropertySource(locations="/application-test.properties")
-@SystemDataActiveProfiles
-@Category(JpaTests.class)
+@Testcontainers
+@Import({MysqlConfiguration.class, ClaService.class})
public class IndividualSignatureRepositoryTests {
@Autowired
@@ -56,6 +56,9 @@ public class IndividualSignatureRepositoryTests {
@Autowired
ClaService claService;
+ @MockBean
+ GitHubApi gitHubApi;
+
ContributorLicenseAgreement cla;
ContributorLicenseAgreement springCla;
@@ -64,7 +67,7 @@ public class IndividualSignatureRepositoryTests {
User user;
- @Before
+ @BeforeEach
public void setup() {
user = DataUtils.createUser();
diff --git a/src/test/java/io/pivotal/cla/data/repository/MysqlConfiguration.java b/src/test/java/io/pivotal/cla/data/repository/MysqlConfiguration.java
new file mode 100644
index 00000000..1fd8ba01
--- /dev/null
+++ b/src/test/java/io/pivotal/cla/data/repository/MysqlConfiguration.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2002-2024 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.pivotal.cla.data.repository;
+
+import org.springframework.boot.test.context.TestConfiguration;
+import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
+import org.springframework.context.annotation.Bean;
+import org.testcontainers.containers.MySQLContainer;
+import org.testcontainers.utility.DockerImageName;
+
+@TestConfiguration(proxyBeanMethods = false)
+public class MysqlConfiguration {
+
+ @Bean
+ @ServiceConnection
+ static MySQLContainer mysqlContainer() {
+ return new MySQLContainer(DockerImageName.parse("mysql:8.0.36"));
+ }
+}
diff --git a/src/test/java/io/pivotal/cla/mvc/admin/AdminUserControllerTests.java b/src/test/java/io/pivotal/cla/mvc/admin/AdminUserControllerTests.java
index eeccf44b..06118869 100644
--- a/src/test/java/io/pivotal/cla/mvc/admin/AdminUserControllerTests.java
+++ b/src/test/java/io/pivotal/cla/mvc/admin/AdminUserControllerTests.java
@@ -3,19 +3,16 @@
import io.pivotal.cla.data.User;
import io.pivotal.cla.data.repository.UserRepository;
+import io.pivotal.cla.security.ImportSecurity;
import io.pivotal.cla.security.WithAdminUser;
import io.pivotal.cla.security.WithClaAuthorUser;
import io.pivotal.cla.security.WithSigningUser;
-import io.pivotal.cla.webdriver.WebDriverContext;
+import io.pivotal.cla.service.ClaService;
import org.hamcrest.CoreMatchers;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
-import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
@@ -25,12 +22,15 @@
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
-@WebDriverContext
-@RunWith(SpringRunner.class)
+@WebMvcTest(AdminUserController.class)
+@ImportSecurity
public class AdminUserControllerTests {
@MockBean
UserRepository users;
+ @MockBean
+ ClaService claService;
+
@Autowired
MockMvc mockMvc;
diff --git a/src/test/java/io/pivotal/cla/mvc/github/GitHubHooksControllerTests.java b/src/test/java/io/pivotal/cla/mvc/github/GitHubHooksControllerTests.java
index 633334f4..4d2cc701 100644
--- a/src/test/java/io/pivotal/cla/mvc/github/GitHubHooksControllerTests.java
+++ b/src/test/java/io/pivotal/cla/mvc/github/GitHubHooksControllerTests.java
@@ -25,10 +25,13 @@
import java.io.UnsupportedEncodingException;
import java.util.Arrays;
-import org.junit.Before;
-import org.junit.Test;
+import io.pivotal.cla.security.GitHubSignature;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.context.annotation.Import;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.RequestPostProcessor;
@@ -38,23 +41,23 @@
import io.pivotal.cla.data.User;
import io.pivotal.cla.egit.github.core.PullRequestId;
import io.pivotal.cla.egit.github.core.event.GithubEvents;
-import io.pivotal.cla.security.GitHubSignature;
import io.pivotal.cla.security.WithSigningUserFactory;
import io.pivotal.cla.service.github.GitHubApi;
import io.pivotal.cla.service.github.PullRequestStatus;
import io.pivotal.cla.webdriver.BaseWebDriverTests;
+@Import(GitHubSignature.class)
public class GitHubHooksControllerTests extends BaseWebDriverTests {
AccessToken accessToken;
@Autowired
- GitHubSignature oauth;
+ GitHubApi gitHubApiMock;
@Autowired
- GitHubApi gitHubApiMock;
+ GitHubSignature oauth;
- @Before
+ @BeforeEach
public void setupAccessToken() {
accessToken = new AccessToken(AccessToken.CLA_ACCESS_TOKEN_ID, "GitHubHooksControllerTests_access_token");
when(mockTokenRepo.findOne(AccessToken.CLA_ACCESS_TOKEN_ID)).thenReturn(accessToken);
diff --git a/src/test/java/io/pivotal/cla/mvc/support/ImportedSignaturesSessionAttrResolverTests.java b/src/test/java/io/pivotal/cla/mvc/support/ImportedSignaturesSessionAttrResolverTests.java
index c626bd73..70f03bf0 100644
--- a/src/test/java/io/pivotal/cla/mvc/support/ImportedSignaturesSessionAttrResolverTests.java
+++ b/src/test/java/io/pivotal/cla/mvc/support/ImportedSignaturesSessionAttrResolverTests.java
@@ -15,8 +15,8 @@
*/
package io.pivotal.cla.mvc.support;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.core.MethodParameter;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.util.ReflectionUtils;
@@ -37,7 +37,7 @@ public class ImportedSignaturesSessionAttrResolverTests {
ImportedSignaturesSessionAttrResolver resolver;
- @Before
+ @BeforeEach
public void setup() {
resolver = new ImportedSignaturesSessionAttrResolver();
method = ReflectionUtils.findMethod(ImportedSignaturesSessionAttrResolverTests.class, "methodParameter", ImportedSignaturesSessionAttr.class, Object.class);
diff --git a/src/test/java/io/pivotal/cla/mvc/support/ImportedSignaturesSessionAttrTests.java b/src/test/java/io/pivotal/cla/mvc/support/ImportedSignaturesSessionAttrTests.java
index a4dd0d05..8f425494 100644
--- a/src/test/java/io/pivotal/cla/mvc/support/ImportedSignaturesSessionAttrTests.java
+++ b/src/test/java/io/pivotal/cla/mvc/support/ImportedSignaturesSessionAttrTests.java
@@ -17,8 +17,8 @@
import static org.assertj.core.api.Assertions.assertThat;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.web.context.request.ServletWebRequest;
@@ -31,7 +31,7 @@ public class ImportedSignaturesSessionAttrTests {
MockHttpServletRequest request;
- @Before
+ @BeforeEach
public void setup() {
request = new MockHttpServletRequest();
attr = new ImportedSignaturesSessionAttr(new ServletWebRequest(request));
diff --git a/src/test/java/io/pivotal/cla/security/GitHubSignatureTests.java b/src/test/java/io/pivotal/cla/security/GitHubSignatureTests.java
index ce2e8cb8..241b5afd 100644
--- a/src/test/java/io/pivotal/cla/security/GitHubSignatureTests.java
+++ b/src/test/java/io/pivotal/cla/security/GitHubSignatureTests.java
@@ -16,14 +16,14 @@
package io.pivotal.cla.security;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.when;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import io.pivotal.cla.data.AccessToken;
import io.pivotal.cla.data.repository.AccessTokenRepository;
@@ -32,7 +32,7 @@
* @author Rob Winch
*
*/
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class GitHubSignatureTests {
@Mock
AccessTokenRepository mockAccessTokens;
@@ -41,7 +41,7 @@ public class GitHubSignatureTests {
AccessToken token;
- @Before
+ @BeforeEach
public void setup() {
gitHubSignature = new GitHubSignature(mockAccessTokens);
token = new AccessToken();
diff --git a/src/test/java/io/pivotal/cla/security/ImportSecurity.java b/src/test/java/io/pivotal/cla/security/ImportSecurity.java
new file mode 100644
index 00000000..9aca8ad2
--- /dev/null
+++ b/src/test/java/io/pivotal/cla/security/ImportSecurity.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2002-2024 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.pivotal.cla.security;
+
+import io.pivotal.cla.config.ClaOAuthConfig;
+import io.pivotal.cla.config.SecurityConfig;
+import org.springframework.context.annotation.Import;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Import({SecurityConfig.class, ClaOAuthConfig.class})
+public @interface ImportSecurity {
+}
diff --git a/src/test/java/io/pivotal/cla/service/github/MylynGitHubApiITests.java b/src/test/java/io/pivotal/cla/service/github/MylynGitHubApiITests.java
index b2235aff..dcdb8133 100644
--- a/src/test/java/io/pivotal/cla/service/github/MylynGitHubApiITests.java
+++ b/src/test/java/io/pivotal/cla/service/github/MylynGitHubApiITests.java
@@ -15,42 +15,40 @@
*/
package io.pivotal.cla.service.github;
-import static org.assertj.core.api.Assertions.*;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Set;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.springframework.core.serializer.support.SerializingConverter;
-
import io.pivotal.cla.config.ClaOAuthConfig;
import io.pivotal.cla.config.OAuthClientCredentials;
import io.pivotal.cla.data.User;
import okhttp3.mockwebserver.EnqueueRequests;
+import okhttp3.mockwebserver.EnqueueRequestsExtension;
import okhttp3.mockwebserver.EnqueueResourcesMockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.core.serializer.support.SerializingConverter;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Rob Winch
* @author Mark Paluch
*/
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith({ MockitoExtension.class, EnqueueRequestsExtension.class })
public class MylynGitHubApiITests {
- @Rule
public final EnqueueResourcesMockWebServer server = new EnqueueResourcesMockWebServer();
ClaOAuthConfig oauthConfig;
MylynGitHubApi service;
- @Before
+ @BeforeEach
public void setup() throws IOException {
OAuthClientCredentials credentials = new OAuthClientCredentials();
@@ -1247,7 +1245,7 @@ public void saveFailureNoComments() throws Exception {
"getStatusNone",
"saveStatus"
})
- @Ignore
+ @Disabled
public void saveFailureNoCommentsPullRequestClosed() throws Exception {
String accessToken = "access-token-123";
@@ -1273,7 +1271,7 @@ public void saveFailureNoCommentsPullRequestClosed() throws Exception {
"getStatusNone",
"saveStatus"
})
- @Ignore
+ @Disabled
public void saveFailureNoCommentsPullRequestUnknownState() throws Exception {
String accessToken = "access-token-123";
diff --git a/src/test/java/io/pivotal/cla/test/context/SystemActiveProfilesResolverTests.java b/src/test/java/io/pivotal/cla/test/context/SystemActiveProfilesResolverTests.java
index 6f094678..ea79ce0a 100644
--- a/src/test/java/io/pivotal/cla/test/context/SystemActiveProfilesResolverTests.java
+++ b/src/test/java/io/pivotal/cla/test/context/SystemActiveProfilesResolverTests.java
@@ -17,8 +17,8 @@
import static org.assertj.core.api.Assertions.assertThat;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.test.context.ActiveProfiles;
/**
@@ -28,7 +28,7 @@
public class SystemActiveProfilesResolverTests {
SystemActiveProfilesResolver resolver;
- @Before
+ @BeforeEach
public void setup() {
resolver = new SystemActiveProfilesResolver();
}
diff --git a/src/test/java/io/pivotal/cla/webdriver/AboutControllerTests.java b/src/test/java/io/pivotal/cla/webdriver/AboutControllerTests.java
index 5b23dafa..ca76f498 100644
--- a/src/test/java/io/pivotal/cla/webdriver/AboutControllerTests.java
+++ b/src/test/java/io/pivotal/cla/webdriver/AboutControllerTests.java
@@ -18,7 +18,7 @@
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class AboutControllerTests extends BaseWebDriverTests {
diff --git a/src/test/java/io/pivotal/cla/webdriver/AccessDeniedTests.java b/src/test/java/io/pivotal/cla/webdriver/AccessDeniedTests.java
index 60749321..e7429885 100644
--- a/src/test/java/io/pivotal/cla/webdriver/AccessDeniedTests.java
+++ b/src/test/java/io/pivotal/cla/webdriver/AccessDeniedTests.java
@@ -15,12 +15,12 @@
*/
package io.pivotal.cla.webdriver;
-import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.any;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import io.pivotal.cla.data.User;
import io.pivotal.cla.security.WithSigningUser;
diff --git a/src/test/java/io/pivotal/cla/webdriver/ActuatorSecurityTests.java b/src/test/java/io/pivotal/cla/webdriver/ActuatorSecurityTests.java
index 59908ddd..26266752 100644
--- a/src/test/java/io/pivotal/cla/webdriver/ActuatorSecurityTests.java
+++ b/src/test/java/io/pivotal/cla/webdriver/ActuatorSecurityTests.java
@@ -18,7 +18,19 @@
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.actuate.autoconfigure.beans.BeansEndpointAutoConfiguration;
+import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration;
+import org.springframework.boot.actuate.autoconfigure.endpoint.web.ServletEndpointManagementContextConfiguration;
+import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration;
+import org.springframework.boot.actuate.autoconfigure.endpoint.web.servlet.WebMvcEndpointManagementContextConfiguration;
+import org.springframework.boot.actuate.autoconfigure.web.server.ManagementContextAutoConfiguration;
+import org.springframework.boot.autoconfigure.*;
+import org.springframework.boot.context.TypeExcludeFilter;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.FilterType;
+import org.springframework.context.annotation.Import;
+import org.springframework.core.Ordered;
import org.springframework.http.MediaType;
import io.pivotal.cla.security.WithAdminUser;
@@ -29,6 +41,7 @@
* @author Rob Winch
*
*/
+@ImportAutoConfiguration({EndpointAutoConfiguration.class, WebEndpointAutoConfiguration.class, BeansEndpointAutoConfiguration.class, ManagementContextAutoConfiguration.class})
public class ActuatorSecurityTests extends BaseWebDriverTests {
@Test
diff --git a/src/test/java/io/pivotal/cla/webdriver/AuthenticationTests.java b/src/test/java/io/pivotal/cla/webdriver/AuthenticationTests.java
index 7b730e65..e29f4372 100644
--- a/src/test/java/io/pivotal/cla/webdriver/AuthenticationTests.java
+++ b/src/test/java/io/pivotal/cla/webdriver/AuthenticationTests.java
@@ -16,9 +16,9 @@
package io.pivotal.cla.webdriver;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anySet;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anySet;
+import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -28,11 +28,14 @@
import java.util.Arrays;
import java.util.Collections;
-import org.junit.Test;
+import io.pivotal.cla.MocksConfig;
+import io.pivotal.cla.security.ImportSecurity;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Import;
import org.springframework.mock.web.MockHttpSession;
import org.springframework.security.test.context.TestSecurityContextHolder;
import org.springframework.util.MultiValueMap;
@@ -49,6 +52,7 @@
import io.pivotal.cla.webdriver.pages.SignClaPage;
import io.pivotal.cla.webdriver.pages.admin.AdminLinkClaPage;
+@Import(MocksConfig.class)
public class AuthenticationTests extends BaseWebDriverTests {
@Autowired
@@ -133,6 +137,7 @@ public void authenticateAdmin() throws Exception {
when(mockGitHub.getCurrentUser(any(CurrentUserRequest.class))).thenReturn(user);
AdminLinkClaPage admin = AdminLinkClaPage.to(driver);
+ System.out.println(driver.getCurrentUrl());
admin.assertAt();
ArgumentCaptor userCaptor = ArgumentCaptor.forClass(CurrentUserRequest.class);
diff --git a/src/test/java/io/pivotal/cla/webdriver/BaseWebDriverTests.java b/src/test/java/io/pivotal/cla/webdriver/BaseWebDriverTests.java
index 059884d1..aa9a0190 100644
--- a/src/test/java/io/pivotal/cla/webdriver/BaseWebDriverTests.java
+++ b/src/test/java/io/pivotal/cla/webdriver/BaseWebDriverTests.java
@@ -19,14 +19,17 @@
import java.net.URLDecoder;
import java.util.concurrent.Executors;
-import org.junit.Before;
-import org.junit.runner.RunWith;
+import io.pivotal.cla.security.GitHubSignature;
+import io.pivotal.cla.security.ImportSecurity;
+import io.pivotal.cla.service.ClaService;
+import org.junit.jupiter.api.BeforeEach;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
+import org.springframework.context.annotation.Import;
import org.springframework.security.concurrent.DelegatingSecurityContextExecutor;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.htmlunit.webdriver.MockMvcHtmlUnitDriverBuilder;
import org.springframework.web.context.WebApplicationContext;
@@ -42,8 +45,9 @@
import io.pivotal.cla.data.repository.UserRepository;
import io.pivotal.cla.service.github.GitHubApi;
-@RunWith(SpringJUnit4ClassRunner.class)
-@WebDriverContext
+@WebMvcTest
+@ImportSecurity
+@Import(ClaService.class)
public abstract class BaseWebDriverTests {
@Autowired
protected WebApplicationContext wac;
@@ -70,7 +74,7 @@ public abstract class BaseWebDriverTests {
protected IndividualSignature individualSignature;
protected CorporateSignature corporateSignature;
- @Before
+ @BeforeEach
public void setup() {
HtmlUnitDriver driver = MockMvcHtmlUnitDriverBuilder
.mockMvcSetup(mockMvc)
diff --git a/src/test/java/io/pivotal/cla/webdriver/CclaControllerTests.java b/src/test/java/io/pivotal/cla/webdriver/CclaControllerTests.java
index 4219e7a1..51c7bb5e 100644
--- a/src/test/java/io/pivotal/cla/webdriver/CclaControllerTests.java
+++ b/src/test/java/io/pivotal/cla/webdriver/CclaControllerTests.java
@@ -16,9 +16,9 @@
package io.pivotal.cla.webdriver;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyCollectionOf;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.ArgumentMatchers.anyCollection;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -31,7 +31,7 @@
import java.util.concurrent.TimeUnit;
import io.pivotal.cla.webdriver.pages.ViewCclaPage;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import io.pivotal.cla.data.AccessToken;
@@ -455,7 +455,7 @@ public void signWithRepositoryIdWithPullRequestId() throws Exception {
when(mockClaRepository.findOne(cla.getId())).thenReturn(cla);
when(mockGitHub.getOrganizations(anyString())).thenReturn(Arrays.asList("spring","pivotal"));
when(mockGitHub.getShaForPullRequest(any(PullRequestStatus.class))).thenReturn("abc123");
- when(mockCorporateSignatureRepository.findSignature(anyString(), anyCollectionOf(String.class), anyCollectionOf(String.class))).thenReturn(null,corporateSignature);
+ when(mockCorporateSignatureRepository.findSignature(anyString(), anyCollection(), anyCollection())).thenReturn(null,corporateSignature);
when(mockTokenRepo.findOne(repositoryId)).thenReturn(new AccessToken(repositoryId, "access-token-123"));
int pullRequestId = 2;
diff --git a/src/test/java/io/pivotal/cla/webdriver/ClaControllerTests.java b/src/test/java/io/pivotal/cla/webdriver/ClaControllerTests.java
index a86ccc9e..8757911e 100644
--- a/src/test/java/io/pivotal/cla/webdriver/ClaControllerTests.java
+++ b/src/test/java/io/pivotal/cla/webdriver/ClaControllerTests.java
@@ -16,8 +16,8 @@
package io.pivotal.cla.webdriver;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -27,9 +27,12 @@
import java.util.Arrays;
import java.util.List;
-import org.junit.Before;
-import org.junit.Test;
+import io.pivotal.cla.MocksConfig;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
+import org.springframework.context.annotation.Import;
+import org.springframework.security.test.context.TestSecurityContextHolder;
import org.springframework.security.test.context.support.WithAnonymousUser;
import io.pivotal.cla.data.AccessToken;
@@ -43,9 +46,10 @@
import io.pivotal.cla.webdriver.pages.SignIclaPage;
@WithSigningUser
+@Import(MocksConfig.class)
public class ClaControllerTests extends BaseWebDriverTests {
- @Before
+ @BeforeEach
public void setup() {
super.setup();
when(mockClaRepository.findByNameAndPrimaryTrue(cla.getName())).thenReturn(cla);
@@ -54,6 +58,7 @@ public void setup() {
@Test
@WithAnonymousUser
public void viewSignedWithRepositoryIdAndPullRequestIdNewUser() throws Exception {
+ TestSecurityContextHolder.clearContext(); // FIXME: This is a work around for bug with AnonymousAuthenticationToken in test security context clears out any new values.
String repositoryId = "spring-projects/spring-security";
User signingUser = WithSigningUserFactory.create();
when(mockGitHub.getCurrentUser(any())).thenReturn(signingUser);
diff --git a/src/test/java/io/pivotal/cla/webdriver/FaqControllerTests.java b/src/test/java/io/pivotal/cla/webdriver/FaqControllerTests.java
index c8e8628d..3f9541f7 100644
--- a/src/test/java/io/pivotal/cla/webdriver/FaqControllerTests.java
+++ b/src/test/java/io/pivotal/cla/webdriver/FaqControllerTests.java
@@ -15,7 +15,7 @@
*/
package io.pivotal.cla.webdriver;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import io.pivotal.cla.webdriver.pages.FaqPage;
diff --git a/src/test/java/io/pivotal/cla/webdriver/HomeControllerTests.java b/src/test/java/io/pivotal/cla/webdriver/HomeControllerTests.java
index 9d300859..55e1e7ee 100644
--- a/src/test/java/io/pivotal/cla/webdriver/HomeControllerTests.java
+++ b/src/test/java/io/pivotal/cla/webdriver/HomeControllerTests.java
@@ -19,7 +19,7 @@
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import io.pivotal.cla.security.WithSigningUser;
import io.pivotal.cla.webdriver.pages.AboutPage;
diff --git a/src/test/java/io/pivotal/cla/webdriver/IclaControllerTests.java b/src/test/java/io/pivotal/cla/webdriver/IclaControllerTests.java
index 043cc2ba..b3ece3a2 100644
--- a/src/test/java/io/pivotal/cla/webdriver/IclaControllerTests.java
+++ b/src/test/java/io/pivotal/cla/webdriver/IclaControllerTests.java
@@ -16,10 +16,10 @@
package io.pivotal.cla.webdriver;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@@ -30,7 +30,7 @@
import java.util.concurrent.TimeUnit;
import io.pivotal.cla.webdriver.pages.ViewIclaPage;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import io.pivotal.cla.data.AccessToken;
@@ -274,7 +274,7 @@ public void signNoRepositoryIdAndNoPullRequestId() {
.sign(SignIclaPage.class);
signPage.assertAt();
- verifyZeroInteractions(mockGitHub);
+ verifyNoInteractions(mockGitHub);
}
@Test
@@ -309,7 +309,7 @@ private void assertThatClaIsSigned(SignClaForm form) {
assertThat(signature.getTelephone()).isEqualTo(form.getTelephone());
assertThat(signature.getDateOfSignature()).isCloseTo(new Date(), TimeUnit.SECONDS.toMillis(5));
- verifyZeroInteractions(mockGitHub);
+ verifyNoInteractions(mockGitHub);
}
@Test
diff --git a/src/test/java/io/pivotal/cla/webdriver/RequiresChannelTests.java b/src/test/java/io/pivotal/cla/webdriver/RequiresChannelTests.java
index 9770b637..e78d40d3 100644
--- a/src/test/java/io/pivotal/cla/webdriver/RequiresChannelTests.java
+++ b/src/test/java/io/pivotal/cla/webdriver/RequiresChannelTests.java
@@ -19,7 +19,7 @@
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class RequiresChannelTests extends BaseWebDriverTests {
diff --git a/src/test/java/io/pivotal/cla/webdriver/WebDriverContext.java b/src/test/java/io/pivotal/cla/webdriver/WebDriverContext.java
deleted file mode 100644
index 2660fc9d..00000000
--- a/src/test/java/io/pivotal/cla/webdriver/WebDriverContext.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2002-2016 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.pivotal.cla.webdriver;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureDataJpa;
-import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
-import org.springframework.test.context.ActiveProfiles;
-
-@Documented
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-@AutoConfigureMockMvc
-@ActiveProfiles("test")
-@SpringBootTest(webEnvironment = WebEnvironment.MOCK)
-public @interface WebDriverContext {
-}
diff --git a/src/test/java/io/pivotal/cla/webdriver/admin/AdminCreateClaTests.java b/src/test/java/io/pivotal/cla/webdriver/admin/AdminCreateClaTests.java
index 03137fca..9ab765c7 100644
--- a/src/test/java/io/pivotal/cla/webdriver/admin/AdminCreateClaTests.java
+++ b/src/test/java/io/pivotal/cla/webdriver/admin/AdminCreateClaTests.java
@@ -21,7 +21,7 @@
import java.util.Arrays;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import io.pivotal.cla.data.ContributorLicenseAgreement;
diff --git a/src/test/java/io/pivotal/cla/webdriver/admin/AdminHelpTests.java b/src/test/java/io/pivotal/cla/webdriver/admin/AdminHelpTests.java
index 24a1c7f8..0b1407d0 100644
--- a/src/test/java/io/pivotal/cla/webdriver/admin/AdminHelpTests.java
+++ b/src/test/java/io/pivotal/cla/webdriver/admin/AdminHelpTests.java
@@ -15,7 +15,7 @@
*/
package io.pivotal.cla.webdriver.admin;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import io.pivotal.cla.security.WithAdminUser;
import io.pivotal.cla.webdriver.BaseWebDriverTests;
diff --git a/src/test/java/io/pivotal/cla/webdriver/admin/AdminHomeTests.java b/src/test/java/io/pivotal/cla/webdriver/admin/AdminHomeTests.java
index 9a7d6d26..2b0f890e 100644
--- a/src/test/java/io/pivotal/cla/webdriver/admin/AdminHomeTests.java
+++ b/src/test/java/io/pivotal/cla/webdriver/admin/AdminHomeTests.java
@@ -19,7 +19,7 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.redirectedUrl;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import io.pivotal.cla.security.WithAdminUser;
import io.pivotal.cla.security.WithClaAuthorUser;
diff --git a/src/test/java/io/pivotal/cla/webdriver/admin/AdminLinkClaTests.java b/src/test/java/io/pivotal/cla/webdriver/admin/AdminLinkClaTests.java
index cba4a771..7d36a899 100644
--- a/src/test/java/io/pivotal/cla/webdriver/admin/AdminLinkClaTests.java
+++ b/src/test/java/io/pivotal/cla/webdriver/admin/AdminLinkClaTests.java
@@ -17,19 +17,18 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyList;
-import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.anyList;
+import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.Arrays;
import java.util.concurrent.Executors;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
-import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.concurrent.DelegatingSecurityContextExecutor;
@@ -50,7 +49,7 @@
@WithAdminUser
public class AdminLinkClaTests extends BaseWebDriverTests {
- @Before
+ @BeforeEach
public void claFormData() throws Exception {
when(mockClaRepository.findByPrimaryTrue()).thenReturn(Arrays.asList(cla,cla));
when(mockGitHub.findRepositoryNamesWithAdminPermission(anyString())).thenReturn(Arrays.asList("test/this"));
diff --git a/src/test/java/io/pivotal/cla/webdriver/admin/AdminListClaTests.java b/src/test/java/io/pivotal/cla/webdriver/admin/AdminListClaTests.java
index f0c604e8..d28c95fc 100644
--- a/src/test/java/io/pivotal/cla/webdriver/admin/AdminListClaTests.java
+++ b/src/test/java/io/pivotal/cla/webdriver/admin/AdminListClaTests.java
@@ -21,7 +21,7 @@
import java.util.Arrays;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import io.pivotal.cla.security.WithClaAuthorUser;
import io.pivotal.cla.webdriver.BaseWebDriverTests;
diff --git a/src/test/java/io/pivotal/cla/webdriver/admin/AdminLookupSignatureTests.java b/src/test/java/io/pivotal/cla/webdriver/admin/AdminLookupSignatureTests.java
index b247a485..862682a1 100644
--- a/src/test/java/io/pivotal/cla/webdriver/admin/AdminLookupSignatureTests.java
+++ b/src/test/java/io/pivotal/cla/webdriver/admin/AdminLookupSignatureTests.java
@@ -20,7 +20,7 @@
import io.pivotal.cla.webdriver.BaseWebDriverTests;
import io.pivotal.cla.webdriver.pages.admin.AdminLookupSignaturePage;
import io.pivotal.cla.webdriver.pages.admin.AdminLookupSignaturePage.FindSignatureForm;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/src/test/java/io/pivotal/cla/webdriver/admin/EditAdminClaTests.java b/src/test/java/io/pivotal/cla/webdriver/admin/EditAdminClaTests.java
index 06d66178..5b907587 100644
--- a/src/test/java/io/pivotal/cla/webdriver/admin/EditAdminClaTests.java
+++ b/src/test/java/io/pivotal/cla/webdriver/admin/EditAdminClaTests.java
@@ -6,7 +6,7 @@
import java.util.Arrays;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import io.pivotal.cla.data.ContributorLicenseAgreement;
@@ -200,7 +200,7 @@ public void editClaSuccessPrimary() {
@Test
public void editClaSuccessPrimaryExistingButSameId() {
- cla.setId(new Long(1L));
+ cla.setId(Long.valueOf(1L));
when(mockClaRepository.findByNameAndPrimaryTrue(cla.getName())).thenReturn(cla);
when(mockClaRepository.findAll()).thenReturn(Arrays.asList(cla));
when(mockClaRepository.findOne(cla.getId())).thenReturn(cla);
diff --git a/src/test/java/io/pivotal/cla/webdriver/pages/BasePage.java b/src/test/java/io/pivotal/cla/webdriver/pages/BasePage.java
index 3443f2f4..4dcbcc49 100644
--- a/src/test/java/io/pivotal/cla/webdriver/pages/BasePage.java
+++ b/src/test/java/io/pivotal/cla/webdriver/pages/BasePage.java
@@ -33,6 +33,8 @@
import io.pivotal.cla.webdriver.pages.admin.AdminLinkClaPage;
import io.pivotal.cla.webdriver.pages.admin.AdminListClasPage;
+import java.time.Duration;
+
public abstract class BasePage {
public static final String WEBDRIVER_BASE_URL = "webdriver.baseUrl";
@@ -157,7 +159,7 @@ public void assertNotSelected() {
}
public void waitUntilAt(Runnable assertAt) {
- new WebDriverWait(getDriver(), 6).until(input -> at(assertAt));
+ new WebDriverWait(getDriver(), Duration.ofSeconds(6)).until(input -> at(assertAt));
}
private boolean at(Runnable assertAt) {
@@ -187,13 +189,13 @@ public AdminLookupSignaturePage lookup() {
protected void userMenu() {
userMenu.click();
- WebDriverWait wait = new WebDriverWait(driver, 5);
+ WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(signout.getAttribute("id"))));
}
protected void adminMenu() {
adminMenu.click();
- WebDriverWait wait = new WebDriverWait(driver, 5);
+ WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(link.getAttribute("id"))));
}
diff --git a/src/test/java/io/pivotal/cla/webdriver/pages/SignCclaPage.java b/src/test/java/io/pivotal/cla/webdriver/pages/SignCclaPage.java
index 1a461539..1ebeb3a1 100644
--- a/src/test/java/io/pivotal/cla/webdriver/pages/SignCclaPage.java
+++ b/src/test/java/io/pivotal/cla/webdriver/pages/SignCclaPage.java
@@ -81,7 +81,7 @@ public static SignCclaPage go(WebDriver driver, String cla) {
}
public static SignCclaPage go(WebDriver driver, String cla, String repositoryId, long pullRequestId) {
- get(driver, url(cla) + "/?repositoryId="+repositoryId+"&pullRequestId="+pullRequestId);
+ get(driver, url(cla) + "?repositoryId="+repositoryId+"&pullRequestId="+pullRequestId);
return PageFactory.initElements(driver, SignCclaPage.class);
}
diff --git a/src/test/java/io/pivotal/cla/webdriver/pages/github/GitHubAuthorizePage.java b/src/test/java/io/pivotal/cla/webdriver/pages/github/GitHubAuthorizePage.java
index 2714f248..c3b0a3e1 100644
--- a/src/test/java/io/pivotal/cla/webdriver/pages/github/GitHubAuthorizePage.java
+++ b/src/test/java/io/pivotal/cla/webdriver/pages/github/GitHubAuthorizePage.java
@@ -7,6 +7,8 @@
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
+import java.time.Duration;
+
public class GitHubAuthorizePage {
final WebDriver driver;
@@ -24,7 +26,7 @@ public void authorizeIfNecessary() {
}
private void waitToBeClickable(By selector) {
- WebDriverWait wait = new WebDriverWait(driver, 60);
+ WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(60));
wait.until(ExpectedConditions.elementToBeClickable(selector));
}
diff --git a/src/test/java/io/pivotal/cla/webdriver/pages/github/GitHubPullRequestPage.java b/src/test/java/io/pivotal/cla/webdriver/pages/github/GitHubPullRequestPage.java
index 103a2778..4cfc70d5 100644
--- a/src/test/java/io/pivotal/cla/webdriver/pages/github/GitHubPullRequestPage.java
+++ b/src/test/java/io/pivotal/cla/webdriver/pages/github/GitHubPullRequestPage.java
@@ -12,6 +12,8 @@
import io.pivotal.cla.webdriver.pages.SignClaPage;
+import java.time.Duration;
+
/**
* Represents a Pull Request Page. For example:
*
@@ -66,7 +68,7 @@ public SignClaPage details() {
}
private void waitForText(String text) {
- new WebDriverWait(driver, 60).until(input -> getBodyText(input).contains(text));
+ new WebDriverWait(driver, Duration.ofSeconds(60)).until(input -> getBodyText(input).contains(text));
}
private String getBodyText(WebDriver driver) {
diff --git a/src/test/java/okhttp3/mockwebserver/EnqueueRequestsExtension.java b/src/test/java/okhttp3/mockwebserver/EnqueueRequestsExtension.java
new file mode 100644
index 00000000..7ae321da
--- /dev/null
+++ b/src/test/java/okhttp3/mockwebserver/EnqueueRequestsExtension.java
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2002-2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package okhttp3.mockwebserver;
+
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.stream.Stream;
+
+import org.junit.jupiter.api.extension.AfterEachCallback;
+import org.junit.jupiter.api.extension.BeforeEachCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+/**
+ * Allows externalizing queued responses using classpath resources. This is
+ * useful when dealing with larger responses from the server that may be
+ * difficult to read inline within a test. An example test can be seen below:
+ *
+ *