Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
41dc53f5
Commit
41dc53f5
authored
Sep 02, 2016
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
b5294a48
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
46 additions
and
57 deletions
+46
-57
MetricExportAutoConfigurationTests.java
...ate/autoconfigure/MetricExportAutoConfigurationTests.java
+5
-3
RedisHealthIndicatorTests.java
...mework/boot/actuate/health/RedisHealthIndicatorTests.java
+2
-2
MetricExportersTests.java
...ork/boot/actuate/metrics/export/MetricExportersTests.java
+3
-3
OpenTsdbGaugeWriterTests.java
...ot/actuate/metrics/opentsdb/OpenTsdbGaugeWriterTests.java
+2
-2
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+8
-7
DataJpaTestIntegrationTests.java
...st/autoconfigure/orm/jpa/DataJpaTestIntegrationTests.java
+2
-1
MockitoBeans.java
.../springframework/boot/test/mock/mockito/MockitoBeans.java
+1
-1
RootUriRequestExpectationManager.java
...oot/test/web/client/RootUriRequestExpectationManager.java
+3
-3
JsonContentAssertTests.java
...pringframework/boot/test/json/JsonContentAssertTests.java
+16
-32
RandomValuePropertySourceTests.java
...k/boot/context/config/RandomValuePropertySourceTests.java
+4
-3
No files found.
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/MetricExportAutoConfigurationTests.java
View file @
41dc53f5
...
@@ -22,7 +22,6 @@ import org.junit.After;
...
@@ -22,7 +22,6 @@ import org.junit.After;
import
org.junit.Rule
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.junit.rules.ExpectedException
;
import
org.mockito.Matchers
;
import
org.mockito.Mockito
;
import
org.mockito.Mockito
;
import
org.springframework.beans.factory.NoSuchBeanDefinitionException
;
import
org.springframework.beans.factory.NoSuchBeanDefinitionException
;
...
@@ -48,6 +47,9 @@ import org.springframework.scheduling.annotation.SchedulingConfigurer;
...
@@ -48,6 +47,9 @@ import org.springframework.scheduling.annotation.SchedulingConfigurer;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Mockito
.
atLeastOnce
;
import
static
org
.
mockito
.
Mockito
.
verify
;
/**
/**
* Tests for {@link MetricExportAutoConfiguration}.
* Tests for {@link MetricExportAutoConfiguration}.
...
@@ -82,7 +84,7 @@ public class MetricExportAutoConfigurationTests {
...
@@ -82,7 +84,7 @@ public class MetricExportAutoConfigurationTests {
MetricExporters
flusher
=
this
.
context
.
getBean
(
MetricExporters
.
class
);
MetricExporters
flusher
=
this
.
context
.
getBean
(
MetricExporters
.
class
);
flusher
.
close
();
// this will be called by Spring on shutdown
flusher
.
close
();
// this will be called by Spring on shutdown
MetricWriter
writer
=
this
.
context
.
getBean
(
"writer"
,
MetricWriter
.
class
);
MetricWriter
writer
=
this
.
context
.
getBean
(
"writer"
,
MetricWriter
.
class
);
Mockito
.
verify
(
writer
,
Mockito
.
atLeastOnce
()).
set
(
Matchers
.
any
(
Metric
.
class
));
verify
(
writer
,
atLeastOnce
()).
set
(
any
(
Metric
.
class
));
}
}
@Test
@Test
...
@@ -113,7 +115,7 @@ public class MetricExportAutoConfigurationTests {
...
@@ -113,7 +115,7 @@ public class MetricExportAutoConfigurationTests {
exporter
.
setIgnoreTimestamps
(
true
);
exporter
.
setIgnoreTimestamps
(
true
);
exporter
.
export
();
exporter
.
export
();
MetricWriter
writer
=
this
.
context
.
getBean
(
"writer"
,
MetricWriter
.
class
);
MetricWriter
writer
=
this
.
context
.
getBean
(
"writer"
,
MetricWriter
.
class
);
Mockito
.
verify
(
writer
,
Mockito
.
atLeastOnce
()).
set
(
Matchers
.
any
(
Metric
.
class
));
Mockito
.
verify
(
writer
,
Mockito
.
atLeastOnce
()).
set
(
any
(
Metric
.
class
));
}
}
@Test
@Test
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/RedisHealthIndicatorTests.java
View file @
41dc53f5
...
@@ -22,7 +22,6 @@ import java.util.Properties;
...
@@ -22,7 +22,6 @@ import java.util.Properties;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.mockito.Mockito
;
import
org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration
;
import
org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration
;
import
org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration
;
import
org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration
;
...
@@ -38,6 +37,7 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
...
@@ -38,6 +37,7 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
Mockito
.
atLeastOnce
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
verify
;
...
@@ -129,7 +129,7 @@ public class RedisHealthIndicatorTests {
...
@@ -129,7 +129,7 @@ public class RedisHealthIndicatorTests {
assertThat
(
health
.
getDetails
().
get
(
"cluster_size"
)).
isEqualTo
(
4L
);
assertThat
(
health
.
getDetails
().
get
(
"cluster_size"
)).
isEqualTo
(
4L
);
assertThat
(
health
.
getDetails
().
get
(
"slots_up"
)).
isEqualTo
(
4L
);
assertThat
(
health
.
getDetails
().
get
(
"slots_up"
)).
isEqualTo
(
4L
);
assertThat
(
health
.
getDetails
().
get
(
"slots_fail"
)).
isEqualTo
(
0L
);
assertThat
(
health
.
getDetails
().
get
(
"slots_fail"
)).
isEqualTo
(
0L
);
verify
(
redisConnectionFactory
,
Mockito
.
atLeastOnce
()).
getConnection
();
verify
(
redisConnectionFactory
,
atLeastOnce
()).
getConnection
();
}
}
}
}
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/export/MetricExportersTests.java
View file @
41dc53f5
...
@@ -21,7 +21,6 @@ import java.util.LinkedHashMap;
...
@@ -21,7 +21,6 @@ import java.util.LinkedHashMap;
import
java.util.Map
;
import
java.util.Map
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.mockito.Mockito
;
import
org.springframework.boot.actuate.metrics.reader.MetricReader
;
import
org.springframework.boot.actuate.metrics.reader.MetricReader
;
import
org.springframework.boot.actuate.metrics.writer.GaugeWriter
;
import
org.springframework.boot.actuate.metrics.writer.GaugeWriter
;
...
@@ -29,6 +28,7 @@ import org.springframework.boot.actuate.metrics.writer.MetricWriter;
...
@@ -29,6 +28,7 @@ import org.springframework.boot.actuate.metrics.writer.MetricWriter;
import
org.springframework.scheduling.config.ScheduledTaskRegistrar
;
import
org.springframework.scheduling.config.ScheduledTaskRegistrar
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.
mock
;
/**
/**
* Tests for {@link MetricExporters}.
* Tests for {@link MetricExporters}.
...
@@ -43,9 +43,9 @@ public class MetricExportersTests {
...
@@ -43,9 +43,9 @@ public class MetricExportersTests {
private
Map
<
String
,
GaugeWriter
>
writers
=
new
LinkedHashMap
<
String
,
GaugeWriter
>();
private
Map
<
String
,
GaugeWriter
>
writers
=
new
LinkedHashMap
<
String
,
GaugeWriter
>();
private
MetricReader
reader
=
Mockito
.
mock
(
MetricReader
.
class
);
private
MetricReader
reader
=
mock
(
MetricReader
.
class
);
private
MetricWriter
writer
=
Mockito
.
mock
(
MetricWriter
.
class
);
private
MetricWriter
writer
=
mock
(
MetricWriter
.
class
);
@Test
@Test
public
void
emptyWriters
()
{
public
void
emptyWriters
()
{
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/opentsdb/OpenTsdbGaugeWriterTests.java
View file @
41dc53f5
...
@@ -21,7 +21,6 @@ import java.util.Map;
...
@@ -21,7 +21,6 @@ import java.util.Map;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.mockito.Mockito
;
import
org.springframework.boot.actuate.metrics.Metric
;
import
org.springframework.boot.actuate.metrics.Metric
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
...
@@ -31,6 +30,7 @@ import org.springframework.web.client.RestOperations;
...
@@ -31,6 +30,7 @@ import org.springframework.web.client.RestOperations;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Matchers
.
any
;
import
static
org
.
mockito
.
Matchers
.
anyString
;
import
static
org
.
mockito
.
Matchers
.
anyString
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
verify
;
/**
/**
...
@@ -42,7 +42,7 @@ public class OpenTsdbGaugeWriterTests {
...
@@ -42,7 +42,7 @@ public class OpenTsdbGaugeWriterTests {
private
OpenTsdbGaugeWriter
writer
;
private
OpenTsdbGaugeWriter
writer
;
private
RestOperations
restTemplate
=
Mockito
.
mock
(
RestOperations
.
class
);
private
RestOperations
restTemplate
=
mock
(
RestOperations
.
class
);
@Before
@Before
public
void
init
()
{
public
void
init
()
{
...
...
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
41dc53f5
...
@@ -53,23 +53,24 @@ something similar to the following:
...
@@ -53,23 +53,24 @@ something similar to the following:
[indent=0]
[indent=0]
----
----
***************************
***************************
APPLICATION FAILED TO START
APPLICATION FAILED TO START
***************************
***************************
Description:
Description:
Embedded servlet container failed to start. Port 8080 was already in use.
Embedded servlet container failed to start. Port 8080 was already in use.
Action:
Action:
Identify and stop the process that's listening on port 8080 or configure this application to listen on another port.
Identify and stop the process that's listening on port 8080 or configure this application to listen on another port.
----
----
NOTE: Spring Boot provides numerous `FailureAnalyzer` implementations and you can
NOTE: Spring Boot provides numerous `FailureAnalyzer` implementations and you can
<<howto.adoc#howto-failure-analyzer,add your own>> very easily.
<<howto.adoc#howto-failure-analyzer,add your own>> very easily.
[[boot-features-banner]]
[[boot-features-banner]]
=== Customizing the Banner
=== Customizing the Banner
The banner that is printed on start up can be changed by adding a `banner.txt` file
The banner that is printed on start up can be changed by adding a `banner.txt` file
...
...
spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/orm/jpa/DataJpaTestIntegrationTests.java
View file @
41dc53f5
...
@@ -77,7 +77,8 @@ public class DataJpaTestIntegrationTests {
...
@@ -77,7 +77,8 @@ public class DataJpaTestIntegrationTests {
Long
.
class
);
Long
.
class
);
assertThat
(
id
).
isNotNull
();
assertThat
(
id
).
isNotNull
();
String
reference
=
this
.
jdbcTemplate
.
queryForObject
(
String
reference
=
this
.
jdbcTemplate
.
queryForObject
(
"SELECT REFERENCE FROM EXAMPLE_ENTITY WHERE ID = ?"
,
new
Object
[]
{
id
},
String
.
class
);
"SELECT REFERENCE FROM EXAMPLE_ENTITY WHERE ID = ?"
,
new
Object
[]
{
id
},
String
.
class
);
assertThat
(
reference
).
isEqualTo
(
"123"
);
assertThat
(
reference
).
isEqualTo
(
"123"
);
}
}
...
...
spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoBeans.java
View file @
41dc53f5
...
@@ -25,7 +25,7 @@ import java.util.List;
...
@@ -25,7 +25,7 @@ import java.util.List;
*
*
* @author Andy Wilkinson
* @author Andy Wilkinson
*/
*/
public
class
MockitoBeans
implements
Iterable
<
Object
>
{
class
MockitoBeans
implements
Iterable
<
Object
>
{
private
final
List
<
Object
>
beans
=
new
ArrayList
<
Object
>();
private
final
List
<
Object
>
beans
=
new
ArrayList
<
Object
>();
...
...
spring-boot-test/src/main/java/org/springframework/boot/test/web/client/RootUriRequestExpectationManager.java
View file @
41dc53f5
...
@@ -37,9 +37,9 @@ import org.springframework.web.client.RestTemplate;
...
@@ -37,9 +37,9 @@ import org.springframework.web.client.RestTemplate;
import
org.springframework.web.util.UriTemplateHandler
;
import
org.springframework.web.util.UriTemplateHandler
;
/**
/**
* {@link RequestExpectationManager} that strips the specified root URI from the
* {@link RequestExpectationManager} that strips the specified root URI from the
request
*
request before verification. Can be used to simply test declarations when all REST
*
before verification. Can be used to simply test declarations when all REST calls start
*
calls start
the same way. For example: <pre class="code">
* the same way. For example: <pre class="code">
* RestTemplate restTemplate = new RestTemplateBuilder().rootUri("http://example.com").build();
* RestTemplate restTemplate = new RestTemplateBuilder().rootUri("http://example.com").build();
* MockRestServiceServer server = RootUriRequestExpectationManager.bindTo(restTemplate);
* MockRestServiceServer server = RootUriRequestExpectationManager.bindTo(restTemplate);
* server.expect(requestTo("/hello")).andRespond(withSuccess());
* server.expect(requestTo("/hello")).andRespond(withSuccess());
...
...
spring-boot-test/src/test/java/org/springframework/boot/test/json/JsonContentAssertTests.java
View file @
41dc53f5
...
@@ -384,29 +384,25 @@ public class JsonContentAssertTests {
...
@@ -384,29 +384,25 @@ public class JsonContentAssertTests {
@Test
@Test
public
void
isEqualToJsonWhenStringIsMatchingAndComparatorShouldPass
()
public
void
isEqualToJsonWhenStringIsMatchingAndComparatorShouldPass
()
throws
Exception
{
throws
Exception
{
assertThat
(
forJson
(
SOURCE
)).
isEqualToJson
(
LENIENT_SAME
,
assertThat
(
forJson
(
SOURCE
)).
isEqualToJson
(
LENIENT_SAME
,
COMPARATOR
);
COMPARATOR
);
}
}
@Test
(
expected
=
AssertionError
.
class
)
@Test
(
expected
=
AssertionError
.
class
)
public
void
isEqualToJsonWhenStringIsNotMatchingAndComparatorShouldFail
()
public
void
isEqualToJsonWhenStringIsNotMatchingAndComparatorShouldFail
()
throws
Exception
{
throws
Exception
{
assertThat
(
forJson
(
SOURCE
)).
isEqualToJson
(
DIFFERENT
,
assertThat
(
forJson
(
SOURCE
)).
isEqualToJson
(
DIFFERENT
,
COMPARATOR
);
COMPARATOR
);
}
}
@Test
@Test
public
void
isEqualToJsonWhenResourcePathIsMatchingAndComparatorShouldPass
()
public
void
isEqualToJsonWhenResourcePathIsMatchingAndComparatorShouldPass
()
throws
Exception
{
throws
Exception
{
assertThat
(
forJson
(
SOURCE
)).
isEqualToJson
(
"lenient-same.json"
,
assertThat
(
forJson
(
SOURCE
)).
isEqualToJson
(
"lenient-same.json"
,
COMPARATOR
);
COMPARATOR
);
}
}
@Test
(
expected
=
AssertionError
.
class
)
@Test
(
expected
=
AssertionError
.
class
)
public
void
isEqualToJsonWhenResourcePathIsNotMatchingAndComparatorShouldFail
()
public
void
isEqualToJsonWhenResourcePathIsNotMatchingAndComparatorShouldFail
()
throws
Exception
{
throws
Exception
{
assertThat
(
forJson
(
SOURCE
)).
isEqualToJson
(
"different.json"
,
assertThat
(
forJson
(
SOURCE
)).
isEqualToJson
(
"different.json"
,
COMPARATOR
);
COMPARATOR
);
}
}
@Test
@Test
...
@@ -426,29 +422,25 @@ public class JsonContentAssertTests {
...
@@ -426,29 +422,25 @@ public class JsonContentAssertTests {
@Test
@Test
public
void
isEqualToJsonWhenBytesAreMatchingAndComparatorShouldPass
()
public
void
isEqualToJsonWhenBytesAreMatchingAndComparatorShouldPass
()
throws
Exception
{
throws
Exception
{
assertThat
(
forJson
(
SOURCE
)).
isEqualToJson
(
LENIENT_SAME
.
getBytes
(),
assertThat
(
forJson
(
SOURCE
)).
isEqualToJson
(
LENIENT_SAME
.
getBytes
(),
COMPARATOR
);
COMPARATOR
);
}
}
@Test
(
expected
=
AssertionError
.
class
)
@Test
(
expected
=
AssertionError
.
class
)
public
void
isEqualToJsonWhenBytesAreNotMatchingAndComparatorShouldFail
()
public
void
isEqualToJsonWhenBytesAreNotMatchingAndComparatorShouldFail
()
throws
Exception
{
throws
Exception
{
assertThat
(
forJson
(
SOURCE
)).
isEqualToJson
(
DIFFERENT
.
getBytes
(),
assertThat
(
forJson
(
SOURCE
)).
isEqualToJson
(
DIFFERENT
.
getBytes
(),
COMPARATOR
);
COMPARATOR
);
}
}
@Test
@Test
public
void
isEqualToJsonWhenFileIsMatchingAndComparatorShouldPass
()
public
void
isEqualToJsonWhenFileIsMatchingAndComparatorShouldPass
()
throws
Exception
{
throws
Exception
{
assertThat
(
forJson
(
SOURCE
)).
isEqualToJson
(
createFile
(
LENIENT_SAME
),
assertThat
(
forJson
(
SOURCE
)).
isEqualToJson
(
createFile
(
LENIENT_SAME
),
COMPARATOR
);
COMPARATOR
);
}
}
@Test
(
expected
=
AssertionError
.
class
)
@Test
(
expected
=
AssertionError
.
class
)
public
void
isEqualToJsonWhenFileIsNotMatchingAndComparatorShouldFail
()
public
void
isEqualToJsonWhenFileIsNotMatchingAndComparatorShouldFail
()
throws
Exception
{
throws
Exception
{
assertThat
(
forJson
(
SOURCE
)).
isEqualToJson
(
createFile
(
DIFFERENT
),
assertThat
(
forJson
(
SOURCE
)).
isEqualToJson
(
createFile
(
DIFFERENT
),
COMPARATOR
);
COMPARATOR
);
}
}
@Test
@Test
...
@@ -475,8 +467,7 @@ public class JsonContentAssertTests {
...
@@ -475,8 +467,7 @@ public class JsonContentAssertTests {
@Test
(
expected
=
AssertionError
.
class
)
@Test
(
expected
=
AssertionError
.
class
)
public
void
isEqualToJsonWhenResourceIsNotMatchingAndComparatorShouldFail
()
public
void
isEqualToJsonWhenResourceIsNotMatchingAndComparatorShouldFail
()
throws
Exception
{
throws
Exception
{
assertThat
(
forJson
(
SOURCE
)).
isEqualToJson
(
createResource
(
DIFFERENT
),
assertThat
(
forJson
(
SOURCE
)).
isEqualToJson
(
createResource
(
DIFFERENT
),
COMPARATOR
);
COMPARATOR
);
}
}
@Test
(
expected
=
AssertionError
.
class
)
@Test
(
expected
=
AssertionError
.
class
)
...
@@ -809,29 +800,25 @@ public class JsonContentAssertTests {
...
@@ -809,29 +800,25 @@ public class JsonContentAssertTests {
@Test
(
expected
=
AssertionError
.
class
)
@Test
(
expected
=
AssertionError
.
class
)
public
void
isNotEqualToJsonWhenStringIsMatchingAndComparatorShouldFail
()
public
void
isNotEqualToJsonWhenStringIsMatchingAndComparatorShouldFail
()
throws
Exception
{
throws
Exception
{
assertThat
(
forJson
(
SOURCE
)).
isNotEqualToJson
(
LENIENT_SAME
,
assertThat
(
forJson
(
SOURCE
)).
isNotEqualToJson
(
LENIENT_SAME
,
COMPARATOR
);
COMPARATOR
);
}
}
@Test
@Test
public
void
isNotEqualToJsonWhenStringIsNotMatchingAndComparatorShouldPass
()
public
void
isNotEqualToJsonWhenStringIsNotMatchingAndComparatorShouldPass
()
throws
Exception
{
throws
Exception
{
assertThat
(
forJson
(
SOURCE
)).
isNotEqualToJson
(
DIFFERENT
,
assertThat
(
forJson
(
SOURCE
)).
isNotEqualToJson
(
DIFFERENT
,
COMPARATOR
);
COMPARATOR
);
}
}
@Test
(
expected
=
AssertionError
.
class
)
@Test
(
expected
=
AssertionError
.
class
)
public
void
isNotEqualToJsonWhenResourcePathIsMatchingAndComparatorShouldFail
()
public
void
isNotEqualToJsonWhenResourcePathIsMatchingAndComparatorShouldFail
()
throws
Exception
{
throws
Exception
{
assertThat
(
forJson
(
SOURCE
)).
isNotEqualToJson
(
"lenient-same.json"
,
assertThat
(
forJson
(
SOURCE
)).
isNotEqualToJson
(
"lenient-same.json"
,
COMPARATOR
);
COMPARATOR
);
}
}
@Test
@Test
public
void
isNotEqualToJsonWhenResourcePathIsNotMatchingAndComparatorShouldPass
()
public
void
isNotEqualToJsonWhenResourcePathIsNotMatchingAndComparatorShouldPass
()
throws
Exception
{
throws
Exception
{
assertThat
(
forJson
(
SOURCE
)).
isNotEqualToJson
(
"different.json"
,
assertThat
(
forJson
(
SOURCE
)).
isNotEqualToJson
(
"different.json"
,
COMPARATOR
);
COMPARATOR
);
}
}
@Test
(
expected
=
AssertionError
.
class
)
@Test
(
expected
=
AssertionError
.
class
)
...
@@ -851,15 +838,13 @@ public class JsonContentAssertTests {
...
@@ -851,15 +838,13 @@ public class JsonContentAssertTests {
@Test
(
expected
=
AssertionError
.
class
)
@Test
(
expected
=
AssertionError
.
class
)
public
void
isNotEqualToJsonWhenBytesAreMatchingAndComparatorShouldFail
()
public
void
isNotEqualToJsonWhenBytesAreMatchingAndComparatorShouldFail
()
throws
Exception
{
throws
Exception
{
assertThat
(
forJson
(
SOURCE
)).
isNotEqualToJson
(
LENIENT_SAME
.
getBytes
(),
assertThat
(
forJson
(
SOURCE
)).
isNotEqualToJson
(
LENIENT_SAME
.
getBytes
(),
COMPARATOR
);
COMPARATOR
);
}
}
@Test
@Test
public
void
isNotEqualToJsonWhenBytesAreNotMatchingAndComparatorShouldPass
()
public
void
isNotEqualToJsonWhenBytesAreNotMatchingAndComparatorShouldPass
()
throws
Exception
{
throws
Exception
{
assertThat
(
forJson
(
SOURCE
)).
isNotEqualToJson
(
DIFFERENT
.
getBytes
(),
assertThat
(
forJson
(
SOURCE
)).
isNotEqualToJson
(
DIFFERENT
.
getBytes
(),
COMPARATOR
);
COMPARATOR
);
}
}
@Test
(
expected
=
AssertionError
.
class
)
@Test
(
expected
=
AssertionError
.
class
)
...
@@ -872,8 +857,7 @@ public class JsonContentAssertTests {
...
@@ -872,8 +857,7 @@ public class JsonContentAssertTests {
@Test
@Test
public
void
isNotEqualToJsonWhenFileIsNotMatchingAndComparatorShouldPass
()
public
void
isNotEqualToJsonWhenFileIsNotMatchingAndComparatorShouldPass
()
throws
Exception
{
throws
Exception
{
assertThat
(
forJson
(
SOURCE
)).
isNotEqualToJson
(
createFile
(
DIFFERENT
),
assertThat
(
forJson
(
SOURCE
)).
isNotEqualToJson
(
createFile
(
DIFFERENT
),
COMPARATOR
);
COMPARATOR
);
}
}
@Test
(
expected
=
AssertionError
.
class
)
@Test
(
expected
=
AssertionError
.
class
)
...
...
spring-boot/src/test/java/org/springframework/boot/context/config/RandomValuePropertySourceTests.java
View file @
41dc53f5
...
@@ -20,9 +20,10 @@ import java.util.Random;
...
@@ -20,9 +20,10 @@ import java.util.Random;
import
java.util.UUID
;
import
java.util.UUID
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.mockito.Mockito
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
Mockito
.
spy
;
/**
/**
* Tests for {@link RandomValuePropertySource}.
* Tests for {@link RandomValuePropertySource}.
...
@@ -91,8 +92,8 @@ public class RandomValuePropertySourceTests {
...
@@ -91,8 +92,8 @@ public class RandomValuePropertySourceTests {
@Test
@Test
public
void
longOverflow
()
{
public
void
longOverflow
()
{
RandomValuePropertySource
source
=
Mockito
.
spy
(
this
.
source
);
RandomValuePropertySource
source
=
spy
(
this
.
source
);
Mockito
.
when
(
source
.
getSource
()).
then
Return
(
new
Random
()
{
given
(
source
.
getSource
()).
will
Return
(
new
Random
()
{
@Override
@Override
public
long
nextLong
()
{
public
long
nextLong
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment