You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by an...@apache.org on 2015/12/09 17:37:17 UTC
[08/18] tomee git commit: EOL
http://git-wip-us.apache.org/repos/asf/tomee/blob/48c99a5a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/DynamicDataSourceTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/DynamicDataSourceTest.java b/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/DynamicDataSourceTest.java
index f4f8efe..8b03d45 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/DynamicDataSourceTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/DynamicDataSourceTest.java
@@ -1,329 +1,329 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.openejb.resource.jdbc;
-
-import org.apache.openejb.OpenEJB;
-import org.apache.openejb.assembler.classic.Assembler;
-import org.apache.openejb.assembler.classic.ProxyFactoryInfo;
-import org.apache.openejb.assembler.classic.ResourceInfo;
-import org.apache.openejb.assembler.classic.SecurityServiceInfo;
-import org.apache.openejb.assembler.classic.StatelessSessionContainerInfo;
-import org.apache.openejb.assembler.classic.TransactionServiceInfo;
-import org.apache.openejb.config.AppModule;
-import org.apache.openejb.config.ConfigurationFactory;
-import org.apache.openejb.config.EjbModule;
-import org.apache.openejb.config.PersistenceModule;
-import org.apache.openejb.config.sys.Resource;
-import org.apache.openejb.core.LocalInitialContextFactory;
-import org.apache.openejb.jee.EjbJar;
-import org.apache.openejb.jee.StatelessBean;
-import org.apache.openejb.jee.jpa.unit.Persistence;
-import org.apache.openejb.jee.jpa.unit.PersistenceUnit;
-import org.apache.openejb.jee.jpa.unit.TransactionType;
-import org.apache.openejb.loader.SystemInstance;
-import org.apache.openejb.resource.jdbc.router.Router;
-import org.apache.openejb.spi.ContainerSystem;
-import org.junit.After;
-import org.junit.Test;
-
-import javax.ejb.Local;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-import javax.ejb.TransactionAttributeType;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.persistence.Entity;
-import javax.persistence.EntityManager;
-import javax.persistence.Id;
-import javax.persistence.PersistenceContext;
-import javax.sql.DataSource;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.Statement;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.ConcurrentHashMap;
-
-import static org.junit.Assert.assertEquals;
-
-public class DynamicDataSourceTest {
-
- @After
- public void tearDown() throws Exception {
- OpenEJB.destroy();
- }
-
- @Test
- public void route() throws Exception {
- System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
-
- final ConfigurationFactory config = new ConfigurationFactory();
-
- final Assembler assembler = new Assembler();
- assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
- assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
- assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
-
- // resources
- for (int i = 1; i <= 3; i++) {
- final String dbName = "database" + i;
- final Resource resourceDs = new Resource(dbName, "DataSource");
- final Properties p = resourceDs.getProperties();
- p.put("JdbcDriver", "org.hsqldb.jdbcDriver");
- p.put("JdbcUrl", "jdbc:hsqldb:mem:db" + i);
- p.put("UserName", "sa");
- p.put("Password", "");
- p.put("JtaManaged", "true");
- assembler.createResource(config.configureService(resourceDs, ResourceInfo.class));
- }
- final Resource resourceRouter = new Resource("My Router", "org.apache.openejb.router.test.DynamicDataSourceTest$DeterminedRouter", "org.router:DeterminedRouter");
- resourceRouter.getProperties().setProperty("DatasourceNames", "database1 database2 database3");
- resourceRouter.getProperties().setProperty("DefaultDataSourceName", "database1");
- assembler.createResource(config.configureService(resourceRouter, ResourceInfo.class));
-
- final Resource resourceRoutedDs = new Resource("Routed Datasource", "org.apache.openejb.resource.jdbc.Router", "RoutedDataSource");
- resourceRoutedDs.getProperties().setProperty("Router", "My Router");
- assembler.createResource(config.configureService(resourceRoutedDs, ResourceInfo.class));
-
- // containers
- final StatelessSessionContainerInfo statelessContainerInfo = config.configureService(StatelessSessionContainerInfo.class);
- assembler.createContainer(statelessContainerInfo);
-
- final EjbJar ejbJar = new EjbJar();
- ejbJar.addEnterpriseBean(new StatelessBean(RoutedEJBBean.class));
- ejbJar.addEnterpriseBean(new StatelessBean(UtilityBean.class));
-
- final EjbModule ejbModule = new EjbModule(ejbJar);
-
- // Create an "ear"
- final AppModule appModule = new AppModule(ejbModule.getClassLoader(), "test-dynamic-data-source");
- appModule.getEjbModules().add(ejbModule);
-
- // Create a persistence-units
- final PersistenceUnit unit = new PersistenceUnit("router");
- unit.addClass(Person.class);
- unit.getProperties().put("openjpa.jdbc.SynchronizeMappings", "buildSchema");
- unit.setTransactionType(TransactionType.JTA);
- unit.setJtaDataSource("Routed Datasource");
- appModule.addPersistenceModule(new PersistenceModule("root", new Persistence(unit)));
- for (int i = 1; i <= 3; i++) {
- final PersistenceUnit u = new PersistenceUnit("db" + i);
- u.addClass(Person.class);
- u.getProperties().put("openjpa.jdbc.SynchronizeMappings", "buildSchema");
- u.setTransactionType(TransactionType.JTA);
- u.setJtaDataSource("database" + i);
- appModule.addPersistenceModule(new PersistenceModule("root", new Persistence(u)));
- }
-
- assembler.createApplication(config.configureApplication(appModule));
-
- // context
- final Context ctx = new InitialContext();
-
- // running persist on all "routed" databases
- final List<String> databases = new ArrayList<String>();
- databases.add("database1");
- databases.add("database2");
- databases.add("database3");
-
- // convinient bean to create tables for each persistence unit
- final Utility utility = (Utility) ctx.lookup("UtilityBeanLocal");
- utility.initDatabase();
-
- final RoutedEJB ejb = (RoutedEJB) ctx.lookup("RoutedEJBBeanLocal");
- for (int i = 0; i < 18; i++) {
- final String name = "record " + i;
- final String db = databases.get(i % 3);
- ejb.persist(i, name, db);
- }
-
- // assert database records number using jdbc
- for (int i = 1; i <= 3; i++) {
- final Connection connection = DriverManager.getConnection("jdbc:hsqldb:mem:db" + i, "sa", "");
- final Statement st = connection.createStatement();
- final ResultSet rs = st.executeQuery("select count(*) from \"DynamicDataSourceTest$Person\"");
- rs.next();
- assertEquals(6, rs.getInt(1));
- st.close();
- connection.close();
- }
- }
-
- @Stateless
- @Local(RoutedEJB.class)
- public static class RoutedEJBBean implements RoutedEJB {
- @PersistenceContext(unitName = "router")
- private EntityManager em;
-
- @javax.annotation.Resource(name = "My Router", type = DeterminedRouter.class)
- private DeterminedRouter router;
-
- public void persist(final int id, final String name, final String ds) {
- router.setDataSource(ds);
- em.persist(new Person(id, name));
- }
-
- }
-
- @Stateless
- @Local(Utility.class)
- public static class UtilityBean implements Utility {
-
- @PersistenceContext(unitName = "db1")
- private EntityManager em1;
- @PersistenceContext(unitName = "db2")
- private EntityManager em2;
- @PersistenceContext(unitName = "db3")
- private EntityManager em3;
-
- @TransactionAttribute(TransactionAttributeType.SUPPORTS)
- public void initDatabase() {
- em1.find(Person.class, 0);
- em2.find(Person.class, 0);
- em3.find(Person.class, 0);
- }
- }
-
- public static interface RoutedEJB {
- void persist(int id, String name, String ds);
- }
-
- public static interface Utility {
- void initDatabase();
- }
-
- @Entity
- public static class Person {
- @Id
- private long id;
- private String name;
-
- public Person() {
- // no-op
- }
-
- public Person(final int i, final String n) {
- id = i;
- name = n;
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(final long id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(final String name) {
- this.name = name;
- }
- }
-
- public static class DeterminedRouter implements Router {
- private String dataSourceNames;
- private String defaultDataSourceName;
- private Map<String, DataSource> dataSources = null;
- private final ThreadLocal<DataSource> currentDataSource = new ThreadLocal<DataSource>();
-
- /**
- * @param datasourceList datasource resource name, separator is a space
- */
- public void setDataSourceNames(final String datasourceList) {
- dataSourceNames = datasourceList;
- }
-
- /**
- * lookup datasource in openejb resources
- */
- private void init() {
- dataSources = new ConcurrentHashMap<String, DataSource>();
- for (final String ds : dataSourceNames.split(" ")) {
- final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
-
- Object o = null;
- final Context ctx = containerSystem.getJNDIContext();
- try {
- o = ctx.lookup("openejb:Resource/" + ds);
- if (o instanceof DataSource) {
- dataSources.put(ds, (DataSource) o);
- }
- } catch (final NamingException e) {
- }
- }
- }
-
- /**
- * @return the user selected data source if it is set
- * or the default one
- * @throws IllegalArgumentException if the data source is not found
- */
- public DataSource getDataSource() {
- // lazy init of routed datasources
- if (dataSources == null) {
- init();
- }
-
- // if no datasource is selected use the default one
- if (currentDataSource.get() == null) {
- if (dataSources.containsKey(defaultDataSourceName)) {
- return dataSources.get(defaultDataSourceName);
-
- } else {
- throw new IllegalArgumentException("you have to specify at least one datasource");
- }
- }
-
- // the developper set the datasource to use
- return currentDataSource.get();
- }
-
- /**
- * @param datasourceName data source name
- */
- public void setDataSource(final String datasourceName) {
- if (dataSources == null) {
- init();
- }
- if (!dataSources.containsKey(datasourceName)) {
- throw new IllegalArgumentException("data source called " + datasourceName + " can't be found.");
- }
- final DataSource ds = dataSources.get(datasourceName);
- currentDataSource.set(ds);
- }
-
- /**
- * reset the data source
- */
- public void clear() {
- currentDataSource.remove();
- }
-
- public void setDefaultDataSourceName(final String name) {
- this.defaultDataSourceName = name;
- }
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.resource.jdbc;
+
+import org.apache.openejb.OpenEJB;
+import org.apache.openejb.assembler.classic.Assembler;
+import org.apache.openejb.assembler.classic.ProxyFactoryInfo;
+import org.apache.openejb.assembler.classic.ResourceInfo;
+import org.apache.openejb.assembler.classic.SecurityServiceInfo;
+import org.apache.openejb.assembler.classic.StatelessSessionContainerInfo;
+import org.apache.openejb.assembler.classic.TransactionServiceInfo;
+import org.apache.openejb.config.AppModule;
+import org.apache.openejb.config.ConfigurationFactory;
+import org.apache.openejb.config.EjbModule;
+import org.apache.openejb.config.PersistenceModule;
+import org.apache.openejb.config.sys.Resource;
+import org.apache.openejb.core.LocalInitialContextFactory;
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.StatelessBean;
+import org.apache.openejb.jee.jpa.unit.Persistence;
+import org.apache.openejb.jee.jpa.unit.PersistenceUnit;
+import org.apache.openejb.jee.jpa.unit.TransactionType;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.resource.jdbc.router.Router;
+import org.apache.openejb.spi.ContainerSystem;
+import org.junit.After;
+import org.junit.Test;
+
+import javax.ejb.Local;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.persistence.Entity;
+import javax.persistence.EntityManager;
+import javax.persistence.Id;
+import javax.persistence.PersistenceContext;
+import javax.sql.DataSource;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static org.junit.Assert.assertEquals;
+
+public class DynamicDataSourceTest {
+
+ @After
+ public void tearDown() throws Exception {
+ OpenEJB.destroy();
+ }
+
+ @Test
+ public void route() throws Exception {
+ System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName());
+
+ final ConfigurationFactory config = new ConfigurationFactory();
+
+ final Assembler assembler = new Assembler();
+ assembler.createProxyFactory(config.configureService(ProxyFactoryInfo.class));
+ assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class));
+ assembler.createSecurityService(config.configureService(SecurityServiceInfo.class));
+
+ // resources
+ for (int i = 1; i <= 3; i++) {
+ final String dbName = "database" + i;
+ final Resource resourceDs = new Resource(dbName, "DataSource");
+ final Properties p = resourceDs.getProperties();
+ p.put("JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("JdbcUrl", "jdbc:hsqldb:mem:db" + i);
+ p.put("UserName", "sa");
+ p.put("Password", "");
+ p.put("JtaManaged", "true");
+ assembler.createResource(config.configureService(resourceDs, ResourceInfo.class));
+ }
+ final Resource resourceRouter = new Resource("My Router", "org.apache.openejb.router.test.DynamicDataSourceTest$DeterminedRouter", "org.router:DeterminedRouter");
+ resourceRouter.getProperties().setProperty("DatasourceNames", "database1 database2 database3");
+ resourceRouter.getProperties().setProperty("DefaultDataSourceName", "database1");
+ assembler.createResource(config.configureService(resourceRouter, ResourceInfo.class));
+
+ final Resource resourceRoutedDs = new Resource("Routed Datasource", "org.apache.openejb.resource.jdbc.Router", "RoutedDataSource");
+ resourceRoutedDs.getProperties().setProperty("Router", "My Router");
+ assembler.createResource(config.configureService(resourceRoutedDs, ResourceInfo.class));
+
+ // containers
+ final StatelessSessionContainerInfo statelessContainerInfo = config.configureService(StatelessSessionContainerInfo.class);
+ assembler.createContainer(statelessContainerInfo);
+
+ final EjbJar ejbJar = new EjbJar();
+ ejbJar.addEnterpriseBean(new StatelessBean(RoutedEJBBean.class));
+ ejbJar.addEnterpriseBean(new StatelessBean(UtilityBean.class));
+
+ final EjbModule ejbModule = new EjbModule(ejbJar);
+
+ // Create an "ear"
+ final AppModule appModule = new AppModule(ejbModule.getClassLoader(), "test-dynamic-data-source");
+ appModule.getEjbModules().add(ejbModule);
+
+ // Create a persistence-units
+ final PersistenceUnit unit = new PersistenceUnit("router");
+ unit.addClass(Person.class);
+ unit.getProperties().put("openjpa.jdbc.SynchronizeMappings", "buildSchema");
+ unit.setTransactionType(TransactionType.JTA);
+ unit.setJtaDataSource("Routed Datasource");
+ appModule.addPersistenceModule(new PersistenceModule("root", new Persistence(unit)));
+ for (int i = 1; i <= 3; i++) {
+ final PersistenceUnit u = new PersistenceUnit("db" + i);
+ u.addClass(Person.class);
+ u.getProperties().put("openjpa.jdbc.SynchronizeMappings", "buildSchema");
+ u.setTransactionType(TransactionType.JTA);
+ u.setJtaDataSource("database" + i);
+ appModule.addPersistenceModule(new PersistenceModule("root", new Persistence(u)));
+ }
+
+ assembler.createApplication(config.configureApplication(appModule));
+
+ // context
+ final Context ctx = new InitialContext();
+
+ // running persist on all "routed" databases
+ final List<String> databases = new ArrayList<String>();
+ databases.add("database1");
+ databases.add("database2");
+ databases.add("database3");
+
+ // convinient bean to create tables for each persistence unit
+ final Utility utility = (Utility) ctx.lookup("UtilityBeanLocal");
+ utility.initDatabase();
+
+ final RoutedEJB ejb = (RoutedEJB) ctx.lookup("RoutedEJBBeanLocal");
+ for (int i = 0; i < 18; i++) {
+ final String name = "record " + i;
+ final String db = databases.get(i % 3);
+ ejb.persist(i, name, db);
+ }
+
+ // assert database records number using jdbc
+ for (int i = 1; i <= 3; i++) {
+ final Connection connection = DriverManager.getConnection("jdbc:hsqldb:mem:db" + i, "sa", "");
+ final Statement st = connection.createStatement();
+ final ResultSet rs = st.executeQuery("select count(*) from \"DynamicDataSourceTest$Person\"");
+ rs.next();
+ assertEquals(6, rs.getInt(1));
+ st.close();
+ connection.close();
+ }
+ }
+
+ @Stateless
+ @Local(RoutedEJB.class)
+ public static class RoutedEJBBean implements RoutedEJB {
+ @PersistenceContext(unitName = "router")
+ private EntityManager em;
+
+ @javax.annotation.Resource(name = "My Router", type = DeterminedRouter.class)
+ private DeterminedRouter router;
+
+ public void persist(final int id, final String name, final String ds) {
+ router.setDataSource(ds);
+ em.persist(new Person(id, name));
+ }
+
+ }
+
+ @Stateless
+ @Local(Utility.class)
+ public static class UtilityBean implements Utility {
+
+ @PersistenceContext(unitName = "db1")
+ private EntityManager em1;
+ @PersistenceContext(unitName = "db2")
+ private EntityManager em2;
+ @PersistenceContext(unitName = "db3")
+ private EntityManager em3;
+
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public void initDatabase() {
+ em1.find(Person.class, 0);
+ em2.find(Person.class, 0);
+ em3.find(Person.class, 0);
+ }
+ }
+
+ public static interface RoutedEJB {
+ void persist(int id, String name, String ds);
+ }
+
+ public static interface Utility {
+ void initDatabase();
+ }
+
+ @Entity
+ public static class Person {
+ @Id
+ private long id;
+ private String name;
+
+ public Person() {
+ // no-op
+ }
+
+ public Person(final int i, final String n) {
+ id = i;
+ name = n;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(final long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+ }
+
+ public static class DeterminedRouter implements Router {
+ private String dataSourceNames;
+ private String defaultDataSourceName;
+ private Map<String, DataSource> dataSources = null;
+ private final ThreadLocal<DataSource> currentDataSource = new ThreadLocal<DataSource>();
+
+ /**
+ * @param datasourceList datasource resource name, separator is a space
+ */
+ public void setDataSourceNames(final String datasourceList) {
+ dataSourceNames = datasourceList;
+ }
+
+ /**
+ * lookup datasource in openejb resources
+ */
+ private void init() {
+ dataSources = new ConcurrentHashMap<String, DataSource>();
+ for (final String ds : dataSourceNames.split(" ")) {
+ final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class);
+
+ Object o = null;
+ final Context ctx = containerSystem.getJNDIContext();
+ try {
+ o = ctx.lookup("openejb:Resource/" + ds);
+ if (o instanceof DataSource) {
+ dataSources.put(ds, (DataSource) o);
+ }
+ } catch (final NamingException e) {
+ }
+ }
+ }
+
+ /**
+ * @return the user selected data source if it is set
+ * or the default one
+ * @throws IllegalArgumentException if the data source is not found
+ */
+ public DataSource getDataSource() {
+ // lazy init of routed datasources
+ if (dataSources == null) {
+ init();
+ }
+
+ // if no datasource is selected use the default one
+ if (currentDataSource.get() == null) {
+ if (dataSources.containsKey(defaultDataSourceName)) {
+ return dataSources.get(defaultDataSourceName);
+
+ } else {
+ throw new IllegalArgumentException("you have to specify at least one datasource");
+ }
+ }
+
+ // the developper set the datasource to use
+ return currentDataSource.get();
+ }
+
+ /**
+ * @param datasourceName data source name
+ */
+ public void setDataSource(final String datasourceName) {
+ if (dataSources == null) {
+ init();
+ }
+ if (!dataSources.containsKey(datasourceName)) {
+ throw new IllegalArgumentException("data source called " + datasourceName + " can't be found.");
+ }
+ final DataSource ds = dataSources.get(datasourceName);
+ currentDataSource.set(ds);
+ }
+
+ /**
+ * reset the data source
+ */
+ public void clear() {
+ currentDataSource.remove();
+ }
+
+ public void setDefaultDataSourceName(final String name) {
+ this.defaultDataSourceName = name;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/48c99a5a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/driver/AlternateDriverJarTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/driver/AlternateDriverJarTest.java b/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/driver/AlternateDriverJarTest.java
index 600a81e..f0b4758 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/driver/AlternateDriverJarTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/resource/jdbc/driver/AlternateDriverJarTest.java
@@ -1,130 +1,130 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.openejb.resource.jdbc.driver;
-
-import org.apache.openejb.jee.EjbJar;
-import org.apache.openejb.jee.SingletonBean;
-import org.apache.openejb.junit.ApplicationComposer;
-import org.apache.openejb.testing.Configuration;
-import org.apache.openejb.testing.Module;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import javax.annotation.Resource;
-import javax.ejb.EJB;
-import javax.ejb.LocalBean;
-import javax.ejb.Singleton;
-import javax.sql.DataSource;
-import java.io.File;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.util.Properties;
-
-@RunWith(ApplicationComposer.class)
-public class AlternateDriverJarTest {
-
- private static final String USER = "SA";
- private static final String PASSWORD = "";
-
- @Configuration
- public Properties config() {
-
- final File drivers = new File(new File(System.getProperty("openejb.home")).getParentFile(), "drivers").getAbsoluteFile();
-
- final Properties p = new Properties();
- p.put("openejb.jdbc.datasource-creator", "dbcp-alternative");
-
- File file = new File(drivers, "derby-10.10.1.1.jar");
- Assert.assertTrue("Failed to find: " + file, file.exists());
-
- p.put("JdbcOne", "new://Resource?type=DataSource&classpath="
- + file.getAbsolutePath().replace("\\", "/"));
- p.put("JdbcOne.JdbcDriver", "org.apache.derby.jdbc.EmbeddedDriver");
- p.put("JdbcOne.JdbcUrl", "jdbc:derby:memory:JdbcOne;create=true");
- p.put("JdbcOne.UserName", USER);
- p.put("JdbcOne.Password", PASSWORD);
- p.put("JdbcOne.JtaManaged", "false");
-
- file = new File(drivers, "derby-10.9.1.0.jar");
- Assert.assertTrue("Failed to find: " + file, file.exists());
-
- p.put("JdbcTwo", "new://Resource?type=DataSource&classpath="
- + file.getAbsolutePath().replace("\\", "/"));
- p.put("JdbcTwo.JdbcDriver", "org.apache.derby.jdbc.EmbeddedDriver");
- p.put("JdbcTwo.JdbcUrl", "jdbc:derby:memory:JdbcTwo;create=true");
- p.put("JdbcTwo.UserName", USER);
- p.put("JdbcTwo.Password", PASSWORD);
- p.put("JdbcTwo.JtaManaged", "false");
- return p;
- }
-
- @Module
- public EjbJar app() throws Exception {
- return new EjbJar()
- .enterpriseBean(new SingletonBean(JdbcOne.class).localBean())
- .enterpriseBean(new SingletonBean(JdbcTwo.class).localBean());
- }
-
- @EJB
- private JdbcOne one;
-
- @EJB
- private JdbcTwo two;
-
- @Test
- public void testBoth() throws Exception {
-
- final String oneDriverVersion = one.getDriverVersion();
- System.out.println("oneDriverVersion = " + oneDriverVersion);
- Assert.assertEquals("Should be using 10.10.1.1 - (1458268)", "10.10.1.1 - (1458268)", oneDriverVersion);
-
- final String twoDriverVersion = two.getDriverVersion();
- System.out.println("twoDriverVersion = " + twoDriverVersion);
- Assert.assertEquals("Should be using 10.9.1.0 - (1344872)", "10.9.1.0 - (1344872)", twoDriverVersion);
- }
-
- @LocalBean
- @Singleton
- public static class JdbcOne {
-
- @Resource(name = "JdbcOne")
- private DataSource ds;
-
- public String getDriverVersion() throws Exception {
-
- final Connection con = ds.getConnection();
- final DatabaseMetaData md = con.getMetaData();
- return md.getDriverVersion();
- }
- }
-
- @LocalBean
- @Singleton
- public static class JdbcTwo {
-
- @Resource(name = "JdbcTwo")
- private DataSource ds;
-
- public String getDriverVersion() throws Exception {
-
- final Connection con = ds.getConnection();
- final DatabaseMetaData md = con.getMetaData();
- return md.getDriverVersion();
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.resource.jdbc.driver;
+
+import org.apache.openejb.jee.EjbJar;
+import org.apache.openejb.jee.SingletonBean;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Configuration;
+import org.apache.openejb.testing.Module;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.ejb.LocalBean;
+import javax.ejb.Singleton;
+import javax.sql.DataSource;
+import java.io.File;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.util.Properties;
+
+@RunWith(ApplicationComposer.class)
+public class AlternateDriverJarTest {
+
+ private static final String USER = "SA";
+ private static final String PASSWORD = "";
+
+ @Configuration
+ public Properties config() {
+
+ final File drivers = new File(new File(System.getProperty("openejb.home")).getParentFile(), "drivers").getAbsoluteFile();
+
+ final Properties p = new Properties();
+ p.put("openejb.jdbc.datasource-creator", "dbcp-alternative");
+
+ File file = new File(drivers, "derby-10.10.1.1.jar");
+ Assert.assertTrue("Failed to find: " + file, file.exists());
+
+ p.put("JdbcOne", "new://Resource?type=DataSource&classpath="
+ + file.getAbsolutePath().replace("\\", "/"));
+ p.put("JdbcOne.JdbcDriver", "org.apache.derby.jdbc.EmbeddedDriver");
+ p.put("JdbcOne.JdbcUrl", "jdbc:derby:memory:JdbcOne;create=true");
+ p.put("JdbcOne.UserName", USER);
+ p.put("JdbcOne.Password", PASSWORD);
+ p.put("JdbcOne.JtaManaged", "false");
+
+ file = new File(drivers, "derby-10.9.1.0.jar");
+ Assert.assertTrue("Failed to find: " + file, file.exists());
+
+ p.put("JdbcTwo", "new://Resource?type=DataSource&classpath="
+ + file.getAbsolutePath().replace("\\", "/"));
+ p.put("JdbcTwo.JdbcDriver", "org.apache.derby.jdbc.EmbeddedDriver");
+ p.put("JdbcTwo.JdbcUrl", "jdbc:derby:memory:JdbcTwo;create=true");
+ p.put("JdbcTwo.UserName", USER);
+ p.put("JdbcTwo.Password", PASSWORD);
+ p.put("JdbcTwo.JtaManaged", "false");
+ return p;
+ }
+
+ @Module
+ public EjbJar app() throws Exception {
+ return new EjbJar()
+ .enterpriseBean(new SingletonBean(JdbcOne.class).localBean())
+ .enterpriseBean(new SingletonBean(JdbcTwo.class).localBean());
+ }
+
+ @EJB
+ private JdbcOne one;
+
+ @EJB
+ private JdbcTwo two;
+
+ @Test
+ public void testBoth() throws Exception {
+
+ final String oneDriverVersion = one.getDriverVersion();
+ System.out.println("oneDriverVersion = " + oneDriverVersion);
+ Assert.assertEquals("Should be using 10.10.1.1 - (1458268)", "10.10.1.1 - (1458268)", oneDriverVersion);
+
+ final String twoDriverVersion = two.getDriverVersion();
+ System.out.println("twoDriverVersion = " + twoDriverVersion);
+ Assert.assertEquals("Should be using 10.9.1.0 - (1344872)", "10.9.1.0 - (1344872)", twoDriverVersion);
+ }
+
+ @LocalBean
+ @Singleton
+ public static class JdbcOne {
+
+ @Resource(name = "JdbcOne")
+ private DataSource ds;
+
+ public String getDriverVersion() throws Exception {
+
+ final Connection con = ds.getConnection();
+ final DatabaseMetaData md = con.getMetaData();
+ return md.getDriverVersion();
+ }
+ }
+
+ @LocalBean
+ @Singleton
+ public static class JdbcTwo {
+
+ @Resource(name = "JdbcTwo")
+ private DataSource ds;
+
+ public String getDriverVersion() throws Exception {
+
+ final Connection con = ds.getConnection();
+ final DatabaseMetaData md = con.getMetaData();
+ return md.getDriverVersion();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/48c99a5a/container/openejb-core/src/test/java/org/apache/openejb/test/annotated/Green.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/test/annotated/Green.java b/container/openejb-core/src/test/java/org/apache/openejb/test/annotated/Green.java
index 7e22c15..9333805 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/test/annotated/Green.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/test/annotated/Green.java
@@ -1,33 +1,33 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.openejb.test.annotated;
-
-import javax.ejb.Stateful;
-import javax.interceptor.AroundInvoke;
-import javax.jws.WebService;
-
-
-@Stateful(description = "test")
-@WebService
-public class Green {
-
- // need to add this @AroundInvoke to cause validation to fail. Validation does not
- // fail on warnings, which causes this framework to not work properly
- @AroundInvoke
- public void sayCheese() {
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.test.annotated;
+
+import javax.ejb.Stateful;
+import javax.interceptor.AroundInvoke;
+import javax.jws.WebService;
+
+
+@Stateful(description = "test")
+@WebService
+public class Green {
+
+ // need to add this @AroundInvoke to cause validation to fail. Validation does not
+ // fail on warnings, which causes this framework to not work properly
+ @AroundInvoke
+ public void sayCheese() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/48c99a5a/container/openejb-core/src/test/java/org/apache/openejb/test/annotated/Red.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/test/annotated/Red.java b/container/openejb-core/src/test/java/org/apache/openejb/test/annotated/Red.java
index 5cff367..69632ec 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/test/annotated/Red.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/test/annotated/Red.java
@@ -1,32 +1,32 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.openejb.test.annotated;
-
-import javax.annotation.ManagedBean;
-import javax.interceptor.AroundInvoke;
-import javax.jws.WebService;
-
-@ManagedBean
-@WebService
-public class Red {
-
- // need to add this @AroundInvoke to cause validation to fail. Validation does not
- // fail on warnings, which causes this framework to not work properly
- @AroundInvoke
- public void sayCheese() {
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.test.annotated;
+
+import javax.annotation.ManagedBean;
+import javax.interceptor.AroundInvoke;
+import javax.jws.WebService;
+
+@ManagedBean
+@WebService
+public class Red {
+
+ // need to add this @AroundInvoke to cause validation to fail. Validation does not
+ // fail on warnings, which causes this framework to not work properly
+ @AroundInvoke
+ public void sayCheese() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/48c99a5a/container/openejb-core/src/test/java/org/apache/openejb/test/annotated/Yellow.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/test/annotated/Yellow.java b/container/openejb-core/src/test/java/org/apache/openejb/test/annotated/Yellow.java
index f8774ff..d16c274 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/test/annotated/Yellow.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/test/annotated/Yellow.java
@@ -1,40 +1,40 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.openejb.test.annotated;
-
-import javax.ejb.MessageDriven;
-import javax.interceptor.AroundInvoke;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jws.WebService;
-
-
-@MessageDriven
-@WebService
-public class Yellow implements MessageListener {
-
- // need to add this @AroundInvoke to cause validation to fail. Validation does not
- // fail on warnings, which causes this framework to not work properly
- @AroundInvoke
- public void sayCheese() {
- }
-
- @Override
- public void onMessage(final Message message) {
- //To change body of implemented methods use File | Settings | File Templates.
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.test.annotated;
+
+import javax.ejb.MessageDriven;
+import javax.interceptor.AroundInvoke;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jws.WebService;
+
+
+@MessageDriven
+@WebService
+public class Yellow implements MessageListener {
+
+ // need to add this @AroundInvoke to cause validation to fail. Validation does not
+ // fail on warnings, which causes this framework to not work properly
+ @AroundInvoke
+ public void sayCheese() {
+ }
+
+ @Override
+ public void onMessage(final Message message) {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/48c99a5a/container/openejb-core/src/test/java/org/apache/openejb/util/BeanTypeComparisonTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/util/BeanTypeComparisonTest.java b/container/openejb-core/src/test/java/org/apache/openejb/util/BeanTypeComparisonTest.java
index 67aa55f..7bc1d27 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/util/BeanTypeComparisonTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/util/BeanTypeComparisonTest.java
@@ -1,35 +1,35 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.openejb.util;
-
-import org.apache.openejb.BeanType;
-import org.apache.openejb.jee.SessionType;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-
-public class BeanTypeComparisonTest {
-
- @Test
- public void testEqualsMethodForDifferentClassTypes() {
- final BeanType beanType = BeanType.STATELESS;
- final SessionType sessionType = SessionType.STATELESS;
- assertFalse(beanType.equals(sessionType));
- }
-
-
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.util;
+
+import org.apache.openejb.BeanType;
+import org.apache.openejb.jee.SessionType;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+
+public class BeanTypeComparisonTest {
+
+ @Test
+ public void testEqualsMethodForDifferentClassTypes() {
+ final BeanType beanType = BeanType.STATELESS;
+ final SessionType sessionType = SessionType.STATELESS;
+ assertFalse(beanType.equals(sessionType));
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/48c99a5a/container/openejb-core/src/test/java/org/apache/openejb/util/CollectionsUtilTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/util/CollectionsUtilTest.java b/container/openejb-core/src/test/java/org/apache/openejb/util/CollectionsUtilTest.java
index 7eca925..fe7373d 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/util/CollectionsUtilTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/util/CollectionsUtilTest.java
@@ -1,34 +1,34 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.openejb.util;
-
-import org.junit.Test;
-
-import java.util.List;
-
-public class CollectionsUtilTest {
-
- @Test
- public void safeIterationForNullList() {
- final List<String> stringList = null;
- for (final String string : CollectionsUtil.safe(stringList)) {
- }
-
- //PASS: No NPE thrown
- }
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.openejb.util;
+
+import org.junit.Test;
+
+import java.util.List;
+
+public class CollectionsUtilTest {
+
+ @Test
+ public void safeIterationForNullList() {
+ final List<String> stringList = null;
+ for (final String string : CollectionsUtil.safe(stringList)) {
+ }
+
+ //PASS: No NPE thrown
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/48c99a5a/container/openejb-core/src/test/java/org/apache/openejb/util/NetworkUtilTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/util/NetworkUtilTest.java b/container/openejb-core/src/test/java/org/apache/openejb/util/NetworkUtilTest.java
index c64889f..25082f6 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/util/NetworkUtilTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/util/NetworkUtilTest.java
@@ -1,132 +1,132 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.openejb.util;
-
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.io.File;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-public class NetworkUtilTest {
-
- private static File f = null;
-
- @BeforeClass
- public static void beforeClass() throws Exception {
- f = File.createTempFile("tomee", "lock");
- }
-
- @AfterClass
- public static void afterClass() {
- if (null != f && !f.delete()) {
- f.deleteOnExit();
- }
- }
-
-
- @Test
- public void testNext() throws Exception {
-
- NetworkUtil.clearLockFile();
-
- final int count = 20;
- final CountDownLatch latch = new CountDownLatch(count);
- final long start = System.currentTimeMillis();
- final CopyOnWriteArrayList<Integer> list = new CopyOnWriteArrayList<Integer>();
-
- final List<NetworkUtil.LastPort> lastPorts = new ArrayList<NetworkUtil.LastPort>();
- for (int i = 0; i < count; i++) {
- final Thread thread = new Thread(new Runnable() {
- public void run() {
- final int nextAvailablePort = NetworkUtil.getNextAvailablePort();
- if (list.contains(nextAvailablePort)) {
- if ((System.currentTimeMillis() - start) < 10000) {
- Assert.fail("Got a duplicate port with ten seconds");
- }
- } else {
- list.add(nextAvailablePort);
- }
-
- latch.countDown();
- }
- }, "test-thread-" + count);
- thread.setDaemon(false);
- thread.start();
- }
-
- final boolean success = latch.await(15, TimeUnit.SECONDS);
- Assert.assertTrue(success);
-
- System.out.println("VM safe port list = " + list);
- }
-
- @Test
- public void testNextLock() throws Exception {
-
- System.setProperty(NetworkUtil.TOMEE_LOCK_FILE, f.getAbsolutePath());
-
- final int count = 20;
- final CountDownLatch latch = new CountDownLatch(count);
- final long start = System.currentTimeMillis();
- final CopyOnWriteArrayList<Integer> list = new CopyOnWriteArrayList<Integer>();
-
- final List<NetworkUtil.LastPort> lastPorts = new ArrayList<NetworkUtil.LastPort>();
- for (int i = 0; i < count; i++) {
- final Thread thread = new Thread(new Runnable() {
- public void run() {
- final int nextAvailablePort = NetworkUtil.getNextAvailablePort(NetworkUtil.PORT_MIN, NetworkUtil.PORT_MAX, Collections.<Integer>emptyList(), lastPorts);
- if (list.contains(nextAvailablePort)) {
- if ((System.currentTimeMillis() - start) < 10000) {
- Assert.fail("Got a duplicate port with ten seconds");
- }
- } else {
- list.add(nextAvailablePort);
- }
-
- latch.countDown();
- }
- }, "test-thread-" + count);
- thread.setDaemon(false);
- thread.start();
- }
-
- final boolean success = latch.await(15, TimeUnit.SECONDS);
- Assert.assertTrue(success);
-
- System.out.println("Machine safe port list = " + list);
- }
-
- @Test
- public void testLocal() throws Exception {
- Assert.assertTrue(NetworkUtil.isLocalAddress(InetAddress.getLocalHost()));
- }
-
- @Test
- public void testLocalhost() throws Exception {
- Assert.assertTrue(NetworkUtil.isLocalAddress("localhost"));
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.util;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.File;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+public class NetworkUtilTest {
+
+ private static File f = null;
+
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ f = File.createTempFile("tomee", "lock");
+ }
+
+ @AfterClass
+ public static void afterClass() {
+ if (null != f && !f.delete()) {
+ f.deleteOnExit();
+ }
+ }
+
+
+ @Test
+ public void testNext() throws Exception {
+
+ NetworkUtil.clearLockFile();
+
+ final int count = 20;
+ final CountDownLatch latch = new CountDownLatch(count);
+ final long start = System.currentTimeMillis();
+ final CopyOnWriteArrayList<Integer> list = new CopyOnWriteArrayList<Integer>();
+
+ final List<NetworkUtil.LastPort> lastPorts = new ArrayList<NetworkUtil.LastPort>();
+ for (int i = 0; i < count; i++) {
+ final Thread thread = new Thread(new Runnable() {
+ public void run() {
+ final int nextAvailablePort = NetworkUtil.getNextAvailablePort();
+ if (list.contains(nextAvailablePort)) {
+ if ((System.currentTimeMillis() - start) < 10000) {
+ Assert.fail("Got a duplicate port with ten seconds");
+ }
+ } else {
+ list.add(nextAvailablePort);
+ }
+
+ latch.countDown();
+ }
+ }, "test-thread-" + count);
+ thread.setDaemon(false);
+ thread.start();
+ }
+
+ final boolean success = latch.await(15, TimeUnit.SECONDS);
+ Assert.assertTrue(success);
+
+ System.out.println("VM safe port list = " + list);
+ }
+
+ @Test
+ public void testNextLock() throws Exception {
+
+ System.setProperty(NetworkUtil.TOMEE_LOCK_FILE, f.getAbsolutePath());
+
+ final int count = 20;
+ final CountDownLatch latch = new CountDownLatch(count);
+ final long start = System.currentTimeMillis();
+ final CopyOnWriteArrayList<Integer> list = new CopyOnWriteArrayList<Integer>();
+
+ final List<NetworkUtil.LastPort> lastPorts = new ArrayList<NetworkUtil.LastPort>();
+ for (int i = 0; i < count; i++) {
+ final Thread thread = new Thread(new Runnable() {
+ public void run() {
+ final int nextAvailablePort = NetworkUtil.getNextAvailablePort(NetworkUtil.PORT_MIN, NetworkUtil.PORT_MAX, Collections.<Integer>emptyList(), lastPorts);
+ if (list.contains(nextAvailablePort)) {
+ if ((System.currentTimeMillis() - start) < 10000) {
+ Assert.fail("Got a duplicate port with ten seconds");
+ }
+ } else {
+ list.add(nextAvailablePort);
+ }
+
+ latch.countDown();
+ }
+ }, "test-thread-" + count);
+ thread.setDaemon(false);
+ thread.start();
+ }
+
+ final boolean success = latch.await(15, TimeUnit.SECONDS);
+ Assert.assertTrue(success);
+
+ System.out.println("Machine safe port list = " + list);
+ }
+
+ @Test
+ public void testLocal() throws Exception {
+ Assert.assertTrue(NetworkUtil.isLocalAddress(InetAddress.getLocalHost()));
+ }
+
+ @Test
+ public void testLocalhost() throws Exception {
+ Assert.assertTrue(NetworkUtil.isLocalAddress("localhost"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/48c99a5a/container/openejb-core/src/test/resources/META-INF/jpa-test-mappings.xml
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/resources/META-INF/jpa-test-mappings.xml b/container/openejb-core/src/test/resources/META-INF/jpa-test-mappings.xml
index a644fac..fe6eae5 100644
--- a/container/openejb-core/src/test/resources/META-INF/jpa-test-mappings.xml
+++ b/container/openejb-core/src/test/resources/META-INF/jpa-test-mappings.xml
@@ -1,24 +1,24 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!-- $Rev$ $Date$ -->
-
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev$ $Date$ -->
+
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" version="1.0">
<mapped-superclass class="org.apache.openejb.test.entity.cmp.BasicCmpBean">
<attributes>
http://git-wip-us.apache.org/repos/asf/tomee/blob/48c99a5a/container/openejb-core/src/test/resources/META-INF/org.acme/service-jar.xml
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/resources/META-INF/org.acme/service-jar.xml b/container/openejb-core/src/test/resources/META-INF/org.acme/service-jar.xml
index c9bceb1..147189f 100644
--- a/container/openejb-core/src/test/resources/META-INF/org.acme/service-jar.xml
+++ b/container/openejb-core/src/test/resources/META-INF/org.acme/service-jar.xml
@@ -1,24 +1,24 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!-- $Rev$ $Date$ -->
-
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev$ $Date$ -->
+
<ServiceJar>
<ServiceProvider id="CheddarContainer" service="Container" class-name="org.acme.SuperContainer">
http://git-wip-us.apache.org/repos/asf/tomee/blob/48c99a5a/container/openejb-core/src/test/resources/META-INF/org.router/service-jar.xml
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/resources/META-INF/org.router/service-jar.xml b/container/openejb-core/src/test/resources/META-INF/org.router/service-jar.xml
index cb86297..e409d7d 100644
--- a/container/openejb-core/src/test/resources/META-INF/org.router/service-jar.xml
+++ b/container/openejb-core/src/test/resources/META-INF/org.router/service-jar.xml
@@ -1,28 +1,28 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!-- $Rev$ -->
-<ServiceJar>
- <ServiceProvider id="DeterminedRouter" service="Resource"
- type="org.apache.openejb.resource.jdbc.router.Router"
- class-name="org.apache.openejb.resource.jdbc.DynamicDataSourceTest$DeterminedRouter">
- DataSourceNames
- DefaultDataSourceName
- </ServiceProvider>
-</ServiceJar>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev$ -->
+<ServiceJar>
+ <ServiceProvider id="DeterminedRouter" service="Resource"
+ type="org.apache.openejb.resource.jdbc.router.Router"
+ class-name="org.apache.openejb.resource.jdbc.DynamicDataSourceTest$DeterminedRouter">
+ DataSourceNames
+ DefaultDataSourceName
+ </ServiceProvider>
+</ServiceJar>
http://git-wip-us.apache.org/repos/asf/tomee/blob/48c99a5a/container/openejb-core/src/test/resources/convert/oej2/cmp/itest-2.2/itest-2.2-openejb-jar.xml
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/resources/convert/oej2/cmp/itest-2.2/itest-2.2-openejb-jar.xml b/container/openejb-core/src/test/resources/convert/oej2/cmp/itest-2.2/itest-2.2-openejb-jar.xml
index 9ea2e3d..e2017c0 100644
--- a/container/openejb-core/src/test/resources/convert/oej2/cmp/itest-2.2/itest-2.2-openejb-jar.xml
+++ b/container/openejb-core/src/test/resources/convert/oej2/cmp/itest-2.2/itest-2.2-openejb-jar.xml
@@ -1,23 +1,23 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<!-- $Rev$ $Date$ -->
-
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- $Rev$ $Date$ -->
+
<openejb-jar xmlns="http://tomee.apache.org/xml/ns/openejb-jar-2.2"
xmlns:naming="http://geronimo.apache.org/xml/ns/naming-1.2"
xmlns:sys="http://geronimo.apache.org/xml/ns/deployment-1.2">