This is an automated email from the ASF dual-hosted git repository.
veithen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ws-axiom.git
The following commit(s) were added to refs/heads/master by this push:
new 160f4861e Initialize SOAPFactory dependencies via Guice in SOAPTestCase
160f4861e is described below
commit 160f4861e930de03ab37cee724e2640072de461f
Author: Andreas Veithen-Knowles <[email protected]>
AuthorDate: Sun May 10 19:25:57 2026 +0100
Initialize SOAPFactory dependencies via Guice in SOAPTestCase
This replaces the setUp() method by injecting soapFactory and
altSoapFactory using Guice. Created a standalone SOAPFactoryModule and an
@AltSOAPFactory binding annotation to wire these dependencies. Installed the
module in SOAPTestSuite and SOAPDOMTestSuite.
---
.../{SOAPTestCase.java => AltSOAPFactory.java} | 28 +--
.../{SOAPTestCase.java => SOAPFactoryModule.java} | 27 +--
.../org/apache/axiom/ts/soap/SOAPTestCase.java | 14 +-
.../org/apache/axiom/ts/soap/SOAPTestSuite.java | 255 +++++++++++++--------
.../apache/axiom/ts/soapdom/SOAPDOMTestSuite.java | 24 +-
5 files changed, 189 insertions(+), 159 deletions(-)
diff --git
a/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java
b/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/AltSOAPFactory.java
similarity index 52%
copy from
testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java
copy to
testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/AltSOAPFactory.java
index 4551d028e..0e71cfe93 100644
---
a/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java
+++
b/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/AltSOAPFactory.java
@@ -18,27 +18,11 @@
*/
package org.apache.axiom.ts.soap;
-import org.apache.axiom.om.OMMetaFactory;
-import org.apache.axiom.soap.SOAPFactory;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
-import junit.framework.TestCase;
+import com.google.inject.BindingAnnotation;
-public abstract class SOAPTestCase extends TestCase {
- protected final OMMetaFactory metaFactory;
- protected final SOAPSpec spec;
- protected SOAPFactory soapFactory;
- protected SOAPFactory altSoapFactory;
-
- public SOAPTestCase(OMMetaFactory metaFactory, SOAPSpec spec) {
- this.metaFactory = metaFactory;
- this.spec = spec;
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- soapFactory =
spec.getAdapter(FactorySelector.class).getFactory(metaFactory);
- altSoapFactory =
-
spec.getAltSpec().getAdapter(FactorySelector.class).getFactory(metaFactory);
- }
-}
+@BindingAnnotation
+@Retention(RetentionPolicy.RUNTIME)
+public @interface AltSOAPFactory {}
diff --git
a/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java
b/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPFactoryModule.java
similarity index 58%
copy from
testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java
copy to
testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPFactoryModule.java
index 4551d028e..08370efc2 100644
---
a/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java
+++
b/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPFactoryModule.java
@@ -18,27 +18,20 @@
*/
package org.apache.axiom.ts.soap;
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.soap.SOAPFactory;
-import junit.framework.TestCase;
-
-public abstract class SOAPTestCase extends TestCase {
- protected final OMMetaFactory metaFactory;
- protected final SOAPSpec spec;
- protected SOAPFactory soapFactory;
- protected SOAPFactory altSoapFactory;
-
- public SOAPTestCase(OMMetaFactory metaFactory, SOAPSpec spec) {
- this.metaFactory = metaFactory;
- this.spec = spec;
+public final class SOAPFactoryModule extends AbstractModule {
+ @Provides
+ public SOAPFactory provideSOAPFactory(OMMetaFactory metaFactory, SOAPSpec
spec) {
+ return spec.getAdapter(FactorySelector.class).getFactory(metaFactory);
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- soapFactory =
spec.getAdapter(FactorySelector.class).getFactory(metaFactory);
- altSoapFactory =
-
spec.getAltSpec().getAdapter(FactorySelector.class).getFactory(metaFactory);
+ @Provides
+ @AltSOAPFactory
+ public SOAPFactory provideAltSOAPFactory(OMMetaFactory metaFactory,
SOAPSpec spec) {
+ return
spec.getAltSpec().getAdapter(FactorySelector.class).getFactory(metaFactory);
}
}
diff --git
a/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java
b/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java
index 4551d028e..16e6738d9 100644
---
a/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java
+++
b/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestCase.java
@@ -18,6 +18,8 @@
*/
package org.apache.axiom.ts.soap;
+import com.google.inject.Inject;
+
import org.apache.axiom.om.OMMetaFactory;
import org.apache.axiom.soap.SOAPFactory;
@@ -26,19 +28,11 @@ import junit.framework.TestCase;
public abstract class SOAPTestCase extends TestCase {
protected final OMMetaFactory metaFactory;
protected final SOAPSpec spec;
- protected SOAPFactory soapFactory;
- protected SOAPFactory altSoapFactory;
+ @Inject protected SOAPFactory soapFactory;
+ @Inject @AltSOAPFactory protected SOAPFactory altSoapFactory;
public SOAPTestCase(OMMetaFactory metaFactory, SOAPSpec spec) {
this.metaFactory = metaFactory;
this.spec = spec;
}
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- soapFactory =
spec.getAdapter(FactorySelector.class).getFactory(metaFactory);
- altSoapFactory =
-
spec.getAltSpec().getAdapter(FactorySelector.class).getFactory(metaFactory);
- }
}
diff --git
a/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuite.java
b/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuite.java
index 42a16bd26..29bb03a7e 100644
---
a/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuite.java
+++
b/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuite.java
@@ -41,7 +41,9 @@ import org.apache.axiom.ts.dimension.ExpansionStrategy;
import org.apache.axiom.ts.dimension.serialization.SerializationStrategy;
import com.google.common.collect.ImmutableList;
+import com.google.inject.AbstractModule;
import com.google.inject.Key;
+import com.google.inject.Provides;
import com.google.inject.name.Names;
import com.google.inject.util.Providers;
@@ -122,7 +124,7 @@ public class SOAPTestSuite {
Multiton.getInstances(SOAPSpec.class),
Binding.singleton(Key.get(SOAPSpec.class)),
LabelBinding.simpleString("spec",
SOAPSpec::getName),
- specTests()),
+ new InjectorNode(new SOAPFactoryModule(),
specTests())),
// Bad SOAP files (spec-independent)
new FanOutNode<>(
badSOAPFiles,
@@ -135,36 +137,53 @@ public class SOAPTestSuite {
goodSOAPFiles,
Binding.singleton(Key.get(SOAPSample.class)),
LabelBinding.simpleString("message",
SOAPSample::getName),
- new ParentNode(
- new MatrixTest(
-
org.apache.axiom.ts.soap.builder.MessageTest.class),
- new MatrixTest(
-
org.apache.axiom.ts.soap.builder
-
.TestRegisterCustomBuilderForPayload.class),
- new MatrixTest(
-
org.apache.axiom.ts.soap.envelope.TestClone.class),
- new FanOutNode<>(
-
getInstances(ExpansionStrategy.class),
-
Binding.singleton(Key.get(ExpansionStrategy.class)),
- LabelBinding.DIMENSION,
+ new InjectorNode(
+ ImmutableList.of(
+ new AbstractModule() {
+ @Provides
+ SOAPSpec
provideSOAPSpec(SOAPSample sample) {
+ return
sample.getSOAPSpec();
+ }
+ },
+ new SOAPFactoryModule()),
+ new ParentNode(
+ new MatrixTest(
+
org.apache.axiom.ts.soap.builder.MessageTest
+ .class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap.builder
+
.TestRegisterCustomBuilderForPayload
+ .class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap.envelope.TestClone
+ .class),
new FanOutNode<>(
-
getInstances(SerializationStrategy.class),
+
getInstances(ExpansionStrategy.class),
Binding.singleton(
- Key.get(
-
SerializationStrategy
-
.class)),
+
Key.get(ExpansionStrategy.class)),
LabelBinding.DIMENSION,
- new ParentNode(
- new MatrixTest(
-
org.apache.axiom.ts.soap
-
.envelope
-
.TestSerialize
+ new FanOutNode<>(
+ getInstances(
+
SerializationStrategy
.class),
- new MatrixTest(
-
org.apache.axiom.ts.soap
-
.message
-
.TestSerialize
-
.class)))))),
+
Binding.singleton(
+
Key.get(
+
SerializationStrategy
+
.class)),
+
LabelBinding.DIMENSION,
+ new ParentNode(
+ new
MatrixTest(
+
org.apache.axiom.ts
+
.soap
+
.envelope
+
.TestSerialize
+
.class),
+ new
MatrixTest(
+
org.apache.axiom.ts
+
.soap
+
.message
+
.TestSerialize
+
.class))))))),
// SOAP 1.1 specific tests
soap11Tests(),
// SOAP 1.2 specific tests
@@ -730,83 +749,119 @@ public class SOAPTestSuite {
}
private static MatrixTestNode soap11Tests() {
- return new ParentNode(
- new
MatrixTest(org.apache.axiom.ts.soap11.builder.TestBuilder.class),
- new
MatrixTest(org.apache.axiom.ts.soap11.fault.TestGetNode.class),
- new
MatrixTest(org.apache.axiom.ts.soap11.fault.TestSetNode.class),
- new
MatrixTest(org.apache.axiom.ts.soap11.faultcode.TestGetValue.class),
- new
MatrixTest(org.apache.axiom.ts.soap11.faultcode.TestGetValueWithParser.class),
- new
MatrixTest(org.apache.axiom.ts.soap11.faultcode.TestSetValueFromQName.class),
- new
MatrixTest(org.apache.axiom.ts.soap11.faultreason.TestAddSOAPText.class),
- new
MatrixTest(org.apache.axiom.ts.soap11.faultreason.TestGetFirstSOAPText.class),
- new
MatrixTest(org.apache.axiom.ts.soap11.faultreason.TestGetTextWithCDATA.class));
+ return new InjectorNode(
+ ImmutableList.of(
+ binder ->
binder.bind(SOAPSpec.class).toInstance(SOAPSpec.SOAP11),
+ new SOAPFactoryModule()),
+ new ParentNode(
+ new
MatrixTest(org.apache.axiom.ts.soap11.builder.TestBuilder.class),
+ new
MatrixTest(org.apache.axiom.ts.soap11.fault.TestGetNode.class),
+ new
MatrixTest(org.apache.axiom.ts.soap11.fault.TestSetNode.class),
+ new
MatrixTest(org.apache.axiom.ts.soap11.faultcode.TestGetValue.class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap11.faultcode.TestGetValueWithParser.class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap11.faultcode.TestSetValueFromQName.class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap11.faultreason.TestAddSOAPText.class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap11.faultreason.TestGetFirstSOAPText.class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap11.faultreason.TestGetTextWithCDATA
+ .class)));
}
private static MatrixTestNode soap12Tests() {
- return new ParentNode(
- new
MatrixTest(org.apache.axiom.ts.soap12.builder.TestBuilder.class),
- new
MatrixTest(org.apache.axiom.ts.soap12.envelope.TestBuildWithAttachments.class),
- new FanOutNode<>(
- ImmutableList.of(true, false),
- Binding.singleton(Key.get(Boolean.class,
Names.named("buildSOAPPart"))),
- LabelBinding.simpleBoolean("buildSOAPPart"),
+ return new InjectorNode(
+ ImmutableList.of(
+ binder ->
binder.bind(SOAPSpec.class).toInstance(SOAPSpec.SOAP12),
+ new SOAPFactoryModule()),
+ new ParentNode(
+ new
MatrixTest(org.apache.axiom.ts.soap12.builder.TestBuilder.class),
new MatrixTest(
-
org.apache.axiom.ts.soap12.envelope.TestMTOMForwardStreaming
- .class)),
- new
MatrixTest(org.apache.axiom.ts.soap12.factory.TestCreateSOAPFaultSubCode.class),
- new
MatrixTest(org.apache.axiom.ts.soap12.fault.TestGetNode.class),
- new
MatrixTest(org.apache.axiom.ts.soap12.fault.TestGetNodeWithParser.class),
- new
MatrixTest(org.apache.axiom.ts.soap12.fault.TestMoreChildrenAddition.class),
- new
MatrixTest(org.apache.axiom.ts.soap12.fault.TestSetNode.class),
- new
MatrixTest(org.apache.axiom.ts.soap12.faultcode.TestGetSubCodeWithParser.class),
- new
MatrixTest(org.apache.axiom.ts.soap12.faultcode.TestGetValueWithParser.class),
- new
MatrixTest(org.apache.axiom.ts.soap12.faultcode.TestSetValueFromQName.class),
- new MatrixTest(
-
org.apache.axiom.ts.soap12.faultcode.TestSetValueFromQNameWithExistingValue
- .class),
- new
MatrixTest(org.apache.axiom.ts.soap12.faultreason.TestAddSOAPText.class),
- new MatrixTest(
-
org.apache.axiom.ts.soap12.faultreason.TestAddSOAPTextMultiple.class),
- new MatrixTest(
- org.apache.axiom.ts.soap12.faultreason
- .TestAddSOAPTextWithSOAPVersionMismatch.class),
- new MatrixTest(
-
org.apache.axiom.ts.soap12.faultreason.TestGetAllSoapTextsWithParser.class),
- new
MatrixTest(org.apache.axiom.ts.soap12.faultreason.TestGetFaultReasonText.class),
- new MatrixTest(
-
org.apache.axiom.ts.soap12.faultreason.TestGetFaultReasonTextCaseSensitivity
- .class),
- new MatrixTest(
- org.apache.axiom.ts.soap12.faultreason
-
.TestGetFaultReasonTextWithoutLangAttribute.class),
- new
MatrixTest(org.apache.axiom.ts.soap12.faultreason.TestGetFirstSOAPText.class),
- new MatrixTest(
-
org.apache.axiom.ts.soap12.faultreason.TestGetFirstSOAPTextWithParser
- .class),
- new MatrixTest(
-
org.apache.axiom.ts.soap12.faultsubcode.TestGetSubCodeNestedWithParser
- .class),
- new MatrixTest(
-
org.apache.axiom.ts.soap12.faultsubcode.TestGetSubCodeWithParser.class),
- new MatrixTest(
-
org.apache.axiom.ts.soap12.faultsubcode.TestGetValueNestedWithParser.class),
- new MatrixTest(
-
org.apache.axiom.ts.soap12.faultsubcode.TestGetValueAsQNameWithParser
- .class),
- new MatrixTest(
-
org.apache.axiom.ts.soap12.faultsubcode.TestGetValueWithParser.class),
- new
MatrixTest(org.apache.axiom.ts.soap12.faulttext.TestGetLangWithParser.class),
- new MatrixTest(
-
org.apache.axiom.ts.soap12.header.TestExamineMustUnderstandHeaderBlocks
- .class),
- new
MatrixTest(org.apache.axiom.ts.soap12.headerblock.TestGetRelayWithParser.class),
- new
MatrixTest(org.apache.axiom.ts.soap12.mtom.TestBuilderDetach.class),
- new FanOutNode<>(
- ImmutableList.of(true, false),
- Binding.singleton(Key.get(Boolean.class,
Names.named("cache"))),
- LabelBinding.simpleBoolean("cache"),
+
org.apache.axiom.ts.soap12.envelope.TestBuildWithAttachments.class),
+ new FanOutNode<>(
+ ImmutableList.of(true, false),
+ Binding.singleton(
+ Key.get(Boolean.class,
Names.named("buildSOAPPart"))),
+ LabelBinding.simpleBoolean("buildSOAPPart"),
+ new MatrixTest(
+
org.apache.axiom.ts.soap12.envelope.TestMTOMForwardStreaming
+ .class)),
new MatrixTest(
-
org.apache.axiom.ts.soap12.mtom.TestGetXMLStreamReaderMTOMEncoded
- .class)));
+
org.apache.axiom.ts.soap12.factory.TestCreateSOAPFaultSubCode
+ .class),
+ new
MatrixTest(org.apache.axiom.ts.soap12.fault.TestGetNode.class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap12.fault.TestGetNodeWithParser.class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap12.fault.TestMoreChildrenAddition.class),
+ new
MatrixTest(org.apache.axiom.ts.soap12.fault.TestSetNode.class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap12.faultcode.TestGetSubCodeWithParser
+ .class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap12.faultcode.TestGetValueWithParser.class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap12.faultcode.TestSetValueFromQName.class),
+ new MatrixTest(
+ org.apache.axiom.ts.soap12.faultcode
+
.TestSetValueFromQNameWithExistingValue.class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap12.faultreason.TestAddSOAPText.class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap12.faultreason.TestAddSOAPTextMultiple
+ .class),
+ new MatrixTest(
+ org.apache.axiom.ts.soap12.faultreason
+
.TestAddSOAPTextWithSOAPVersionMismatch.class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap12.faultreason.TestGetAllSoapTextsWithParser
+ .class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap12.faultreason.TestGetFaultReasonText
+ .class),
+ new MatrixTest(
+ org.apache.axiom.ts.soap12.faultreason
+
.TestGetFaultReasonTextCaseSensitivity.class),
+ new MatrixTest(
+ org.apache.axiom.ts.soap12.faultreason
+
.TestGetFaultReasonTextWithoutLangAttribute.class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap12.faultreason.TestGetFirstSOAPText.class),
+ new MatrixTest(
+ org.apache.axiom.ts.soap12.faultreason
+ .TestGetFirstSOAPTextWithParser.class),
+ new MatrixTest(
+ org.apache.axiom.ts.soap12.faultsubcode
+ .TestGetSubCodeNestedWithParser.class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap12.faultsubcode.TestGetSubCodeWithParser
+ .class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap12.faultsubcode.TestGetValueNestedWithParser
+ .class),
+ new MatrixTest(
+ org.apache.axiom.ts.soap12.faultsubcode
+ .TestGetValueAsQNameWithParser.class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap12.faultsubcode.TestGetValueWithParser
+ .class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap12.faulttext.TestGetLangWithParser.class),
+ new MatrixTest(
+ org.apache.axiom.ts.soap12.header
+
.TestExamineMustUnderstandHeaderBlocks.class),
+ new MatrixTest(
+
org.apache.axiom.ts.soap12.headerblock.TestGetRelayWithParser
+ .class),
+ new
MatrixTest(org.apache.axiom.ts.soap12.mtom.TestBuilderDetach.class),
+ new FanOutNode<>(
+ ImmutableList.of(true, false),
+ Binding.singleton(Key.get(Boolean.class,
Names.named("cache"))),
+ LabelBinding.simpleBoolean("cache"),
+ new MatrixTest(
+ org.apache.axiom.ts.soap12.mtom
+
.TestGetXMLStreamReaderMTOMEncoded.class))));
}
}
diff --git
a/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soapdom/SOAPDOMTestSuite.java
b/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soapdom/SOAPDOMTestSuite.java
index 0cea29d74..968a87275 100644
---
a/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soapdom/SOAPDOMTestSuite.java
+++
b/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soapdom/SOAPDOMTestSuite.java
@@ -28,6 +28,7 @@ import org.apache.axiom.testutils.suite.LabelBinding;
import org.apache.axiom.testutils.suite.MatrixTestNode;
import org.apache.axiom.testutils.suite.MatrixTest;
import org.apache.axiom.testutils.suite.ParentNode;
+import org.apache.axiom.ts.soap.SOAPFactoryModule;
import org.apache.axiom.ts.soap.SOAPSpec;
import com.google.inject.Key;
@@ -40,15 +41,18 @@ public class SOAPDOMTestSuite {
Multiton.getInstances(SOAPSpec.class),
Binding.singleton(Key.get(SOAPSpec.class)),
LabelBinding.simpleString("spec", SOAPSpec::getName),
- new ParentNode(
- new MatrixTest(
- org.apache.axiom.ts.soapdom.header
-
.TestExamineAllHeaderBlocks.class),
- new MatrixTest(
- org.apache.axiom.ts.soapdom.header
-
.TestExamineMustUnderstandHeaderBlocks.class),
- new MatrixTest(
- org.apache.axiom.ts.soapdom.message
-
.TestLazySOAPFactorySelection.class))));
+ new InjectorNode(
+ new SOAPFactoryModule(),
+ new ParentNode(
+ new MatrixTest(
+
org.apache.axiom.ts.soapdom.header
+
.TestExamineAllHeaderBlocks.class),
+ new MatrixTest(
+
org.apache.axiom.ts.soapdom.header
+
.TestExamineMustUnderstandHeaderBlocks
+ .class),
+ new MatrixTest(
+
org.apache.axiom.ts.soapdom.message
+
.TestLazySOAPFactorySelection.class)))));
}
}