Skip to content

Commit b04f256

Browse files
committed
Apply new formatting rules to the messaging TCK
Signed-off-by: Clement Escoffier <[email protected]>
1 parent 19bab62 commit b04f256

17 files changed

+834
-844
lines changed

messaging/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/CompletionStageIncomingMethodVerification.java

+275-283
Large diffs are not rendered by default.

messaging/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/ReactiveMessagingTck.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@
2323

2424
/**
2525
* The TCK.
26-
*
26+
* <p>
2727
* Run this class to run all TCK tests.
2828
*/
2929
public class ReactiveMessagingTck {
3030

31-
@Factory
32-
public Object[] getAllTests() {
33-
return new Object[] {
34-
new CompletionStageIncomingMethodVerification()
35-
};
36-
}
31+
@Factory
32+
public Object[] getAllTests() {
33+
return new Object[]{
34+
new CompletionStageIncomingMethodVerification()
35+
};
36+
}
3737

3838
}

messaging/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/WaitAssert.java

+15-15
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@
2323

2424
public class WaitAssert {
2525

26-
private WaitAssert() {
27-
}
26+
private WaitAssert() {
27+
}
2828

29-
public static void waitUntil(Duration timeout, Runnable block) {
30-
long deadline = System.currentTimeMillis() + timeout.toMillis();
31-
while (true) {
32-
try {
33-
block.run();
34-
break;
35-
}
36-
catch (Throwable t) {
37-
if (System.currentTimeMillis() >= deadline) {
38-
throw new AssertionError("Action was not completed in " + timeout.toMillis() + "ms", t);
39-
}
40-
}
29+
public static void waitUntil(Duration timeout, Runnable block) {
30+
long deadline = System.currentTimeMillis() + timeout.toMillis();
31+
while (true) {
32+
try {
33+
block.run();
34+
break;
35+
}
36+
catch (Throwable t) {
37+
if (System.currentTimeMillis() >= deadline) {
38+
throw new AssertionError("Action was not completed in " + timeout.toMillis() + "ms", t);
39+
}
40+
}
4141

42+
}
4243
}
43-
}
4444

4545
}

messaging/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/arquillian/TckArquillianDeployListener.java

+71-71
Original file line numberDiff line numberDiff line change
@@ -42,93 +42,93 @@
4242

4343
public class TckArquillianDeployListener {
4444

45-
private final TckContainer tckContainer;
45+
private final TckContainer tckContainer;
4646

47-
private final Map<Class<?>, List<DeploymentDescription>> activeDeployments = new ConcurrentHashMap<>();
47+
private final Map<Class<?>, List<DeploymentDescription>> activeDeployments = new ConcurrentHashMap<>();
4848

49-
private final Archive<?> frameworkClasses = ShrinkWrap.create(JavaArchive.class)
50-
.addPackage(TckMessagingManager.class.getPackage().getName());
49+
private final Archive<?> frameworkClasses = ShrinkWrap.create(JavaArchive.class)
50+
.addPackage(TckMessagingManager.class.getPackage().getName());
5151

52-
private final Archive<?> frameworkArchive = ShrinkWrap.create(JavaArchive.class)
53-
.addPackage(TckMessagingManager.class.getPackage().getName())
54-
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
52+
private final Archive<?> frameworkArchive = ShrinkWrap.create(JavaArchive.class)
53+
.addPackage(TckMessagingManager.class.getPackage().getName())
54+
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
5555

5656

57-
public TckArquillianDeployListener() {
58-
Iterator<TckContainer> containers = ServiceLoader.load(TckContainer.class).iterator();
57+
public TckArquillianDeployListener() {
58+
Iterator<TckContainer> containers = ServiceLoader.load(TckContainer.class).iterator();
5959

60-
if (containers.hasNext()) {
61-
this.tckContainer = containers.next();
60+
if (containers.hasNext()) {
61+
this.tckContainer = containers.next();
62+
}
63+
else {
64+
throw new RuntimeException("No " + TckContainer.class.getName() +
65+
" found. To run this TCK, you must provide an implementation of " +
66+
TckContainer.class + " via the JDK service loader mechanism.");
67+
}
6268
}
63-
else {
64-
throw new RuntimeException("No " + TckContainer.class.getName() +
65-
" found. To run this TCK, you must provide an implementation of " +
66-
TckContainer.class + " via the JDK service loader mechanism.");
67-
}
68-
}
69-
70-
public void onBeforeDeploy(@Observes BeforeDeploy beforeDeploy, TestClass testClass) throws DeploymentException {
71-
72-
String[] topicNames = getTopicsUsedByTestClass(testClass);
73-
74-
DeployableContainer<?> container = beforeDeploy.getDeployableContainer();
75-
DeploymentDescription description = beforeDeploy.getDeployment();
76-
77-
List<DeploymentDescription> deployed = new ArrayList<>();
78-
activeDeployments.put(testClass.getJavaClass(), deployed);
7969

80-
List<DeploymentDescription> deployments = tckContainer.createDeployments(topicNames);
81-
for (DeploymentDescription deployable: deployments) {
82-
if (!tckContainer.mergeArchives() || deployable.isDescriptorDeployment() || description.isDescriptorDeployment()) {
83-
deployed.add(deployable);
84-
container.deploy(deployable.getDescriptor());
85-
}
86-
else {
87-
description.getArchive().merge(deployable.getArchive());
88-
}
70+
public void onBeforeDeploy(@Observes BeforeDeploy beforeDeploy, TestClass testClass) throws DeploymentException {
71+
72+
String[] topicNames = getTopicsUsedByTestClass(testClass);
73+
74+
DeployableContainer<?> container = beforeDeploy.getDeployableContainer();
75+
DeploymentDescription description = beforeDeploy.getDeployment();
76+
77+
List<DeploymentDescription> deployed = new ArrayList<>();
78+
activeDeployments.put(testClass.getJavaClass(), deployed);
79+
80+
List<DeploymentDescription> deployments = tckContainer.createDeployments(topicNames);
81+
for (DeploymentDescription deployable : deployments) {
82+
if (!tckContainer.mergeArchives() || deployable.isDescriptorDeployment() || description.isDescriptorDeployment()) {
83+
deployed.add(deployable);
84+
container.deploy(deployable.getDescriptor());
85+
}
86+
else {
87+
description.getArchive().merge(deployable.getArchive());
88+
}
89+
}
90+
91+
if (description.isArchiveDeployment()) {
92+
description.getArchive().merge(frameworkClasses);
93+
}
94+
else {
95+
deployed.add(new DeploymentDescription("reactive-messaging-tck-framework.jar", frameworkArchive));
96+
container.deploy(frameworkArchive);
97+
}
8998
}
9099

91-
if (description.isArchiveDeployment()) {
92-
description.getArchive().merge(frameworkClasses);
93-
}
94-
else {
95-
deployed.add(new DeploymentDescription("reactive-messaging-tck-framework.jar", frameworkArchive));
96-
container.deploy(frameworkArchive);
97-
}
98-
}
100+
public void onAfterUnDeploy(@Observes AfterUnDeploy afterUnDeploy, TestClass testClass) throws DeploymentException {
99101

100-
public void onAfterUnDeploy(@Observes AfterUnDeploy afterUnDeploy, TestClass testClass) throws DeploymentException {
102+
String[] topicNames = getTopicsUsedByTestClass(testClass);
101103

102-
String[] topicNames = getTopicsUsedByTestClass(testClass);
104+
DeployableContainer<?> container = afterUnDeploy.getDeployableContainer();
103105

104-
DeployableContainer<?> container = afterUnDeploy.getDeployableContainer();
106+
List<DeploymentDescription> deployments = activeDeployments.remove(testClass.getJavaClass());
107+
if (deployments == null) {
108+
throw new IllegalStateException("After undeploy on test class that wasn't deployed?");
109+
}
110+
for (DeploymentDescription deployable : deployments) {
111+
if (deployable.isDescriptorDeployment()) {
112+
container.undeploy(deployable.getDescriptor());
113+
}
114+
else {
115+
container.undeploy(deployable.getArchive());
116+
}
117+
}
105118

106-
List<DeploymentDescription> deployments = activeDeployments.remove(testClass.getJavaClass());
107-
if (deployments == null) {
108-
throw new IllegalStateException("After undeploy on test class that wasn't deployed?");
109-
}
110-
for (DeploymentDescription deployable: deployments) {
111-
if (deployable.isDescriptorDeployment()) {
112-
container.undeploy(deployable.getDescriptor());
113-
}
114-
else {
115-
container.undeploy(deployable.getArchive());
116-
}
119+
tckContainer.teardownTopics(topicNames);
117120
}
118121

119-
tckContainer.teardownTopics(topicNames);
120-
}
121-
122-
private String[] getTopicsUsedByTestClass(TestClass testClass) {
123-
Topics topics = testClass.getAnnotation(Topics.class);
124-
String[] topicNames;
125-
if (topics != null) {
126-
topicNames = topics.value();
127-
}
128-
else {
129-
topicNames = new String[0];
122+
private String[] getTopicsUsedByTestClass(TestClass testClass) {
123+
Topics topics = testClass.getAnnotation(Topics.class);
124+
String[] topicNames;
125+
if (topics != null) {
126+
topicNames = topics.value();
127+
}
128+
else {
129+
topicNames = new String[0];
130+
}
131+
return topicNames;
130132
}
131-
return topicNames;
132-
}
133133

134134
}

messaging/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/arquillian/TckArquillianExtension.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import org.jboss.arquillian.core.spi.LoadableExtension;
2323

2424
public class TckArquillianExtension implements LoadableExtension {
25-
@Override
26-
public void register(ExtensionBuilder builder) {
27-
builder.observer(TckArquillianDeployListener.class);
28-
}
25+
@Override
26+
public void register(ExtensionBuilder builder) {
27+
builder.observer(TckArquillianDeployListener.class);
28+
}
2929
}

messaging/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/arquillian/Topics.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@
3030
@Target(ElementType.TYPE)
3131
@Retention(RetentionPolicy.RUNTIME)
3232
public @interface Topics {
33-
String[] value();
33+
String[] value();
3434
}

messaging/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/framework/ContainerController.java

+19-20
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,29 @@
3636
@ApplicationScoped
3737
public class ContainerController {
3838

39-
@Inject
40-
private TckMessagingPuppet container;
39+
private final Jsonb jsonb = JsonbBuilder.create();
40+
@Inject
41+
private TckMessagingPuppet container;
4142

42-
private final Jsonb jsonb = JsonbBuilder.create();
43-
44-
public void sendMessages(String topic, Message<?>... messages) {
45-
for (Message<?> message: messages) {
46-
ByteArrayOutputStream baos = new ByteArrayOutputStream();
47-
jsonb.toJson(message.getPayload(), baos);
48-
container.sendMessage(topic, Message.of(baos.toByteArray()));
43+
public void sendMessages(String topic, Message<?>... messages) {
44+
for (Message<?> message : messages) {
45+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
46+
jsonb.toJson(message.getPayload(), baos);
47+
container.sendMessage(topic, Message.of(baos.toByteArray()));
48+
}
4949
}
50-
}
5150

52-
public void sendPayloads(String topic, Object... payloads) {
53-
for (Object payload: payloads) {
54-
ByteArrayOutputStream baos = new ByteArrayOutputStream();
55-
jsonb.toJson(payload, baos);
56-
container.sendMessage(topic, Message.of(baos.toByteArray()));
51+
public void sendPayloads(String topic, Object... payloads) {
52+
for (Object payload : payloads) {
53+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
54+
jsonb.toJson(payload, baos);
55+
container.sendMessage(topic, Message.of(baos.toByteArray()));
56+
}
5757
}
58-
}
5958

60-
@Produces
61-
public TestEnvironment produceTestEnvironment() {
62-
return container.testEnvironment();
63-
}
59+
@Produces
60+
public TestEnvironment produceTestEnvironment() {
61+
return container.testEnvironment();
62+
}
6463

6564
}

messaging/tck/src/main/java/org/eclipse/microprofile/reactive/messaging/tck/framework/MockPayload.java

+42-42
Original file line numberDiff line numberDiff line change
@@ -22,57 +22,57 @@
2222
import java.util.Objects;
2323

2424
public class MockPayload {
25-
private String field1;
26-
private int field2;
25+
private String field1;
26+
private int field2;
2727

28-
public MockPayload(String field1, int field2) {
29-
this.field1 = field1;
30-
this.field2 = field2;
31-
}
32-
33-
public MockPayload() {
34-
}
28+
public MockPayload(String field1, int field2) {
29+
this.field1 = field1;
30+
this.field2 = field2;
31+
}
3532

36-
public String getField1() {
37-
return field1;
38-
}
33+
public MockPayload() {
34+
}
3935

40-
public int getField2() {
41-
return field2;
42-
}
36+
public String getField1() {
37+
return field1;
38+
}
4339

44-
public void setField1(String field1) {
45-
this.field1 = field1;
46-
}
40+
public void setField1(String field1) {
41+
this.field1 = field1;
42+
}
4743

48-
public void setField2(int field2) {
49-
this.field2 = field2;
50-
}
44+
public int getField2() {
45+
return field2;
46+
}
5147

52-
@Override
53-
public boolean equals(Object o) {
54-
if (this == o) {
55-
return true;
48+
public void setField2(int field2) {
49+
this.field2 = field2;
5650
}
57-
if (o == null || getClass() != o.getClass()) {
58-
return false;
51+
52+
@Override
53+
public boolean equals(Object o) {
54+
if (this == o) {
55+
return true;
56+
}
57+
if (o == null || getClass() != o.getClass()) {
58+
return false;
59+
}
60+
MockPayload that = (MockPayload) o;
61+
return field2 == that.field2 &&
62+
Objects.equals(field1, that.field1);
5963
}
60-
MockPayload that = (MockPayload) o;
61-
return field2 == that.field2 &&
62-
Objects.equals(field1, that.field1);
63-
}
6464

65-
@Override
66-
public int hashCode() {
65+
@Override
66+
public int hashCode() {
6767

68-
return Objects.hash(field1, field2);
69-
}
68+
return Objects.hash(field1, field2);
69+
}
7070

71-
@Override
72-
public String toString() {
73-
return "MockPayload{" +
74-
"field1='" + field1 + '\'' +
75-
", field2=" + field2 +
76-
'}';
77-
}
71+
@Override
72+
public String toString() {
73+
return "MockPayload{" +
74+
"field1='" + field1 + '\'' +
75+
", field2=" + field2 +
76+
'}';
77+
}
7878
}

0 commit comments

Comments
 (0)