@@ -92,15 +92,19 @@ private void startMailSession(final MailSessionService mailSessionService,
final ServiceBuilder<ManagedReferenceFactory> binderBuilder = serviceTarget
.addService(bindInfo.getBinderServiceName(), binderService)
.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()).addListener(new LifecycleListener() {
private volatile boolean bound;
@Override
public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) {
switch (event) {
case UP: {
MailLogger.ROOT_LOGGER.boundMailSession(jndiName);
bound = true;
break;
}
case DOWN: {
MailLogger.ROOT_LOGGER.unboundMailSession(jndiName);
if (bound) {
MailLogger.ROOT_LOGGER.unboundMailSession(jndiName);
}
break;
}
case REMOVED: {
@@ -106,15 +106,19 @@ public static void installAliasBinderService(final ServiceTarget serviceTarget,
sb.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, aliasBinderService.getNamingStoreInjector());
sb.requires(bindInfo.getBinderServiceName());
sb.addListener(new LifecycleListener() {
private volatile boolean bound;
@Override
public void handleEvent(ServiceController<?> controller, LifecycleEvent event) {
switch (event) {
case UP: {
ROOT_LOGGER.boundJndiName(alias);
bound = true;
break;
}
case DOWN: {
ROOT_LOGGER.unboundJndiName(alias);
if (bound) {
ROOT_LOGGER.unboundJndiName(alias);
}
break;
}
case REMOVED: {
@@ -298,14 +298,18 @@ private void startTopic(String topicName,
final ContextListAndJndiViewManagedReferenceFactory referenceFactoryService = new MessagingJMSDestinationManagedReferenceFactory(destinationService);
injector.inject(referenceFactoryService);
serviceBuilder.addListener(new LifecycleListener() {
private volatile boolean bound;
public void handleEvent(final ServiceController<?> controller, final LifecycleEvent event) {
switch (event) {
case UP: {
ROOT_LOGGER.boundJndiName(jndiName);
bound = true;
break;
}
case DOWN: {
ROOT_LOGGER.unboundJndiName(jndiName);
if (bound) {
ROOT_LOGGER.unboundJndiName(jndiName);
}
break;
}
case REMOVED: {
31 pom.xml
@@ -173,6 +173,14 @@
<!-- Version suffix that is appended to directories. Default is the maven GAV version but this can be edited to use a short form version -->
<server.output.dir.version>${project.version}</server.output.dir.version>

<!-- Protocol to use for communication with remote maven repositories.
You can set to 'http' if you are using a maven proxy and 'https'
interferes with that. Use 'https' for builds that will be released
to non-snapshot public maven repos -->
<maven.repository.protocol>https</maven.repository.protocol>
<!-- The full remote maven repo URL; can be overridden via -D for special use cases -->
<maven.repository.url>${maven.repository.protocol}://repository.jboss.org/nexus/content/groups/public/</maven.repository.url>

<!-- Surefire args -->
<surefire.extra.args></surefire.extra.args>
<surefire.jpda.args></surefire.jpda.args>
@@ -312,7 +320,7 @@
<version.org.javassist>3.23.1-GA</version.org.javassist>
<version.org.jberet>1.3.3.Final</version.org.jberet>
<version.org.jboss.activemq.artemis.integration>1.0.2</version.org.jboss.activemq.artemis.integration>
<version.org.jboss.arquillian.core>1.1.13.Final</version.org.jboss.arquillian.core>
<version.org.jboss.arquillian.core>1.4.0.Final</version.org.jboss.arquillian.core>
<version.org.jboss.common.jboss-common-beans>2.0.0.Final</version.org.jboss.common.jboss-common-beans>
<version.org.jboss.ejb-client>4.0.16.Final</version.org.jboss.ejb-client>
<version.org.jboss.ejb-client-legacy>3.0.3.Final</version.org.jboss.ejb-client-legacy>
@@ -326,14 +334,14 @@
<version.org.jboss.logmanager.commons-logging-jboss-logmanager>1.0.3.Final</version.org.jboss.logmanager.commons-logging-jboss-logmanager>
<version.org.jboss.metadata>13.0.0.Final</version.org.jboss.metadata>
<version.org.jboss.mod_cluster>1.4.0.Final</version.org.jboss.mod_cluster>
<version.org.jboss.narayana>5.9.3.Final</version.org.jboss.narayana>
<version.org.jboss.narayana>5.9.5.Final</version.org.jboss.narayana>
<version.org.jboss.openjdk-orb>8.1.2.Final</version.org.jboss.openjdk-orb>
<version.org.jboss.resteasy>3.6.3.Final</version.org.jboss.resteasy>
<version.org.jboss.seam.int>7.0.0.GA</version.org.jboss.seam.int>
<version.org.jboss.security.jboss-negotiation>3.0.5.Final</version.org.jboss.security.jboss-negotiation>
<version.org.jboss.security.jbossxacml>2.0.8.Final</version.org.jboss.security.jbossxacml>
<!-- only needed here until wildfly-arquillian has this version properly synced with arquillian itslef -->
<version.org.jboss.shrinkwrap.descriptors>2.0.0-alpha-10</version.org.jboss.shrinkwrap.descriptors>
<version.org.jboss.shrinkwrap.descriptors>2.0.0</version.org.jboss.shrinkwrap.descriptors>
<version.org.jboss.shrinkwrap.shrinkwrap>1.2.6</version.org.jboss.shrinkwrap.shrinkwrap>
<!-- Include the artifactId for org.jboss.spec project versions because artifactId contains the API spec version -->
<version.org.jboss.spec.javax.annotation.jboss-annotations-api_1.3_spec>1.0.1.Final</version.org.jboss.spec.javax.annotation.jboss-annotations-api_1.3_spec>
@@ -375,7 +383,7 @@
<version.org.picketlink>2.5.5.SP12</version.org.picketlink>
<version.org.reactivestreams>1.0.2</version.org.reactivestreams>
<version.org.syslog4j>0.9.30</version.org.syslog4j>
<version.org.wildfly.arquillian>2.1.1.Final</version.org.wildfly.arquillian>
<version.org.wildfly.arquillian>2.2.0.Final</version.org.wildfly.arquillian>
<version.org.wildfly.common>1.4.0.Final</version.org.wildfly.common>
<version.org.wildfly.core>9.0.0.Beta2</version.org.wildfly.core>
<version.org.wildfly.extras.creaper>1.6.1</version.org.wildfly.extras.creaper>
@@ -6653,6 +6661,17 @@
<scope>test</scope>
</dependency>

<!-- Required for the MicroProfile health TCK that is run as part of the testsuite and the TCK brings in an
older version.
It also needs to be a runtime dependency because the shared testsuite requires it.
-->
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-container-test-spi</artifactId>
<version>${version.org.jboss.arquillian.core}</version>
</dependency>

<dependency>
<groupId>org.jboss.logmanager</groupId>
<artifactId>commons-logging-jboss-logmanager</artifactId>
@@ -6711,7 +6730,7 @@
</snapshots>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<url>${maven.repository.url}</url>
<layout>default</layout>
</repository>
</repositories>
@@ -6726,7 +6745,7 @@
</snapshots>
<id>jboss-public-repository-group</id>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
<url>${maven.repository.url}</url>
</pluginRepository>
</pluginRepositories>

@@ -33,7 +33,6 @@

import javax.naming.InitialContext;

import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

@@ -44,7 +43,6 @@
* @author Antti Laisi
*/
@RunWith(Arquillian.class)
@Ignore("WFLY-10340")
public class OpenJPASharedModuleProviderTestCase {

private static final String ARCHIVE_NAME = "openjpa_module_test";
@@ -87,18 +87,14 @@
&lt;/resources&gt;

&lt;dependencies&gt;
&lt;module name="javax.api"/&gt;
&lt;module name="javax.annotation.api"/&gt;
&lt;module name="javax.enterprise.api"/&gt;
&lt;module name="javax.persistence.api"/&gt;
&lt;module name="javax.transaction.api"/&gt;
&lt;module name="javax.validation.api"/&gt;
&lt;module name="javax.xml.bind.api"/&gt;
&lt;module name="org.apache.commons.collections"/&gt;
&lt;module name="org.apache.commons.lang"/&gt;
&lt;module name="org.jboss.as.jpa.spi"/&gt;
&lt;module name="org.jboss.logging"/&gt;
&lt;module name="org.jboss.vfs"/&gt;
&lt;module name="org.jboss.jandex"/&gt;
&lt;/dependencies&gt;
&lt;/module&gt;
@@ -0,0 +1,88 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2019, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.ejb.remote.byreference;


import java.util.logging.Logger;

import javax.ejb.Stateless;

@Stateless
public class HelloBean implements HelloRemote {

private Logger log = Logger.getLogger(this.getClass().getSimpleName().toString());

public TransferReturnValue hello ( TransferParameter param ) throws RemoteByReferenceException {
log.info("hello("+ param +") = Hello " + param );

if(param == null)
throw new RemoteByReferenceException("Param was null");

return new TransferReturnValue ( "Hello " + param );
}

@Override
public SerializableObject helloSerializable(SerializableObject param) throws RemoteByReferenceException {
log.info("helloserializable("+ param +") = Hello " + param );

if(param == null)
throw new RemoteByReferenceException("Param was null");
param.setValue("Bye");

return param;
}

@Override
public NonSerializableObject helloNonSerializable(NonSerializableObject param) throws RemoteByReferenceException {
log.info("helloserializable("+ param +") = Hello " + param );

if(param == null)
throw new RemoteByReferenceException("Param was null");
param.setValue("Bye");

return param;
}

@Override
public SerializableObject helloNonSerializableToSerializable(NonSerializableObject param)
throws RemoteByReferenceException {
log.info("helloserializable("+ param +") = Hello " + param );

if(param == null)
throw new RemoteByReferenceException("Param was null");
param.setValue("Bye");

return new SerializableObject(param.getValue());
}

@Override
public NonSerializableObject helloSerializableToNonSerializable(SerializableObject param)
throws RemoteByReferenceException {
log.info("helloserializable("+ param +") = Hello " + param );

if(param == null)
throw new RemoteByReferenceException("Param was null");
param.setValue("Bye");

return new NonSerializableObject(param.getValue());
}
}
@@ -0,0 +1,39 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2019, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.as.test.integration.ejb.remote.byreference;

import javax.ejb.Remote;

@Remote
public interface HelloRemote {
public TransferReturnValue hello ( TransferParameter param ) throws RemoteByReferenceException;

public SerializableObject helloSerializable ( SerializableObject param ) throws RemoteByReferenceException;

public NonSerializableObject helloNonSerializable(NonSerializableObject param) throws RemoteByReferenceException;

public SerializableObject helloNonSerializableToSerializable(NonSerializableObject param) throws RemoteByReferenceException;

public NonSerializableObject helloSerializableToNonSerializable(SerializableObject param) throws RemoteByReferenceException;
}

@@ -0,0 +1,47 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2019, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.as.test.integration.ejb.remote.byreference;

public class NonSerializableObject {

private String value;

public NonSerializableObject() {
}

public NonSerializableObject(String value) {
this.value = value;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}

public String toString() {
return value;
}
}
@@ -0,0 +1,39 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2019, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.as.test.integration.ejb.remote.byreference;

public class RemoteByReferenceException extends Exception {

private NonSerializableObject nonSerializableObject;

public RemoteByReferenceException() {
super();
nonSerializableObject = new NonSerializableObject("null");
}

public RemoteByReferenceException(String msg) {
super(msg);
nonSerializableObject = new NonSerializableObject(msg);
}
}

@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* Copyright 2019, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* Copyright 2019, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -74,7 +74,8 @@ public void tearDown(final ManagementClient managementClient, final String conta
@Deployment
public static Archive<?> createDeployment() {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, ARCHIVE_NAME + ".jar");
jar.addClasses(StatelessRemoteBean.class, RemoteInterface.class, RemoteInvocationByReferenceTestCaseSetup.class);
jar.addClasses(StatelessRemoteBean.class, RemoteInterface.class, RemoteInvocationByReferenceTestCaseSetup.class, RemoteByReferenceException.class, NonSerializableObject.class,
HelloBean.class, HelloRemote.class, TransferParameter.class, TransferReturnValue.class, SerializableObject.class);
return jar;
}

@@ -96,4 +97,78 @@ public void testPassByReferenceSemanticsOnRemoteInterface() throws Exception {
remote.modifyFirstElementOfArray(array, newValue);
Assert.assertEquals("Invocation on remote interface of an EJB did *not* use pass-by-reference semantics", newValue, array[0]);
}

/**
* Test that invocation on a remote interface of an EJB uses pass-by-reference semantics and the Exception also is pass-by-reference
* @throws Exception
*/
@Test
public void testPassByReferenceObjectAndException() throws Exception {
final HelloRemote remote = lookup(HelloBean.class.getSimpleName(), HelloRemote.class);
// invoke on the remote interface
TransferReturnValue ret = remote.hello(new TransferParameter(this.getClass().getSimpleName()));
Assert.assertEquals("Invocation on remote interface of Hello did *not* use pass-by-reference semantics", ret.getValue(), "Hello " + this.getClass().getSimpleName());

try {
remote.hello(null);
} catch(RemoteByReferenceException he) {
Assert.assertEquals("Invocation on remote interface of an EJB did *not* use pass-by-reference in exception", he.getMessage(), "Param was null");
}
}

@Test
public void testPassByReferenceNonSerializableAndException() throws Exception {
final HelloRemote remote = lookup(HelloBean.class.getSimpleName(), HelloRemote.class);
// invoke on the remote interface
NonSerializableObject ret = remote.helloNonSerializable(new NonSerializableObject("Hello"));
Assert.assertEquals("Invocation on remote interface of Hello did *not* use pass-by-reference semantics", ret.getValue(), "Bye");

try {
remote.helloNonSerializable(null);
} catch(RemoteByReferenceException he) {
Assert.assertEquals("Invocation on remote interface of an EJB did *not* use pass-by-reference in exception", he.getMessage(), "Param was null");
}
}

@Test
public void testPassByReferenceSerializable() throws Exception {
final HelloRemote remote = lookup(HelloBean.class.getSimpleName(), HelloRemote.class);
// invoke on the remote interface
SerializableObject ret = remote.helloSerializable(new SerializableObject("Hello"));
Assert.assertEquals("Invocation on remote interface of Hello did *not* use pass-by-reference semantics", ret.getValue(), "Bye");

try {
remote.helloSerializable(null);
} catch(RemoteByReferenceException he) {
Assert.assertEquals("Invocation on remote interface of an EJB did *not* use pass-by-reference in exception", he.getMessage(), "Param was null");
}
}

@Test
public void testPassByReferenceSerializableToNonSerializable() throws Exception {
final HelloRemote remote = lookup(HelloBean.class.getSimpleName(), HelloRemote.class);
// invoke on the remote interface
NonSerializableObject ret = remote.helloSerializableToNonSerializable(new SerializableObject("Hello"));
Assert.assertEquals("Invocation on remote interface of Hello did *not* use pass-by-reference semantics", ret.getValue(), "Bye");

try {
remote.helloSerializableToNonSerializable(null);
} catch(RemoteByReferenceException he) {
Assert.assertEquals("Invocation on remote interface of an EJB did *not* use pass-by-reference in exception", he.getMessage(), "Param was null");
}
}

@Test
public void testPassByReferenceNonSerializableToSerializable() throws Exception {
final HelloRemote remote = lookup(HelloBean.class.getSimpleName(), HelloRemote.class);
// invoke on the remote interface
SerializableObject ret = remote.helloNonSerializableToSerializable(new NonSerializableObject("Hello"));
Assert.assertEquals("Invocation on remote interface of Hello did *not* use pass-by-reference semantics", ret.getValue(), "Bye");

try {
remote.helloNonSerializableToSerializable(null);
} catch(RemoteByReferenceException he) {
Assert.assertEquals("Invocation on remote interface of an EJB did *not* use pass-by-reference in exception", he.getMessage(), "Param was null");
}
}
}
@@ -0,0 +1,49 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2019, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.as.test.integration.ejb.remote.byreference;

import java.io.Serializable;

public class SerializableObject implements Serializable {

private String value;

public SerializableObject() {
}

public SerializableObject(String value) {
this.value = value;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}

public String toString() {
return value;
}
}
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* Copyright 2019, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -0,0 +1,50 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2019, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.as.test.integration.ejb.remote.byreference;

/**
* A class that does not implement serializable used in pass-by-reference
*/
public class TransferParameter {

private String value;

public TransferParameter() {
}

public TransferParameter( String value ) {
this.value = value;
}

public String getValue() {
return value;
}
public void setValue ( String value ) {
this.value = value;
}

public String toString() {
return value;
}
}

@@ -0,0 +1,49 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2019, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.as.test.integration.ejb.remote.byreference;

/**
* A return value class that does not implement serializable
*/
public class TransferReturnValue {

private String value;

public TransferReturnValue() {
}

public TransferReturnValue( String value ) {
this.value = value;
}

public String getValue() {
return value;
}
public void setValue ( String value ) {
this.value = value;
}

public String getString() {
return value;
}
}
@@ -28,7 +28,6 @@
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
@@ -46,7 +45,6 @@
public static Archive<?> deploy() {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "Jar.jar");
jar.addPackage(TxTimeoutTimerServiceTestCase.class.getPackage());
jar.addAsManifestResource(new StringAsset("Dependencies: org.jboss.jts \n"), "MANIFEST.MF");
return jar;
}

@@ -25,7 +25,6 @@
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -42,9 +41,6 @@
@Deployment
public static Archive<?> createDeployment() {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "test-ejb-cmt-timeout.jar");
// a manifest must have a \n at the end or else it'll not be properly process
// here we hack one in place
jar.addAsManifestResource(new StringAsset("Dependencies: org.jboss.jts \n"), "MANIFEST.MF");
jar.addClass(BeanWithTimeoutValue.class);
jar.addClass(TimeoutRemoteView.class);
jar.addClass(TimeoutLocalView.class);
@@ -27,7 +27,6 @@
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
@@ -41,9 +40,6 @@
@Deployment
public static Archive<?> createDeployment() {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "test-ejb-cmt-timeout.jar");
// a manifest must have a \n at the end or else it'll not be properly process
// here we hack one in place
jar.addAsManifestResource(new StringAsset("Dependencies: org.jboss.jts \n"), "MANIFEST.MF");
jar.addClass(BeanWithTimeoutValue.class);
jar.addClass(TimeoutRemoteView.class);
jar.addClass(TimeoutLocalView.class);
@@ -36,7 +36,7 @@
private static final Logger log = Logger.getLogger(TimerEJBRuntimeNameTestCase.class);
private static final String EJB_TYPE = EJBManagementUtil.SINGLETON;
private static final Package BEAN_PACKAGE = PointLessBean.class.getPackage();
private static final Class BEAN_CLASS = PointlessInterface.class;
private static final Class<?> BEAN_CLASS = PointlessInterface.class;
private static final String BEAN_NAME = "POINT";

private static final String RT_MODULE_NAME = "nooma-nooma6-" + EJB_TYPE;
@@ -21,7 +21,6 @@
*/
package org.jboss.as.test.integration.management.deploy.runtime.ejb.singleton.timer;

import java.util.concurrent.TimeUnit;
import javax.annotation.Resource;
import javax.ejb.Singleton;
import javax.ejb.Timeout;
@@ -35,8 +34,6 @@
@Singleton(name = "POINT")
public class PointLessBean implements PointlessInterface {

private static final int WAIT_TIME = 1;
private static final TimeUnit WAIT_UNIT = TimeUnit.SECONDS;
private static final TimerConfig TIMER_CONFIG = new TimerConfig("Eye Candy", true);

private int count = 0;
@@ -36,9 +36,9 @@
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.AfterClass;
import org.junit.After;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Before;

/**
* @author Ondrej Chaloupka
@@ -49,8 +49,8 @@
protected static final String MODULE_NAME = RemoteEJBClientStatefulFailoverTestBase.class.getSimpleName();
protected static final String MODULE_NAME_SINGLE = MODULE_NAME + "-single";

protected static EJBDirectory singletonDirectory;
protected static EJBDirectory directory;
protected EJBDirectory singletonDirectory;
protected EJBDirectory directory;

protected static Archive<?> createDeploymentSingleton() {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, MODULE_NAME_SINGLE + ".jar");
@@ -69,14 +69,14 @@ public void afterTestMethod() {
undeploy(TWO_DEPLOYMENT_HELPERS);
}

@BeforeClass
public static void beforeClass() throws NamingException {
@Before
public void beforeTest() throws NamingException {
directory = new RemoteEJBDirectory(MODULE_NAME);
singletonDirectory = new RemoteEJBDirectory(MODULE_NAME_SINGLE);
}

@AfterClass
public static void destroy() throws Exception {
@After
public void afterTest() throws Exception {
directory.close();
singletonDirectory.close();
}
@@ -39,9 +39,9 @@
import org.jboss.as.test.clustering.ejb.RemoteEJBDirectory;
import org.jboss.ejb.client.EJBClientContext;
import org.jboss.logging.Logger;
import org.junit.AfterClass;
import org.junit.After;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Before;

/**
* Base class for passivation tests on EJB2 beans.
@@ -52,15 +52,15 @@
private static Logger log = Logger.getLogger(ClusterPassivationTestBase.class);
public static final String MODULE_NAME = ClusterPassivationTestBase.class.getSimpleName();

protected static EJBDirectory directory;
protected EJBDirectory directory;

@BeforeClass
public static void beforeClass() throws NamingException {
@Before
public void beforeTest() throws NamingException {
directory = new RemoteEJBDirectory(MODULE_NAME);
}

@AfterClass
public static void destroy() throws Exception {
@After
public void afterTest() throws Exception {
directory.close();
}

@@ -49,8 +49,9 @@
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.AfterClass;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -64,8 +65,6 @@
@RunWith(Arquillian.class)
public class RemoteStatelessFailoverTestCase {
private static final Logger log = Logger.getLogger(RemoteStatelessFailoverTestCase.class);
private static EJBDirectory directoryAnnotation;
private static EJBDirectory directoryDD;

private static final String MODULE_NAME = RemoteStatelessFailoverTestCase.class.getSimpleName();
private static final String MODULE_NAME_DD = MODULE_NAME + "dd";
@@ -74,11 +73,11 @@
private static final Map<String, Boolean> started = new HashMap<String, Boolean>();
private static final Map<String, List<String>> container2deployment = new HashMap<String, List<String>>();

private EJBDirectory directoryAnnotation;
private EJBDirectory directoryDD;

@BeforeClass
public static void init() throws NamingException {
directoryAnnotation = new RemoteEJBDirectory(MODULE_NAME);
directoryDD = new RemoteEJBDirectory(MODULE_NAME_DD);

deployed.put(DEPLOYMENT_1, false);
deployed.put(DEPLOYMENT_2, false);
deployed.put(DEPLOYMENT_HELPER_1, false);
@@ -96,8 +95,15 @@ public static void init() throws NamingException {
container2deployment.put(NODE_2, deployments2);
}

@AfterClass
public static void destroy() throws Exception {

@Before
public void beforeTest() throws Exception {
directoryAnnotation = new RemoteEJBDirectory(MODULE_NAME);
directoryDD = new RemoteEJBDirectory(MODULE_NAME_DD);
}

@After
public void afterTest() throws Exception {
directoryAnnotation.close();
directoryDD.close();
}
@@ -29,6 +29,7 @@
* @author Paul Ferraro
*/
@ServerSetup(CoarseDatabasePersistenceWebFailoverTestCase.ServerSetupTask.class)
@org.junit.Ignore("Fails intermittently due to ISPN-10029")
public class CoarseDatabasePersistenceWebFailoverTestCase extends AbstractDatabasePersistenceWebFailoverTestCase {

public static class ServerSetupTask extends CLIServerSetupTask {
@@ -29,6 +29,12 @@

/**
* {@link EJBDirectory} that uses remote JNDI.
*
* NOTE:
* if you hold a static reference to this class, it causes any JNDI lookups across different tests to use the same discovered node registry (DNR).
* This can cause server starts and stops in one test to contaminate other tests and produce incorrect results.
* It is adviseable to use one instance per test by defining a @Before and @After method to create and dispose of the instance on a per test basis.
*
* @author Paul Ferraro
*/
public class RemoteEJBDirectory extends NamingEJBDirectory {
@@ -26,6 +26,7 @@
import javax.ws.rs.core.Response;

import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
@@ -86,11 +87,11 @@ public void testCommit() throws Exception {

final JSONArray jsonArray = getInboundBridgeResourceInvocations();

Assert.assertEquals(4, jsonArray.length());
Assert.assertEquals("LoggingXAResource.start", jsonArray.get(0));
Assert.assertEquals("LoggingXAResource.end", jsonArray.get(1));
Assert.assertEquals("LoggingXAResource.prepare", jsonArray.get(2));
Assert.assertEquals("LoggingXAResource.commit", jsonArray.get(3));
assertJsonArray(jsonArray, "LoggingXAResource.start", 1);
assertJsonArray(jsonArray, "LoggingXAResource.end", 1);
assertJsonArray(jsonArray, "LoggingXAResource.prepare", 1);
assertJsonArray(jsonArray, "LoggingXAResource.commit", 1);
assertJsonArray(jsonArray, "LoggingXAResource.rollback", 0);
}

@Test
@@ -101,10 +102,11 @@ public void testRollback() throws Exception {

JSONArray jsonArray = getInboundBridgeResourceInvocations();

Assert.assertEquals(3, jsonArray.length());
Assert.assertEquals("LoggingXAResource.start", jsonArray.get(0));
Assert.assertEquals("LoggingXAResource.end", jsonArray.get(1));
Assert.assertEquals("LoggingXAResource.rollback", jsonArray.get(2));
assertJsonArray(jsonArray, "LoggingXAResource.start", 1);
assertJsonArray(jsonArray, "LoggingXAResource.end", 1);
assertJsonArray(jsonArray, "LoggingXAResource.prepare", 0);
assertJsonArray(jsonArray, "LoggingXAResource.commit", 0);
assertJsonArray(jsonArray, "LoggingXAResource.rollback", 1);
}

@Test
@@ -123,12 +125,11 @@ public void testCommitWithTwoParticipants() throws Exception {
Assert.assertEquals("LoggingRestATResource.terminateParticipant(" + TxStatusMediaType.TX_COMMITTED + ")",
participantResourceInvocations.get(1));

Assert.assertEquals(4, xaResourceInvocations.length());
Assert.assertEquals("LoggingXAResource.start", xaResourceInvocations.get(0));
Assert.assertEquals("LoggingXAResource.end", xaResourceInvocations.get(1));
Assert.assertEquals("LoggingXAResource.prepare", xaResourceInvocations.get(2));
Assert.assertEquals("LoggingXAResource.commit", xaResourceInvocations.get(3));

assertJsonArray(xaResourceInvocations, "LoggingXAResource.start", 1);
assertJsonArray(xaResourceInvocations, "LoggingXAResource.end", 1);
assertJsonArray(xaResourceInvocations, "LoggingXAResource.prepare", 1);
assertJsonArray(xaResourceInvocations, "LoggingXAResource.commit", 1);
assertJsonArray(xaResourceInvocations, "LoggingXAResource.rollback", 0);
}

@Test
@@ -145,10 +146,11 @@ public void testRollbackWithTwoParticipants() throws Exception {
Assert.assertEquals("LoggingRestATResource.terminateParticipant(" + TxStatusMediaType.TX_ROLLEDBACK + ")",
participantResourceInvocations.get(0));

Assert.assertEquals(3, xaResourceInvocations.length());
Assert.assertEquals("LoggingXAResource.start", xaResourceInvocations.get(0));
Assert.assertEquals("LoggingXAResource.end", xaResourceInvocations.get(1));
Assert.assertEquals("LoggingXAResource.rollback", xaResourceInvocations.get(2));
assertJsonArray(xaResourceInvocations, "LoggingXAResource.start", 1);
assertJsonArray(xaResourceInvocations, "LoggingXAResource.end", 1);
assertJsonArray(xaResourceInvocations, "LoggingXAResource.prepare", 0);
assertJsonArray(xaResourceInvocations, "LoggingXAResource.commit", 0);
assertJsonArray(xaResourceInvocations, "LoggingXAResource.rollback", 1);
}

protected String getBaseUrl() {
@@ -192,4 +194,23 @@ private JSONArray getLoggingRestATParticipantInvocations() throws Exception {
return jsonArray;
}

/**
* Checking if the parameter <code>recordToAssert</code>
* is placed exactly once in the {@link JSONArray}.
*/
private void assertJsonArray(JSONArray invocationsJSONArray, String recordToAssert, int expectedRecordFoundCount) throws JSONException {
if(recordToAssert == null) throw new NullPointerException("recordToAssert");
int recordFoundCount = 0;
for(int i = 0; i < invocationsJSONArray.length(); i++) {
if(recordToAssert.equals(invocationsJSONArray.get(i))) {
recordFoundCount++;
}
}
if (recordFoundCount != expectedRecordFoundCount) {
Assert.fail("Invocation result returned as a JSON array '" + invocationsJSONArray + "' "
+ "expected to contain the record '" + recordToAssert + "' " + expectedRecordFoundCount + " times "
+ "but the record was " + recordFoundCount + " times in the array");
}
}

}
@@ -83,6 +83,12 @@
<artifactId>jboss-jaxws-api_2.3_spec</artifactId>
<scope>test</scope>
</dependency>
<!-- ExampleDS used in tests -->
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
@@ -0,0 +1,140 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2018, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.as.test.txbridge.fromjta;

import javax.naming.InitialContext;
import javax.transaction.UserTransaction;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.txbridge.fromjta.service.FirstServiceAT;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

/**
* <p>
* Simple set of starting JTA transaction and getting it bridged to the XTS-AT.
* <p>
* Test ported from https://github.com/jbosstm/quickstart repository.
*/
@RunWith(Arquillian.class)
public class BridgeFromJTATestCase {
private static final Logger log = Logger.getLogger(BridgeFromJTATestCase.class);

private static final String DEPLOYMENT = "fromjta-bridge";
private static final String ManifestMF =
"Manifest-Version: 1.0\nDependencies: org.jboss.xts\n";
private static final String persistentXml =
"<persistence>\n" +
" <persistence-unit name=\"first\">\n" +
" <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>\n" +
" <properties>\n" +
" <property name=\"hibernate.hbm2ddl.auto\" value=\"create-drop\"/>\n" +
" </properties>\n" +
" </persistence-unit>\n" +
"</persistence>";

private UserTransaction ut;
private FirstServiceAT firstClient;

@Deployment(name = DEPLOYMENT)
public static JavaArchive createTestArchive1() {
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, DEPLOYMENT + ".jar")
.addPackages(true, BridgeFromJTATestCase.class.getPackage())
.addAsManifestResource(new StringAsset(ManifestMF), "MANIFEST.MF")
.addAsManifestResource(new StringAsset(persistentXml), "persistence.xml");
return archive;
}

@Before
public void setupTest() throws Exception {
ut = (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction");
firstClient = FirstClient.newInstance();
}

@After
public void teardownTest() throws Exception {
tryRollback(ut);
try {
ut.begin();
firstClient.resetCounter();
ut.commit();
} finally {
tryRollback(ut);
}
}

/**
* Test starts the JTA transaction while calling the 'incrementCounter' on the stub.
* Expecting the interceptor bridges from JTA to WS-AT.
* The commit of the JTA transaction should cause the commit of the WS-AT transaction as well.
*/
@Test
public void testCommit() throws Exception {
ut.begin();
firstClient.incrementCounter(1);
ut.commit();

// second JTA checks if the counter was really incremented
ut.begin();
int counter = firstClient.getCounter();
ut.commit();

Assert.assertEquals("Bridged JTA transaction should commit the WS-AT and the counter is expected to be incremented",
1, counter);
}

/**
* Test starts the JTA transaction while calling the 'incrementCounter' on the stub.
* Expecting the interceptor bridges from JTA to WS-AT.
* The rollback of the JTA transaction should cause the rollback of the WS-AT transaction as well.
*/
@Test
public void testRollback() throws Exception {
ut.begin();
firstClient.incrementCounter(1);
ut.rollback();

// second JTA checks if the counter was not incremented
ut.begin();
int counter = firstClient.getCounter();
ut.commit();

Assert.assertEquals("Asserting that the counters were *not* incremented successfully", 0, counter);
}

private void tryRollback(UserTransaction ut) {
try {
ut.rollback();
} catch (Throwable th2) {
log.trace("Cannot rollback transaction " + ut, th2);
}
}
}
@@ -0,0 +1,45 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2018, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.as.test.txbridge.fromjta;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;

import org.jboss.as.test.txbridge.fromjta.service.FirstServiceAT;

import java.net.URL;

public class FirstClient {

public static FirstServiceAT newInstance() throws Exception {
URL wsdlLocation = new URL("http://localhost:8080/test/FirstServiceATService/FirstServiceAT?wsdl");
QName serviceName = new QName("http://www.jboss.com/jbossas/test/txbridge/fromjta/first", "FirstServiceATService");
QName portName = new QName("http://www.jboss.com/jbossas/test/txbridge/fromjta/first", "FirstServiceAT");

Service service = Service.create(wsdlLocation, serviceName);
FirstServiceAT client = service.getPort(portName, FirstServiceAT.class);

return client;
}
}

@@ -0,0 +1,68 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2018, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.as.test.txbridge.fromjta.service;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.io.Serializable;

/**
* Entity to verify the transaction participant
* is handled correctly when transaction is bridged
* from JTA to WS-AT.
*/
@Entity
public class FirstCounterEntity implements Serializable {
private static final long serialVersionUID = 1L;
private int id;
private int counter;

public FirstCounterEntity() {
}

public FirstCounterEntity(int id, int initialCounterValue) {
this.id = id;
this.counter = initialCounterValue;
}

@Id
public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public int getCounter() {
return counter;
}

public void setCounter(int counter) {
this.counter = counter;
}

public void incrementCounter(int howMany) {
setCounter(getCounter() + howMany);
}
}
@@ -0,0 +1,56 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2018, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.as.test.txbridge.fromjta.service;

import javax.ejb.Remote;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;

/**
* Interface to a simple First. Provides simple methods to manipulate with counter.
*/
@WebService(name = "FirstServiceAT", targetNamespace = "http://www.jboss.com/jbossas/test/txbridge/fromjta/first")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@Remote
public interface FirstServiceAT {

/**
* Create a new booking
*/
@WebMethod
public void incrementCounter(int numSeats);

/**
* Obtain the number of existing bookings
*/
@WebMethod
public int getCounter();

/**
* Reset the booking count to zero
*/
@WebMethod
public void resetCounter();

}
@@ -0,0 +1,88 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2018, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.as.test.txbridge.fromjta.service;

import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.jboss.logging.Logger;

@Stateless
@Remote(FirstServiceAT.class)
@WebService(serviceName = "FirstServiceATService", portName = "FirstServiceAT",
name = "FirstServiceAT", targetNamespace = "http://www.jboss.com/jbossas/test/txbridge/fromjta/first")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public class FirstServiceATImpl implements FirstServiceAT {
private static final Logger log = Logger.getLogger(FirstServiceATImpl.class);
private static final int ENTITY_ID = 1;

@PersistenceContext
protected EntityManager em;

/**
* Increment the first counter. This is done by updating the counter within a JTA transaction.
* The JTA transaction was automatically bridged from the WS-AT transaction.
*/
@WebMethod
public void incrementCounter(int num) {
log.trace("Service invoked to increment the counter by '" + num + "'");
FirstCounterEntity entityFirst = lookupCounterEntity();
entityFirst.incrementCounter(num);
em.merge(entityFirst);
}

@WebMethod
public int getCounter() {
log.trace("Service getCounter was invoked");
FirstCounterEntity firstCounterEntity = lookupCounterEntity();
if (firstCounterEntity == null) {
return -1;
}
return firstCounterEntity.getCounter();
}

@WebMethod
public void resetCounter() {
FirstCounterEntity entityFirst = lookupCounterEntity();
entityFirst.setCounter(0);
em.merge(entityFirst);
}

private FirstCounterEntity lookupCounterEntity() {
FirstCounterEntity entityFirst = em.find(FirstCounterEntity.class, ENTITY_ID);
if (entityFirst == null) {
entityFirst = new FirstCounterEntity(ENTITY_ID, 0);
em.persist(entityFirst);
}
return entityFirst;
}

}
@@ -0,0 +1,84 @@
/*
* JBoss, Home of Professional Open Source.
* Copyright 2018, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/

package org.jboss.as.test.txbridge.fromjta.service;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;

import org.jboss.logging.Logger;

import java.net.MalformedURLException;
import java.net.URL;

/**
* This class was generated by the JAX-WS RI. JAX-WS RI 2.1.6 in JDK 6 Generated source version: 2.1
*/
@WebServiceClient(name = "FirstServiceATService", targetNamespace = "http://www.jboss.com/jbossas/test/txbridge/fromjta/first")
public class FirstServiceATService extends Service {
private static final Logger log = Logger.getLogger(FirstServiceATService.class.getName());

private static final URL FIRSTSERVICEATSERVICE_WSDL_LOCATION;

static {
URL url = null;
try {
URL baseUrl;
baseUrl = FirstServiceATService.class.getResource(".");
url = new URL(baseUrl, "FirstServiceAT.wsdl");
} catch (MalformedURLException e) {
log.warn("Failed to create URL for the wsdl Location: 'FirstServiceAT.wsdl', retrying as a local file", e);
}
FIRSTSERVICEATSERVICE_WSDL_LOCATION = url;
}

public FirstServiceATService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}

public FirstServiceATService() {
super(FIRSTSERVICEATSERVICE_WSDL_LOCATION,
new QName("http://www.jboss.com/jbossas/test/txbridge/fromjta/First", "FirstServiceATService"));
}

@WebEndpoint(name = "FirstServiceAT")
public FirstServiceAT getFirstServiceAT() {
return super.getPort(
new QName("http://www.jboss.com/jbossas/test/txbridge/fromjta/First", "FirstServiceAT"),
FirstServiceAT.class);
}

/**
* @param features A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.
* Supported features not in the <code>features</code> parameter will have their default values.
*/
@WebEndpoint(name = "FirstServiceAT")
public FirstServiceAT getFirstServiceAT(WebServiceFeature... features) {
return super.getPort(
new QName("http://www.jboss.com/jbossas/test/txbridge/fromjta/First", "FirstServiceAT"),
FirstServiceAT.class, features);
}

}
@@ -199,8 +199,28 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<jboss.test.host.slave.jvmhome>${java8.home}</jboss.test.host.slave.jvmhome>
<jboss.test.host.slave.controller.jvmhome>${java8.home}</jboss.test.host.slave.controller.jvmhome>
<jboss.test.legacy.host.java8.home>${java8.home}</jboss.test.legacy.host.java8.home>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>legacy-slave-java11-home</id>
<activation>
<jdk>[12,)</jdk>
<property>
<name>java11.home</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<jboss.test.legacy.host.java11.home>${java11.home}</jboss.test.legacy.host.java11.home>
</systemPropertyVariables>
</configuration>
</plugin>
@@ -87,9 +87,6 @@ static void adjustForVersion(final DomainClient client, final Version.AsVersion

final DomainAdjuster adjuster;
switch (asVersion) {
case EAP_6_2_0:
case EAP_6_3_0:
throw new UnsupportedOperationException();
case EAP_6_4_0:
adjuster = new DomainAdjuster640();
break;
@@ -47,9 +47,6 @@ static void adjustForVersion(final DomainClient client, final Version.AsVersion

final LegacyConfigAdjuster adjuster;
switch (asVersion) {
case EAP_6_2_0:
case EAP_6_3_0:
throw new UnsupportedOperationException();
case EAP_6_4_0:
adjuster = new LegacyConfigAdjuster640();
break;
@@ -68,7 +68,7 @@ protected static MixedDomainTestSupport getSupport(Class<?> testClass) {
return getSupport(testClass, Profile.FULL_HA, false);
}

protected static MixedDomainTestSupport getSupport(Class<?> testClass, boolean withMasterServers) {
protected static MixedDomainTestSupport getSupport(Class<?> testClass, boolean withMasterServers) {
return getSupport(testClass, Profile.FULL_HA, withMasterServers);
}

@@ -79,6 +79,7 @@ protected static MixedDomainTestSupport getSupport(Class<?> testClass, Profile p
}
return support;
}

/**
* Call this from a @BeforeClass method
*
@@ -91,6 +92,7 @@ protected static MixedDomainTestSupport getSupport(Class<?> testClass, String ma
protected static MixedDomainTestSupport getSupport(Class<?> testClass, String masterConfig, boolean adjustDomain, boolean legacyConfig, boolean withMasterServers) {
return getSupport(testClass, masterConfig, null, Profile.FULL_HA, adjustDomain, legacyConfig, withMasterServers);
}

/**
* Call this from a @BeforeClass method
*
@@ -147,7 +149,8 @@ static MixedDomainTestSupport getSupport(Class<?> testClass, String domainConfig
testSupport = MixedDomainTestSupport.create(testClass.getSimpleName(), version);
}
} catch (Exception e) {
throw new RuntimeException(e);
MixedDomainTestSuite.version = null;
throw (e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e));
}
try {
//Start the the domain with adjustments to domain.xml
@@ -43,6 +43,7 @@
import org.jboss.as.test.shared.TimeoutUtil;
import org.jboss.dmr.ModelNode;
import org.junit.Assert;
import org.junit.Assume;


/**
@@ -52,6 +53,12 @@

public static final String STANDARD_DOMAIN_CONFIG = "copied-master-config/domain.xml";
private static final String JBOSS_DOMAIN_SERVER_ARGS = "jboss.domain.server.args";
private static final int TEST_VM_VERSION;

static {
String spec = System.getProperty("java.specification.version");
TEST_VM_VERSION = "1.8".equals(spec) ? 8 : Integer.parseInt(spec);
}

private final Version.AsVersion version;
private final boolean adjustDomain;
@@ -69,6 +76,7 @@ private MixedDomainTestSupport(Version.AsVersion version, String testClass, Stri
this.legacyConfig = legacyConfig;
this.withMasterServers = withMasterServers;
this.profile = profile;
configureSlaveJavaHome();
}

private static WildFlyManagedConfiguration configWithDisabledAsserts(String jbossHome){
@@ -158,6 +166,29 @@ private void startSlaveServer() {
Assert.fail("Slave server-one did not start within " + timeout + " ms");
}

private void configureSlaveJavaHome() {
// Look for properties pointing to a java home to use for the legacy host.
// Look for homes for the max JVM version the host can handle, working back to the min it can handle.
// We could start with the oldest and work forward, but that would likely result in all versions testing
// against the oldest VM. Starting with the newest will increase coverage by increasing the probability
// of different VM versions being used across the overall set of legacy host versions.
String javaHome = null;
for (int i = Math.min(version.getMaxVMVersion(), TEST_VM_VERSION - 1); i >= version.getMinVMVersion() && javaHome == null; i--) {
javaHome = System.getProperty("jboss.test.legacy.host.java" + i + ".home");
}

if (javaHome != null) {
WildFlyManagedConfiguration cfg = getDomainSlaveConfiguration();
cfg.setJavaHome(javaHome);
cfg.setControllerJavaHome(javaHome);
System.out.println("Set legacy host controller to use " + javaHome + " as JAVA_HOME");
} else {
// Ignore the test if the slave cannot run using the current VM version
Assume.assumeTrue(TEST_VM_VERSION <= version.getMaxVMVersion());
Assume.assumeTrue(TEST_VM_VERSION >= version.getMinVMVersion());
}
}

private void startAndAdjust() {

String jbossDomainServerArgsValue = null;
@@ -116,9 +116,7 @@ public void test00001_ServerRunning() throws Exception {

@Test
public void test00002_Versioning() throws Exception {
if (version == Version.AsVersion.EAP_6_2_0
|| version == Version.AsVersion.EAP_7_0_0) {
//6.2.0 (https://issues.jboss.org/browse/WFLY-3228) and
if (version == Version.AsVersion.EAP_7_0_0) {
//7.0.0 (https://issues.jboss.org/browse/WFCORE-401)
// have the slave report back its own version, rather than the one from the DC,
//which is what should happen
@@ -226,10 +224,6 @@ public void test00010_JgroupsTransformers() throws Exception {
*/
@Test
public void test00011_ExampleDSConnection() throws Exception{
if (version == Version.AsVersion.EAP_6_2_0) {
// see: https://issues.jboss.org/browse/WFLY-7792
return;
}
PathAddress exampleDSAddress = PathAddress.pathAddress(PathElement.pathElement(HOST, "slave"),
PathElement.pathElement(RUNNING_SERVER, "server-one"), PathElement.pathElement(SUBSYSTEM, "datasources"),
PathElement.pathElement("data-source", "ExampleDS"));
@@ -21,6 +21,8 @@
*/
package org.jboss.as.test.integration.domain.mixed;

import org.junit.Assume;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -41,12 +43,10 @@
String EAP = "jboss-eap-";

enum AsVersion {
EAP_6_2_0(EAP, 6, 2, 0),
EAP_6_3_0(EAP, 6, 3, 0),
EAP_6_4_0(EAP, 6, 4, 0),
EAP_7_0_0(EAP, 7, 0, 0),
EAP_7_1_0(EAP, 7, 1, 0),
EAP_7_2_0(EAP, 7, 2, 0),
EAP_6_4_0(EAP, 6, 4, 0, 8, 8),
EAP_7_0_0(EAP, 7, 0, 0, 8, 8),
EAP_7_1_0(EAP, 7, 1, 0, 8, 8),
EAP_7_2_0(EAP, 7, 2, 0, 11, 8),
;


@@ -55,14 +55,18 @@
private final int major;
private final int minor;
private final int micro;
private final int maxVM;
private final int minVM;
final String version;

AsVersion(String basename, int major, int minor, int micro){
AsVersion(String basename, int major, int minor, int micro, int maxVM, int minVM){
this.basename = basename;
this.major = major;
this.minor = minor;
this.micro = micro;
this.version = major + "." + minor + "." + micro;
this.maxVM = maxVM;
this.minVM = minVM;
}

public String getBaseName() {
@@ -86,7 +90,7 @@ public String getZipFileName() {
}

public boolean isEAP6Version() {
return (this == EAP_6_2_0 || this == EAP_6_3_0 || this == EAP_6_4_0);
return (this == EAP_6_4_0);
}

public int getMajor() {
@@ -101,6 +105,34 @@ public int getMicro() {
return micro;
}

/**
* Gets the maximum Java version under which a legacy host can properly
* execute tests.
*/
public int getMaxVMVersion() {
return maxVM;
}

/**
* Gets the minimum Java version under which a legacy host can properly
* execute tests.
*/
public int getMinVMVersion() {
return minVM;
}

/**
* Checks whether the current VM version exceeds the maximum version under which a legacy host can properly
* execute tests. The check is disabled if system property "jboss.test.host.slave.jvmhome" is set.
*/
public void assumeMaxVM() {
if (System.getProperty("jboss.test.host.slave.jvmhome") == null) {
String javaSpecVersion = System.getProperty("java.specification.version");
int vm = "1.8".equals(javaSpecVersion) ? 8 : Integer.parseInt(javaSpecVersion);
Assume.assumeFalse(vm > maxVM);
}
}

int compare(int major, int minor) {
if (this.major < major) {
return -1;
@@ -36,6 +36,7 @@

@BeforeClass
public static void initializeDomain() {
Version.AsVersion.EAP_6_4_0.assumeMaxVM();
ElytronOnlyMasterTestSuite.getSupport(ElytronOnlyMaster640TestSuite.class);
}
}