View Source

If your custom component is based on Petals Component Developer Toolkit, some changes can occur according to the target version of the Petals CDK required

{anchor:from58xto59x}
h1. From 5.8.x to 5.9.x

h2. Migrating your component runtime

Please apply the following changes in the unit tests of your custom component:
* move Java EE package to Jakarta EE 9+ package:
** {{javax.activation}} -> {{jakarta.activation}}
** {{javax.mail}} -> {{jakarta.mail}}
** {{javax.xml.bind}} -> {{jakarta.xml.bind}}
** ...
* to generate your beans from an XSD or WSDL definition, use the Maven plugin '{{org.patrodyne.jvnet:hisrc-higherjaxb-maven-plugin}}' instead of '{{org.jvnet.jaxb2.maven2:maven-jaxb2-plugin}}'.

h2. Migrating your component unit tests

Please apply the following changes in the unit tests of your custom component:
* JUnit 5 is now required for your unit tests,
* move Java EE package to Jakarta EE 9+ package:
** {{javax.activation}} -> {{jakarta.activation}}
** {{javax.mail}} -> {{jakarta.mail}}
** {{javax.xml.bind}} -> {{jakarta.xml.bind}}
** ...
* to generate your beans from an XSD or WSDL definition, use the Maven plugin '{{org.patrodyne.jvnet:hisrc-higherjaxb-maven-plugin}}' instead of '{{org.jvnet.jaxb2.maven2:maven-jaxb2-plugin}}',
* the component under test instance is now initialized through the annotation '{{@ComponentUnderTestExtension}}' with its own '{{InMemoryLogHandler}}' retrieved from the component under test instance using the accessor '{{getInMemoryLogHandler()}}':
{code}
public class MyComponentTest

@ComponentUnderTestExtension(
inMemoryLogHandler = @InMemoryLogHandlerExtension,
installesComponent = true,
startsComponent = true,
explicitPostInitialization = true,
componentConfiguration = @ComponentConfigurationExtension(
name = "componentUnderTest",
implementation = ExtendedComponentConfiguration.class))
protected static ComponentUnderTest COMPONENT_UNDER_TEST;

protected static class ExtendedComponentConfiguration extends ComponentConfiguration {

public ExtendedComponentConfiguration(final String configurationName) {
super(configurationName);
}

@Override
protected void extraJBIConfiguration(final @Nullable Document jbiDocument) {
assert jbiDocument != null;

final Element compo = getComponentElement(jbiDocument);

// Here, add a component configuration directly in the component JBI descriptor.
final Element transport = addElement(jbiDocument, compo, BcGatewayJbiConstants.EL_TRANSPORT_LISTENER);
transport.setAttribute(BcGatewayJbiTestConstants.ATTR_TRANSPORT_LISTENER_ID,
AbstractEnvironmentTest.TEST_TRANSPORT_NAME);
}
}

@BeforeAll
private static void completesComponentUnderTestConfiguration() throws Exception {
COMPONENT_UNDER_TEST
.setParameter(
new QName("http://petals.ow2.org/components/extensions/version-5", "properties-file"),
new ParameterGenerator() {

@Override
public String generate() throws Exception {

final Properties componentProperties = new Properties();

final File componentPropertiesFile = Files
.createTempFile(tempFolder, "component-properties", "properties").toFile();
try (final FileOutputStream fos = new FileOutputStream(componentPropertiesFile)) {
componentProperties.store(fos, "Initial placeholders");
}

return componentPropertiesFile.getAbsolutePath();
}
})
.registerServiceToDeploy(VALID_INTEGRATION_SU_PROVIDE, new ServiceConfigurationFactory() {
@Override
public ServiceConfiguration create() {

final URL wsdlUrl = Thread.currentThread().getContextClassLoader()
.getResource("su/valid/integrationMailService.wsdl");
assertNotNull(wsdlUrl, "WSDl not found");

final ProvidesServiceConfiguration serviceConfiguration = new ProvidesServiceConfiguration(
IntegrationService.INTERFACE_NAME, INTEGRATION_SVC_NAME, INTEGRATION_EDP, wsdlUrl);

serviceConfiguration.setParameter(
new QName(MailConstants.MAIL_SERVICE_NS, MailConstants.SCHEME_PATHELEMENT),
MailConstants.MAIL_SCHEME_SMTP);
...

return serviceConfiguration;
}
})
.registerServiceToDeploy(VALID_SU_CONSUME_POP3, new ServiceConfigurationFactory() {
@Override
public ServiceConfiguration create() {

final ConsumesServiceConfiguration serviceConfiguration = new ConsumesServiceConfiguration(
PROVIDER_ITF_NAME, PROVIDER_SVC_NAME, PROVIDER_EDP);
serviceConfiguration.setOperation(CONSUMED_OPERATION);
serviceConfiguration.setTimeout(CONSUMED_TIMEOUT);
serviceConfiguration.setParameter(
new QName(MailConstants.MAIL_SERVICE_NS, MailConstants.SCHEME_PATHELEMENT),
MailConstants.MAIL_SCHEME_POP3);
...

return serviceConfiguration;
}
})
.registerExternalServiceProvider(PROVIDER_EDP, PROVIDER_SVC_NAME, PROVIDER_ITF_NAME)
.postInitComponentUnderTest();
}

@Test
public void receiveMail() throws Exception {

...

COMPONENT.receiveAsExternalProvider(
ServiceProviderImplementation.statusMessage(ExchangeStatus.DONE).with(new MessageChecks() {
@Override
public void checks(Message message) throws Exception {
...
}
}), 4000, true);

// Check MONIT traces
final List<LogRecord> monitLogs = COMPONENT_UNDER_TEST.getInMemoryLogHandler().getAllRecords(Level.MONIT);
assertEquals(4, monitLogs_1.size());
final FlowLogData consumeExtLogData = assertMonitMailConsumerBeginLog(..., monitLogs.get(0));
final FlowLogData provideLogData = assertMonitProviderBeginLog(..., monitLogs.get(1));
assertMonitProviderEndLog(provideLogData, monitLogs.get(2));
assertMonitConsumerExtEndLog(consumeExtLogData, monitLogs.get(3));
}
}
{code}

{anchor:from57xto58x}
h1. From 5.7.x to 5.8.x

h2. Migrating your component runtime

Please apply the following changes in the source code of your custom component:
* Placeholders are no more defined through {{Properties}} but through {{Placeholders}}.