diff --git a/build.gradle b/build.gradle index af81b41a..2a65e8f5 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ buildscript { ext { - springBootVersion = '2.0.2.RELEASE' + springBootVersion = '2.5.3' } repositories { mavenCentral() @@ -72,12 +72,13 @@ task incrementVersion { dependencyManagement { imports { mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES - mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Finchley.SR2' + mavenBom 'org.springframework.cloud:spring-cloud-dependencies:2020.0.6' } applyMavenExclusions = false } distributions { + main { contents { from 'src/main/resources/application.properties' @@ -87,7 +88,7 @@ distributions { } distTar { - archiveName "pulsar-manager.tar" + archiveFileName = "pulsar-manager.tar" } jar { @@ -108,7 +109,7 @@ dependencies { implementation group: 'org.springframework.boot', name: 'spring-boot-starter', version: springBootVersion implementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: springBootVersion - implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-zuul', version: springBootVersion + implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-zuul', version: '2.2.10.RELEASE' implementation group: 'org.mybatis.spring.boot', name: 'mybatis-spring-boot-starter', version: springMybatisVersion implementation group: 'com.github.pagehelper', name: 'pagehelper', version: pagehelperVersion implementation group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf', version: springBootVersion @@ -152,8 +153,6 @@ dependencies { compileOnly group: 'org.springframework.boot', name: 'spring-boot-devtools', version: springBootVersion testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: springBootVersion testImplementation group: 'org.mockito', name: 'mockito-core', version: mockitoVersion - testImplementation group: 'org.powermock', name: 'powermock-api-mockito2', version: apiMockitoVersion - testImplementation group: 'org.powermock', name: 'powermock-module-junit4', version: mockitoJunit4Version constraints { implementation("org.bouncycastle:bcprov-jdk15on:${bouncycastleVersion}") diff --git a/gradle.properties b/gradle.properties index cb0710dd..ede35b63 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,19 +6,17 @@ hibernateValidatorVersion=6.0.13.Final jsonWebTokenVersion=0.9.0 jsonWebTokenApiVersion=0.10.5 jsonWebTokenImplVersion=0.10.5 -lombokVersion=1.18.26 -pageHelperVersion=1.2.4 -mockitoVersion=2.8.47 +lombokVersion=1.18.30 +pageHelperVersion=2.1.0 +mockitoVersion=3.11.2 guavaVersion=21.0 pulsarVersion=2.7.0 athenzVersion=1.10.9 swagger2Version=2.9.2 swaggeruiVersion=2.9.2 -apiMockitoVersion=1.7.1 -mockitoJunit4Version=1.7.1 gsonVersion=2.8.2 postgresqlVersion=42.2.5 -herddbVersion=0.24.0 +herddbVersion=0.28.0 commonsValidatorVersion=1.6 bkvmVersion=3.1.1 tomcatVersion=8.5.31 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8049c684..a5952066 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/org/apache/pulsar/manager/EmbeddedTomcatCustomizer.java b/src/main/java/org/apache/pulsar/manager/EmbeddedTomcatCustomizer.java index e262c97e..0032906f 100644 --- a/src/main/java/org/apache/pulsar/manager/EmbeddedTomcatCustomizer.java +++ b/src/main/java/org/apache/pulsar/manager/EmbeddedTomcatCustomizer.java @@ -93,7 +93,7 @@ protected TomcatWebServer getTomcatWebServer(Tomcat tomcat) { } } return super.getTomcatWebServer(tomcat); - } catch (IOException | ServletException ex) { + } catch (IOException ex) { throw new RuntimeException(ex); } } diff --git a/src/main/java/org/apache/pulsar/manager/service/impl/BookiesServiceImpl.java b/src/main/java/org/apache/pulsar/manager/service/impl/BookiesServiceImpl.java index e1dcacfa..5430fc20 100644 --- a/src/main/java/org/apache/pulsar/manager/service/impl/BookiesServiceImpl.java +++ b/src/main/java/org/apache/pulsar/manager/service/impl/BookiesServiceImpl.java @@ -20,6 +20,8 @@ import org.apache.pulsar.manager.service.EnvironmentCacheService; import org.apache.pulsar.manager.utils.HttpUtil; import org.apache.commons.lang3.StringUtils; + +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -49,6 +51,9 @@ public class BookiesServiceImpl implements BookiesService { @Value("${backend.jwt.token}") private static String pulsarJwtToken; + @Autowired + HttpUtil httpUtil; + private static final Map header = new HashMap(){{ put("Authorization", String.format("Bearer %s", pulsarJwtToken)); @@ -76,15 +81,15 @@ public Map getBookiesList(Integer pageNum, Integer pageSize, Str if(StringUtils.isBlank(bookieUrl)){ return bookiesMap; } - String rwBookieList = HttpUtil.doGet( + String rwBookieList = httpUtil.doGet( bookieUrl + "/api/v1/bookie/list_bookies?type=rw&print_hostnames=true", header); Map rwBookies = gson.fromJson( rwBookieList, new TypeToken>() {}.getType()); - String roBookieList = HttpUtil.doGet( + String roBookieList = httpUtil.doGet( bookieUrl + "/api/v1/bookie/list_bookies?type=ro&print_hostnames=true", header); Map roBookies = gson.fromJson( roBookieList, new TypeToken>() {}.getType()); - String listBookieInfo = HttpUtil.doGet( + String listBookieInfo = httpUtil.doGet( bookieUrl + "/api/v1/bookie/list_bookie_info", header); Map listBookies = gson.fromJson( listBookieInfo, new TypeToken>() {}.getType()); @@ -122,13 +127,13 @@ public Map getBookiesList(Integer pageNum, Integer pageSize, Str public String forwardBookiesHeartbeat(String bookie) { bookie = checkBookie(bookie); - return HttpUtil.doGet(bookie + "/heartbeat", header); + return httpUtil.doGet(bookie + "/heartbeat", header); } public void forwardGc(String bookie) { bookie = checkBookie(bookie); try { - HttpUtil.doPut(bookie + "/api/v1/bookie/gc", header, ""); + httpUtil.doPut(bookie + "/api/v1/bookie/gc", header, ""); } catch (UnsupportedEncodingException e) { } @@ -141,7 +146,7 @@ public void forwardAutorecovery(List bookieSrc, List bookieDest, Map body = Maps.newHashMap(); body.put("bookie_src", bookieSrc); body.put("bookie_dest", bookieDest); - HttpUtil.doPut(bookieUrl + "/api/v1/autorecovery/bookie/", header, gson.toJson(body)); + httpUtil.doPut(bookieUrl + "/api/v1/autorecovery/bookie/", header, gson.toJson(body)); } catch (UnsupportedEncodingException e) { } @@ -153,7 +158,7 @@ public void forwardBookieDecommission(String bookie) { body.put("bookie_src", bookie); try { Gson gson = new Gson(); - HttpUtil.doPut(bookie + "/api/v1/autorecovery/decommission", header, gson.toJson(body)); + httpUtil.doPut(bookie + "/api/v1/autorecovery/decommission", header, gson.toJson(body)); } catch (UnsupportedEncodingException e) { } diff --git a/src/main/java/org/apache/pulsar/manager/utils/HttpUtil.java b/src/main/java/org/apache/pulsar/manager/utils/HttpUtil.java index c45662c7..248ad945 100644 --- a/src/main/java/org/apache/pulsar/manager/utils/HttpUtil.java +++ b/src/main/java/org/apache/pulsar/manager/utils/HttpUtil.java @@ -130,7 +130,7 @@ public static void initHttpClient() { } } - public static String doGet(String url, Map header){ + public String doGet(String url, Map header){ HttpGet request = new HttpGet(url); return httpRequest(request, header); } @@ -143,21 +143,21 @@ public static String doGet(String url, Map header){ * @return HTTP response information * @throws UnsupportedEncodingException */ - public static String doPost(String url, Map header, String body) + public String doPost(String url, Map header, String body) throws UnsupportedEncodingException { HttpPost request = new HttpPost(url); request.setEntity(new StringEntity(body)); return httpRequest(request, header); } - public static String doPut(String url, Map header, String body) + public String doPut(String url, Map header, String body) throws UnsupportedEncodingException { HttpPut request = new HttpPut(url); request.setEntity(new StringEntity(body)); return httpRequest(request, header); } - public static String httpRequest(HttpUriRequest request, Map header) { + public String httpRequest(HttpUriRequest request, Map header) { CloseableHttpResponse response = null; try { for (Map.Entry entry: header.entrySet()) { diff --git a/src/test/java/org/apache/pulsar/manager/service/BookiesServiceImplTest.java b/src/test/java/org/apache/pulsar/manager/service/BookiesServiceImplTest.java deleted file mode 100644 index f8143000..00000000 --- a/src/test/java/org/apache/pulsar/manager/service/BookiesServiceImplTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * 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 org.apache.pulsar.manager.service; - -import com.google.common.collect.Maps; -import org.apache.commons.lang3.StringUtils; -import org.apache.pulsar.manager.PulsarManagerApplication; -import org.apache.pulsar.manager.profiles.HerdDBTestProfile; -import org.apache.pulsar.manager.utils.HttpUtil; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.modules.junit4.PowerMockRunnerDelegate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.context.junit4.SpringRunner; - -import java.util.Map; - -@RunWith(PowerMockRunner.class) -@PowerMockRunnerDelegate(SpringRunner.class) -@PowerMockIgnore( {"javax.*", "sun.*", "com.sun.*", "org.xml.*", "org.w3c.*"}) -@PrepareForTest(HttpUtil.class) -@TestPropertySource(locations= "classpath:test-bookie.properties") -@SpringBootTest( - classes = { - PulsarManagerApplication.class, - HerdDBTestProfile.class - } -) -@ActiveProfiles("test") -public class BookiesServiceImplTest { - - @Autowired - private EnvironmentCacheService environmentCacheService; - @Autowired - private BookiesService bookiesService ; - - @Value("${backend.jwt.token}") - private static String pulsarJwtToken; - - @Test - public void bookiesServiceTest() { - PowerMockito.mockStatic(HttpUtil.class); - Map header = Maps.newHashMap(); - header.put("Content-Type", "application/json"); - if (StringUtils.isNotBlank(pulsarJwtToken)) { - header.put("Authorization", String.format("Bearer %s", pulsarJwtToken)); - } - PowerMockito.when(HttpUtil.doGet("http://localhost:8050/api/v1/bookie/list_bookies?type=rw&print_hostnames=true", header)) - .thenReturn("{\"192.168.2.116:3181\" : \"192.168.2.116\"}"); - PowerMockito.when(HttpUtil.doGet("http://localhost:8080/admin/v2/brokers/standalone", header)) - .thenReturn("{ }"); - PowerMockito.when(HttpUtil.doGet("http://localhost:8050/api/v1/bookie/list_bookie_info", header)) - .thenReturn("{\"192.168.2.116:3181\" : \": {Free: 48920571904(48.92GB), Total: 250790436864(250.79GB)}," + - "\",\"ClusterInfo: \" : \"{Free: 48920571904(48.92GB), Total: 250790436864(250.79GB)}\" }"); - HttpUtil.doGet("http://localhost:8080/admin/v2/brokers/standalone", header); - } -} diff --git a/src/test/java/org/apache/pulsar/manager/service/DashboardServiceImplTest.java b/src/test/java/org/apache/pulsar/manager/service/DashboardServiceImplTest.java index c9f7d205..02bc56a7 100644 --- a/src/test/java/org/apache/pulsar/manager/service/DashboardServiceImplTest.java +++ b/src/test/java/org/apache/pulsar/manager/service/DashboardServiceImplTest.java @@ -13,41 +13,41 @@ */ package org.apache.pulsar.manager.service; -import com.google.common.collect.Maps; -import org.apache.commons.lang3.StringUtils; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + import org.apache.pulsar.manager.PulsarManagerApplication; -import org.apache.pulsar.manager.entity.*; +import org.apache.pulsar.manager.entity.ConsumerStatsEntity; +import org.apache.pulsar.manager.entity.ConsumersStatsRepository; +import org.apache.pulsar.manager.entity.NamespaceEntity; +import org.apache.pulsar.manager.entity.NamespacesRepository; +import org.apache.pulsar.manager.entity.TenantEntity; +import org.apache.pulsar.manager.entity.TenantsRepository; +import org.apache.pulsar.manager.entity.TopicStatsEntity; +import org.apache.pulsar.manager.entity.TopicsStatsRepository; import org.apache.pulsar.manager.profiles.HerdDBTestProfile; import org.apache.pulsar.manager.utils.HttpUtil; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.modules.junit4.PowerMockRunnerDelegate; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -@RunWith(PowerMockRunner.class) -@PowerMockRunnerDelegate(SpringRunner.class) -@PowerMockIgnore( {"javax.*", "sun.*", "com.sun.*", "org.xml.*", "org.w3c.*"}) -@PrepareForTest(HttpUtil.class) -@TestPropertySource(locations= "classpath:test-bookie.properties") +@RunWith(SpringRunner.class) +@TestPropertySource(locations = "classpath:test-bookie.properties") @SpringBootTest( - classes = { - PulsarManagerApplication.class, - HerdDBTestProfile.class - } + classes = { + PulsarManagerApplication.class, + HerdDBTestProfile.class + } ) @ActiveProfiles("test") public class DashboardServiceImplTest { @@ -67,8 +67,9 @@ public class DashboardServiceImplTest { @Autowired NamespacesRepository namespacesRepository; - @Value("${backend.jwt.token}") - private static String pulsarJwtToken; + @MockBean + HttpUtil httpUtil; + @Test public void getDashboardStatsTest() { @@ -81,21 +82,7 @@ public void getDashboardStatsTest() { int producerPerTopic = 1; int consumerPerTopic = 1; - PowerMockito.mockStatic(HttpUtil.class); - Map header = Maps.newHashMap(); - header.put("Content-Type", "application/json"); - if (StringUtils.isNotBlank(pulsarJwtToken)) { - header.put("Authorization", String.format("Bearer %s", pulsarJwtToken)); - } - PowerMockito.when(HttpUtil.doGet("http://localhost:8050/api/v1/bookie/list_bookies?type=rw&print_hostnames=true", header)) - .thenReturn("{\"192.168.2.116:3181\" : \"192.168.2.116\"}"); - PowerMockito.when(HttpUtil.doGet("http://localhost:8080/admin/v2/brokers/standalone", header)) - .thenReturn("{ }"); - PowerMockito.when(HttpUtil.doGet("http://localhost:8050/api/v1/bookie/list_bookie_info", header)) - .thenReturn("{\"192.168.2.116:3181\" : \": {Free: 48920571904(48.92GB), Total: 250790436864(250.79GB)}," + - "\",\"ClusterInfo: \" : \"{Free: 48920571904(48.92GB), Total: 250790436864(250.79GB)}\" }"); - - long topicStatsId = 0L; + long topicStatsId; for (String tenant: tenantList) { TenantEntity tenantEntity = new TenantEntity(); tenantEntity.setEnvironmentName(environmentList.get(0)); @@ -123,14 +110,14 @@ public void getDashboardStatsTest() { topicStatsEntity.setTopic("neutral"); topicStatsEntity.setProducerCount(producerPerTopic); topicStatsEntity.setTime_stamp(timestamp); - topicsStatsRepository.save(topicStatsEntity); - topicStatsId++; + topicStatsId = topicsStatsRepository.save(topicStatsEntity); for (int i = 0; i < consumerPerTopic; i++) { ConsumerStatsEntity consumerStatsEntity = new ConsumerStatsEntity(); consumerStatsEntity.setConsumer("neutral"); consumerStatsEntity.setTopicStatsId(topicStatsId); consumerStatsEntity.setTime_stamp(timestamp); consumersStatsRepository.save(consumerStatsEntity); + System.out.println("2 saves, TS " + timestamp); } } } @@ -138,6 +125,7 @@ public void getDashboardStatsTest() { } long topicCount = clusterList.size() * brokerList.size(); + System.out.println("searching for env " + environmentList.get(0)); Map dashboardStats = dashboardService.getDashboardStats(Arrays.asList(environmentList.get(0))); Assert.assertEquals(clusterList.size(), dashboardStats.get("totalClusterCount")); Assert.assertEquals(brokerList.size(), dashboardStats.get("totalBrokerCount")); diff --git a/src/test/java/org/apache/pulsar/manager/service/PulsarEventImplTest.java b/src/test/java/org/apache/pulsar/manager/service/PulsarEventImplTest.java index 19141832..944dcac8 100644 --- a/src/test/java/org/apache/pulsar/manager/service/PulsarEventImplTest.java +++ b/src/test/java/org/apache/pulsar/manager/service/PulsarEventImplTest.java @@ -13,6 +13,8 @@ */ package org.apache.pulsar.manager.service; +import java.util.Optional; + import org.apache.pulsar.manager.PulsarManagerApplication; import org.apache.pulsar.manager.entity.NamespaceEntity; import org.apache.pulsar.manager.entity.NamespacesRepository; @@ -20,21 +22,15 @@ import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.modules.junit4.PowerMockRunnerDelegate; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; -import java.util.Optional; - -@RunWith(PowerMockRunner.class) -@PowerMockRunnerDelegate(SpringRunner.class) -@PowerMockIgnore( {"javax.*", "sun.*", "com.sun.*", "org.xml.*", "org.w3c.*"}) +@RunWith(SpringRunner.class) @SpringBootTest( classes = { PulsarManagerApplication.class, diff --git a/src/test/java/org/apache/pulsar/manager/service/TopicsServiceImplTest.java b/src/test/java/org/apache/pulsar/manager/service/TopicsServiceImplTest.java index bdeef378..ad147b9e 100644 --- a/src/test/java/org/apache/pulsar/manager/service/TopicsServiceImplTest.java +++ b/src/test/java/org/apache/pulsar/manager/service/TopicsServiceImplTest.java @@ -91,7 +91,7 @@ public void topicsServiceImplTest() throws PulsarAdminException { @Test public void getTopicsStatsImplTest() throws Exception { - String environment = "staging"; + String environment = "topic-stats-test-environment"; String tenant = "public"; String namespace = "functions"; String topic = "metadata"; diff --git a/src/test/java/org/apache/pulsar/manager/service/UsersServiceImplTest.java b/src/test/java/org/apache/pulsar/manager/service/UsersServiceImplTest.java index 460c4bac..c8119269 100644 --- a/src/test/java/org/apache/pulsar/manager/service/UsersServiceImplTest.java +++ b/src/test/java/org/apache/pulsar/manager/service/UsersServiceImplTest.java @@ -13,36 +13,16 @@ */ package org.apache.pulsar.manager.service; -import org.apache.pulsar.manager.PulsarManagerApplication; +import java.util.Map; + import org.apache.pulsar.manager.entity.UserInfoEntity; -import org.apache.pulsar.manager.profiles.HerdDBTestProfile; +import org.apache.pulsar.manager.service.impl.UsersServiceImpl; import org.junit.Assert; import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.modules.junit4.PowerMockRunnerDelegate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; - -import java.util.Map; -@RunWith(PowerMockRunner.class) -@PowerMockRunnerDelegate(SpringRunner.class) -@PowerMockIgnore( {"javax.*", "sun.*", "com.sun.*", "org.xml.*", "org.w3c.*"}) -@SpringBootTest( - classes = { - PulsarManagerApplication.class, - HerdDBTestProfile.class - } -) -@ActiveProfiles("test") public class UsersServiceImplTest { - @Autowired - private UsersService usersService; + private UsersService usersService = new UsersServiceImpl(); @Test public void validateUserInfoTest() { diff --git a/src/test/java/org/apache/pulsar/manager/service/impl/BrokerTokensServiceImplTest.java b/src/test/java/org/apache/pulsar/manager/service/impl/BrokerTokensServiceImplTest.java index 3b936fc5..2e89a267 100644 --- a/src/test/java/org/apache/pulsar/manager/service/impl/BrokerTokensServiceImplTest.java +++ b/src/test/java/org/apache/pulsar/manager/service/impl/BrokerTokensServiceImplTest.java @@ -13,29 +13,26 @@ */ package org.apache.pulsar.manager.service.impl; -import io.jsonwebtoken.Claims; -import io.jsonwebtoken.Jwt; -import io.jsonwebtoken.Jwts; import org.apache.pulsar.manager.PulsarManagerApplication; import org.apache.pulsar.manager.profiles.HerdDBTestProfile; import org.apache.pulsar.manager.service.impl.JwtServiceImpl; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.modules.junit4.PowerMockRunnerDelegate; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jwt; +import io.jsonwebtoken.Jwts; + import java.security.Key; -@RunWith(PowerMockRunner.class) -@PowerMockRunnerDelegate(SpringRunner.class) -@PowerMockIgnore( {"javax.*", "sun.*", "com.sun.*", "org.xml.*", "org.w3c.*"}) +@RunWith(SpringRunner.class) @TestPropertySource( properties = { "jwt.broker.token.mode=SECRET", diff --git a/src/test/resources/application-test.properties b/src/test/resources/application-test.properties new file mode 100644 index 00000000..cae3fcba --- /dev/null +++ b/src/test/resources/application-test.properties @@ -0,0 +1,15 @@ +# +# 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. +# + +spring.main.allow-bean-definition-overriding=true