2 Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; version 2 of the License.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 package testsuite.clusterj;
20 import java.util.Properties;
22 import com.mysql.clusterj.Constants;
24 import testsuite.clusterj.model.Employee;
26 public class DefaultConnectValuesTest extends AbstractClusterJModelTest {
28 private static final int NUMBER_TO_INSERT = 1;
31 public void localSetUp() {
32 createSessionFactory();
33 session = sessionFactory.getSession();
34 createEmployeeInstances(NUMBER_TO_INSERT);
35 tx = session.currentTransaction();
37 session.deletePersistentAll(Employee.class);
39 addTearDownClasses(Employee.class);
42 /** Remove the properties that can be defaulted.
45 protected Properties modifyProperties() {
46 Properties modifiedProperties = new Properties();
47 modifiedProperties.putAll(props);
48 modifiedProperties.remove(Constants.PROPERTY_CLUSTER_CONNECT_DELAY);
49 modifiedProperties.remove(Constants.PROPERTY_CLUSTER_CONNECT_RETRIES);
50 modifiedProperties.remove(Constants.PROPERTY_CLUSTER_CONNECT_TIMEOUT_AFTER);
51 modifiedProperties.remove(Constants.PROPERTY_CLUSTER_CONNECT_TIMEOUT_BEFORE);
52 modifiedProperties.remove(Constants.PROPERTY_CLUSTER_CONNECT_VERBOSE);
53 modifiedProperties.remove(Constants.PROPERTY_CLUSTER_DATABASE);
54 modifiedProperties.remove(Constants.PROPERTY_CLUSTER_MAX_TRANSACTIONS);
55 return modifiedProperties;
58 public void testFind() {
59 // first, create instances to find
60 tx = session.currentTransaction();
65 for (int i = 0; i < NUMBER_TO_INSERT; ++i) {
66 // must be done with an active transaction
67 session.makePersistent(employees.get(i));
74 for (int i = 0; i < NUMBER_TO_INSERT; ++i) {
75 // must be done with an active transaction
76 Employee e = session.find(Employee.class, i);
77 // make sure all fields were fetched
79 // see if it is the right Employee
80 int actualId = e.getId();
82 error("Expected Employee.id " + i + " but got " + actualId);