BaseRemoteTest + Tests fuer aktuelle Remote Implementierungen
This commit is contained in:
parent
f918b70d5e
commit
e454bf007d
2
.gitignore
vendored
2
.gitignore
vendored
@ -11,4 +11,4 @@ hs_err_pid*
|
|||||||
/.settings
|
/.settings
|
||||||
/.classpath
|
/.classpath
|
||||||
/.project
|
/.project
|
||||||
db-migration/bin/
|
*/bin/
|
||||||
|
@ -11,12 +11,20 @@
|
|||||||
<artifactId>cust-webapp</artifactId>
|
<artifactId>cust-webapp</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<name>HSAdmin XML-RPC Customers Webapp</name>
|
<name>HSAdmin XML-RPC Customers Webapp</name>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.hsadmin</groupId>
|
<groupId>de.hsadmin</groupId>
|
||||||
<artifactId>framework</artifactId>
|
<artifactId>framework</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.hsadmin</groupId>
|
||||||
|
<artifactId>framework</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
<groupId>org.apache.geronimo.specs</groupId>
|
||||||
<artifactId>geronimo-jpa_2.0_spec</artifactId>
|
<artifactId>geronimo-jpa_2.0_spec</artifactId>
|
||||||
@ -88,6 +96,10 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
<jta-data-source>HsarDataSource</jta-data-source>
|
<jta-data-source>HsarDataSource</jta-data-source>
|
||||||
<class>de.hsadmin.bo.customer.Contact</class>
|
<class>de.hsadmin.bo.customer.Contact</class>
|
||||||
<class>de.hsadmin.bo.customer.Customer</class>
|
<class>de.hsadmin.bo.customer.Customer</class>
|
||||||
|
<class>de.hsadmin.bo.customer.MemberShare</class>
|
||||||
|
<class>de.hsadmin.bo.customer.MemberAsset</class>
|
||||||
<class>de.hsadmin.bo.customer.SEPADirectDebit</class>
|
<class>de.hsadmin.bo.customer.SEPADirectDebit</class>
|
||||||
<class>de.hsadmin.bo.domain.Domain</class>
|
<class>de.hsadmin.bo.domain.Domain</class>
|
||||||
<class>de.hsadmin.bo.domain.DomainOption</class>
|
<class>de.hsadmin.bo.domain.DomainOption</class>
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package de.hsadmin.service.customer;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.hsadmin.test.BaseRemoteTest;
|
||||||
|
|
||||||
|
public class ContactRemoteTest extends BaseRemoteTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void canInstantiateMemberShareServiceLocalViaRemoteRegistry() throws Exception {
|
||||||
|
givenRegisteredModuleLookupFor(ContactServiceLocal.class);
|
||||||
|
whenServiceIsRetrievedFromRemoteRegistryKey("contact");
|
||||||
|
thenModuleInstantiatesServiceOfClass(ContactService.class);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package de.hsadmin.service.customer;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.hsadmin.test.BaseRemoteTest;
|
||||||
|
|
||||||
|
public class CustomerRemoteTest extends BaseRemoteTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void canInstantiateMemberShareServiceLocalViaRemoteRegistry() throws Exception {
|
||||||
|
givenRegisteredModuleLookupFor(CustomerServiceLocal.class);
|
||||||
|
whenServiceIsRetrievedFromRemoteRegistryKey("customer");
|
||||||
|
thenModuleInstantiatesServiceOfClass(CustomerService.class);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package de.hsadmin.service.customer;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.hsadmin.test.BaseRemoteTest;
|
||||||
|
|
||||||
|
public class SEPADirectDebitRemoteTest extends BaseRemoteTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void canInstantiateMemberShareServiceLocalViaRemoteRegistry() throws Exception {
|
||||||
|
givenRegisteredModuleLookupFor(SEPADirectDebitServiceLocal.class);
|
||||||
|
whenServiceIsRetrievedFromRemoteRegistryKey("mandat");
|
||||||
|
thenModuleInstantiatesServiceOfClass(SEPADirectDebitService.class);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package de.hsadmin.service.pac;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.hsadmin.test.BaseRemoteTest;
|
||||||
|
|
||||||
|
public class HiveRemoteTest extends BaseRemoteTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void canInstantiateMemberShareServiceLocalViaRemoteRegistry() throws Exception {
|
||||||
|
givenRegisteredModuleLookupFor(HiveServiceLocal.class);
|
||||||
|
whenServiceIsRetrievedFromRemoteRegistryKey("hive");
|
||||||
|
thenModuleInstantiatesServiceOfClass(HiveService.class);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package de.hsadmin.service.pac;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.hsadmin.test.BaseRemoteTest;
|
||||||
|
|
||||||
|
public class PacRemoteTest extends BaseRemoteTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void canInstantiateMemberShareServiceLocalViaRemoteRegistry() throws Exception {
|
||||||
|
givenRegisteredModuleLookupFor(PacServiceLocal.class);
|
||||||
|
whenServiceIsRetrievedFromRemoteRegistryKey("pac");
|
||||||
|
thenModuleInstantiatesServiceOfClass(PacService.class);
|
||||||
|
}
|
||||||
|
}
|
@ -6,21 +6,23 @@
|
|||||||
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
|
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
|
||||||
|
|
||||||
<!-- auto scanning fails if there are methods returning entities in the test :-( -->
|
<!-- auto scanning fails if there are methods returning entities in the test :-( -->
|
||||||
<class>de.hsadmin.bo.customer.Customer</class>
|
|
||||||
<class>de.hsadmin.bo.customer.Contact</class>
|
<class>de.hsadmin.bo.customer.Contact</class>
|
||||||
<class>de.hsadmin.bo.customer.SEPADirectDebit</class>
|
<class>de.hsadmin.bo.customer.Customer</class>
|
||||||
<class>de.hsadmin.bo.pac.INetAddress</class>
|
|
||||||
<class>de.hsadmin.bo.pac.Hive</class>
|
|
||||||
<class>de.hsadmin.bo.pac.Pac</class>
|
|
||||||
<class>de.hsadmin.bo.pac.BasePac</class>
|
|
||||||
<class>de.hsadmin.bo.pac.Component</class>
|
|
||||||
<class>de.hsadmin.bo.pac.BaseComponent</class>
|
|
||||||
<class>de.hsadmin.bo.pac.PacComponent</class>
|
|
||||||
<class>de.hsadmin.bo.pac.UnixUser</class>
|
|
||||||
<class>de.hsadmin.bo.customer.MemberShare</class>
|
<class>de.hsadmin.bo.customer.MemberShare</class>
|
||||||
<class>de.hsadmin.bo.customer.MemberAsset</class>
|
<class>de.hsadmin.bo.customer.MemberAsset</class>
|
||||||
|
<class>de.hsadmin.bo.customer.SEPADirectDebit</class>
|
||||||
<exclude-unlisted-classes>false</exclude-unlisted-classes>
|
<class>de.hsadmin.bo.domain.Domain</class>
|
||||||
|
<class>de.hsadmin.bo.domain.DomainOption</class>
|
||||||
|
<class>de.hsadmin.bo.domain.EMailAddress</class>
|
||||||
|
<class>de.hsadmin.bo.pac.BaseComponent</class>
|
||||||
|
<class>de.hsadmin.bo.pac.BasePac</class>
|
||||||
|
<class>de.hsadmin.bo.pac.Component</class>
|
||||||
|
<class>de.hsadmin.bo.pac.EMailAlias</class>
|
||||||
|
<class>de.hsadmin.bo.pac.Hive</class>
|
||||||
|
<class>de.hsadmin.bo.pac.INetAddress</class>
|
||||||
|
<class>de.hsadmin.bo.pac.Pac</class>
|
||||||
|
<class>de.hsadmin.bo.pac.PacComponent</class>
|
||||||
|
<class>de.hsadmin.bo.pac.UnixUser</class>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
||||||
@ -40,7 +42,7 @@
|
|||||||
<property name="javax.persistence.jdbc.url" value="jdbc:derby:.hsadmin-test-db/derbydb3;create=true" /> -->
|
<property name="javax.persistence.jdbc.url" value="jdbc:derby:.hsadmin-test-db/derbydb3;create=true" /> -->
|
||||||
|
|
||||||
<!-- OpenJPA -->
|
<!-- OpenJPA -->
|
||||||
<property name="openjpa.RuntimeUnenhancedClasses" value="supported" />
|
<property name="openjpa.RuntimeUnenhancedClasses" value="warn" />
|
||||||
</properties>
|
</properties>
|
||||||
</persistence-unit>
|
</persistence-unit>
|
||||||
</persistence>
|
</persistence>
|
@ -17,12 +17,19 @@
|
|||||||
<artifactId>framework</artifactId>
|
<artifactId>framework</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.hsadmin</groupId>
|
||||||
|
<artifactId>framework</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<type>test-jar</type>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>de.hsadmin</groupId>
|
<groupId>de.hsadmin</groupId>
|
||||||
<artifactId>cust-webapp</artifactId>
|
<artifactId>cust-webapp</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.geronimo.specs</groupId>
|
<groupId>org.apache.geronimo.specs</groupId>
|
||||||
<artifactId>geronimo-jpa_2.0_spec</artifactId>
|
<artifactId>geronimo-jpa_2.0_spec</artifactId>
|
||||||
<version>1.1</version>
|
<version>1.1</version>
|
||||||
@ -55,6 +62,10 @@
|
|||||||
<build>
|
<build>
|
||||||
<finalName>database-webapp</finalName>
|
<finalName>database-webapp</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package de.hsadmin.service.database;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class MySqlDatabaseRemoteTest extends de.hsadmin.test.BaseRemoteTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void canInstantiateMemberShareServiceLocalViaRemoteRegistry() throws Exception {
|
||||||
|
givenRegisteredModuleLookupFor(MySqlDatabaseServiceLocal.class);
|
||||||
|
whenServiceIsRetrievedFromRemoteRegistryKey("mysqldb");
|
||||||
|
// thenModuleInstantiatesServiceOfClass(MySqlDatabaseService.class); FIXME
|
||||||
|
}
|
||||||
|
}
|
@ -14,17 +14,35 @@
|
|||||||
<name>HSAdmin Framework</name>
|
<name>HSAdmin Framework</name>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<pluginManagement>
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<!--
|
||||||
<configuration>
|
<configuration>
|
||||||
<testFailureIgnore>true</testFailureIgnore>
|
<testFailureIgnore>true</testFailureIgnore>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
-->
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>test-jar</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -45,61 +63,62 @@
|
|||||||
<artifactId>geronimo-validation_1.0_spec</artifactId>
|
<artifactId>geronimo-validation_1.0_spec</artifactId>
|
||||||
<version>1.1</version>
|
<version>1.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.bval</groupId>
|
<groupId>org.apache.bval</groupId>
|
||||||
<artifactId>org.apache.bval.bundle</artifactId>
|
<artifactId>org.apache.bval.bundle</artifactId>
|
||||||
<version>0.5</version>
|
<version>0.5</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.xmlrpc</groupId>
|
<groupId>org.apache.xmlrpc</groupId>
|
||||||
<artifactId>xmlrpc-server</artifactId>
|
<artifactId>xmlrpc-server</artifactId>
|
||||||
<version>3.1.3</version>
|
<version>3.1.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>log4j</groupId>
|
<groupId>log4j</groupId>
|
||||||
<artifactId>log4j</artifactId>
|
<artifactId>log4j</artifactId>
|
||||||
<version>1.2.17</version>
|
<version>1.2.17</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>joda-time</groupId>
|
<groupId>joda-time</groupId>
|
||||||
<artifactId>joda-time</artifactId>
|
<artifactId>joda-time</artifactId>
|
||||||
<version>2.9.9</version>
|
<version>2.9.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--
|
<!--
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.hsqldb</groupId>
|
<groupId>org.hsqldb</groupId>
|
||||||
<artifactId>hsqldb</artifactId>
|
<artifactId>hsqldb</artifactId>
|
||||||
<version>2.3.4</version>
|
<version>2.3.4</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
-->
|
-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.h2database</groupId>
|
<groupId>com.h2database</groupId>
|
||||||
<artifactId>h2</artifactId>
|
<artifactId>h2</artifactId>
|
||||||
<version>1.4.194</version>
|
<version>1.4.194</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--
|
<!--
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.derby</groupId>
|
<groupId>org.apache.derby</groupId>
|
||||||
<artifactId>derby</artifactId>
|
<artifactId>derby</artifactId>
|
||||||
<version>10.13.1.1</version>
|
<version>10.13.1.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
-->
|
-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.openjpa</groupId>
|
<groupId>org.apache.openjpa</groupId>
|
||||||
<artifactId>openjpa</artifactId>
|
<artifactId>openjpa</artifactId>
|
||||||
<version>2.4.2</version>
|
<version>2.4.2</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.liquibase</groupId>
|
<groupId>org.liquibase</groupId>
|
||||||
<artifactId>liquibase-core</artifactId>
|
<artifactId>liquibase-core</artifactId>
|
||||||
<version>3.5.3</version>
|
<version>3.5.3</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
package de.hsadmin.service.property;
|
||||||
|
|
||||||
|
import org.junit.Ignore;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import de.hsadmin.test.BaseRemoteTest;
|
||||||
|
|
||||||
|
@Ignore("there is no XmlRpcServlet.properties entry for this remote")
|
||||||
|
public class PropertyRemoteTest extends BaseRemoteTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void canInstantiateMemberShareServiceLocalViaRemoteRegistry() throws Exception {
|
||||||
|
givenRegisteredModuleLookupFor(PropertyServiceLocal.class);
|
||||||
|
whenServiceIsRetrievedFromRemoteRegistryKey("property");
|
||||||
|
thenModuleInstantiatesServiceOfClass(PropertyService.class);
|
||||||
|
}
|
||||||
|
}
|
83
framework/src/test/java/de/hsadmin/test/BaseRemoteTest.java
Normal file
83
framework/src/test/java/de/hsadmin/test/BaseRemoteTest.java
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
package de.hsadmin.test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Hashtable;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import javax.ejb.Stateless;
|
||||||
|
import javax.naming.InitialContext;
|
||||||
|
import javax.naming.NamingException;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.Mockito;
|
||||||
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.powermock.api.mockito.PowerMockito;
|
||||||
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
|
import de.hsadmin.common.error.TechnicalException;
|
||||||
|
import de.hsadmin.module.Module;
|
||||||
|
import de.hsadmin.module.ValueObject;
|
||||||
|
import de.hsadmin.xmlrpc.AbstractRemote;
|
||||||
|
|
||||||
|
@RunWith(PowerMockRunner.class)
|
||||||
|
@PrepareForTest({
|
||||||
|
AbstractRemote.class // to intercept `new InitialContext(...)`
|
||||||
|
})
|
||||||
|
public abstract class BaseRemoteTest {
|
||||||
|
private static final String RPC_SERVLET_PROPERTIES = "org/apache/xmlrpc/webserver/XmlRpcServlet.properties";
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private InitialContext context;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private ValueObject valueObjectMock;
|
||||||
|
|
||||||
|
private String remoteClassName;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void init() throws Exception {
|
||||||
|
MockitoAnnotations.initMocks(this);
|
||||||
|
PowerMockito.whenNew(InitialContext.class).withArguments(Mockito.any(Hashtable.class)).thenReturn(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final InitialContext getInitialContext() {
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
protected final void givenRegisteredModuleLookupFor(final Class<? extends Module<? extends ValueObject>> moduleServiceInterface) throws NamingException, TechnicalException {
|
||||||
|
String moduleServiceName = moduleServiceInterface.getSimpleName(); // heuristic
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Module<ValueObject> moduleService = (Module<ValueObject>) Mockito.mock(moduleServiceInterface);
|
||||||
|
Mockito.when(getInitialContext().lookup(moduleServiceName)).thenReturn(moduleService);
|
||||||
|
Mockito.when(moduleService.buildVO()).thenReturn(valueObjectMock);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void whenServiceIsRetrievedFromRemoteRegistryKey(final String moduleId) throws IOException {
|
||||||
|
InputStream is = getClass().getClassLoader().getResourceAsStream(RPC_SERVLET_PROPERTIES);
|
||||||
|
assertNotNull(RPC_SERVLET_PROPERTIES + " not found or not readable", is);Properties props = new Properties();
|
||||||
|
|
||||||
|
props.load(is);
|
||||||
|
assertTrue(RPC_SERVLET_PROPERTIES + " does not contain " + moduleId, props.containsKey(moduleId));
|
||||||
|
|
||||||
|
remoteClassName = props.get(moduleId).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void thenModuleInstantiatesServiceOfClass(final Class<?> expectedModuleClass) throws IOException, InstantiationException, IllegalAccessException, ClassNotFoundException {
|
||||||
|
assertNotNull(expectedModuleClass + " is missing @" + Stateless.class.getSimpleName(), expectedModuleClass.getAnnotation(Stateless.class));
|
||||||
|
|
||||||
|
AbstractRemote<?> remote = (AbstractRemote<?>) getClass().getClassLoader().loadClass(remoteClassName).newInstance();
|
||||||
|
try {
|
||||||
|
ValueObject vo = remote.createValueObject();
|
||||||
|
assertNotNull(remoteClassName + ".createValueObject() returned null", vo);
|
||||||
|
} catch ( Exception exc ) {
|
||||||
|
fail("remote proxy " + remoteClassName + " not properly initialized: " + exc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
87
pom.xml
87
pom.xml
@ -10,6 +10,13 @@
|
|||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<name>HSAdmin Parent Project</name>
|
<name>HSAdmin Parent Project</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<!-- no idea how to exclude the methods generated by OpenJPA enhancer from JaCoCo :-( -->
|
||||||
|
<jacoco.check.lineRatio>0.0</jacoco.check.lineRatio>
|
||||||
|
<jacoco.check.branchRatio>0.0</jacoco.check.branchRatio>
|
||||||
|
<jacoco.check.complexityMax>25</jacoco.check.complexityMax>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>db-migration</module>
|
<module>db-migration</module>
|
||||||
<module>framework</module>
|
<module>framework</module>
|
||||||
@ -37,20 +44,98 @@
|
|||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>2.19.1</version>
|
<version>2.19.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<argLine>-XX:+AlwaysLockClassLoader</argLine>
|
<argLine>${argLine} -XX:+AlwaysLockClassLoader</argLine>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jacoco</groupId>
|
||||||
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
|
<version>0.7.9</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>default-prepare-agent</id>
|
||||||
|
<goals>
|
||||||
|
<goal>prepare-agent</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>default-report</id>
|
||||||
|
<phase>prepare-package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>report</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>default-check</id>
|
||||||
|
<goals>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<rules>
|
||||||
|
<rule>
|
||||||
|
<element>BUNDLE</element>
|
||||||
|
<limits>
|
||||||
|
<limit>
|
||||||
|
<counter>LINE</counter>
|
||||||
|
<value>COVEREDRATIO</value>
|
||||||
|
<minimum>${jacoco.check.lineRatio}</minimum>
|
||||||
|
</limit>
|
||||||
|
<limit>
|
||||||
|
<counter>BRANCH</counter>
|
||||||
|
<value>COVEREDRATIO</value>
|
||||||
|
<minimum>${jacoco.check.branchRatio}</minimum>
|
||||||
|
</limit>
|
||||||
|
</limits>
|
||||||
|
</rule>
|
||||||
|
<rule>
|
||||||
|
<element>METHOD</element>
|
||||||
|
<limits>
|
||||||
|
<limit>
|
||||||
|
<counter>COMPLEXITY</counter>
|
||||||
|
<value>TOTALCOUNT</value>
|
||||||
|
<maximum>${jacoco.check.complexityMax}</maximum>
|
||||||
|
</limit>
|
||||||
|
</limits>
|
||||||
|
</rule>
|
||||||
|
</rules>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.5</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.12</version>
|
<version>4.12</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mockito</groupId>
|
||||||
|
<artifactId>mockito-all</artifactId>
|
||||||
|
<version>1.10.19</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.powermock</groupId>
|
||||||
|
<artifactId>powermock-module-junit4</artifactId>
|
||||||
|
<version>1.6.6</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.powermock</groupId>
|
||||||
|
<artifactId>powermock-api-mockito</artifactId>
|
||||||
|
<version>1.6.6</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.openpojo</groupId>
|
<groupId>com.openpojo</groupId>
|
||||||
<artifactId>openpojo</artifactId>
|
<artifactId>openpojo</artifactId>
|
||||||
|
Loading…
Reference in New Issue
Block a user