Adding mail-session to Wildfly CLI

This is my first stab at using wildfly-maven-plugin to add and remove a mail-session temporarly to a running Wildfly server. This is done over integration testing phases.

<project>
    <build>
        <plugins>
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>1.2.0.Alpha3</version>
		<executions>
		    <execution>
			<phase>pre-integration-test</phase>
			<configuration>
			    <batch>true</batch>
			    <fail-on-error>false</fail-on-error>
			    <commands>
				<command>
				    /socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=mail-smtp-25000:add( \
				    host=smtp.gmail.com, \
				    port=465)
				</command>
				<command>
				    /subsystem=mail/mail-session=MyMail:add(jndi-name="java:jboss/mail/BedtimeSMTP", \
				    from="jane.doe@gmail.example.com", \
				    debug=false)
				</command>
				<command>
				    /subsystem=mail/mail-session=MyMail/server=smtp:add(outbound-socket-binding-ref=mail-smtp-25000, \
				    ssl=true, \
				    username=jane.doe@gmail.example.com,
				password=***)
				</command>
			    </commands>
			    <goals>
				<goal>execute-commands</goal>
			    </goals>
			</configuration>
		    </execution>
		    <execution>
			<phase>post-integration-test</phase>
			<configuration>
			    <batch>true</batch>
			    <fail-on-error>false</fail-on-error>
			    <commands>
				<command>
				    /socket-binding-group=standard-sockets/remote-destination-outbound-socket-binding=mail-smtp-25000:remove
				</command>
				<command>
				    /subsystem=mail/mail-session=MyMail:remove
				</command>
				<command>
				    /subsystem=mail/mail-session=MyMail/server=smtp:remove
				</command>
			    </commands>
			    <goals>
				<goal>execute-commands</goal>
			    </goals>
			</configuration>
		    </execution>
		</executions>
	    </plugin>
	</plugins>
    </build>
</project>

Leave a comment