Skip to content

Commit 56535d8

Browse files
committed
Rename WebDriverContextCustomizerFactory's customizer
Closes gh-36416
1 parent e7706b4 commit 56535d8

File tree

2 files changed

+55
-29
lines changed

2 files changed

+55
-29
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2012-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.test.autoconfigure.web.servlet;
18+
19+
import org.springframework.context.ConfigurableApplicationContext;
20+
import org.springframework.test.context.ContextCustomizer;
21+
import org.springframework.test.context.MergedContextConfiguration;
22+
23+
/**
24+
* {@link ContextCustomizer} that registers a {@link WebDriverScope} and configures
25+
* appropriate bean definitions to use it.
26+
*
27+
* @author Phillip Webb
28+
* @see WebDriverScope
29+
*/
30+
class WebDriverContextCustomizer implements ContextCustomizer {
31+
32+
@Override
33+
public void customizeContext(ConfigurableApplicationContext context, MergedContextConfiguration mergedConfig) {
34+
WebDriverScope.registerWith(context);
35+
}
36+
37+
@Override
38+
public boolean equals(Object obj) {
39+
if (obj == this) {
40+
return true;
41+
}
42+
if (obj == null || obj.getClass() != getClass()) {
43+
return false;
44+
}
45+
return true;
46+
}
47+
48+
@Override
49+
public int hashCode() {
50+
return getClass().hashCode();
51+
}
52+
53+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,11 +18,9 @@
1818

1919
import java.util.List;
2020

21-
import org.springframework.context.ConfigurableApplicationContext;
2221
import org.springframework.test.context.ContextConfigurationAttributes;
2322
import org.springframework.test.context.ContextCustomizer;
2423
import org.springframework.test.context.ContextCustomizerFactory;
25-
import org.springframework.test.context.MergedContextConfiguration;
2624

2725
/**
2826
* {@link ContextCustomizerFactory} to register a {@link WebDriverScope} and configure
@@ -38,32 +36,7 @@ class WebDriverContextCustomizerFactory implements ContextCustomizerFactory {
3836
@Override
3937
public ContextCustomizer createContextCustomizer(Class<?> testClass,
4038
List<ContextConfigurationAttributes> configAttributes) {
41-
return new Customizer();
42-
}
43-
44-
private static class Customizer implements ContextCustomizer {
45-
46-
@Override
47-
public void customizeContext(ConfigurableApplicationContext context, MergedContextConfiguration mergedConfig) {
48-
WebDriverScope.registerWith(context);
49-
}
50-
51-
@Override
52-
public boolean equals(Object obj) {
53-
if (obj == this) {
54-
return true;
55-
}
56-
if (obj == null || obj.getClass() != getClass()) {
57-
return false;
58-
}
59-
return true;
60-
}
61-
62-
@Override
63-
public int hashCode() {
64-
return getClass().hashCode();
65-
}
66-
39+
return new WebDriverContextCustomizer();
6740
}
6841

6942
}

0 commit comments

Comments
 (0)