View | Details | Raw Unified | Return to bug 352696 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUI.java (-6 / +7 lines)
Lines 14-19 Link Here
14
import org.eclipse.emf.cdo.dawn.tests.ui.gmf.DawnBasicGMFUITest;
14
import org.eclipse.emf.cdo.dawn.tests.ui.gmf.DawnBasicGMFUITest;
15
import org.eclipse.emf.cdo.dawn.tests.ui.gmf.DawnCreationWizardTest;
15
import org.eclipse.emf.cdo.dawn.tests.ui.gmf.DawnCreationWizardTest;
16
import org.eclipse.emf.cdo.tests.AllTests;
16
import org.eclipse.emf.cdo.tests.AllTests;
17
import org.eclipse.emf.cdo.tests.config.IScenario;
17
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
18
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
18
19
19
import java.util.List;
20
import java.util.List;
Lines 34-49 Link Here
34
  }
35
  }
35
36
36
  @Override
37
  @Override
37
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
38
  protected void initConfigSuites(TestSuite parent)
38
  {
39
  {
39
    testClasses.add(DawnCreationWizardTest.class);
40
    addScenario(parent, COMBINED, MEM, TCP, NATIVE);
40
    testClasses.add(DawnBasicGMFUITest.class);
41
    testClasses.add(DawnBasicEMFUITest.class);
42
  }
41
  }
43
42
44
  @Override
43
  @Override
45
  protected void initConfigSuites(TestSuite parent)
44
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
46
  {
45
  {
47
    addScenario(parent, COMBINED, MEM, TCP, NATIVE);
46
    testClasses.add(DawnCreationWizardTest.class);
47
    testClasses.add(DawnBasicGMFUITest.class);
48
    testClasses.add(DawnBasicEMFUITest.class);
48
  }
49
  }
49
}
50
}
(-)src/org/eclipse/emf/cdo/dawn/tests/TCPConfigStarter.java (-4 / +5 lines)
Lines 12-17 Link Here
12
12
13
import org.eclipse.emf.cdo.tests.AllConfigs;
13
import org.eclipse.emf.cdo.tests.AllConfigs;
14
import org.eclipse.emf.cdo.tests.InitialTest;
14
import org.eclipse.emf.cdo.tests.InitialTest;
15
import org.eclipse.emf.cdo.tests.config.IScenario;
15
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
16
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
16
17
17
import java.util.List;
18
import java.util.List;
Lines 30-43 Link Here
30
  }
31
  }
31
32
32
  @Override
33
  @Override
33
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
34
  protected void initConfigSuites(TestSuite parent)
34
  {
35
  {
35
    testClasses.add(InitialTest.class);
36
    addScenario(parent, COMBINED, MEM_BRANCHES, TCP, NATIVE);
36
  }
37
  }
37
38
38
  @Override
39
  @Override
39
  protected void initConfigSuites(TestSuite parent)
40
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
40
  {
41
  {
41
    addScenario(parent, COMBINED, MEM_BRANCHES, TCP, NATIVE);
42
    testClasses.add(InitialTest.class);
42
  }
43
  }
43
}
44
}
(-)src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBot.java (-2 / +2 lines)
Lines 23-28 Link Here
23
import org.eclipse.emf.cdo.dawn.tests.ui.gmf.MultipleResourcesTest;
23
import org.eclipse.emf.cdo.dawn.tests.ui.gmf.MultipleResourcesTest;
24
import org.eclipse.emf.cdo.dawn.tests.ui.gmf.SimpleDiagramTest;
24
import org.eclipse.emf.cdo.dawn.tests.ui.gmf.SimpleDiagramTest;
25
import org.eclipse.emf.cdo.tests.AllTests;
25
import org.eclipse.emf.cdo.tests.AllTests;
26
import org.eclipse.emf.cdo.tests.config.IScenario;
26
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
27
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
27
import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
28
import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
28
29
Lines 51-59 Link Here
51
  }
52
  }
52
53
53
  @Override
54
  @Override
54
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
55
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
55
  {
56
  {
56
57
    /******************** GMF **********************/
57
    /******************** GMF **********************/
58
    testClasses.add(DawnPreferencesTest.class);
58
    testClasses.add(DawnPreferencesTest.class);
59
    testClasses.add(DawnCreationWizardSWTBotTest.class);
59
    testClasses.add(DawnCreationWizardSWTBotTest.class);
(-)src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawn.java (-7 / +8 lines)
Lines 15-20 Link Here
15
import org.eclipse.emf.cdo.dawn.tests.common.GMFTest;
15
import org.eclipse.emf.cdo.dawn.tests.common.GMFTest;
16
import org.eclipse.emf.cdo.dawn.tests.common.TestFrameworkTest;
16
import org.eclipse.emf.cdo.dawn.tests.common.TestFrameworkTest;
17
import org.eclipse.emf.cdo.tests.AllTests;
17
import org.eclipse.emf.cdo.tests.AllTests;
18
import org.eclipse.emf.cdo.tests.config.IScenario;
18
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
19
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
19
20
20
import java.util.List;
21
import java.util.List;
Lines 35-51 Link Here
35
  }
36
  }
36
37
37
  @Override
38
  @Override
38
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
39
  protected void initConfigSuites(TestSuite parent)
39
  {
40
  {
40
    testClasses.add(TestFrameworkTest.class);
41
    addScenario(parent, COMBINED, MEM, JVM, NATIVE);
41
    testClasses.add(GMFTest.class);
42
    testClasses.add(DawnWrapperResourceTest.class);
43
    testClasses.add(DawnCodeGenGMFFragmentTest.class);
44
  }
42
  }
45
43
46
  @Override
44
  @Override
47
  protected void initConfigSuites(TestSuite parent)
45
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
48
  {
46
  {
49
    addScenario(parent, COMBINED, MEM, JVM, NATIVE);
47
    testClasses.add(TestFrameworkTest.class);
48
    testClasses.add(GMFTest.class);
49
    testClasses.add(DawnWrapperResourceTest.class);
50
    testClasses.add(DawnCodeGenGMFFragmentTest.class);
50
  }
51
  }
51
}
52
}
(-)src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldbNonAudit.java (-53 / +5 lines)
Lines 10-25 Link Here
10
 */
10
 */
11
package org.eclipse.emf.cdo.tests.db;
11
package org.eclipse.emf.cdo.tests.db;
12
12
13
import org.eclipse.emf.cdo.server.IRepository;
13
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
14
import org.eclipse.emf.cdo.server.db.CDODBUtil;
15
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
16
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_261218_Test;
14
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_261218_Test;
15
import org.eclipse.emf.cdo.tests.config.IScenario;
17
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
16
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
18
import org.eclipse.emf.cdo.tests.db.verifier.DBStoreVerifier;
19
import org.eclipse.emf.cdo.tests.db.verifier.DBStoreVerifier.NonAudit;
20
17
21
import java.util.List;
18
import java.util.List;
22
import java.util.Map;
23
19
24
import junit.framework.Test;
20
import junit.framework.Test;
25
import junit.framework.TestSuite;
21
import junit.framework.TestSuite;
Lines 37-95 Link Here
37
  @Override
33
  @Override
38
  protected void initConfigSuites(TestSuite parent)
34
  protected void initConfigSuites(TestSuite parent)
39
  {
35
  {
40
    addScenario(parent, COMBINED, AllTestsDBHsqldbNonAudit.HsqldbNonAudit.INSTANCE, TCP, NATIVE);
36
    addScenario(parent, COMBINED, new HsqldbConfig(false, false, IDGenerationLocation.STORE), TCP, NATIVE);
41
  }
37
  }
42
38
43
  @Override
39
  @Override
44
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
40
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
45
  {
41
  {
46
    super.initTestClasses(testClasses);
42
    super.initTestClasses(testClasses, scenario);
47
43
48
    // this takes ages - so for now, we disable it
44
    // this takes ages - so for now, we disable it
49
    testClasses.remove(Bugzilla_261218_Test.class);
45
    testClasses.remove(Bugzilla_261218_Test.class);
50
  }
46
  }
51
52
  @Override
53
  protected boolean hasAuditSupport()
54
  {
55
    return false;
56
  }
57
58
  @Override
59
  protected boolean hasBranchingSupport()
60
  {
61
    return false;
62
  }
63
64
  public static class HsqldbNonAudit extends AllTestsDBHsqldb.Hsqldb
65
  {
66
    private static final long serialVersionUID = 1L;
67
68
    public static final AllTestsDBHsqldbNonAudit.HsqldbNonAudit INSTANCE = new HsqldbNonAudit(
69
        "DBStore: Hsqldb (non audit)");
70
71
    public HsqldbNonAudit(String name)
72
    {
73
      super(name);
74
    }
75
76
    @Override
77
    protected void initRepositoryProperties(Map<String, String> props)
78
    {
79
      super.initRepositoryProperties(props);
80
      props.put(IRepository.Props.SUPPORTING_AUDITS, "false");
81
    }
82
83
    @Override
84
    protected IMappingStrategy createMappingStrategy()
85
    {
86
      return CDODBUtil.createHorizontalMappingStrategy(false);
87
    }
88
89
    @Override
90
    protected DBStoreVerifier getVerifier(IRepository repository)
91
    {
92
      return new NonAudit(repository);
93
    }
94
  }
95
}
47
}
(-)src/org/eclipse/emf/cdo/tests/db/DBConfig.java (-4 / +32 lines)
Lines 10-15 Link Here
10
 */
10
 */
11
package org.eclipse.emf.cdo.tests.db;
11
package org.eclipse.emf.cdo.tests.db;
12
12
13
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
13
import org.eclipse.emf.cdo.server.IStore;
14
import org.eclipse.emf.cdo.server.IStore;
14
import org.eclipse.emf.cdo.server.db.CDODBUtil;
15
import org.eclipse.emf.cdo.server.db.CDODBUtil;
15
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
16
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
Lines 29-41 Link Here
29
/**
30
/**
30
 * @author Eike Stepper
31
 * @author Eike Stepper
31
 */
32
 */
32
public abstract class DBStoreRepositoryConfig extends RepositoryConfig
33
public abstract class DBConfig extends RepositoryConfig
33
{
34
{
34
  private static final long serialVersionUID = 1L;
35
  private static final long serialVersionUID = 1L;
35
36
36
  public DBStoreRepositoryConfig(String name)
37
  private boolean withRanges;
38
39
  private boolean copyOnBranch;
40
41
  public DBConfig(String name, boolean supportingAudits, boolean supportingBranches, boolean withRanges,
42
      boolean copyOnBranch, IDGenerationLocation idGenerationLocation)
43
  {
44
    super(name, supportingAudits, supportingBranches, idGenerationLocation);
45
    this.withRanges = withRanges;
46
    this.copyOnBranch = copyOnBranch;
47
  }
48
49
  public boolean isWithRanges()
50
  {
51
    return withRanges;
52
  }
53
54
  public boolean isCopyOnBranch()
37
  {
55
  {
38
    super(name);
56
    return copyOnBranch;
39
  }
57
  }
40
58
41
  @Override
59
  @Override
Lines 65-74 Link Here
65
  {
83
  {
66
    Map<String, String> props = new HashMap<String, String>();
84
    Map<String, String> props = new HashMap<String, String>();
67
    props.put(IMappingStrategy.PROP_QUALIFIED_NAMES, "true");
85
    props.put(IMappingStrategy.PROP_QUALIFIED_NAMES, "true");
86
    props.put(CDODBUtil.PROP_COPY_ON_BRANCH, Boolean.toString(copyOnBranch));
68
    return props;
87
    return props;
69
  }
88
  }
70
89
71
  protected abstract IMappingStrategy createMappingStrategy();
90
  protected IMappingStrategy createMappingStrategy()
91
  {
92
    return CDODBUtil.createHorizontalMappingStrategy(isSupportingAudits(), isSupportingBranches(), withRanges);
93
  }
94
95
  @Override
96
  protected String getMappingStrategySpecialization()
97
  {
98
    return (withRanges ? "-ranges" : "") + (copyOnBranch ? "-copy" : "");
99
  }
72
100
73
  protected abstract IDBAdapter createDBAdapter();
101
  protected abstract IDBAdapter createDBAdapter();
74
102
(-)src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2NonAudit.java (-192 / +2 lines)
Lines 10-35 Link Here
10
 */
10
 */
11
package org.eclipse.emf.cdo.tests.db;
11
package org.eclipse.emf.cdo.tests.db;
12
12
13
import org.eclipse.emf.cdo.server.IRepository;
13
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
14
import org.eclipse.emf.cdo.server.db.CDODBUtil;
15
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
16
17
import org.eclipse.net4j.db.DBUtil;
18
import org.eclipse.net4j.db.IDBAdapter;
19
import org.eclipse.net4j.db.h2.H2Adapter;
20
import org.eclipse.net4j.util.WrappedException;
21
import org.eclipse.net4j.util.io.IOUtil;
22
import org.eclipse.net4j.util.io.TMPUtil;
23
24
import org.h2.jdbcx.JdbcDataSource;
25
26
import javax.sql.DataSource;
27
28
import java.io.File;
29
import java.sql.Connection;
30
import java.sql.Statement;
31
import java.util.ArrayList;
32
import java.util.Map;
33
14
34
import junit.framework.Test;
15
import junit.framework.Test;
35
import junit.framework.TestSuite;
16
import junit.framework.TestSuite;
Lines 47-223 Link Here
47
  @Override
28
  @Override
48
  protected void initConfigSuites(TestSuite parent)
29
  protected void initConfigSuites(TestSuite parent)
49
  {
30
  {
50
    addScenario(parent, COMBINED, AllTestsDBH2NonAudit.H2NonAudit.ReusableFolder.INSTANCE, JVM, NATIVE);
31
    addScenario(parent, COMBINED, new H2Config(false, false, false, false, IDGenerationLocation.STORE), JVM, NATIVE);
51
  }
52
53
  @Override
54
  protected boolean hasAuditSupport()
55
  {
56
    return false;
57
  }
58
59
  @Override
60
  protected boolean hasBranchingSupport()
61
  {
62
    return false;
63
  }
64
65
  /**
66
   * @author Eike Stepper
67
   */
68
  public static class H2NonAudit extends DBStoreRepositoryConfig
69
  {
70
    private static final long serialVersionUID = 1L;
71
72
    public static final AllTestsDBH2NonAudit.H2NonAudit INSTANCE = new H2NonAudit("DBStore: H2 (non-audit)");
73
74
    protected transient File dbFolder;
75
76
    public H2NonAudit(String name)
77
    {
78
      super(name);
79
    }
80
81
    @Override
82
    protected void initRepositoryProperties(Map<String, String> props)
83
    {
84
      super.initRepositoryProperties(props);
85
      props.put(IRepository.Props.SUPPORTING_AUDITS, "false");
86
    }
87
88
    @Override
89
    protected IMappingStrategy createMappingStrategy()
90
    {
91
      return CDODBUtil.createHorizontalMappingStrategy(false);
92
    }
93
94
    @Override
95
    protected IDBAdapter createDBAdapter()
96
    {
97
      return new H2Adapter();
98
    }
99
100
    @Override
101
    protected DataSource createDataSource(String repoName)
102
    {
103
      if (dbFolder == null)
104
      {
105
        dbFolder = createDBFolder();
106
        tearDownClean();
107
      }
108
109
      JdbcDataSource dataSource = new JdbcDataSource();
110
      dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName);
111
      return dataSource;
112
    }
113
114
    protected void tearDownClean()
115
    {
116
      IOUtil.delete(dbFolder);
117
    }
118
119
    protected File createDBFolder()
120
    {
121
      return TMPUtil.createTempFolder("h2_", "_test");
122
    }
123
124
    /**
125
     * @author Eike Stepper
126
     */
127
    public static class ReusableFolder extends H2NonAudit
128
    {
129
      private static final long serialVersionUID = 1L;
130
131
      public static final ReusableFolder INSTANCE = new ReusableFolder("DBStore: H2 (non-audit)");
132
133
      private static File reusableFolder;
134
135
      private static JdbcDataSource defaultDataSource;
136
137
      private transient ArrayList<String> repoNames = new ArrayList<String>();
138
139
      public ReusableFolder(String name)
140
      {
141
        super(name);
142
      }
143
144
      @Override
145
      protected DataSource createDataSource(String repoName)
146
      {
147
        if (reusableFolder == null)
148
        {
149
          reusableFolder = createDBFolder();
150
          IOUtil.delete(reusableFolder);
151
        }
152
153
        dbFolder = reusableFolder;
154
        if (defaultDataSource == null)
155
        {
156
          defaultDataSource = new JdbcDataSource();
157
          defaultDataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test");
158
        }
159
160
        Connection conn = null;
161
        Statement stmt = null;
162
163
        try
164
        {
165
          conn = defaultDataSource.getConnection();
166
          stmt = conn.createStatement();
167
168
          if (!isRestarting())
169
          {
170
            stmt.execute("DROP SCHEMA IF EXISTS " + repoName);
171
          }
172
173
          stmt.execute("CREATE SCHEMA IF NOT EXISTS " + repoName);
174
        }
175
        catch (Exception e)
176
        {
177
          e.printStackTrace();
178
        }
179
        finally
180
        {
181
          DBUtil.close(conn);
182
          DBUtil.close(stmt);
183
        }
184
185
        JdbcDataSource dataSource = new JdbcDataSource();
186
        dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName);
187
        return dataSource;
188
      }
189
190
      @Override
191
      protected void tearDownClean()
192
      {
193
        for (String repoName : repoNames)
194
        {
195
          tearDownClean(repoName);
196
        }
197
      }
198
199
      protected void tearDownClean(String repoName)
200
      {
201
        reusableFolder.deleteOnExit();
202
        Connection connection = null;
203
        Statement stmt = null;
204
205
        try
206
        {
207
          connection = defaultDataSource.getConnection();
208
          stmt = connection.createStatement();
209
          stmt.execute("DROP SCHEMA " + repoName);
210
        }
211
        catch (Exception ex)
212
        {
213
          throw WrappedException.wrap(ex);
214
        }
215
        finally
216
        {
217
          DBUtil.close(stmt);
218
          DBUtil.close(connection);
219
        }
220
      }
221
    }
222
  }
32
  }
223
}
33
}
(-)src/org/eclipse/emf/cdo/tests/db/DISABLE_AttributeTest.java (-3 / +3 lines)
Lines 21-27 Link Here
21
  public void testByteArray() throws Exception
21
  public void testByteArray() throws Exception
22
  {
22
  {
23
    // XXX disabled because of Bug 289445
23
    // XXX disabled because of Bug 289445
24
    skipConfig(AllTestsDBPsql.Psql.INSTANCE);
24
    skipTest(getRepositoryConfig() instanceof PostgresqlConfig);
25
    super.testByteArray();
25
    super.testByteArray();
26
  }
26
  }
27
27
Lines 29-35 Link Here
29
  public void testByteArrayEmpty() throws Exception
29
  public void testByteArrayEmpty() throws Exception
30
  {
30
  {
31
    // XXX disabled because of Bug 289445
31
    // XXX disabled because of Bug 289445
32
    skipConfig(AllTestsDBPsql.Psql.INSTANCE);
32
    skipTest(getRepositoryConfig() instanceof PostgresqlConfig);
33
    super.testByteArrayEmpty();
33
    super.testByteArrayEmpty();
34
  }
34
  }
35
35
Lines 37-43 Link Here
37
  public void testByteArrayNull() throws Exception
37
  public void testByteArrayNull() throws Exception
38
  {
38
  {
39
    // XXX disabled because of Bug 289445
39
    // XXX disabled because of Bug 289445
40
    skipConfig(AllTestsDBPsql.Psql.INSTANCE);
40
    skipTest(getRepositoryConfig() instanceof PostgresqlConfig);
41
    super.testByteArrayNull();
41
    super.testByteArrayNull();
42
  }
42
  }
43
}
43
}
(-)src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Branching.java (-248 / +4 lines)
Lines 10-35 Link Here
10
 */
10
 */
11
package org.eclipse.emf.cdo.tests.db;
11
package org.eclipse.emf.cdo.tests.db;
12
12
13
import org.eclipse.emf.cdo.server.IRepository;
13
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
14
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
15
16
import org.eclipse.net4j.db.DBUtil;
17
import org.eclipse.net4j.db.IDBAdapter;
18
import org.eclipse.net4j.db.h2.H2Adapter;
19
import org.eclipse.net4j.util.WrappedException;
20
import org.eclipse.net4j.util.io.IOUtil;
21
import org.eclipse.net4j.util.io.TMPUtil;
22
23
import org.h2.jdbcx.JdbcDataSource;
24
25
import javax.sql.DataSource;
26
27
import java.io.File;
28
import java.sql.Connection;
29
import java.sql.Statement;
30
import java.util.ArrayList;
31
import java.util.HashMap;
32
import java.util.Map;
33
14
34
import junit.framework.Test;
15
import junit.framework.Test;
35
import junit.framework.TestSuite;
16
import junit.framework.TestSuite;
Lines 47-279 Link Here
47
  @Override
28
  @Override
48
  protected void initConfigSuites(TestSuite parent)
29
  protected void initConfigSuites(TestSuite parent)
49
  {
30
  {
50
    addScenario(parent, COMBINED, H2Branching.ReusableFolder.INSTANCE, JVM, NATIVE);
31
    addScenario(parent, COMBINED, new H2Config(true, true, false, false, IDGenerationLocation.STORE), JVM, NATIVE);
51
    addScenario(parent, COMBINED, H2Branching.ReusableFolder.RANGE_INSTANCE, JVM, NATIVE);
32
    addScenario(parent, COMBINED, new H2Config(true, true, true, false, IDGenerationLocation.STORE), JVM, NATIVE);
52
    addScenario(parent, COMBINED, H2Branching.ReusableFolder.CopyOnBranch.INSTANCE, JVM, NATIVE);
33
    addScenario(parent, COMBINED, new H2Config(true, true, true, true, IDGenerationLocation.STORE), JVM, NATIVE);
53
  }
54
55
  @Override
56
  protected boolean hasAuditSupport()
57
  {
58
    return true;
59
  }
60
61
  @Override
62
  protected boolean hasBranchingSupport()
63
  {
64
    return true;
65
  }
66
67
  /**
68
   * @author Eike Stepper
69
   */
70
  public static class H2Branching extends DBStoreRepositoryConfig
71
  {
72
    private static final long serialVersionUID = 1L;
73
74
    public static final H2Branching INSTANCE = new H2Branching("DBStore: H2 (branching)",
75
        "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingMappingStrategy");
76
77
    protected transient File dbFolder;
78
79
    private String mappingStrategy;
80
81
    public H2Branching(String name, String mappingStrategy)
82
    {
83
      super(name);
84
      this.mappingStrategy = mappingStrategy;
85
    }
86
87
    @Override
88
    protected void initRepositoryProperties(Map<String, String> props)
89
    {
90
      super.initRepositoryProperties(props);
91
      props.put(IRepository.Props.SUPPORTING_AUDITS, "true");
92
      props.put(IRepository.Props.SUPPORTING_BRANCHES, "true");
93
    }
94
95
    @SuppressWarnings("unchecked")
96
    @Override
97
    protected IMappingStrategy createMappingStrategy()
98
    {
99
      try
100
      {
101
        Class<IMappingStrategy> clazz = (Class<IMappingStrategy>)Class.forName(mappingStrategy);
102
        return clazz.newInstance();
103
      }
104
      catch (Exception ex)
105
      {
106
        throw WrappedException.wrap(ex);
107
      }
108
    }
109
110
    @Override
111
    protected IDBAdapter createDBAdapter()
112
    {
113
      return new H2Adapter();
114
    }
115
116
    @Override
117
    protected DataSource createDataSource(String repoName)
118
    {
119
      if (dbFolder == null)
120
      {
121
        dbFolder = createDBFolder();
122
        tearDownClean();
123
      }
124
125
      JdbcDataSource dataSource = new JdbcDataSource();
126
      dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName);
127
128
      return dataSource;
129
    }
130
131
    protected void tearDownClean()
132
    {
133
      IOUtil.delete(dbFolder);
134
    }
135
136
    protected File createDBFolder()
137
    {
138
      return TMPUtil.createTempFolder("h2_", "_test");
139
    }
140
141
    /**
142
     * @author Eike Stepper
143
     */
144
    public static class ReusableFolder extends H2Branching
145
    {
146
      private static final long serialVersionUID = 1L;
147
148
      public static final ReusableFolder INSTANCE = new ReusableFolder("DBStore: H2 (branching)",
149
          "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingMappingStrategy");
150
151
      public static final ReusableFolder RANGE_INSTANCE = new ReusableFolder("DBStore: H2 (branching, range-based)",
152
          "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingMappingStrategyWithRanges");
153
154
      private static File reusableFolder;
155
156
      private static JdbcDataSource defaultDataSource;
157
158
      private transient ArrayList<String> repoNames = new ArrayList<String>();
159
160
      public ReusableFolder(String name, String mappingStrategy)
161
      {
162
        super(name, mappingStrategy);
163
      }
164
165
      @Override
166
      protected DataSource createDataSource(String repoName)
167
      {
168
        if (reusableFolder == null)
169
        {
170
          reusableFolder = createDBFolder();
171
          IOUtil.delete(reusableFolder);
172
        }
173
174
        dbFolder = reusableFolder;
175
        if (defaultDataSource == null)
176
        {
177
          defaultDataSource = new JdbcDataSource();
178
          defaultDataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test");
179
        }
180
181
        Connection conn = null;
182
        Statement stmt = null;
183
184
        try
185
        {
186
          conn = defaultDataSource.getConnection();
187
          stmt = conn.createStatement();
188
189
          if (!isRestarting())
190
          {
191
            stmt.execute("DROP SCHEMA IF EXISTS " + repoName);
192
          }
193
194
          stmt.execute("CREATE SCHEMA IF NOT EXISTS " + repoName);
195
196
          /*
197
           * final WebServer webServer = new WebServer(); webServer.init(new String[] { "-webPort", "7778" });
198
           * webServer.start(); System.out.println("----------------------------------");
199
           * System.out.println("----------------------------------"); System.out.println(webServer.addSession(conn));
200
           * System.out.println("----------------------------------");
201
           * System.out.println("----------------------------------"); new Thread() {
202
           * @Override public void run() { webServer.listen(); } }.start();
203
           */
204
        }
205
        catch (Exception ex)
206
        {
207
          ex.printStackTrace();
208
        }
209
        finally
210
        {
211
          DBUtil.close(stmt);
212
          DBUtil.close(conn);
213
        }
214
215
        JdbcDataSource dataSource = new JdbcDataSource();
216
        dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName);
217
        return dataSource;
218
      }
219
220
      @Override
221
      protected void tearDownClean()
222
      {
223
        for (String repoName : repoNames)
224
        {
225
          tearDownClean(repoName);
226
        }
227
      }
228
229
      protected void tearDownClean(String repoName)
230
      {
231
        reusableFolder.deleteOnExit();
232
        Connection connection = null;
233
        Statement stmt = null;
234
235
        try
236
        {
237
          connection = defaultDataSource.getConnection();
238
          stmt = connection.createStatement();
239
          stmt.execute("DROP SCHEMA " + repoName);
240
        }
241
        catch (Exception ex)
242
        {
243
          throw WrappedException.wrap(ex);
244
        }
245
        finally
246
        {
247
          DBUtil.close(stmt);
248
          DBUtil.close(connection);
249
        }
250
      }
251
252
      public static class CopyOnBranch extends ReusableFolder
253
      {
254
        private static final long serialVersionUID = 1L;
255
256
        public static final ReusableFolder INSTANCE = new CopyOnBranch(
257
            "DBStore: H2 (branching, range-based, copyOnBranch)",
258
            "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingMappingStrategyWithRanges");
259
260
        public CopyOnBranch(String name, String ms)
261
        {
262
          super(name, ms);
263
        }
264
265
        @Override
266
        protected IMappingStrategy createMappingStrategy()
267
        {
268
          IMappingStrategy ms = super.createMappingStrategy();
269
270
          Map<String, String> properties = new HashMap<String, String>();
271
          properties.put("copyOnBranch", "true");
272
          ms.setProperties(properties);
273
274
          return ms;
275
        }
276
      }
277
    }
278
  }
34
  }
279
}
35
}
(-)src/org/eclipse/emf/cdo/tests/db/HsqldbConfig.java (+153 lines)
Line 0 Link Here
1
/**
2
 * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *    Eike Stepper - initial API and implementation
10
 */
11
package org.eclipse.emf.cdo.tests.db;
12
13
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
14
import org.eclipse.emf.cdo.server.IRepository;
15
import org.eclipse.emf.cdo.server.IRepository.Props;
16
import org.eclipse.emf.cdo.tests.db.bundle.OM;
17
import org.eclipse.emf.cdo.tests.db.verifier.DBStoreVerifier;
18
19
import org.eclipse.net4j.db.DBUtil;
20
import org.eclipse.net4j.db.IDBAdapter;
21
import org.eclipse.net4j.db.hsqldb.HSQLDBAdapter;
22
import org.eclipse.net4j.db.hsqldb.HSQLDBDataSource;
23
24
import org.eclipse.emf.common.util.WrappedException;
25
26
import javax.sql.DataSource;
27
28
import java.io.PrintWriter;
29
import java.sql.Connection;
30
import java.sql.SQLException;
31
import java.sql.Statement;
32
import java.util.ArrayList;
33
import java.util.Map;
34
35
/**
36
 * @author Eike Stepper
37
 */
38
public class HsqldbConfig extends DBConfig
39
{
40
  private static final long serialVersionUID = 1L;
41
42
  public static boolean USE_VERIFIER = false;
43
44
  private transient ArrayList<HSQLDBDataSource> dataSources;
45
46
  public HsqldbConfig(boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation)
47
  {
48
    super("Hsqldb", supportingAudits, supportingBranches, false, false, idGenerationLocation);
49
  }
50
51
  @Override
52
  protected IDBAdapter createDBAdapter()
53
  {
54
    return new HSQLDBAdapter();
55
  }
56
57
  @Override
58
  protected DataSource createDataSource(String repoName)
59
  {
60
    HSQLDBDataSource dataSource = new HSQLDBDataSource();
61
    dataSource.setDatabase("jdbc:hsqldb:mem:" + repoName);
62
    dataSource.setUser("sa");
63
64
    try
65
    {
66
      dataSource.setLogWriter(new PrintWriter(System.err));
67
    }
68
    catch (SQLException ex)
69
    {
70
      OM.LOG.warn(ex.getMessage());
71
    }
72
73
    if (dataSources == null)
74
    {
75
      dataSources = new ArrayList<HSQLDBDataSource>();
76
    }
77
78
    dataSources.add(dataSource);
79
    return dataSource;
80
  }
81
82
  @Override
83
  public void tearDown() throws Exception
84
  {
85
    try
86
    {
87
      if (USE_VERIFIER)
88
      {
89
        IRepository testRepository = getRepository(REPOSITORY_NAME);
90
        if (testRepository != null)
91
        {
92
          getVerifier(testRepository).verify();
93
        }
94
      }
95
    }
96
    finally
97
    {
98
      super.tearDown();
99
    }
100
  }
101
102
  @Override
103
  protected void deactivateRepositories()
104
  {
105
    try
106
    {
107
      shutDownHsqldb();
108
    }
109
    catch (SQLException e)
110
    {
111
      throw new WrappedException(e);
112
    }
113
    finally
114
    {
115
      super.deactivateRepositories();
116
    }
117
  }
118
119
  protected DBStoreVerifier getVerifier(IRepository repository)
120
  {
121
    return new DBStoreVerifier.Audit(repository);
122
  }
123
124
  private void shutDownHsqldb() throws SQLException
125
  {
126
    for (HSQLDBDataSource ds : dataSources)
127
    {
128
      Connection connection = null;
129
      Statement statement = null;
130
131
      try
132
      {
133
        connection = ds.getConnection();
134
        statement = connection.createStatement();
135
        statement.execute("SHUTDOWN");
136
      }
137
      finally
138
      {
139
        DBUtil.close(statement);
140
        DBUtil.close(connection);
141
      }
142
    }
143
144
    dataSources.clear();
145
  }
146
147
  @Override
148
  protected void initRepositoryProperties(Map<String, String> props)
149
  {
150
    super.initRepositoryProperties(props);
151
    props.put(Props.SUPPORTING_AUDITS, "true");
152
  }
153
}
(-)src/org/eclipse/emf/cdo/tests/db/DISABLE_ExternalReferenceTest.java (-2 / +2 lines)
Lines 21-27 Link Here
21
  public void testOneXMIResourceManyViewsOnOneResourceSet() throws Exception
21
  public void testOneXMIResourceManyViewsOnOneResourceSet() throws Exception
22
  {
22
  {
23
    // XXX disabled because of Bug 290097
23
    // XXX disabled because of Bug 290097
24
    skipConfig(AllTestsDBPsql.Psql.INSTANCE);
24
    skipTest(getRepositoryConfig() instanceof PostgresqlConfig);
25
    super.testOneXMIResourceManyViewsOnOneResourceSet();
25
    super.testOneXMIResourceManyViewsOnOneResourceSet();
26
  }
26
  }
27
27
Lines 29-35 Link Here
29
  public void testManyViewsOnOneResourceSet() throws Exception
29
  public void testManyViewsOnOneResourceSet() throws Exception
30
  {
30
  {
31
    // XXX disabled because of Bug 290097
31
    // XXX disabled because of Bug 290097
32
    skipConfig(AllTestsDBPsql.Psql.INSTANCE);
32
    skipTest(getRepositoryConfig() instanceof PostgresqlConfig);
33
    super.testManyViewsOnOneResourceSet();
33
    super.testManyViewsOnOneResourceSet();
34
  }
34
  }
35
}
35
}
(-)src/org/eclipse/emf/cdo/tests/db/AllTestsDBHsqldb.java (-163 / +5 lines)
Lines 10-40 Link Here
10
 */
10
 */
11
package org.eclipse.emf.cdo.tests.db;
11
package org.eclipse.emf.cdo.tests.db;
12
12
13
import org.eclipse.emf.cdo.server.IRepository;
13
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
14
import org.eclipse.emf.cdo.server.IRepository.Props;
15
import org.eclipse.emf.cdo.server.db.CDODBUtil;
16
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
17
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_266982_Test;
14
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_266982_Test;
15
import org.eclipse.emf.cdo.tests.config.IScenario;
18
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
16
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
19
import org.eclipse.emf.cdo.tests.db.bundle.OM;
20
import org.eclipse.emf.cdo.tests.db.verifier.DBStoreVerifier;
21
22
import org.eclipse.net4j.db.DBUtil;
23
import org.eclipse.net4j.db.IDBAdapter;
24
import org.eclipse.net4j.db.hsqldb.HSQLDBAdapter;
25
import org.eclipse.net4j.db.hsqldb.HSQLDBDataSource;
26
27
import org.eclipse.emf.common.util.WrappedException;
28
29
import javax.sql.DataSource;
30
17
31
import java.io.PrintWriter;
32
import java.sql.Connection;
33
import java.sql.SQLException;
34
import java.sql.Statement;
35
import java.util.ArrayList;
36
import java.util.List;
18
import java.util.List;
37
import java.util.Map;
38
19
39
import junit.framework.Test;
20
import junit.framework.Test;
40
import junit.framework.TestSuite;
21
import junit.framework.TestSuite;
Lines 52-205 Link Here
52
  @Override
33
  @Override
53
  protected void initConfigSuites(TestSuite parent)
34
  protected void initConfigSuites(TestSuite parent)
54
  {
35
  {
55
    addScenario(parent, COMBINED, AllTestsDBHsqldb.Hsqldb.INSTANCE, JVM, NATIVE);
36
    addScenario(parent, COMBINED, new HsqldbConfig(true, false, IDGenerationLocation.STORE), JVM, NATIVE);
56
  }
57
58
  @Override
59
  protected boolean hasAuditSupport()
60
  {
61
    return true;
62
  }
37
  }
63
38
64
  @Override
39
  @Override
65
  protected boolean hasBranchingSupport()
40
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
66
  {
41
  {
67
    return false;
42
    super.initTestClasses(testClasses, scenario);
68
  }
69
70
  @Override
71
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
72
  {
73
    super.initTestClasses(testClasses);
74
43
75
    // this takes ages ...
44
    // this takes ages ...
76
    testClasses.remove(Bugzilla_266982_Test.class);
45
    testClasses.remove(Bugzilla_266982_Test.class);
77
  }
46
  }
78
79
  /**
80
   * @author Eike Stepper
81
   */
82
  public static class Hsqldb extends DBStoreRepositoryConfig
83
  {
84
    private static final long serialVersionUID = 1L;
85
86
    public static final AllTestsDBHsqldb.Hsqldb INSTANCE = new Hsqldb("HSQLDB");
87
88
    public static boolean USE_VERIFIER = false;
89
90
    private transient ArrayList<HSQLDBDataSource> dataSources;
91
92
    public Hsqldb(String name)
93
    {
94
      super(name);
95
    }
96
97
    @Override
98
    protected IMappingStrategy createMappingStrategy()
99
    {
100
      return CDODBUtil.createHorizontalMappingStrategy(true);
101
    }
102
103
    @Override
104
    protected IDBAdapter createDBAdapter()
105
    {
106
      return new HSQLDBAdapter();
107
    }
108
109
    @Override
110
    protected DataSource createDataSource(String repoName)
111
    {
112
      HSQLDBDataSource dataSource = new HSQLDBDataSource();
113
      dataSource.setDatabase("jdbc:hsqldb:mem:" + repoName);
114
      dataSource.setUser("sa");
115
116
      try
117
      {
118
        dataSource.setLogWriter(new PrintWriter(System.err));
119
      }
120
      catch (SQLException ex)
121
      {
122
        OM.LOG.warn(ex.getMessage());
123
      }
124
125
      if (dataSources == null)
126
      {
127
        dataSources = new ArrayList<HSQLDBDataSource>();
128
      }
129
      dataSources.add(dataSource);
130
      return dataSource;
131
    }
132
133
    @Override
134
    public void tearDown() throws Exception
135
    {
136
      try
137
      {
138
        if (USE_VERIFIER)
139
        {
140
          IRepository testRepository = getRepository(REPOSITORY_NAME);
141
          if (testRepository != null)
142
          {
143
            getVerifier(testRepository).verify();
144
          }
145
        }
146
      }
147
      finally
148
      {
149
        super.tearDown();
150
      }
151
    }
152
153
    @Override
154
    protected void deactivateRepositories()
155
    {
156
      try
157
      {
158
        shutDownHsqldb();
159
      }
160
      catch (SQLException e)
161
      {
162
        throw new WrappedException(e);
163
      }
164
      finally
165
      {
166
        super.deactivateRepositories();
167
      }
168
    }
169
170
    protected DBStoreVerifier getVerifier(IRepository repository)
171
    {
172
      return new DBStoreVerifier.Audit(repository);
173
    }
174
175
    private void shutDownHsqldb() throws SQLException
176
    {
177
      for (HSQLDBDataSource ds : dataSources)
178
      {
179
        Connection connection = null;
180
        Statement statement = null;
181
182
        try
183
        {
184
          connection = ds.getConnection();
185
          statement = connection.createStatement();
186
          statement.execute("SHUTDOWN");
187
        }
188
        finally
189
        {
190
          DBUtil.close(statement);
191
          DBUtil.close(connection);
192
        }
193
      }
194
195
      dataSources.clear();
196
    }
197
198
    @Override
199
    protected void initRepositoryProperties(Map<String, String> props)
200
    {
201
      super.initRepositoryProperties(props);
202
      props.put(Props.SUPPORTING_AUDITS, "true");
203
    }
204
  }
205
}
47
}
(-)src/org/eclipse/emf/cdo/tests/db/DISABLE_FeatureMapTest.java (-1 / +1 lines)
Lines 21-27 Link Here
21
  @Override
21
  @Override
22
  public void testFeatureMaps() throws Exception
22
  public void testFeatureMaps() throws Exception
23
  {
23
  {
24
    skipConfig(AllTestsDBPsql.Psql.INSTANCE);
24
    skipTest(getRepositoryConfig() instanceof PostgresqlConfig);
25
    super.testFeatureMaps();
25
    super.testFeatureMaps();
26
  }
26
  }
27
}
27
}
(-)src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Offline.java (-205 / +3 lines)
Lines 10-21 Link Here
10
 */
10
 */
11
package org.eclipse.emf.cdo.tests.db;
11
package org.eclipse.emf.cdo.tests.db;
12
12
13
import org.eclipse.emf.cdo.server.IRepository;
13
import org.eclipse.emf.cdo.tests.config.IScenario;
14
import org.eclipse.emf.cdo.server.IStore;
15
import org.eclipse.emf.cdo.server.db.CDODBUtil;
16
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
17
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
14
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
18
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig.OfflineConfig;
19
import org.eclipse.emf.cdo.tests.offline.Bugzilla_319552_Test;
15
import org.eclipse.emf.cdo.tests.offline.Bugzilla_319552_Test;
20
import org.eclipse.emf.cdo.tests.offline.Bugzilla_325097_Test;
16
import org.eclipse.emf.cdo.tests.offline.Bugzilla_325097_Test;
21
import org.eclipse.emf.cdo.tests.offline.Bugzilla_326047_Test;
17
import org.eclipse.emf.cdo.tests.offline.Bugzilla_326047_Test;
Lines 26-49 Link Here
26
import org.eclipse.emf.cdo.tests.offline.OfflineRawTest;
22
import org.eclipse.emf.cdo.tests.offline.OfflineRawTest;
27
import org.eclipse.emf.cdo.tests.offline.OfflineTest;
23
import org.eclipse.emf.cdo.tests.offline.OfflineTest;
28
24
29
import org.eclipse.net4j.db.DBUtil;
30
import org.eclipse.net4j.db.IDBAdapter;
31
import org.eclipse.net4j.db.h2.H2Adapter;
32
import org.eclipse.net4j.util.WrappedException;
33
import org.eclipse.net4j.util.container.IPluginContainer;
34
import org.eclipse.net4j.util.io.IOUtil;
35
import org.eclipse.net4j.util.io.TMPUtil;
36
37
import org.h2.jdbcx.JdbcDataSource;
38
39
import javax.sql.DataSource;
40
41
import java.io.File;
42
import java.sql.Connection;
43
import java.sql.Statement;
44
import java.util.ArrayList;
45
import java.util.List;
25
import java.util.List;
46
import java.util.Map;
47
26
48
import junit.framework.Test;
27
import junit.framework.Test;
49
import junit.framework.TestSuite;
28
import junit.framework.TestSuite;
Lines 59-86 Link Here
59
  }
38
  }
60
39
61
  @Override
40
  @Override
62
  protected boolean hasAuditSupport()
63
  {
64
    return true;
65
  }
66
67
  @Override
68
  protected boolean hasBranchingSupport()
69
  {
70
    return true;
71
  }
72
73
  @Override
74
  protected void initConfigSuites(TestSuite parent)
41
  protected void initConfigSuites(TestSuite parent)
75
  {
42
  {
76
    addScenario(parent, COMBINED, H2Offline.ReusableFolder.INSTANCE, JVM, NATIVE);
43
    addScenario(parent, COMBINED, new H2OfflineConfig(), JVM, NATIVE);
77
  }
44
  }
78
45
79
  @Override
46
  @Override
80
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
47
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
81
  {
48
  {
82
    // super.initTestClasses(testClasses);
83
84
    testClasses.add(OfflineTest.class);
49
    testClasses.add(OfflineTest.class);
85
    testClasses.add(OfflineRawTest.class);
50
    testClasses.add(OfflineRawTest.class);
86
    testClasses.add(OfflineDelayedTest.class);
51
    testClasses.add(OfflineDelayedTest.class);
Lines 93-263 Link Here
93
58
94
    testClasses.add(FailoverTest.class);
59
    testClasses.add(FailoverTest.class);
95
  }
60
  }
96
97
  /**
98
   * @author Eike Stepper
99
   */
100
  public static class H2Offline extends OfflineConfig
101
  {
102
    public static final H2Offline INSTANCE = new H2Offline("DBStore: H2 (offline)");
103
104
    private static final long serialVersionUID = 1L;
105
106
    protected transient File dbFolder;
107
108
    public H2Offline(String name)
109
    {
110
      super(name);
111
    }
112
113
    @Override
114
    protected void initRepositoryProperties(Map<String, String> props)
115
    {
116
      super.initRepositoryProperties(props);
117
      props.put(IRepository.Props.SUPPORTING_AUDITS, "true");
118
      props.put(IRepository.Props.SUPPORTING_BRANCHES, "true");
119
    }
120
121
    public IStore createStore(String repoName)
122
    {
123
      IMappingStrategy mappingStrategy = createMappingStrategy();
124
      IDBAdapter dbAdapter = createDBAdapter();
125
      DataSource dataSource = createDataSource(repoName);
126
      return CDODBUtil.createStore(mappingStrategy, dbAdapter, DBUtil.createConnectionProvider(dataSource));
127
    }
128
129
    protected IMappingStrategy createMappingStrategy()
130
    {
131
      return CDODBUtil.createHorizontalMappingStrategy(true, true);
132
    }
133
134
    protected IDBAdapter createDBAdapter()
135
    {
136
      return new H2Adapter();
137
    }
138
139
    protected DataSource createDataSource(String repoName)
140
    {
141
      if (dbFolder == null)
142
      {
143
        dbFolder = createDBFolder();
144
        tearDownClean();
145
      }
146
147
      JdbcDataSource dataSource = new JdbcDataSource();
148
      dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName);
149
      return dataSource;
150
    }
151
152
    @Override
153
    public void setUp() throws Exception
154
    {
155
      CDODBUtil.prepareContainer(IPluginContainer.INSTANCE);
156
      super.setUp();
157
    }
158
159
    protected void tearDownClean()
160
    {
161
      IOUtil.delete(dbFolder);
162
    }
163
164
    protected File createDBFolder()
165
    {
166
      return TMPUtil.createTempFolder("h2_", "_test");
167
    }
168
169
    /**
170
     * @author Eike Stepper
171
     */
172
    public static class ReusableFolder extends H2Offline
173
    {
174
      private static final long serialVersionUID = 1L;
175
176
      public static final ReusableFolder INSTANCE = new ReusableFolder("DBStore: H2 (offline)");
177
178
      private static File reusableFolder;
179
180
      private static JdbcDataSource defaultDataSource;
181
182
      private transient ArrayList<String> repoNames = new ArrayList<String>();
183
184
      public ReusableFolder(String name)
185
      {
186
        super(name);
187
      }
188
189
      @Override
190
      protected DataSource createDataSource(String repoName)
191
      {
192
        if (reusableFolder == null)
193
        {
194
          reusableFolder = createDBFolder();
195
          IOUtil.delete(reusableFolder);
196
        }
197
198
        dbFolder = reusableFolder;
199
        if (defaultDataSource == null)
200
        {
201
          defaultDataSource = new JdbcDataSource();
202
          defaultDataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test");
203
        }
204
205
        Connection conn = null;
206
        Statement stmt = null;
207
208
        try
209
        {
210
          conn = defaultDataSource.getConnection();
211
          stmt = conn.createStatement();
212
          stmt.execute("DROP SCHEMA IF EXISTS " + repoName);
213
          stmt.execute("CREATE SCHEMA " + repoName);
214
        }
215
        catch (Exception e)
216
        {
217
          e.printStackTrace();
218
        }
219
        finally
220
        {
221
          DBUtil.close(conn);
222
          DBUtil.close(stmt);
223
        }
224
225
        JdbcDataSource dataSource = new JdbcDataSource();
226
        dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName);
227
        return dataSource;
228
      }
229
230
      @Override
231
      protected void tearDownClean()
232
      {
233
        for (String repoName : repoNames)
234
        {
235
          tearDownClean(repoName);
236
        }
237
      }
238
239
      protected void tearDownClean(String repoName)
240
      {
241
        reusableFolder.deleteOnExit();
242
        Connection connection = null;
243
        Statement stmt = null;
244
245
        try
246
        {
247
          connection = defaultDataSource.getConnection();
248
          stmt = connection.createStatement();
249
          stmt.execute("DROP SCHEMA " + repoName);
250
        }
251
        catch (Exception ex)
252
        {
253
          throw WrappedException.wrap(ex);
254
        }
255
        finally
256
        {
257
          DBUtil.close(stmt);
258
          DBUtil.close(connection);
259
        }
260
      }
261
    }
262
  }
263
}
61
}
(-)src/org/eclipse/emf/cdo/tests/db/DISABLE_XRefTest.java (-2 / +1 lines)
Lines 11-17 Link Here
11
package org.eclipse.emf.cdo.tests.db;
11
package org.eclipse.emf.cdo.tests.db;
12
12
13
import org.eclipse.emf.cdo.tests.XRefTest;
13
import org.eclipse.emf.cdo.tests.XRefTest;
14
import org.eclipse.emf.cdo.tests.db.AllTestsDBH2.H2;
15
14
16
/**
15
/**
17
 * @author Eike Stepper
16
 * @author Eike Stepper
Lines 22-28 Link Here
22
  protected void doSetUp() throws Exception
21
  protected void doSetUp() throws Exception
23
  {
22
  {
24
    super.doSetUp();
23
    super.doSetUp();
25
    skipConfig(H2.ReusableFolder.RANGE_INSTANCE);
24
    // skipConfig(H2Config.RANGE_INSTANCE);
26
  }
25
  }
27
26
28
  // @Override
27
  // @Override
(-)src/org/eclipse/emf/cdo/tests/db/AutomatedTests.java (-1 / +1 lines)
Lines 22-28 Link Here
22
  {
22
  {
23
    TestSuite suite = new TestSuite(AutomatedTests.class.getName());
23
    TestSuite suite = new TestSuite(AutomatedTests.class.getName());
24
    suite.addTest(AllTestsDBH2NonAudit.suite());
24
    suite.addTest(AllTestsDBH2NonAudit.suite());
25
    suite.addTest(AllTestsDBH2.suite());
25
    suite.addTest(AllTestsDBH2Audit.suite());
26
    suite.addTest(AllTestsDBH2Branching.suite());
26
    suite.addTest(AllTestsDBH2Branching.suite());
27
    // suite.addTest(AllTestsDBH2Offline.suite());
27
    // suite.addTest(AllTestsDBH2Offline.suite());
28
    // suite.addTest(AllTestsDBHsqldb.suite());
28
    // suite.addTest(AllTestsDBHsqldb.suite());
(-)src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Audit.java (-213 / +5 lines)
Lines 11-35 Link Here
11
 */
11
 */
12
package org.eclipse.emf.cdo.tests.db;
12
package org.eclipse.emf.cdo.tests.db;
13
13
14
import org.eclipse.emf.cdo.server.IRepository;
14
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
15
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
16
17
import org.eclipse.net4j.db.DBUtil;
18
import org.eclipse.net4j.db.IDBAdapter;
19
import org.eclipse.net4j.db.h2.H2Adapter;
20
import org.eclipse.net4j.util.WrappedException;
21
import org.eclipse.net4j.util.io.IOUtil;
22
import org.eclipse.net4j.util.io.TMPUtil;
23
24
import org.h2.jdbcx.JdbcDataSource;
25
26
import javax.sql.DataSource;
27
28
import java.io.File;
29
import java.sql.Connection;
30
import java.sql.Statement;
31
import java.util.ArrayList;
32
import java.util.Map;
33
15
34
import junit.framework.Test;
16
import junit.framework.Test;
35
import junit.framework.TestSuite;
17
import junit.framework.TestSuite;
Lines 37-243 Link Here
37
/**
19
/**
38
 * @author Eike Stepper
20
 * @author Eike Stepper
39
 */
21
 */
40
public class AllTestsDBH2 extends DBConfigs
22
public class AllTestsDBH2Audit extends DBConfigs
41
{
23
{
42
  public static Test suite()
24
  public static Test suite()
43
  {
25
  {
44
    return new AllTestsDBH2().getTestSuite("CDO Tests (DBStore H2 Horizontal)");
26
    return new AllTestsDBH2Audit().getTestSuite("CDO Tests (DBStore H2 Horizontal)");
45
  }
27
  }
46
28
47
  @Override
29
  @Override
48
  protected void initConfigSuites(TestSuite parent)
30
  protected void initConfigSuites(TestSuite parent)
49
  {
31
  {
50
    addScenario(parent, COMBINED, AllTestsDBH2.H2.ReusableFolder.AUDIT_INSTANCE, JVM, NATIVE);
32
    addScenario(parent, COMBINED, new H2Config(true, false, false, false, IDGenerationLocation.STORE), JVM, NATIVE);
51
    addScenario(parent, COMBINED, AllTestsDBH2.H2.ReusableFolder.RANGE_INSTANCE, JVM, NATIVE);
33
    addScenario(parent, COMBINED, new H2Config(true, false, true, false, IDGenerationLocation.STORE), JVM, NATIVE);
52
  }
53
54
  @Override
55
  protected boolean hasAuditSupport()
56
  {
57
    return true;
58
  }
59
60
  @Override
61
  protected boolean hasBranchingSupport()
62
  {
63
    return false;
64
  }
65
66
  /**
67
   * @author Eike Stepper
68
   */
69
  public static class H2 extends DBStoreRepositoryConfig
70
  {
71
    private static final long serialVersionUID = 1L;
72
73
    public static final AllTestsDBH2.H2 INSTANCE = new H2("DBStore: H2 (audit)",
74
        "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategy");
75
76
    protected transient File dbFolder;
77
78
    private String mappingStrategy;
79
80
    public H2(String name, String mappingStrategy)
81
    {
82
      super(name);
83
      this.mappingStrategy = mappingStrategy;
84
    }
85
86
    @Override
87
    protected void initRepositoryProperties(Map<String, String> props)
88
    {
89
      super.initRepositoryProperties(props);
90
      props.put(IRepository.Props.SUPPORTING_AUDITS, "true");
91
      props.put(IRepository.Props.SUPPORTING_BRANCHES, "false");
92
    }
93
94
    @SuppressWarnings("unchecked")
95
    @Override
96
    protected IMappingStrategy createMappingStrategy()
97
    {
98
      try
99
      {
100
        Class<IMappingStrategy> clazz = (Class<IMappingStrategy>)Class.forName(mappingStrategy);
101
        return clazz.newInstance();
102
      }
103
      catch (Exception ex)
104
      {
105
        throw WrappedException.wrap(ex);
106
      }
107
    }
108
109
    @Override
110
    protected IDBAdapter createDBAdapter()
111
    {
112
      return new H2Adapter();
113
    }
114
115
    @Override
116
    protected DataSource createDataSource(String repoName)
117
    {
118
      if (dbFolder == null)
119
      {
120
        dbFolder = createDBFolder();
121
        tearDownClean();
122
      }
123
124
      JdbcDataSource dataSource = new JdbcDataSource();
125
      dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName);
126
      return dataSource;
127
    }
128
129
    protected void tearDownClean()
130
    {
131
      IOUtil.delete(dbFolder);
132
    }
133
134
    protected File createDBFolder()
135
    {
136
      return TMPUtil.createTempFolder("h2_", "_test");
137
    }
138
139
    /**
140
     * @author Eike Stepper
141
     */
142
    public static class ReusableFolder extends H2
143
    {
144
      private static final long serialVersionUID = 1L;
145
146
      public static final ReusableFolder AUDIT_INSTANCE = new ReusableFolder("DBStore: H2 (Reusable Folder, audit), ",
147
          "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategy");
148
149
      public static final ReusableFolder RANGE_INSTANCE = new ReusableFolder(
150
          "DBStore: H2 (Reusable Folder, audit, range-based mapping strategy)",
151
          "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategyWithRanges");
152
153
      private static File reusableFolder;
154
155
      private static JdbcDataSource defaultDataSource;
156
157
      private transient ArrayList<String> repoNames = new ArrayList<String>();
158
159
      public ReusableFolder(String name, String mappingStrategy)
160
      {
161
        super(name, mappingStrategy);
162
      }
163
164
      @Override
165
      protected DataSource createDataSource(String repoName)
166
      {
167
        if (reusableFolder == null)
168
        {
169
          reusableFolder = createDBFolder();
170
          IOUtil.delete(reusableFolder);
171
        }
172
173
        dbFolder = reusableFolder;
174
        if (defaultDataSource == null)
175
        {
176
          defaultDataSource = new JdbcDataSource();
177
          defaultDataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test");
178
        }
179
180
        Connection conn = null;
181
        Statement stmt = null;
182
183
        try
184
        {
185
          conn = defaultDataSource.getConnection();
186
          stmt = conn.createStatement();
187
188
          if (!isRestarting())
189
          {
190
            stmt.execute("DROP SCHEMA IF EXISTS " + repoName);
191
          }
192
193
          stmt.execute("CREATE SCHEMA IF NOT EXISTS " + repoName);
194
        }
195
        catch (Exception e)
196
        {
197
          e.printStackTrace();
198
        }
199
        finally
200
        {
201
          DBUtil.close(conn);
202
          DBUtil.close(stmt);
203
        }
204
205
        JdbcDataSource dataSource = new JdbcDataSource();
206
        dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName);
207
        return dataSource;
208
      }
209
210
      @Override
211
      protected void tearDownClean()
212
      {
213
        for (String repoName : repoNames)
214
        {
215
          tearDownClean(repoName);
216
        }
217
      }
218
219
      protected void tearDownClean(String repoName)
220
      {
221
        reusableFolder.deleteOnExit();
222
        Connection connection = null;
223
        Statement stmt = null;
224
225
        try
226
        {
227
          connection = defaultDataSource.getConnection();
228
          stmt = connection.createStatement();
229
          stmt.execute("DROP SCHEMA " + repoName);
230
        }
231
        catch (Exception ex)
232
        {
233
          throw WrappedException.wrap(ex);
234
        }
235
        finally
236
        {
237
          DBUtil.close(stmt);
238
          DBUtil.close(connection);
239
        }
240
      }
241
    }
242
  }
34
  }
243
}
35
}
(-)src/org/eclipse/emf/cdo/tests/db/AllTestsDBPsql.java (-129 / +2 lines)
Lines 12-33 Link Here
12
 */
12
 */
13
package org.eclipse.emf.cdo.tests.db;
13
package org.eclipse.emf.cdo.tests.db;
14
14
15
import org.eclipse.emf.cdo.server.db.CDODBUtil;
15
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
16
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
17
import org.eclipse.emf.cdo.tests.db.bundle.OM;
18
19
import org.eclipse.net4j.db.DBUtil;
20
import org.eclipse.net4j.db.IDBAdapter;
21
import org.eclipse.net4j.db.postgresql.PostgreSQLAdapter;
22
import org.eclipse.net4j.util.io.IOUtil;
23
24
import org.postgresql.jdbc3.Jdbc3SimpleDataSource;
25
26
import javax.sql.DataSource;
27
28
import java.io.PrintWriter;
29
import java.sql.Connection;
30
import java.sql.SQLException;
31
16
32
import junit.framework.Test;
17
import junit.framework.Test;
33
import junit.framework.TestSuite;
18
import junit.framework.TestSuite;
Lines 52-169 Link Here
52
  @Override
37
  @Override
53
  protected void initConfigSuites(TestSuite parent)
38
  protected void initConfigSuites(TestSuite parent)
54
  {
39
  {
55
    addScenario(parent, COMBINED, AllTestsDBPsql.Psql.INSTANCE, JVM, NATIVE);
40
    addScenario(parent, COMBINED, new PostgresqlConfig(false, false, IDGenerationLocation.STORE), JVM, NATIVE);
56
  }
57
58
  @Override
59
  protected boolean hasAuditSupport()
60
  {
61
    return true;
62
  }
63
64
  @Override
65
  protected boolean hasBranchingSupport()
66
  {
67
    return false;
68
  }
69
70
  /**
71
   * @author Victor Roldan Betancort
72
   */
73
  public static class Psql extends DBStoreRepositoryConfig
74
  {
75
    private static final long serialVersionUID = 1L;
76
77
    public static final AllTestsDBPsql.Psql INSTANCE = new Psql("PostgreSQL");
78
79
    private transient Jdbc3SimpleDataSource dataSource;
80
81
    private transient Jdbc3SimpleDataSource setupDataSource;
82
83
    private String currentRepositoryName = "cdodb1";
84
85
    public Psql(String name)
86
    {
87
      super(name);
88
    }
89
90
    @Override
91
    protected IMappingStrategy createMappingStrategy()
92
    {
93
      return CDODBUtil.createHorizontalMappingStrategy(false);
94
    }
95
96
    @Override
97
    protected IDBAdapter createDBAdapter()
98
    {
99
      return new PostgreSQLAdapter();
100
    }
101
102
    @Override
103
    protected DataSource createDataSource(String repoName)
104
    {
105
      currentRepositoryName = repoName;
106
107
      dataSource = new Jdbc3SimpleDataSource();
108
      dataSource.setServerName("localhost");
109
      dataSource.setDatabaseName(currentRepositoryName);
110
      dataSource.setUser("sa");
111
      dataSource.setPassword("sa");
112
113
      try
114
      {
115
        dataSource.setLogWriter(new PrintWriter(System.err));
116
      }
117
      catch (SQLException ex)
118
      {
119
        OM.LOG.warn(ex.getMessage());
120
      }
121
122
      dropDatabase();
123
124
      return dataSource;
125
    }
126
127
    @Override
128
    protected void deactivateRepositories()
129
    {
130
      super.deactivateRepositories();
131
      dataSource = null;
132
      setupDataSource = null;
133
      dropDatabase();
134
    }
135
136
    private void dropDatabase()
137
    {
138
      Connection connection = null;
139
140
      try
141
      {
142
        connection = getSetupDataSource().getConnection();
143
        DBUtil.dropAllTables(connection, currentRepositoryName);
144
      }
145
      catch (SQLException ignore)
146
      {
147
        IOUtil.ERR().println(ignore);
148
      }
149
      finally
150
      {
151
        DBUtil.close(connection);
152
      }
153
    }
154
155
    private DataSource getSetupDataSource()
156
    {
157
      if (setupDataSource == null)
158
      {
159
        setupDataSource = new Jdbc3SimpleDataSource();
160
        setupDataSource.setServerName("localhost");
161
        setupDataSource.setDatabaseName(currentRepositoryName);
162
        setupDataSource.setUser("sa");
163
        setupDataSource.setPassword("sa");
164
      }
165
166
      return setupDataSource;
167
    }
168
  }
41
  }
169
}
42
}
(-)src/org/eclipse/emf/cdo/tests/db/H2OfflineConfig.java (+141 lines)
Line 0 Link Here
1
/**
2
 * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *    Eike Stepper - initial API and implementation
10
 */
11
package org.eclipse.emf.cdo.tests.db;
12
13
import org.eclipse.emf.cdo.server.IStore;
14
import org.eclipse.emf.cdo.server.db.CDODBUtil;
15
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
16
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig.OfflineConfig;
17
18
import org.eclipse.net4j.db.DBUtil;
19
import org.eclipse.net4j.db.IDBAdapter;
20
import org.eclipse.net4j.db.h2.H2Adapter;
21
import org.eclipse.net4j.util.WrappedException;
22
import org.eclipse.net4j.util.container.IPluginContainer;
23
import org.eclipse.net4j.util.io.IOUtil;
24
import org.eclipse.net4j.util.io.TMPUtil;
25
26
import org.h2.jdbcx.JdbcDataSource;
27
28
import javax.sql.DataSource;
29
30
import java.io.File;
31
import java.sql.Connection;
32
import java.sql.Statement;
33
34
/**
35
 * @author Eike Stepper
36
 */
37
public class H2OfflineConfig extends OfflineConfig
38
{
39
  private static final long serialVersionUID = 1L;
40
41
  private static File reusableFolder;
42
43
  private static JdbcDataSource defaultDataSource;
44
45
  public H2OfflineConfig()
46
  {
47
    super("H2Offline");
48
  }
49
50
  public IStore createStore(String repoName)
51
  {
52
    IMappingStrategy mappingStrategy = createMappingStrategy();
53
    IDBAdapter dbAdapter = createDBAdapter();
54
    DataSource dataSource = createDataSource(repoName);
55
    return CDODBUtil.createStore(mappingStrategy, dbAdapter, DBUtil.createConnectionProvider(dataSource));
56
  }
57
58
  protected IMappingStrategy createMappingStrategy()
59
  {
60
    return CDODBUtil.createHorizontalMappingStrategy();
61
  }
62
63
  protected IDBAdapter createDBAdapter()
64
  {
65
    return new H2Adapter();
66
  }
67
68
  protected DataSource createDataSource(String repoName)
69
  {
70
    if (reusableFolder == null)
71
    {
72
      reusableFolder = createDBFolder();
73
      IOUtil.delete(reusableFolder);
74
    }
75
76
    if (defaultDataSource == null)
77
    {
78
      defaultDataSource = new JdbcDataSource();
79
      defaultDataSource.setURL("jdbc:h2:" + reusableFolder.getAbsolutePath() + "/h2test");
80
    }
81
82
    Connection conn = null;
83
    Statement stmt = null;
84
85
    try
86
    {
87
      conn = defaultDataSource.getConnection();
88
      stmt = conn.createStatement();
89
      stmt.execute("DROP SCHEMA IF EXISTS " + repoName);
90
      stmt.execute("CREATE SCHEMA " + repoName);
91
    }
92
    catch (Exception ex)
93
    {
94
      ex.printStackTrace();
95
    }
96
    finally
97
    {
98
      DBUtil.close(conn);
99
      DBUtil.close(stmt);
100
    }
101
102
    JdbcDataSource dataSource = new JdbcDataSource();
103
    dataSource.setURL("jdbc:h2:" + reusableFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName);
104
    return dataSource;
105
  }
106
107
  @Override
108
  public void setUp() throws Exception
109
  {
110
    CDODBUtil.prepareContainer(IPluginContainer.INSTANCE);
111
    super.setUp();
112
  }
113
114
  protected File createDBFolder()
115
  {
116
    return TMPUtil.createTempFolder("h2_", "_test");
117
  }
118
119
  protected void tearDownClean(String repoName)
120
  {
121
    reusableFolder.deleteOnExit();
122
    Connection connection = null;
123
    Statement stmt = null;
124
125
    try
126
    {
127
      connection = defaultDataSource.getConnection();
128
      stmt = connection.createStatement();
129
      stmt.execute("DROP SCHEMA " + repoName);
130
    }
131
    catch (Exception ex)
132
    {
133
      throw WrappedException.wrap(ex);
134
    }
135
    finally
136
    {
137
      DBUtil.close(stmt);
138
      DBUtil.close(connection);
139
    }
140
  }
141
}
(-)src/org/eclipse/emf/cdo/tests/db/H2Config.java (+104 lines)
Line 0 Link Here
1
/**
2
 * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *    Eike Stepper - initial API and implementation
10
 */
11
package org.eclipse.emf.cdo.tests.db;
12
13
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
14
15
import org.eclipse.net4j.db.DBUtil;
16
import org.eclipse.net4j.db.IDBAdapter;
17
import org.eclipse.net4j.db.h2.H2Adapter;
18
import org.eclipse.net4j.util.io.IOUtil;
19
import org.eclipse.net4j.util.io.TMPUtil;
20
21
import org.h2.jdbcx.JdbcDataSource;
22
23
import javax.sql.DataSource;
24
25
import java.io.File;
26
import java.sql.Connection;
27
import java.sql.Statement;
28
29
/**
30
 * @author Eike Stepper
31
 */
32
public class H2Config extends DBConfig
33
{
34
  private static final long serialVersionUID = 1L;
35
36
  private static File reusableFolder;
37
38
  private static JdbcDataSource defaultDataSource;
39
40
  protected transient File dbFolder;
41
42
  public H2Config(boolean supportingAudits, boolean supportingBranches, boolean withRanges, boolean copyOnBranch,
43
      IDGenerationLocation idGenerationLocation)
44
  {
45
    super("H2", supportingAudits, supportingBranches, withRanges, copyOnBranch, idGenerationLocation);
46
  }
47
48
  @Override
49
  protected IDBAdapter createDBAdapter()
50
  {
51
    return new H2Adapter();
52
  }
53
54
  @Override
55
  protected DataSource createDataSource(String repoName)
56
  {
57
    if (reusableFolder == null)
58
    {
59
      reusableFolder = createDBFolder();
60
      IOUtil.delete(reusableFolder);
61
    }
62
63
    dbFolder = reusableFolder;
64
    if (defaultDataSource == null)
65
    {
66
      defaultDataSource = new JdbcDataSource();
67
      defaultDataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test");
68
    }
69
70
    Connection conn = null;
71
    Statement stmt = null;
72
73
    try
74
    {
75
      conn = defaultDataSource.getConnection();
76
      stmt = conn.createStatement();
77
78
      if (!isRestarting())
79
      {
80
        stmt.execute("DROP SCHEMA IF EXISTS " + repoName);
81
      }
82
83
      stmt.execute("CREATE SCHEMA IF NOT EXISTS " + repoName);
84
    }
85
    catch (Exception e)
86
    {
87
      e.printStackTrace();
88
    }
89
    finally
90
    {
91
      DBUtil.close(conn);
92
      DBUtil.close(stmt);
93
    }
94
95
    JdbcDataSource dataSource = new JdbcDataSource();
96
    dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName);
97
    return dataSource;
98
  }
99
100
  protected File createDBFolder()
101
  {
102
    return TMPUtil.createTempFolder("h2_", "_test");
103
  }
104
}
(-)src/org/eclipse/emf/cdo/tests/db/AllTestsDBMysql.java (-169 / +5 lines)
Lines 11-38 Link Here
11
 */
11
 */
12
package org.eclipse.emf.cdo.tests.db;
12
package org.eclipse.emf.cdo.tests.db;
13
13
14
import org.eclipse.emf.cdo.server.IRepository.Props;
14
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
15
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
16
import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingMappingStrategyWithRanges;
17
import org.eclipse.emf.cdo.tests.BranchingSameSessionTest;
15
import org.eclipse.emf.cdo.tests.BranchingSameSessionTest;
18
import org.eclipse.emf.cdo.tests.BranchingTest;
16
import org.eclipse.emf.cdo.tests.BranchingTest;
19
import org.eclipse.emf.cdo.tests.MergingTest;
17
import org.eclipse.emf.cdo.tests.MergingTest;
18
import org.eclipse.emf.cdo.tests.config.IScenario;
20
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
19
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
21
20
22
import org.eclipse.net4j.db.DBUtil;
23
import org.eclipse.net4j.db.IDBAdapter;
24
import org.eclipse.net4j.db.mysql.MYSQLAdapter;
25
26
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
27
28
import javax.sql.DataSource;
29
30
import java.sql.Connection;
31
import java.sql.SQLException;
32
import java.sql.Statement;
33
import java.util.ArrayList;
34
import java.util.List;
21
import java.util.List;
35
import java.util.Map;
36
22
37
import junit.framework.Test;
23
import junit.framework.Test;
38
import junit.framework.TestSuite;
24
import junit.framework.TestSuite;
Lines 42-58 Link Here
42
 */
28
 */
43
public class AllTestsDBMysql extends DBConfigs
29
public class AllTestsDBMysql extends DBConfigs
44
{
30
{
45
  /**
46
   * Instructions to test with MySQL: - create a mysql instance - set HOST to the host where the DB is running
47
   * (listening on TCP) - set USER to a user who can create and drop databases (root, essentially) - set PASS to the
48
   * password of the said user
49
   */
50
  public static final String HOST = "localhost";
51
52
  public static final String USER = "root";
53
54
  public static final String PASS = "root";
55
56
  public static Test suite()
31
  public static Test suite()
57
  {
32
  {
58
    return new AllTestsDBMysql().getTestSuite("CDO Tests (DBStore MySql Horizontal)");
33
    return new AllTestsDBMysql().getTestSuite("CDO Tests (DBStore MySql Horizontal)");
Lines 61-216 Link Here
61
  @Override
36
  @Override
62
  protected void initConfigSuites(TestSuite parent)
37
  protected void initConfigSuites(TestSuite parent)
63
  {
38
  {
64
    addScenario(parent, COMBINED, AllTestsDBMysql.Mysql.INSTANCE, JVM, NATIVE);
39
    addScenario(parent, COMBINED, new MysqlConfig(false, false, IDGenerationLocation.STORE), JVM, NATIVE);
65
  }
66
67
  @Override
68
  protected boolean hasAuditSupport()
69
  {
70
    return true;
71
  }
40
  }
72
41
73
  @Override
42
  @Override
74
  protected boolean hasBranchingSupport()
43
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
75
  {
76
    return true;
77
  }
78
79
  @Override
80
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
81
  {
44
  {
82
    // add branching tests for this testsuite
45
    // add branching tests for this testsuite
83
    testClasses.add(BranchingTest.class);
46
    testClasses.add(BranchingTest.class);
84
    testClasses.add(BranchingSameSessionTest.class);
47
    testClasses.add(BranchingSameSessionTest.class);
85
    testClasses.add(MergingTest.class);
48
    testClasses.add(MergingTest.class);
86
49
87
    super.initTestClasses(testClasses);
50
    super.initTestClasses(testClasses, scenario);
88
  }
89
90
  /**
91
   * @author Simon McDuff
92
   */
93
  public static class Mysql extends DBStoreRepositoryConfig
94
  {
95
    private static final long serialVersionUID = 1L;
96
97
    public static final AllTestsDBMysql.Mysql INSTANCE = new Mysql("DBStore: Mysql");
98
99
    private transient DataSource setupDataSource;
100
101
    private transient List<String> databases = new ArrayList<String>();
102
103
    public Mysql(String name)
104
    {
105
      super(name);
106
    }
107
108
    @Override
109
    protected IMappingStrategy createMappingStrategy()
110
    {
111
      return new HorizontalBranchingMappingStrategyWithRanges();
112
    }
113
114
    @Override
115
    protected IDBAdapter createDBAdapter()
116
    {
117
      return new MYSQLAdapter();
118
    }
119
120
    @Override
121
    protected DataSource createDataSource(String repoName)
122
    {
123
      MysqlDataSource ds = new MysqlDataSource();
124
125
      initDatabase("test_" + repoName);
126
127
      ds.setUrl("jdbc:mysql://" + HOST + "/test_" + repoName);
128
      ds.setUser(USER);
129
      if (PASS != null)
130
      {
131
        ds.setPassword(PASS);
132
      }
133
134
      return ds;
135
    }
136
137
    private void initDatabase(String dbName)
138
    {
139
      dropDatabase(dbName);
140
      Connection connection = null;
141
      Statement stmt = null;
142
143
      try
144
      {
145
        connection = getSetupDataSource().getConnection();
146
        stmt = connection.createStatement();
147
        stmt.execute("create database " + dbName);
148
      }
149
      catch (SQLException ignore)
150
      {
151
      }
152
      finally
153
      {
154
        DBUtil.close(stmt);
155
        DBUtil.close(connection);
156
      }
157
    }
158
159
    @Override
160
    protected void deactivateRepositories()
161
    {
162
      super.deactivateRepositories();
163
      for (String dbName : databases)
164
      {
165
        dropDatabase(dbName);
166
      }
167
    }
168
169
    private void dropDatabase(String dbName)
170
    {
171
      Connection connection = null;
172
      Statement stmt = null;
173
174
      try
175
      {
176
        connection = getSetupDataSource().getConnection();
177
        stmt = connection.createStatement();
178
        stmt.execute("DROP database " + dbName);
179
      }
180
      catch (SQLException ignore)
181
      {
182
      }
183
      finally
184
      {
185
        DBUtil.close(stmt);
186
        DBUtil.close(connection);
187
      }
188
    }
189
190
    private DataSource getSetupDataSource()
191
    {
192
      if (setupDataSource == null)
193
      {
194
        MysqlDataSource ds = new MysqlDataSource();
195
        ds.setUrl("jdbc:mysql://" + HOST);
196
        ds.setUser(USER);
197
        if (PASS != null)
198
        {
199
          ds.setPassword(PASS);
200
        }
201
202
        setupDataSource = ds;
203
      }
204
205
      return setupDataSource;
206
    }
207
208
    @Override
209
    protected void initRepositoryProperties(Map<String, String> props)
210
    {
211
      super.initRepositoryProperties(props);
212
      props.put(Props.SUPPORTING_AUDITS, "true");
213
      props.put(Props.SUPPORTING_BRANCHES, "true");
214
    }
215
  }
51
  }
216
}
52
}
(-)src/org/eclipse/emf/cdo/tests/db/PostgresqlConfig.java (+120 lines)
Line 0 Link Here
1
/**
2
 * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *    Eike Stepper - initial API and implementation
10
 */
11
package org.eclipse.emf.cdo.tests.db;
12
13
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
14
import org.eclipse.emf.cdo.tests.db.bundle.OM;
15
16
import org.eclipse.net4j.db.DBUtil;
17
import org.eclipse.net4j.db.IDBAdapter;
18
import org.eclipse.net4j.db.postgresql.PostgreSQLAdapter;
19
import org.eclipse.net4j.util.io.IOUtil;
20
21
import org.postgresql.jdbc3.Jdbc3SimpleDataSource;
22
23
import javax.sql.DataSource;
24
25
import java.io.PrintWriter;
26
import java.sql.Connection;
27
import java.sql.SQLException;
28
29
/**
30
 * @author Victor Roldan Betancort
31
 */
32
public class PostgresqlConfig extends DBConfig
33
{
34
  private static final long serialVersionUID = 1L;
35
36
  private transient Jdbc3SimpleDataSource dataSource;
37
38
  private transient Jdbc3SimpleDataSource setupDataSource;
39
40
  private String currentRepositoryName = "cdodb1";
41
42
  public PostgresqlConfig(boolean supportingAudits, boolean supportingBranches,
43
      IDGenerationLocation idGenerationLocation)
44
  {
45
    super("Postgresql", supportingAudits, supportingBranches, false, false, idGenerationLocation);
46
  }
47
48
  @Override
49
  protected IDBAdapter createDBAdapter()
50
  {
51
    return new PostgreSQLAdapter();
52
  }
53
54
  @Override
55
  protected DataSource createDataSource(String repoName)
56
  {
57
    currentRepositoryName = repoName;
58
59
    dataSource = new Jdbc3SimpleDataSource();
60
    dataSource.setServerName("localhost");
61
    dataSource.setDatabaseName(currentRepositoryName);
62
    dataSource.setUser("sa");
63
    dataSource.setPassword("sa");
64
65
    try
66
    {
67
      dataSource.setLogWriter(new PrintWriter(System.err));
68
    }
69
    catch (SQLException ex)
70
    {
71
      OM.LOG.warn(ex.getMessage());
72
    }
73
74
    dropDatabase();
75
76
    return dataSource;
77
  }
78
79
  @Override
80
  protected void deactivateRepositories()
81
  {
82
    super.deactivateRepositories();
83
    dataSource = null;
84
    setupDataSource = null;
85
    dropDatabase();
86
  }
87
88
  private void dropDatabase()
89
  {
90
    Connection connection = null;
91
92
    try
93
    {
94
      connection = getSetupDataSource().getConnection();
95
      DBUtil.dropAllTables(connection, currentRepositoryName);
96
    }
97
    catch (SQLException ignore)
98
    {
99
      IOUtil.ERR().println(ignore);
100
    }
101
    finally
102
    {
103
      DBUtil.close(connection);
104
    }
105
  }
106
107
  private DataSource getSetupDataSource()
108
  {
109
    if (setupDataSource == null)
110
    {
111
      setupDataSource = new Jdbc3SimpleDataSource();
112
      setupDataSource.setServerName("localhost");
113
      setupDataSource.setDatabaseName(currentRepositoryName);
114
      setupDataSource.setUser("sa");
115
      setupDataSource.setPassword("sa");
116
    }
117
118
    return setupDataSource;
119
  }
120
}
(-)CDO AllTests (H2 audit).launch (-2 / +2 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
2
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
3
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
3
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
4
<listEntry value="/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2.java"/>
4
<listEntry value="/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2Audit.java"/>
5
</listAttribute>
5
</listAttribute>
6
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
6
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
7
<listEntry value="1"/>
7
<listEntry value="1"/>
Lines 10-16 Link Here
10
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
10
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
11
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
11
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
12
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
12
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
13
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBH2"/>
13
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBH2Audit"/>
14
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
14
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
15
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m&#13;&#10;-Xmx1024m&#13;&#10;-Dorg.eclipse.net4j.util.om.trace.disable=true"/>
15
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m&#13;&#10;-Xmx1024m&#13;&#10;-Dorg.eclipse.net4j.util.om.trace.disable=true"/>
16
</launchConfiguration>
16
</launchConfiguration>
(-)src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2.java (-243 lines)
Lines 1-243 Link Here
1
/**
2
 * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    Eike Stepper - initial API and implementation
10
 *    Stefan Winkler - introduced variable mapping strategies
11
 */
12
package org.eclipse.emf.cdo.tests.db;
13
14
import org.eclipse.emf.cdo.server.IRepository;
15
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
16
17
import org.eclipse.net4j.db.DBUtil;
18
import org.eclipse.net4j.db.IDBAdapter;
19
import org.eclipse.net4j.db.h2.H2Adapter;
20
import org.eclipse.net4j.util.WrappedException;
21
import org.eclipse.net4j.util.io.IOUtil;
22
import org.eclipse.net4j.util.io.TMPUtil;
23
24
import org.h2.jdbcx.JdbcDataSource;
25
26
import javax.sql.DataSource;
27
28
import java.io.File;
29
import java.sql.Connection;
30
import java.sql.Statement;
31
import java.util.ArrayList;
32
import java.util.Map;
33
34
import junit.framework.Test;
35
import junit.framework.TestSuite;
36
37
/**
38
 * @author Eike Stepper
39
 */
40
public class AllTestsDBH2 extends DBConfigs
41
{
42
  public static Test suite()
43
  {
44
    return new AllTestsDBH2().getTestSuite("CDO Tests (DBStore H2 Horizontal)");
45
  }
46
47
  @Override
48
  protected void initConfigSuites(TestSuite parent)
49
  {
50
    addScenario(parent, COMBINED, AllTestsDBH2.H2.ReusableFolder.AUDIT_INSTANCE, JVM, NATIVE);
51
    addScenario(parent, COMBINED, AllTestsDBH2.H2.ReusableFolder.RANGE_INSTANCE, JVM, NATIVE);
52
  }
53
54
  @Override
55
  protected boolean hasAuditSupport()
56
  {
57
    return true;
58
  }
59
60
  @Override
61
  protected boolean hasBranchingSupport()
62
  {
63
    return false;
64
  }
65
66
  /**
67
   * @author Eike Stepper
68
   */
69
  public static class H2 extends DBStoreRepositoryConfig
70
  {
71
    private static final long serialVersionUID = 1L;
72
73
    public static final AllTestsDBH2.H2 INSTANCE = new H2("DBStore: H2 (audit)",
74
        "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategy");
75
76
    protected transient File dbFolder;
77
78
    private String mappingStrategy;
79
80
    public H2(String name, String mappingStrategy)
81
    {
82
      super(name);
83
      this.mappingStrategy = mappingStrategy;
84
    }
85
86
    @Override
87
    protected void initRepositoryProperties(Map<String, String> props)
88
    {
89
      super.initRepositoryProperties(props);
90
      props.put(IRepository.Props.SUPPORTING_AUDITS, "true");
91
      props.put(IRepository.Props.SUPPORTING_BRANCHES, "false");
92
    }
93
94
    @SuppressWarnings("unchecked")
95
    @Override
96
    protected IMappingStrategy createMappingStrategy()
97
    {
98
      try
99
      {
100
        Class<IMappingStrategy> clazz = (Class<IMappingStrategy>)Class.forName(mappingStrategy);
101
        return clazz.newInstance();
102
      }
103
      catch (Exception ex)
104
      {
105
        throw WrappedException.wrap(ex);
106
      }
107
    }
108
109
    @Override
110
    protected IDBAdapter createDBAdapter()
111
    {
112
      return new H2Adapter();
113
    }
114
115
    @Override
116
    protected DataSource createDataSource(String repoName)
117
    {
118
      if (dbFolder == null)
119
      {
120
        dbFolder = createDBFolder();
121
        tearDownClean();
122
      }
123
124
      JdbcDataSource dataSource = new JdbcDataSource();
125
      dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName);
126
      return dataSource;
127
    }
128
129
    protected void tearDownClean()
130
    {
131
      IOUtil.delete(dbFolder);
132
    }
133
134
    protected File createDBFolder()
135
    {
136
      return TMPUtil.createTempFolder("h2_", "_test");
137
    }
138
139
    /**
140
     * @author Eike Stepper
141
     */
142
    public static class ReusableFolder extends H2
143
    {
144
      private static final long serialVersionUID = 1L;
145
146
      public static final ReusableFolder AUDIT_INSTANCE = new ReusableFolder("DBStore: H2 (Reusable Folder, audit), ",
147
          "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategy");
148
149
      public static final ReusableFolder RANGE_INSTANCE = new ReusableFolder(
150
          "DBStore: H2 (Reusable Folder, audit, range-based mapping strategy)",
151
          "org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategyWithRanges");
152
153
      private static File reusableFolder;
154
155
      private static JdbcDataSource defaultDataSource;
156
157
      private transient ArrayList<String> repoNames = new ArrayList<String>();
158
159
      public ReusableFolder(String name, String mappingStrategy)
160
      {
161
        super(name, mappingStrategy);
162
      }
163
164
      @Override
165
      protected DataSource createDataSource(String repoName)
166
      {
167
        if (reusableFolder == null)
168
        {
169
          reusableFolder = createDBFolder();
170
          IOUtil.delete(reusableFolder);
171
        }
172
173
        dbFolder = reusableFolder;
174
        if (defaultDataSource == null)
175
        {
176
          defaultDataSource = new JdbcDataSource();
177
          defaultDataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test");
178
        }
179
180
        Connection conn = null;
181
        Statement stmt = null;
182
183
        try
184
        {
185
          conn = defaultDataSource.getConnection();
186
          stmt = conn.createStatement();
187
188
          if (!isRestarting())
189
          {
190
            stmt.execute("DROP SCHEMA IF EXISTS " + repoName);
191
          }
192
193
          stmt.execute("CREATE SCHEMA IF NOT EXISTS " + repoName);
194
        }
195
        catch (Exception e)
196
        {
197
          e.printStackTrace();
198
        }
199
        finally
200
        {
201
          DBUtil.close(conn);
202
          DBUtil.close(stmt);
203
        }
204
205
        JdbcDataSource dataSource = new JdbcDataSource();
206
        dataSource.setURL("jdbc:h2:" + dbFolder.getAbsolutePath() + "/h2test;SCHEMA=" + repoName);
207
        return dataSource;
208
      }
209
210
      @Override
211
      protected void tearDownClean()
212
      {
213
        for (String repoName : repoNames)
214
        {
215
          tearDownClean(repoName);
216
        }
217
      }
218
219
      protected void tearDownClean(String repoName)
220
      {
221
        reusableFolder.deleteOnExit();
222
        Connection connection = null;
223
        Statement stmt = null;
224
225
        try
226
        {
227
          connection = defaultDataSource.getConnection();
228
          stmt = connection.createStatement();
229
          stmt.execute("DROP SCHEMA " + repoName);
230
        }
231
        catch (Exception ex)
232
        {
233
          throw WrappedException.wrap(ex);
234
        }
235
        finally
236
        {
237
          DBUtil.close(stmt);
238
          DBUtil.close(connection);
239
        }
240
      }
241
    }
242
  }
243
}
(-)src/org/eclipse/emf/cdo/tests/db/DBAnnotationsTest.java (-12 / +10 lines)
Lines 68-77 Link Here
68
  public void testLengthAnnotationNegative() throws Exception
68
  public void testLengthAnnotationNegative() throws Exception
69
  {
69
  {
70
    // HSQL does not support length annotations
70
    // HSQL does not support length annotations
71
    skipConfig(AllTestsDBHsqldb.Hsqldb.INSTANCE);
71
    skipTest(getRepositoryConfig() instanceof HsqldbConfig);
72
    skipConfig(AllTestsDBHsqldbNonAudit.HsqldbNonAudit.INSTANCE);
72
73
    // XXX PSQL fails, too - need to investigate
73
    // XXX PSQL fails, too - need to investigate
74
    skipConfig(AllTestsDBPsql.Psql.INSTANCE);
74
    skipTest(getRepositoryConfig() instanceof PostgresqlConfig);
75
75
76
    msg("Opening session");
76
    msg("Opening session");
77
    EPackage model1 = createModel();
77
    EPackage model1 = createModel();
Lines 111-117 Link Here
111
  public void testLengthAnnotationByMetaData() throws CommitException
111
  public void testLengthAnnotationByMetaData() throws CommitException
112
  {
112
  {
113
    // XXX [PSQL] disabled because of Bug 290095
113
    // XXX [PSQL] disabled because of Bug 290095
114
    skipConfig(AllTestsDBPsql.Psql.INSTANCE);
114
    skipTest(getRepositoryConfig() instanceof PostgresqlConfig);
115
115
116
    msg("Opening session");
116
    msg("Opening session");
117
    final EPackage model1 = createModel();
117
    final EPackage model1 = createModel();
Lines 152-162 Link Here
152
  public void testTypeAnnotationByMetaData() throws CommitException
152
  public void testTypeAnnotationByMetaData() throws CommitException
153
  {
153
  {
154
    // XXX [PSQL] disabled because of Bug 290095
154
    // XXX [PSQL] disabled because of Bug 290095
155
    skipConfig(AllTestsDBPsql.Psql.INSTANCE);
155
    skipTest(getRepositoryConfig() instanceof PostgresqlConfig);
156
156
157
    // HSQL does not support type annotations
157
    // HSQL does not support type annotations
158
    skipConfig(AllTestsDBHsqldb.Hsqldb.INSTANCE);
158
    skipTest(getRepositoryConfig() instanceof HsqldbConfig);
159
    skipConfig(AllTestsDBHsqldbNonAudit.HsqldbNonAudit.INSTANCE);
160
159
161
    msg("Opening session");
160
    msg("Opening session");
162
    final EPackage model1 = createModel();
161
    final EPackage model1 = createModel();
Lines 197-203 Link Here
197
  public void testTableNameAnnotationByMetaData() throws CommitException
196
  public void testTableNameAnnotationByMetaData() throws CommitException
198
  {
197
  {
199
    // XXX [PSQL] disabled because of Bug 290095
198
    // XXX [PSQL] disabled because of Bug 290095
200
    skipConfig(AllTestsDBPsql.Psql.INSTANCE);
199
    skipTest(getRepositoryConfig() instanceof PostgresqlConfig);
201
200
202
    msg("Opening session");
201
    msg("Opening session");
203
    EPackage model1 = createModel();
202
    EPackage model1 = createModel();
Lines 237-243 Link Here
237
  public void testColumnNameAnnotationByMetaData() throws CommitException
236
  public void testColumnNameAnnotationByMetaData() throws CommitException
238
  {
237
  {
239
    // XXX [PSQL] disabled because of Bug 290095
238
    // XXX [PSQL] disabled because of Bug 290095
240
    skipConfig(AllTestsDBPsql.Psql.INSTANCE);
239
    skipTest(getRepositoryConfig() instanceof PostgresqlConfig);
241
240
242
    msg("Opening session");
241
    msg("Opening session");
243
    final EPackage model1 = createModel();
242
    final EPackage model1 = createModel();
Lines 278-288 Link Here
278
  public void testColumnNameTypeAnnotationByMetaData() throws CommitException
277
  public void testColumnNameTypeAnnotationByMetaData() throws CommitException
279
  {
278
  {
280
    // HSQL does not support type annotations
279
    // HSQL does not support type annotations
281
    skipConfig(AllTestsDBHsqldb.Hsqldb.INSTANCE);
280
    skipTest(getRepositoryConfig() instanceof HsqldbConfig);
282
    skipConfig(AllTestsDBHsqldbNonAudit.HsqldbNonAudit.INSTANCE);
283
281
284
    // XXX [PSQL] disabled because of Bug 290095
282
    // XXX [PSQL] disabled because of Bug 290095
285
    skipConfig(AllTestsDBPsql.Psql.INSTANCE);
283
    skipTest(getRepositoryConfig() instanceof PostgresqlConfig);
286
284
287
    msg("Opening session");
285
    msg("Opening session");
288
    final EPackage model1 = createModel();
286
    final EPackage model1 = createModel();
(-)src/org/eclipse/emf/cdo/tests/db/AllTestsDBDerby.java (-189 / +2 lines)
Lines 10-36 Link Here
10
 */
10
 */
11
package org.eclipse.emf.cdo.tests.db;
11
package org.eclipse.emf.cdo.tests.db;
12
12
13
import org.eclipse.emf.cdo.server.IRepository;
13
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
14
import org.eclipse.emf.cdo.server.db.CDODBUtil;
15
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
16
17
import org.eclipse.net4j.db.DBUtil;
18
import org.eclipse.net4j.db.IDBAdapter;
19
import org.eclipse.net4j.db.derby.EmbeddedDerbyAdapter;
20
import org.eclipse.net4j.util.WrappedException;
21
import org.eclipse.net4j.util.io.IOUtil;
22
import org.eclipse.net4j.util.io.TMPUtil;
23
24
import org.apache.derby.jdbc.EmbeddedDataSource;
25
26
import javax.sql.DataSource;
27
28
import java.io.File;
29
import java.sql.Connection;
30
import java.util.ArrayList;
31
import java.util.Collection;
32
import java.util.HashMap;
33
import java.util.Map;
34
14
35
import junit.framework.Test;
15
import junit.framework.Test;
36
import junit.framework.TestSuite;
16
import junit.framework.TestSuite;
Lines 48-221 Link Here
48
  @Override
28
  @Override
49
  protected void initConfigSuites(TestSuite parent)
29
  protected void initConfigSuites(TestSuite parent)
50
  {
30
  {
51
    addScenario(parent, COMBINED, AllTestsDBDerby.Derby.ReusableFolder.INSTANCE, JVM, NATIVE);
31
    addScenario(parent, COMBINED, new DerbyConfig(true, true, IDGenerationLocation.STORE), JVM, NATIVE);
52
    // addScenario(parent, COMBINED, AllTestsDBDerby.Derby.INSTANCE, TCP, NATIVE);
32
    // addScenario(parent, COMBINED, AllTestsDBDerby.Derby.INSTANCE, TCP, NATIVE);
53
  }
33
  }
54
55
  @Override
56
  protected boolean hasAuditSupport()
57
  {
58
    return true;
59
  }
60
61
  @Override
62
  protected boolean hasBranchingSupport()
63
  {
64
    return false;
65
  }
66
67
  /**
68
   * @author Eike Stepper
69
   */
70
  public static class Derby extends DBStoreRepositoryConfig
71
  {
72
    private static final long serialVersionUID = 1L;
73
74
    public static final AllTestsDBDerby.Derby INSTANCE = new Derby("DBStore: Derby");
75
76
    private transient ArrayList<File> dbFolders = new ArrayList<File>();
77
78
    public Derby(String name)
79
    {
80
      super(name);
81
    }
82
83
    @Override
84
    protected IMappingStrategy createMappingStrategy()
85
    {
86
      return CDODBUtil.createHorizontalMappingStrategy(true);
87
    }
88
89
    @Override
90
    protected IDBAdapter createDBAdapter()
91
    {
92
      return new EmbeddedDerbyAdapter();
93
    }
94
95
    @Override
96
    protected void initRepositoryProperties(Map<String, String> props)
97
    {
98
      super.initRepositoryProperties(props);
99
      props.put(IRepository.Props.SUPPORTING_AUDITS, "true");
100
    }
101
102
    @Override
103
    protected DataSource createDataSource(String repoName)
104
    {
105
      File dbFolder = createDBFolder(repoName);
106
      dbFolders.add(dbFolder);
107
108
      tearDownClean(dbFolder);
109
110
      EmbeddedDataSource dataSource = new EmbeddedDataSource();
111
      dataSource.setDatabaseName(dbFolder.getAbsolutePath());
112
      dataSource.setCreateDatabase("create");
113
114
      return dataSource;
115
    }
116
117
    public Collection<File> getDbFolders()
118
    {
119
      return dbFolders;
120
    }
121
122
    @Override
123
    protected void deactivateRepositories()
124
    {
125
      for (File folder : getDbFolders())
126
      {
127
        tearDownClean(folder);
128
      }
129
130
      super.deactivateRepositories();
131
    }
132
133
    protected void tearDownClean(File dbFolder)
134
    {
135
      IOUtil.delete(dbFolder);
136
    }
137
138
    protected File createDBFolder(String repo)
139
    {
140
      return TMPUtil.createTempFolder("derby_" + repo + "_", "_test");
141
    }
142
143
    /**
144
     * @author Eike Stepper
145
     */
146
    public static class ReusableFolder extends Derby
147
    {
148
      private static final long serialVersionUID = 1L;
149
150
      public static final ReusableFolder INSTANCE = new ReusableFolder("DBStore: Derby");
151
152
      private static HashMap<String, File> dbFolders = new HashMap<String, File>();
153
154
      private static HashMap<File, EmbeddedDataSource> dataSources = new HashMap<File, EmbeddedDataSource>();
155
156
      public ReusableFolder(String name)
157
      {
158
        super(name);
159
      }
160
161
      @Override
162
      protected DataSource createDataSource(String repoName)
163
      {
164
        File reusableFolder = dbFolders.get(repoName);
165
166
        boolean needsNewFolder = reusableFolder == null;
167
        if (needsNewFolder)
168
        {
169
          reusableFolder = createDBFolder(repoName);
170
          IOUtil.delete(reusableFolder);
171
          dbFolders.put(repoName, reusableFolder);
172
        }
173
174
        EmbeddedDataSource dataSource = new EmbeddedDataSource();
175
        dataSource.setDatabaseName(reusableFolder.getAbsolutePath());
176
        dataSource.setCreateDatabase("create");
177
        dataSources.put(reusableFolder, dataSource);
178
179
        if (!needsNewFolder)
180
        {
181
          tearDownClean(reusableFolder);
182
        }
183
184
        return dataSource;
185
      }
186
187
      @Override
188
      public Collection<File> getDbFolders()
189
      {
190
        return dbFolders.values();
191
      }
192
193
      @Override
194
      protected void tearDownClean(File folder)
195
      {
196
        folder.deleteOnExit();
197
        Connection connection = null;
198
199
        EmbeddedDataSource dataSource = dataSources.get(folder);
200
201
        try
202
        {
203
          connection = dataSource.getConnection();
204
          DBUtil.dropAllTables(connection, dataSource.getDatabaseName());
205
        }
206
        catch (RuntimeException ex)
207
        {
208
          throw ex;
209
        }
210
        catch (Exception ex)
211
        {
212
          throw WrappedException.wrap(ex);
213
        }
214
        finally
215
        {
216
          DBUtil.close(connection);
217
        }
218
      }
219
    }
220
  }
221
}
34
}
(-)src/org/eclipse/emf/cdo/tests/db/DBStoreRepositoryConfig.java (-76 lines)
Lines 1-76 Link Here
1
/**
2
 * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    Eike Stepper - initial API and implementation
10
 */
11
package org.eclipse.emf.cdo.tests.db;
12
13
import org.eclipse.emf.cdo.server.IStore;
14
import org.eclipse.emf.cdo.server.db.CDODBUtil;
15
import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
16
import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
17
import org.eclipse.emf.cdo.server.internal.db.mapping.TypeMappingRegistry;
18
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
19
20
import org.eclipse.net4j.db.DBUtil;
21
import org.eclipse.net4j.db.IDBAdapter;
22
import org.eclipse.net4j.util.container.IPluginContainer;
23
24
import javax.sql.DataSource;
25
26
import java.util.HashMap;
27
import java.util.Map;
28
29
/**
30
 * @author Eike Stepper
31
 */
32
public abstract class DBStoreRepositoryConfig extends RepositoryConfig
33
{
34
  private static final long serialVersionUID = 1L;
35
36
  public DBStoreRepositoryConfig(String name)
37
  {
38
    super(name);
39
  }
40
41
  @Override
42
  public void setUp() throws Exception
43
  {
44
    CDODBUtil.prepareContainer(IPluginContainer.INSTANCE);
45
    super.setUp();
46
    ((TypeMappingRegistry)ITypeMapping.Registry.INSTANCE).init();
47
  }
48
49
  @Override
50
  protected boolean isOptimizing()
51
  {
52
    return true;
53
  }
54
55
  public IStore createStore(String repoName)
56
  {
57
    IMappingStrategy mappingStrategy = createMappingStrategy();
58
    mappingStrategy.setProperties(createMappingStrategyProperties());
59
    IDBAdapter dbAdapter = createDBAdapter();
60
    DataSource dataSource = createDataSource(repoName);
61
    return CDODBUtil.createStore(mappingStrategy, dbAdapter, DBUtil.createConnectionProvider(dataSource));
62
  }
63
64
  protected Map<String, String> createMappingStrategyProperties()
65
  {
66
    Map<String, String> props = new HashMap<String, String>();
67
    props.put(IMappingStrategy.PROP_QUALIFIED_NAMES, "true");
68
    return props;
69
  }
70
71
  protected abstract IMappingStrategy createMappingStrategy();
72
73
  protected abstract IDBAdapter createDBAdapter();
74
75
  protected abstract DataSource createDataSource(String repoName);
76
}
(-)src/org/eclipse/emf/cdo/tests/db/DISABLE_XATransactionTest.java (-2 / +2 lines)
Lines 27-33 Link Here
27
  public void testCommitFromTransactionDisabled() throws Exception
27
  public void testCommitFromTransactionDisabled() throws Exception
28
  {
28
  {
29
    // XXX disabled because of Bug 290097
29
    // XXX disabled because of Bug 290097
30
    skipConfig(AllTestsDBPsql.Psql.INSTANCE);
30
    skipTest(getRepositoryConfig() instanceof PostgresqlConfig);
31
    super.testCommitFromTransactionDisabled();
31
    super.testCommitFromTransactionDisabled();
32
  }
32
  }
33
33
Lines 36-42 Link Here
36
  public void test_ExceptionInReadingStream() throws Exception
36
  public void test_ExceptionInReadingStream() throws Exception
37
  {
37
  {
38
    // XXX disabled because of Bug 290097
38
    // XXX disabled because of Bug 290097
39
    skipConfig(AllTestsDBPsql.Psql.INSTANCE);
39
    skipTest(getRepositoryConfig() instanceof PostgresqlConfig);
40
    super.test_ExceptionInReadingStream();
40
    super.test_ExceptionInReadingStream();
41
  }
41
  }
42
}
42
}
(-)src/org/eclipse/emf/cdo/tests/db/MysqlConfig.java (+159 lines)
Line 0 Link Here
1
/**
2
 * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *    Eike Stepper - initial API and implementation
10
 */
11
package org.eclipse.emf.cdo.tests.db;
12
13
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
14
import org.eclipse.emf.cdo.server.IRepository.Props;
15
16
import org.eclipse.net4j.db.DBUtil;
17
import org.eclipse.net4j.db.IDBAdapter;
18
import org.eclipse.net4j.db.mysql.MYSQLAdapter;
19
20
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
21
22
import javax.sql.DataSource;
23
24
import java.sql.Connection;
25
import java.sql.SQLException;
26
import java.sql.Statement;
27
import java.util.ArrayList;
28
import java.util.List;
29
import java.util.Map;
30
31
/**
32
 * @author Simon McDuff
33
 */
34
public class MysqlConfig extends DBConfig
35
{
36
  private static final long serialVersionUID = 1L;
37
38
  private transient DataSource setupDataSource;
39
40
  private transient List<String> databases = new ArrayList<String>();
41
42
  /**
43
   * Instructions to test with MySQL: - create a mysql instance - set HOST to the host where the DB is running
44
   * (listening on TCP) - set USER to a user who can create and drop databases (root, essentially) - set PASS to the
45
   * password of the said user
46
   */
47
  public static final String HOST = "localhost";
48
49
  public static final String USER = "root";
50
51
  public static final String PASS = "root";
52
53
  public MysqlConfig(boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation)
54
  {
55
    super("Mysql", supportingAudits, supportingBranches, false, false, idGenerationLocation);
56
  }
57
58
  @Override
59
  protected IDBAdapter createDBAdapter()
60
  {
61
    return new MYSQLAdapter();
62
  }
63
64
  @Override
65
  protected DataSource createDataSource(String repoName)
66
  {
67
    MysqlDataSource ds = new MysqlDataSource();
68
69
    initDatabase("test_" + repoName);
70
71
    ds.setUrl("jdbc:mysql://" + MysqlConfig.HOST + "/test_" + repoName);
72
    ds.setUser(MysqlConfig.USER);
73
    if (MysqlConfig.PASS != null)
74
    {
75
      ds.setPassword(MysqlConfig.PASS);
76
    }
77
78
    return ds;
79
  }
80
81
  private void initDatabase(String dbName)
82
  {
83
    dropDatabase(dbName);
84
    Connection connection = null;
85
    Statement stmt = null;
86
87
    try
88
    {
89
      connection = getSetupDataSource().getConnection();
90
      stmt = connection.createStatement();
91
      stmt.execute("create database " + dbName);
92
    }
93
    catch (SQLException ignore)
94
    {
95
    }
96
    finally
97
    {
98
      DBUtil.close(stmt);
99
      DBUtil.close(connection);
100
    }
101
  }
102
103
  @Override
104
  protected void deactivateRepositories()
105
  {
106
    super.deactivateRepositories();
107
    for (String dbName : databases)
108
    {
109
      dropDatabase(dbName);
110
    }
111
  }
112
113
  private void dropDatabase(String dbName)
114
  {
115
    Connection connection = null;
116
    Statement stmt = null;
117
118
    try
119
    {
120
      connection = getSetupDataSource().getConnection();
121
      stmt = connection.createStatement();
122
      stmt.execute("DROP database " + dbName);
123
    }
124
    catch (SQLException ignore)
125
    {
126
    }
127
    finally
128
    {
129
      DBUtil.close(stmt);
130
      DBUtil.close(connection);
131
    }
132
  }
133
134
  private DataSource getSetupDataSource()
135
  {
136
    if (setupDataSource == null)
137
    {
138
      MysqlDataSource ds = new MysqlDataSource();
139
      ds.setUrl("jdbc:mysql://" + MysqlConfig.HOST);
140
      ds.setUser(MysqlConfig.USER);
141
      if (MysqlConfig.PASS != null)
142
      {
143
        ds.setPassword(MysqlConfig.PASS);
144
      }
145
146
      setupDataSource = ds;
147
    }
148
149
    return setupDataSource;
150
  }
151
152
  @Override
153
  protected void initRepositoryProperties(Map<String, String> props)
154
  {
155
    super.initRepositoryProperties(props);
156
    props.put(Props.SUPPORTING_AUDITS, "true");
157
    props.put(Props.SUPPORTING_BRANCHES, "true");
158
  }
159
}
(-)src/org/eclipse/emf/cdo/tests/db/DerbyConfig.java (+125 lines)
Line 0 Link Here
1
/**
2
 * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 * 
8
 * Contributors:
9
 *    Eike Stepper - initial API and implementation
10
 */
11
package org.eclipse.emf.cdo.tests.db;
12
13
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
14
15
import org.eclipse.net4j.db.DBUtil;
16
import org.eclipse.net4j.db.IDBAdapter;
17
import org.eclipse.net4j.db.derby.EmbeddedDerbyAdapter;
18
import org.eclipse.net4j.util.WrappedException;
19
import org.eclipse.net4j.util.io.IOUtil;
20
import org.eclipse.net4j.util.io.TMPUtil;
21
22
import org.apache.derby.jdbc.EmbeddedDataSource;
23
24
import javax.sql.DataSource;
25
26
import java.io.File;
27
import java.sql.Connection;
28
import java.util.Collection;
29
import java.util.HashMap;
30
31
/**
32
 * @author Eike Stepper
33
 */
34
public class DerbyConfig extends DBConfig
35
{
36
  private static final long serialVersionUID = 1L;
37
38
  private static HashMap<String, File> dbFolders = new HashMap<String, File>();
39
40
  private static HashMap<File, EmbeddedDataSource> dataSources = new HashMap<File, EmbeddedDataSource>();
41
42
  public DerbyConfig(boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation)
43
  {
44
    super("Derby", supportingAudits, supportingBranches, false, false, idGenerationLocation);
45
  }
46
47
  public Collection<File> getDBFolders()
48
  {
49
    return dbFolders.values();
50
  }
51
52
  @Override
53
  protected IDBAdapter createDBAdapter()
54
  {
55
    return new EmbeddedDerbyAdapter();
56
  }
57
58
  @Override
59
  protected DataSource createDataSource(String repoName)
60
  {
61
    File reusableFolder = dbFolders.get(repoName);
62
63
    boolean needsNewFolder = reusableFolder == null;
64
    if (needsNewFolder)
65
    {
66
      reusableFolder = createDBFolder(repoName);
67
      IOUtil.delete(reusableFolder);
68
      dbFolders.put(repoName, reusableFolder);
69
    }
70
71
    EmbeddedDataSource dataSource = new EmbeddedDataSource();
72
    dataSource.setDatabaseName(reusableFolder.getAbsolutePath());
73
    dataSource.setCreateDatabase("create");
74
    dataSources.put(reusableFolder, dataSource);
75
76
    if (!needsNewFolder)
77
    {
78
      tearDownClean(reusableFolder);
79
    }
80
81
    return dataSource;
82
  }
83
84
  @Override
85
  protected void deactivateRepositories()
86
  {
87
    for (File folder : getDBFolders())
88
    {
89
      tearDownClean(folder);
90
    }
91
92
    super.deactivateRepositories();
93
  }
94
95
  protected void tearDownClean(File folder)
96
  {
97
    folder.deleteOnExit();
98
    Connection connection = null;
99
100
    EmbeddedDataSource dataSource = dataSources.get(folder);
101
102
    try
103
    {
104
      connection = dataSource.getConnection();
105
      DBUtil.dropAllTables(connection, dataSource.getDatabaseName());
106
    }
107
    catch (RuntimeException ex)
108
    {
109
      throw ex;
110
    }
111
    catch (Exception ex)
112
    {
113
      throw WrappedException.wrap(ex);
114
    }
115
    finally
116
    {
117
      DBUtil.close(connection);
118
    }
119
  }
120
121
  protected File createDBFolder(String repo)
122
  {
123
    return TMPUtil.createTempFolder("derby_" + repo + "_", "_test");
124
  }
125
}
(-)CDO AllTests (H2 ALL).launch (+16 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
3
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
4
<listEntry value="/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java"/>
5
</listAttribute>
6
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
7
<listEntry value="1"/>
8
</listAttribute>
9
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
10
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
11
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
12
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
13
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db.AllTestsDBH2All"/>
14
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db"/>
15
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xms40m&#13;&#10;-Xmx1024m&#13;&#10;-Dorg.eclipse.net4j.util.om.trace.disable=true"/>
16
</launchConfiguration>
(-)src/org/eclipse/emf/cdo/tests/db/AllTestsDBH2All.java (-11 / +15 lines)
Lines 11-16 Link Here
11
 */
11
 */
12
package org.eclipse.emf.cdo.tests.db;
12
package org.eclipse.emf.cdo.tests.db;
13
13
14
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
15
14
import junit.framework.Test;
16
import junit.framework.Test;
15
import junit.framework.TestSuite;
17
import junit.framework.TestSuite;
16
18
Lines 27-46 Link Here
27
  @Override
29
  @Override
28
  protected void initConfigSuites(TestSuite parent)
30
  protected void initConfigSuites(TestSuite parent)
29
  {
31
  {
30
    addScenario(parent, COMBINED, AllTestsDBH2NonAudit.H2NonAudit.ReusableFolder.INSTANCE, JVM, NATIVE);
32
    addScenarios(parent, IDGenerationLocation.STORE);
31
    addScenario(parent, COMBINED, AllTestsDBH2.H2.ReusableFolder.RANGE_INSTANCE, JVM, NATIVE);
33
    addScenarios(parent, IDGenerationLocation.CLIENT);
32
    addScenario(parent, COMBINED, AllTestsDBH2Branching.H2Branching.ReusableFolder.INSTANCE, JVM, NATIVE);
33
  }
34
  }
34
35
35
  @Override
36
  private void addScenarios(TestSuite parent, IDGenerationLocation idGenerationLocation)
36
  protected boolean hasAuditSupport()
37
  {
37
  {
38
    return true;
38
    // Non-audit
39
  }
39
    addScenario(parent, COMBINED, new H2Config(false, false, false, false, idGenerationLocation), JVM, NATIVE);
40
40
41
  @Override
41
    // Audit
42
  protected boolean hasBranchingSupport()
42
    addScenario(parent, COMBINED, new H2Config(true, false, false, false, idGenerationLocation), JVM, NATIVE);
43
  {
43
    addScenario(parent, COMBINED, new H2Config(true, false, true, false, idGenerationLocation), JVM, NATIVE);
44
    return false;
44
45
    // Branching
46
    addScenario(parent, COMBINED, new H2Config(true, true, false, false, idGenerationLocation), JVM, NATIVE);
47
    addScenario(parent, COMBINED, new H2Config(true, true, true, false, idGenerationLocation), JVM, NATIVE);
48
    addScenario(parent, COMBINED, new H2Config(true, true, true, true, idGenerationLocation), JVM, NATIVE);
45
  }
49
  }
46
}
50
}
(-)src/org/eclipse/emf/cdo/tests/db/DBConfigs.java (-8 / +5 lines)
Lines 25-30 Link Here
25
import org.eclipse.emf.cdo.tests.XRefTest;
25
import org.eclipse.emf.cdo.tests.XRefTest;
26
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_252214_Test;
26
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_252214_Test;
27
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_303807_Test;
27
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_303807_Test;
28
import org.eclipse.emf.cdo.tests.config.IScenario;
28
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
29
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
29
30
30
import java.util.List;
31
import java.util.List;
Lines 35-41 Link Here
35
public abstract class DBConfigs extends AllConfigs
36
public abstract class DBConfigs extends AllConfigs
36
{
37
{
37
  @Override
38
  @Override
38
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
39
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
39
  {
40
  {
40
    testClasses.add(Net4jDBTest.class);
41
    testClasses.add(Net4jDBTest.class);
41
    testClasses.add(DBAnnotationsTest.class);
42
    testClasses.add(DBAnnotationsTest.class);
Lines 43-52 Link Here
43
    testClasses.add(CustomTypeMappingTest.class);
44
    testClasses.add(CustomTypeMappingTest.class);
44
    testClasses.add(SQLQueryTest.class);
45
    testClasses.add(SQLQueryTest.class);
45
46
46
    super.initTestClasses(testClasses);
47
    super.initTestClasses(testClasses, scenario);
47
    testClasses.remove(MEMStoreQueryTest.class);
48
    testClasses.remove(MEMStoreQueryTest.class);
48
49
49
    if (!hasBranchingSupport())
50
    if (!scenario.getRepositoryConfig().isSupportingBranches())
50
    {
51
    {
51
      testClasses.remove(BranchingTest.class);
52
      testClasses.remove(BranchingTest.class);
52
      testClasses.remove(BranchingSameSessionTest.class);
53
      testClasses.remove(BranchingSameSessionTest.class);
Lines 54-60 Link Here
54
      testClasses.remove(Bugzilla_303807_Test.class);
55
      testClasses.remove(Bugzilla_303807_Test.class);
55
    }
56
    }
56
57
57
    if (!hasAuditSupport())
58
    if (!scenario.getRepositoryConfig().isSupportingAudits())
58
    {
59
    {
59
      // non-audit mode - remove audit tests
60
      // non-audit mode - remove audit tests
60
      testClasses.remove(AuditTest.class);
61
      testClasses.remove(AuditTest.class);
Lines 87-94 Link Here
87
    testClasses.remove(ExternalReferenceTest.class);
88
    testClasses.remove(ExternalReferenceTest.class);
88
    testClasses.add(DISABLE_ExternalReferenceTest.class);
89
    testClasses.add(DISABLE_ExternalReferenceTest.class);
89
  }
90
  }
90
91
  protected abstract boolean hasBranchingSupport();
92
93
  protected abstract boolean hasAuditSupport();
94
}
91
}
(-)src/org/eclipse/emf/cdo/tests/mongodb/MongoDBStoreRepositoryConfig.java (-118 lines)
Lines 1-118 Link Here
1
/**
2
 * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    Eike Stepper - initial API and implementation
10
 */
11
package org.eclipse.emf.cdo.tests.mongodb;
12
13
import org.eclipse.emf.cdo.server.CDOServerBrowser;
14
import org.eclipse.emf.cdo.server.IRepository;
15
import org.eclipse.emf.cdo.server.IStore;
16
import org.eclipse.emf.cdo.server.internal.mongodb.MongoDBStore;
17
import org.eclipse.emf.cdo.server.mongodb.CDOMongoDBUtil;
18
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
19
20
import org.eclipse.net4j.util.WrappedException;
21
import org.eclipse.net4j.util.container.IPluginContainer;
22
23
import com.mongodb.DB;
24
import com.mongodb.Mongo;
25
import com.mongodb.MongoURI;
26
27
import java.util.Map;
28
29
/**
30
 * @author Eike Stepper
31
 */
32
public class MongoDBStoreRepositoryConfig extends RepositoryConfig
33
{
34
  public static final MongoDBStoreRepositoryConfig INSTANCE = new MongoDBStoreRepositoryConfig(false, false);
35
36
  public static final MongoDBStoreRepositoryConfig AUDITING = new MongoDBStoreRepositoryConfig(true, false);
37
38
  public static final MongoDBStoreRepositoryConfig BRANCHING = new MongoDBStoreRepositoryConfig(true, true);
39
40
  private static final long serialVersionUID = 1L;
41
42
  private boolean auditing;
43
44
  private boolean branching;
45
46
  private transient CDOServerBrowser mongoBrowser;
47
48
  public MongoDBStoreRepositoryConfig(boolean auditing, boolean branching)
49
  {
50
    super("MongoDBStore" + (branching ? " (branching)" : auditing ? " (auditing)" : ""));
51
    this.auditing = auditing;
52
    this.branching = branching;
53
  }
54
55
  @Override
56
  public void setUp() throws Exception
57
  {
58
    CDOMongoDBUtil.prepareContainer(IPluginContainer.INSTANCE);
59
60
    mongoBrowser = new CDOServerBrowser(MongoDBStore.REPOS);
61
    mongoBrowser.setPort(7778);
62
    mongoBrowser.activate();
63
64
    super.setUp();
65
  }
66
67
  @Override
68
  public void tearDown() throws Exception
69
  {
70
    mongoBrowser.deactivate();
71
    super.tearDown();
72
  }
73
74
  public IStore createStore(String repoName)
75
  {
76
    MongoURI mongoURI = new MongoURI("mongodb://localhost");
77
    if (!isRestarting())
78
    {
79
      dropDatabase(mongoURI, repoName);
80
    }
81
82
    return CDOMongoDBUtil.createStore(mongoURI.toString(), repoName);
83
  }
84
85
  protected void dropDatabase(MongoURI mongoURI, String repoName)
86
  {
87
    Mongo mongo = null;
88
89
    try
90
    {
91
      mongo = new Mongo(mongoURI);
92
      DB db = mongo.getDB(repoName);
93
      if (!db.getCollectionNames().isEmpty())
94
      {
95
        db.dropDatabase();
96
      }
97
    }
98
    catch (Exception ex)
99
    {
100
      throw WrappedException.wrap(ex);
101
    }
102
    finally
103
    {
104
      if (mongo != null)
105
      {
106
        mongo.close();
107
      }
108
    }
109
  }
110
111
  @Override
112
  protected void initRepositoryProperties(Map<String, String> props)
113
  {
114
    super.initRepositoryProperties(props);
115
    props.put(IRepository.Props.SUPPORTING_AUDITS, Boolean.toString(auditing));
116
    props.put(IRepository.Props.SUPPORTING_BRANCHES, Boolean.toString(branching));
117
  }
118
}
(-)src/org/eclipse/emf/cdo/tests/mongodb/AllTestsMongoDB.java (-4 / +6 lines)
Lines 11-18 Link Here
11
 */
11
 */
12
package org.eclipse.emf.cdo.tests.mongodb;
12
package org.eclipse.emf.cdo.tests.mongodb;
13
13
14
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
14
import org.eclipse.emf.cdo.tests.AllConfigs;
15
import org.eclipse.emf.cdo.tests.AllConfigs;
15
import org.eclipse.emf.cdo.tests.MEMStoreQueryTest;
16
import org.eclipse.emf.cdo.tests.MEMStoreQueryTest;
17
import org.eclipse.emf.cdo.tests.config.IScenario;
16
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
18
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
17
19
18
import java.util.List;
20
import java.util.List;
Lines 33-48 Link Here
33
  @Override
35
  @Override
34
  protected void initConfigSuites(TestSuite parent)
36
  protected void initConfigSuites(TestSuite parent)
35
  {
37
  {
36
    addScenario(parent, COMBINED, MongoDBStoreRepositoryConfig.INSTANCE, JVM, NATIVE);
38
    addScenario(parent, COMBINED, new MongoDBConfig(false, false, IDGenerationLocation.STORE), JVM, NATIVE);
37
    addScenario(parent, COMBINED, MongoDBStoreRepositoryConfig.AUDITING, JVM, NATIVE);
39
    addScenario(parent, COMBINED, new MongoDBConfig(true, false, IDGenerationLocation.STORE), JVM, NATIVE);
38
    // addScenario(parent, COMBINED, MongoDBStoreRepositoryConfig.BRANCHING, JVM, NATIVE);
40
    // addScenario(parent, COMBINED, MongoDBStoreRepositoryConfig.BRANCHING, JVM, NATIVE);
39
  }
41
  }
40
42
41
  @Override
43
  @Override
42
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
44
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
43
  {
45
  {
44
    testClasses.add(MongoDBInitialTest.class);
46
    testClasses.add(MongoDBInitialTest.class);
45
    super.initTestClasses(testClasses);
47
    super.initTestClasses(testClasses, scenario);
46
    testClasses.remove(MEMStoreQueryTest.class);
48
    testClasses.remove(MEMStoreQueryTest.class);
47
  }
49
  }
48
}
50
}
(-)src/org/eclipse/emf/cdo/tests/mongodb/MongoDBConfig.java (-42 / +4 lines)
Lines 10-19 Link Here
10
 */
10
 */
11
package org.eclipse.emf.cdo.tests.mongodb;
11
package org.eclipse.emf.cdo.tests.mongodb;
12
12
13
import org.eclipse.emf.cdo.server.CDOServerBrowser;
13
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
14
import org.eclipse.emf.cdo.server.IRepository;
15
import org.eclipse.emf.cdo.server.IStore;
14
import org.eclipse.emf.cdo.server.IStore;
16
import org.eclipse.emf.cdo.server.internal.mongodb.MongoDBStore;
17
import org.eclipse.emf.cdo.server.mongodb.CDOMongoDBUtil;
15
import org.eclipse.emf.cdo.server.mongodb.CDOMongoDBUtil;
18
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
16
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
19
17
Lines 24-76 Link Here
24
import com.mongodb.Mongo;
22
import com.mongodb.Mongo;
25
import com.mongodb.MongoURI;
23
import com.mongodb.MongoURI;
26
24
27
import java.util.Map;
28
29
/**
25
/**
30
 * @author Eike Stepper
26
 * @author Eike Stepper
31
 */
27
 */
32
public class MongoDBStoreRepositoryConfig extends RepositoryConfig
28
public class MongoDBConfig extends RepositoryConfig
33
{
29
{
34
  public static final MongoDBStoreRepositoryConfig INSTANCE = new MongoDBStoreRepositoryConfig(false, false);
35
36
  public static final MongoDBStoreRepositoryConfig AUDITING = new MongoDBStoreRepositoryConfig(true, false);
37
38
  public static final MongoDBStoreRepositoryConfig BRANCHING = new MongoDBStoreRepositoryConfig(true, true);
39
40
  private static final long serialVersionUID = 1L;
30
  private static final long serialVersionUID = 1L;
41
31
42
  private boolean auditing;
32
  public MongoDBConfig(boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation)
43
44
  private boolean branching;
45
46
  private transient CDOServerBrowser mongoBrowser;
47
48
  public MongoDBStoreRepositoryConfig(boolean auditing, boolean branching)
49
  {
33
  {
50
    super("MongoDBStore" + (branching ? " (branching)" : auditing ? " (auditing)" : ""));
34
    super("MongoDB", supportingAudits, supportingBranches, idGenerationLocation);
51
    this.auditing = auditing;
52
    this.branching = branching;
53
  }
35
  }
54
36
55
  @Override
37
  @Override
56
  public void setUp() throws Exception
38
  public void setUp() throws Exception
57
  {
39
  {
58
    CDOMongoDBUtil.prepareContainer(IPluginContainer.INSTANCE);
40
    CDOMongoDBUtil.prepareContainer(IPluginContainer.INSTANCE);
59
60
    mongoBrowser = new CDOServerBrowser(MongoDBStore.REPOS);
61
    mongoBrowser.setPort(7778);
62
    mongoBrowser.activate();
63
64
    super.setUp();
41
    super.setUp();
65
  }
42
  }
66
43
67
  @Override
68
  public void tearDown() throws Exception
69
  {
70
    mongoBrowser.deactivate();
71
    super.tearDown();
72
  }
73
74
  public IStore createStore(String repoName)
44
  public IStore createStore(String repoName)
75
  {
45
  {
76
    MongoURI mongoURI = new MongoURI("mongodb://localhost");
46
    MongoURI mongoURI = new MongoURI("mongodb://localhost");
Lines 107-118 Link Here
107
      }
77
      }
108
    }
78
    }
109
  }
79
  }
110
111
  @Override
112
  protected void initRepositoryProperties(Map<String, String> props)
113
  {
114
    super.initRepositoryProperties(props);
115
    props.put(IRepository.Props.SUPPORTING_AUDITS, Boolean.toString(auditing));
116
    props.put(IRepository.Props.SUPPORTING_BRANCHES, Boolean.toString(branching));
117
  }
118
}
80
}
119
  + text/plain
81
  + text/plain
(-)src/org/eclipse/emf/cdo/tests/config/IRepositoryConfig.java (+7 lines)
Lines 10-15 Link Here
10
 */
10
 */
11
package org.eclipse.emf.cdo.tests.config;
11
package org.eclipse.emf.cdo.tests.config;
12
12
13
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
13
import org.eclipse.emf.cdo.server.IStore;
14
import org.eclipse.emf.cdo.server.IStore;
14
import org.eclipse.emf.cdo.spi.server.InternalRepository;
15
import org.eclipse.emf.cdo.spi.server.InternalRepository;
15
16
Lines 22-27 Link Here
22
{
23
{
23
  public static final String REPOSITORY_NAME = "repo1";
24
  public static final String REPOSITORY_NAME = "repo1";
24
25
26
  public boolean isSupportingAudits();
27
28
  public boolean isSupportingBranches();
29
30
  public IDGenerationLocation getIDGenerationLocation();
31
25
  public Map<String, String> getRepositoryProperties();
32
  public Map<String, String> getRepositoryProperties();
26
33
27
  public InternalRepository getRepository(String name, boolean activate);
34
  public InternalRepository getRepository(String name, boolean activate);
(-)src/org/eclipse/emf/cdo/tests/config/impl/ConfigTestSuite.java (-2 / +2 lines)
Lines 67-73 Link Here
67
      TestSuite suite = new TestSuite(scenario.toString());
67
      TestSuite suite = new TestSuite(scenario.toString());
68
68
69
      List<Class<? extends ConfigTest>> testClasses = new ArrayList<Class<? extends ConfigTest>>();
69
      List<Class<? extends ConfigTest>> testClasses = new ArrayList<Class<? extends ConfigTest>>();
70
      initTestClasses(testClasses);
70
      initTestClasses(testClasses, scenario);
71
71
72
      for (Class<? extends ConfigTest> testClass : testClasses)
72
      for (Class<? extends ConfigTest> testClass : testClasses)
73
      {
73
      {
Lines 98-104 Link Here
98
  // }
98
  // }
99
  // }
99
  // }
100
100
101
  protected abstract void initTestClasses(List<Class<? extends ConfigTest>> testClasses);
101
  protected abstract void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario);
102
102
103
  /**
103
  /**
104
   * @author Eike Stepper
104
   * @author Eike Stepper
(-)src/org/eclipse/emf/cdo/tests/defs/AllTestsCDODefs.java (-1 / +2 lines)
Lines 11-16 Link Here
11
 */
11
 */
12
package org.eclipse.emf.cdo.tests.defs;
12
package org.eclipse.emf.cdo.tests.defs;
13
13
14
import org.eclipse.emf.cdo.tests.config.IScenario;
14
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
15
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
15
import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
16
import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
16
17
Lines 36-42 Link Here
36
  }
37
  }
37
38
38
  @Override
39
  @Override
39
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
40
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
40
  {
41
  {
41
    testClasses.add(EGlobalPackageDefImplTest.class);
42
    testClasses.add(EGlobalPackageDefImplTest.class);
42
    testClasses.add(CDOPackageRegistryDefImplTest.class);
43
    testClasses.add(CDOPackageRegistryDefImplTest.class);
(-)src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java (-87 / +50 lines)
Lines 11-16 Link Here
11
 */
11
 */
12
package org.eclipse.emf.cdo.tests.config.impl;
12
package org.eclipse.emf.cdo.tests.config.impl;
13
13
14
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
14
import org.eclipse.emf.cdo.common.CDOCommonView;
15
import org.eclipse.emf.cdo.common.CDOCommonView;
15
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
16
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
16
import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
17
import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
Lines 93-98 Link Here
93
94
94
  private static final long serialVersionUID = 1L;
95
  private static final long serialVersionUID = 1L;
95
96
97
  private boolean supportingAudits;
98
99
  private boolean supportingBranches;
100
101
  private IDGenerationLocation idGenerationLocation;
102
96
  protected transient Map<String, InternalRepository> repositories;
103
  protected transient Map<String, InternalRepository> repositories;
97
104
98
  /**
105
  /**
Lines 107-115 Link Here
107
114
108
  private transient IRepository.WriteAccessHandler resourcePathChecker;
115
  private transient IRepository.WriteAccessHandler resourcePathChecker;
109
116
110
  public RepositoryConfig(String name)
117
  public RepositoryConfig(String name, boolean supportingAudits, boolean supportingBranches,
118
      IDGenerationLocation idGenerationLocation)
111
  {
119
  {
112
    super(name);
120
    super(name);
121
122
    this.supportingAudits = supportingAudits;
123
    this.supportingBranches = supportingBranches;
124
    this.idGenerationLocation = idGenerationLocation;
125
  }
126
127
  public boolean isSupportingAudits()
128
  {
129
    return supportingAudits;
130
  }
131
132
  public boolean isSupportingBranches()
133
  {
134
    return supportingBranches;
135
  }
136
137
  public IDGenerationLocation getIDGenerationLocation()
138
  {
139
    return idGenerationLocation;
140
  }
141
142
  @Override
143
  public String getName()
144
  {
145
    return super.getName() + (supportingBranches ? "-branching" : supportingAudits ? "-auditing" : "")
146
        + getMappingStrategySpecialization() + (idGenerationLocation == IDGenerationLocation.CLIENT ? "-uuids" : "");
147
  }
148
149
  protected String getMappingStrategySpecialization()
150
  {
151
    return "";
113
  }
152
  }
114
153
115
  public void setRestarting(boolean restarting)
154
  public void setRestarting(boolean restarting)
Lines 139-146 Link Here
139
      }
178
      }
140
    }
179
    }
141
180
142
    // int xxx;
143
    // repositoryProperties.put(IRepository.Props.ID_GENERATION_LOCATION, IDGenerationLocation.CLIENT.toString());
144
    return repositoryProperties;
181
    return repositoryProperties;
145
  }
182
  }
146
183
Lines 195-202 Link Here
195
  protected void initRepositoryProperties(Map<String, String> props)
232
  protected void initRepositoryProperties(Map<String, String> props)
196
  {
233
  {
197
    props.put(Props.OVERRIDE_UUID, ""); // UUID := name !!!
234
    props.put(Props.OVERRIDE_UUID, ""); // UUID := name !!!
198
    props.put(Props.SUPPORTING_AUDITS, "false");
235
    props.put(Props.SUPPORTING_AUDITS, Boolean.toString(supportingAudits));
199
    props.put(Props.SUPPORTING_BRANCHES, "false");
236
    props.put(Props.SUPPORTING_BRANCHES, Boolean.toString(supportingBranches));
237
    props.put(Props.ID_GENERATION_LOCATION, idGenerationLocation.toString());
238
200
  }
239
  }
201
240
202
  public void registerRepository(final InternalRepository repository)
241
  public void registerRepository(final InternalRepository repository)
Lines 542-548 Link Here
542
581
543
    public OfflineConfig(String name)
582
    public OfflineConfig(String name)
544
    {
583
    {
545
      super(name);
584
      super(name, true, true, IDGenerationLocation.CLIENT);
546
    }
585
    }
547
586
548
    @Override
587
    @Override
Lines 560-573 Link Here
560
    }
599
    }
561
600
562
    @Override
601
    @Override
563
    protected void initRepositoryProperties(Map<String, String> props)
564
    {
565
      super.initRepositoryProperties(props);
566
      props.put(Props.SUPPORTING_AUDITS, "true");
567
      props.put(Props.SUPPORTING_BRANCHES, "true");
568
    }
569
570
    @Override
571
    protected InternalRepository createRepository(String name)
602
    protected InternalRepository createRepository(String name)
572
    {
603
    {
573
      boolean failover = getTestFailover();
604
      boolean failover = getTestFailover();
Lines 755-851 Link Here
755
  /**
786
  /**
756
   * @author Eike Stepper
787
   * @author Eike Stepper
757
   */
788
   */
758
  public static class MEM extends RepositoryConfig
789
  public static class MEMConfig extends RepositoryConfig
759
  {
790
  {
760
    public static final MEM INSTANCE = new MEM();
761
762
    private static final long serialVersionUID = 1L;
791
    private static final long serialVersionUID = 1L;
763
792
764
    public MEM()
793
    public MEMConfig(boolean supportingAudits, boolean supportingBranches, IDGenerationLocation idGenerationLocation)
765
    {
794
    {
766
      super("MEM");
795
      super("MEM", supportingAudits, supportingBranches, idGenerationLocation);
767
    }
796
    }
768
797
769
    public IStore createStore(String repoName)
798
    public IStore createStore(String repoName)
770
    {
799
    {
771
      return MEMStoreUtil.createMEMStore();
800
      return MEMStoreUtil.createMEMStore();
772
    }
801
    }
773
774
    @Override
775
    protected void initRepositoryProperties(Map<String, String> props)
776
    {
777
      super.initRepositoryProperties(props);
778
      props.put(Props.SUPPORTING_AUDITS, "false");
779
      props.put(Props.SUPPORTING_BRANCHES, "false");
780
    }
781
  }
802
  }
782
803
783
  /**
804
  /**
784
   * @author Eike Stepper
805
   * @author Eike Stepper
785
   */
806
   */
786
  public static class MEMAudits extends RepositoryConfig
807
  public static class MEMOfflineConfig extends OfflineConfig
787
  {
808
  {
788
    public static final MEMAudits INSTANCE = new MEMAudits();
789
790
    private static final long serialVersionUID = 1L;
809
    private static final long serialVersionUID = 1L;
791
810
792
    public MEMAudits()
811
    public MEMOfflineConfig()
793
    {
794
      super("MEMAudits");
795
    }
796
797
    public IStore createStore(String repoName)
798
    {
799
      return MEMStoreUtil.createMEMStore();
800
    }
801
802
    @Override
803
    protected void initRepositoryProperties(Map<String, String> props)
804
    {
805
      super.initRepositoryProperties(props);
806
      props.put(Props.SUPPORTING_AUDITS, "true");
807
      props.put(Props.SUPPORTING_BRANCHES, "false");
808
    }
809
  }
810
811
  /**
812
   * @author Eike Stepper
813
   */
814
  public static class MEMBranches extends RepositoryConfig
815
  {
816
    public static final MEMBranches INSTANCE = new MEMBranches();
817
818
    private static final long serialVersionUID = 1L;
819
820
    public MEMBranches()
821
    {
822
      super("MEMBranches");
823
    }
824
825
    public IStore createStore(String repoName)
826
    {
827
      return MEMStoreUtil.createMEMStore();
828
    }
829
830
    @Override
831
    protected void initRepositoryProperties(Map<String, String> props)
832
    {
833
      super.initRepositoryProperties(props);
834
      props.put(Props.SUPPORTING_AUDITS, "true");
835
      props.put(Props.SUPPORTING_BRANCHES, "true");
836
    }
837
  }
838
839
  /**
840
   * @author Eike Stepper
841
   */
842
  public static class MEMOffline extends OfflineConfig
843
  {
844
    public static final MEMOffline INSTANCE = new MEMOffline();
845
846
    private static final long serialVersionUID = 1L;
847
848
    public MEMOffline()
849
    {
812
    {
850
      super("MEMOffline");
813
      super("MEMOffline");
851
    }
814
    }
(-)src/org/eclipse/emf/cdo/tests/config/impl/Scenario.java (-5 / +5 lines)
Lines 11-22 Link Here
11
package org.eclipse.emf.cdo.tests.config.impl;
11
package org.eclipse.emf.cdo.tests.config.impl;
12
12
13
import org.eclipse.emf.cdo.tests.config.IConfig;
13
import org.eclipse.emf.cdo.tests.config.IConfig;
14
import org.eclipse.emf.cdo.tests.config.IConstants;
14
import org.eclipse.emf.cdo.tests.config.IContainerConfig;
15
import org.eclipse.emf.cdo.tests.config.IContainerConfig;
15
import org.eclipse.emf.cdo.tests.config.IModelConfig;
16
import org.eclipse.emf.cdo.tests.config.IModelConfig;
16
import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
17
import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
17
import org.eclipse.emf.cdo.tests.config.IScenario;
18
import org.eclipse.emf.cdo.tests.config.IScenario;
18
import org.eclipse.emf.cdo.tests.config.ISessionConfig;
19
import org.eclipse.emf.cdo.tests.config.ISessionConfig;
19
import org.eclipse.emf.cdo.tests.config.impl.SessionConfig.Net4j;
20
20
21
import org.eclipse.net4j.util.WrappedException;
21
import org.eclipse.net4j.util.WrappedException;
22
import org.eclipse.net4j.util.io.IOUtil;
22
import org.eclipse.net4j.util.io.IOUtil;
Lines 315-324 Link Here
315
315
316
    private Default()
316
    private Default()
317
    {
317
    {
318
      setContainerConfig(ContainerConfig.Combined.INSTANCE);
318
      setContainerConfig(IConstants.COMBINED);
319
      setRepositoryConfig(RepositoryConfig.MEMBranches.INSTANCE);
319
      setRepositoryConfig(IConstants.MEM_BRANCHES);
320
      setSessionConfig(Net4j.JVM.INSTANCE);
320
      setSessionConfig(IConstants.JVM);
321
      setModelConfig(ModelConfig.Native.INSTANCE);
321
      setModelConfig(IConstants.NATIVE);
322
    }
322
    }
323
  }
323
  }
324
}
324
}
(-)src/org/eclipse/emf/cdo/tests/config/IConstants.java (-4 / +7 lines)
Lines 10-18 Link Here
10
 */
10
 */
11
package org.eclipse.emf.cdo.tests.config;
11
package org.eclipse.emf.cdo.tests.config;
12
12
13
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
13
import org.eclipse.emf.cdo.tests.config.impl.ContainerConfig;
14
import org.eclipse.emf.cdo.tests.config.impl.ContainerConfig;
14
import org.eclipse.emf.cdo.tests.config.impl.ModelConfig;
15
import org.eclipse.emf.cdo.tests.config.impl.ModelConfig;
15
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
16
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
17
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig.MEMConfig;
18
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig.MEMOfflineConfig;
16
import org.eclipse.emf.cdo.tests.config.impl.SessionConfig;
19
import org.eclipse.emf.cdo.tests.config.impl.SessionConfig;
17
import org.eclipse.emf.cdo.tests.config.impl.SessionConfig.Net4j;
20
import org.eclipse.emf.cdo.tests.config.impl.SessionConfig.Net4j;
18
21
Lines 25-37 Link Here
25
28
26
  public static final ContainerConfig SEPARATED = ContainerConfig.Separated.INSTANCE;
29
  public static final ContainerConfig SEPARATED = ContainerConfig.Separated.INSTANCE;
27
30
28
  public static final RepositoryConfig.MEM MEM = RepositoryConfig.MEM.INSTANCE;
31
  public static final RepositoryConfig MEM = new MEMConfig(false, false, IDGenerationLocation.STORE);
29
32
30
  public static final RepositoryConfig.MEMAudits MEM_AUDITS = RepositoryConfig.MEMAudits.INSTANCE;
33
  public static final RepositoryConfig MEM_AUDITS = new MEMConfig(true, false, IDGenerationLocation.STORE);
31
34
32
  public static final RepositoryConfig.MEMBranches MEM_BRANCHES = RepositoryConfig.MEMBranches.INSTANCE;
35
  public static final RepositoryConfig MEM_BRANCHES = new MEMConfig(true, true, IDGenerationLocation.STORE);
33
36
34
  public static final RepositoryConfig.MEMOffline MEM_OFFLINE = RepositoryConfig.MEMOffline.INSTANCE;
37
  public static final RepositoryConfig MEM_OFFLINE = new MEMOfflineConfig();
35
38
36
  public static final SessionConfig EMBEDDED = SessionConfig.Embedded.INSTANCE;
39
  public static final SessionConfig EMBEDDED = SessionConfig.Embedded.INSTANCE;
37
40
(-)src/org/eclipse/emf/cdo/tests/AllConfigs.java (-1 / +2 lines)
Lines 11-16 Link Here
11
package org.eclipse.emf.cdo.tests;
11
package org.eclipse.emf.cdo.tests;
12
12
13
import org.eclipse.emf.cdo.tests.bugzilla.*;
13
import org.eclipse.emf.cdo.tests.bugzilla.*;
14
import org.eclipse.emf.cdo.tests.config.IScenario;
14
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
15
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
15
import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
16
import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
16
17
Lines 22-28 Link Here
22
public abstract class AllConfigs extends ConfigTestSuite
23
public abstract class AllConfigs extends ConfigTestSuite
23
{
24
{
24
  @Override
25
  @Override
25
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
26
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
26
  {
27
  {
27
    // General
28
    // General
28
    testClasses.add(InitialTest.class);
29
    testClasses.add(InitialTest.class);
(-)src/org/eclipse/emf/cdo/tests/AllTestsMEMOffline.java (-8 / +7 lines)
Lines 10-15 Link Here
10
 */
10
 */
11
package org.eclipse.emf.cdo.tests;
11
package org.eclipse.emf.cdo.tests;
12
12
13
import org.eclipse.emf.cdo.tests.config.IScenario;
13
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
14
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
14
import org.eclipse.emf.cdo.tests.offline.FailoverTest;
15
import org.eclipse.emf.cdo.tests.offline.FailoverTest;
15
import org.eclipse.emf.cdo.tests.offline.OfflineDelayed2Test;
16
import org.eclipse.emf.cdo.tests.offline.OfflineDelayed2Test;
Lines 31-40 Link Here
31
  }
32
  }
32
33
33
  @Override
34
  @Override
34
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
35
  protected void initConfigSuites(TestSuite parent)
35
  {
36
  {
36
    // super.initTestClasses(testClasses);
37
    addScenario(parent, COMBINED, MEM_OFFLINE, JVM, NATIVE);
38
  }
37
39
40
  @Override
41
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
42
  {
38
    // MEM does not support raw replication
43
    // MEM does not support raw replication
39
    // testClasses.add(OfflineRawTest.class);
44
    // testClasses.add(OfflineRawTest.class);
40
45
Lines 42-51 Link Here
42
    testClasses.add(OfflineDelayed2Test.class);
47
    testClasses.add(OfflineDelayed2Test.class);
43
    testClasses.add(FailoverTest.class);
48
    testClasses.add(FailoverTest.class);
44
  }
49
  }
45
46
  @Override
47
  protected void initConfigSuites(TestSuite parent)
48
  {
49
    addScenario(parent, COMBINED, MEM_OFFLINE, JVM, NATIVE);
50
  }
51
}
50
}
(-)src/org/eclipse/emf/cdo/tests/objectivity/SampleTestsObjy.java (-44 / +3 lines)
Lines 10-16 Link Here
10
 */
10
 */
11
package org.eclipse.emf.cdo.tests.objectivity;
11
package org.eclipse.emf.cdo.tests.objectivity;
12
12
13
import org.eclipse.emf.cdo.server.IRepository;
14
import org.eclipse.emf.cdo.tests.BranchingWithCacheClearTest;
13
import org.eclipse.emf.cdo.tests.BranchingWithCacheClearTest;
15
import org.eclipse.emf.cdo.tests.InitialTest;
14
import org.eclipse.emf.cdo.tests.InitialTest;
16
import org.eclipse.emf.cdo.tests.MergingTest;
15
import org.eclipse.emf.cdo.tests.MergingTest;
Lines 19-28 Link Here
19
import org.eclipse.emf.cdo.tests.RevisionDeltaInBranchTest;
18
import org.eclipse.emf.cdo.tests.RevisionDeltaInBranchTest;
20
import org.eclipse.emf.cdo.tests.UnsetTest;
19
import org.eclipse.emf.cdo.tests.UnsetTest;
21
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_261218_Test;
20
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_261218_Test;
21
import org.eclipse.emf.cdo.tests.config.IScenario;
22
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
22
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
23
23
24
import java.util.List;
24
import java.util.List;
25
import java.util.Map;
26
25
27
import junit.framework.Test;
26
import junit.framework.Test;
28
import junit.framework.TestSuite;
27
import junit.framework.TestSuite;
Lines 40-55 Link Here
40
  @Override
39
  @Override
41
  protected void initConfigSuites(TestSuite parent)
40
  protected void initConfigSuites(TestSuite parent)
42
  {
41
  {
43
    ObjyStoreRepositoryConfig repConfig = ObjySampleConfig.INSTANCE;
42
    addScenario(parent, COMBINED, new ObjyConfig(false, false), JVM, NATIVE);
44
    addScenario(parent, COMBINED, repConfig, JVM, NATIVE);
45
  }
43
  }
46
44
47
  @Override
45
  @Override
48
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
46
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
49
  {
47
  {
50
    // super.initTestClasses(testClasses);
51
    // testClasses.remove(XATransactionTest.class);
52
53
    testClasses.clear();
48
    testClasses.clear();
54
49
55
    // testClasses.add(ComplexTest.class);
50
    // testClasses.add(ComplexTest.class);
Lines 110-149 Link Here
110
    // testClasses.add(Bugzilla_259949_Test.class);
105
    // testClasses.add(Bugzilla_259949_Test.class);
111
    testClasses.add(Bugzilla_261218_Test.class);
106
    testClasses.add(Bugzilla_261218_Test.class);
112
  }
107
  }
113
114
  @Override
115
  protected boolean hasBranchingSupport()
116
  {
117
    return true;
118
  }
119
120
  @Override
121
  protected boolean hasAuditSupport()
122
  {
123
    return true;
124
  }
125
126
  public static class ObjySampleConfig extends ObjyStoreRepositoryConfig
127
  {
128
    private static final long serialVersionUID = 1L;
129
130
    public static final SampleTestsObjy.ObjySampleConfig INSTANCE = new ObjySampleConfig("ObjectivityStore: (sample)"); //$NON-NLS-1$
131
132
    public ObjySampleConfig(String name)
133
    {
134
      super(name);
135
136
      org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.DEBUG.setEnabled(true);
137
      org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.INFO.setEnabled(true);
138
    }
139
140
    @Override
141
    protected void initRepositoryProperties(Map<String, String> props)
142
    {
143
      super.initRepositoryProperties(props);
144
      props.put(IRepository.Props.SUPPORTING_AUDITS, "true");
145
      props.put(IRepository.Props.SUPPORTING_BRANCHES, "true");
146
    }
147
  }
148
149
}
108
}
(-)src/org/eclipse/emf/cdo/tests/objectivity/AllTestsObjyNonAudit.java (-42 / +4 lines)
Lines 11-22 Link Here
11
 */
11
 */
12
package org.eclipse.emf.cdo.tests.objectivity;
12
package org.eclipse.emf.cdo.tests.objectivity;
13
13
14
import org.eclipse.emf.cdo.server.IRepository;
15
import org.eclipse.emf.cdo.tests.ExternalReferenceTest;
14
import org.eclipse.emf.cdo.tests.ExternalReferenceTest;
15
import org.eclipse.emf.cdo.tests.config.IScenario;
16
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
16
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
17
17
18
import java.util.List;
18
import java.util.List;
19
import java.util.Map;
20
19
21
import junit.framework.Test;
20
import junit.framework.Test;
22
import junit.framework.TestSuite;
21
import junit.framework.TestSuite;
Lines 34-84 Link Here
34
  @Override
33
  @Override
35
  protected void initConfigSuites(TestSuite parent)
34
  protected void initConfigSuites(TestSuite parent)
36
  {
35
  {
37
    // ObjyStoreRepositoryConfig repoConfig = ObjyNonAuditConfig.INSTANCE;
36
    addScenario(parent, COMBINED, new ObjyConfig(false, false), JVM, NATIVE);
38
    ObjyStoreRepositoryConfig repoConfig = new ObjyNonAuditConfig("ObjectivityStore: (non-audit)"); //$NON-NLS-1$
39
    addScenario(parent, COMBINED, repoConfig, JVM, NATIVE);
40
  }
41
42
  @Override
43
  protected boolean hasAuditSupport()
44
  {
45
    return false;
46
  }
37
  }
47
38
48
  @Override
39
  @Override
49
  protected boolean hasBranchingSupport()
40
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
50
  {
51
    return false;
52
  }
53
54
  public static class ObjyNonAuditConfig extends ObjyStoreRepositoryConfig
55
  {
41
  {
56
    private static final long serialVersionUID = 1L;
42
    super.initTestClasses(testClasses, scenario);
57
58
    public static final AllTestsObjyNonAudit.ObjyNonAuditConfig INSTANCE = new ObjyNonAuditConfig(
59
        "ObjectivityStore: (non-audit)"); //$NON-NLS-1$
60
61
    public ObjyNonAuditConfig(String name)
62
    {
63
      super(name);
64
65
      org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.DEBUG.setEnabled(true);
66
      org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.INFO.setEnabled(true);
67
    }
68
43
69
    @Override
70
    protected void initRepositoryProperties(Map<String, String> props)
71
    {
72
      super.initRepositoryProperties(props);
73
      props.put(IRepository.Props.SUPPORTING_AUDITS, "false"); //$NON-NLS-1$
74
      props.put(IRepository.Props.SUPPORTING_BRANCHES, "false"); //$NON-NLS-1$
75
    }
76
  }
77
78
  @Override
79
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
80
  {
81
    super.initTestClasses(testClasses);
82
    // There is a problem with the root resource sharing, so for now we're commenting
44
    // There is a problem with the root resource sharing, so for now we're commenting
83
    // out ExternalReferenceTest and Bugzilla_259869_Test
45
    // out ExternalReferenceTest and Bugzilla_259869_Test
84
    testClasses.remove(ExternalReferenceTest.class);
46
    testClasses.remove(ExternalReferenceTest.class);
(-)src/org/eclipse/emf/cdo/tests/objectivity/AllTestsObjyAudit.java (-49 / +1 lines)
Lines 11-22 Link Here
11
 */
11
 */
12
package org.eclipse.emf.cdo.tests.objectivity;
12
package org.eclipse.emf.cdo.tests.objectivity;
13
13
14
import org.eclipse.emf.cdo.server.IRepository;
15
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
16
17
import java.util.List;
18
import java.util.Map;
19
20
import junit.framework.Test;
14
import junit.framework.Test;
21
import junit.framework.TestSuite;
15
import junit.framework.TestSuite;
22
16
Lines 33-80 Link Here
33
  @Override
27
  @Override
34
  protected void initConfigSuites(TestSuite parent)
28
  protected void initConfigSuites(TestSuite parent)
35
  {
29
  {
36
    ObjyStoreRepositoryConfig repoConfig = ObjyAuditConfig.INSTANCE;
30
    addScenario(parent, COMBINED, new ObjyConfig(true, false), JVM, NATIVE);
37
    addScenario(parent, COMBINED, repoConfig, JVM, NATIVE);
38
  }
39
40
  @Override
41
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
42
  {
43
    super.initTestClasses(testClasses);
44
  }
45
46
  @Override
47
  protected boolean hasAuditSupport()
48
  {
49
    return true;
50
  }
51
52
  @Override
53
  protected boolean hasBranchingSupport()
54
  {
55
    return false;
56
  }
57
58
  public static class ObjyAuditConfig extends ObjyStoreRepositoryConfig
59
  {
60
    private static final long serialVersionUID = 1L;
61
62
    public static final AllTestsObjyAudit.ObjyAuditConfig INSTANCE = new ObjyAuditConfig("ObjectivityStore: (audit)"); //$NON-NLS-1$
63
64
    public ObjyAuditConfig(String name)
65
    {
66
      super(name);
67
68
      org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.DEBUG.setEnabled(true);
69
      org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.INFO.setEnabled(true);
70
    }
71
72
    @Override
73
    protected void initRepositoryProperties(Map<String, String> props)
74
    {
75
      super.initRepositoryProperties(props);
76
      props.put(IRepository.Props.SUPPORTING_AUDITS, "true"); //$NON-NLS-1$
77
      props.put(IRepository.Props.SUPPORTING_BRANCHES, "false"); //$NON-NLS-1$
78
    }
79
  }
31
  }
80
}
32
}
(-)src/org/eclipse/emf/cdo/tests/objectivity/ObjyDBConfigs.java (-10 / +7 lines)
Lines 11-24 Link Here
11
package org.eclipse.emf.cdo.tests.objectivity;
11
package org.eclipse.emf.cdo.tests.objectivity;
12
12
13
import org.eclipse.emf.cdo.tests.AllConfigs;
13
import org.eclipse.emf.cdo.tests.AllConfigs;
14
import org.eclipse.emf.cdo.tests.AuditTest;
15
import org.eclipse.emf.cdo.tests.AuditSameSessionTest;
14
import org.eclipse.emf.cdo.tests.AuditSameSessionTest;
16
import org.eclipse.emf.cdo.tests.BranchingTest;
15
import org.eclipse.emf.cdo.tests.AuditTest;
17
import org.eclipse.emf.cdo.tests.BranchingSameSessionTest;
16
import org.eclipse.emf.cdo.tests.BranchingSameSessionTest;
17
import org.eclipse.emf.cdo.tests.BranchingTest;
18
import org.eclipse.emf.cdo.tests.MergingTest;
18
import org.eclipse.emf.cdo.tests.MergingTest;
19
import org.eclipse.emf.cdo.tests.XATransactionTest;
19
import org.eclipse.emf.cdo.tests.XATransactionTest;
20
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_252214_Test;
20
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_252214_Test;
21
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_303807_Test;
21
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_303807_Test;
22
import org.eclipse.emf.cdo.tests.config.IScenario;
22
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
23
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
23
24
24
import java.util.List;
25
import java.util.List;
Lines 29-41 Link Here
29
public abstract class ObjyDBConfigs extends AllConfigs
30
public abstract class ObjyDBConfigs extends AllConfigs
30
{
31
{
31
  @Override
32
  @Override
32
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
33
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
33
  {
34
  {
34
    super.initTestClasses(testClasses);
35
    super.initTestClasses(testClasses, scenario);
35
36
36
    // remove BranchingTests because most mappings do not support it
37
    // remove BranchingTests because most mappings do not support it
37
    // Subclasses should add Banching tests if supported
38
    // Subclasses should add Banching tests if supported
38
    if (!hasBranchingSupport())
39
    if (!scenario.getRepositoryConfig().isSupportingBranches())
39
    {
40
    {
40
      testClasses.remove(BranchingTest.class);
41
      testClasses.remove(BranchingTest.class);
41
      testClasses.remove(BranchingSameSessionTest.class);
42
      testClasses.remove(BranchingSameSessionTest.class);
Lines 43-49 Link Here
43
      testClasses.remove(Bugzilla_303807_Test.class);
44
      testClasses.remove(Bugzilla_303807_Test.class);
44
    }
45
    }
45
46
46
    if (!hasAuditSupport())
47
    if (!scenario.getRepositoryConfig().isSupportingAudits())
47
    {
48
    {
48
      // non-audit mode - remove audit tests
49
      // non-audit mode - remove audit tests
49
      testClasses.remove(AuditTest.class);
50
      testClasses.remove(AuditTest.class);
Lines 58-65 Link Here
58
    // sometime cause a crash (Investigate!!)
59
    // sometime cause a crash (Investigate!!)
59
    testClasses.remove(XATransactionTest.class);
60
    testClasses.remove(XATransactionTest.class);
60
  }
61
  }
61
62
  protected abstract boolean hasBranchingSupport();
63
64
  protected abstract boolean hasAuditSupport();
65
}
62
}
(-)src/org/eclipse/emf/cdo/tests/objectivity/ObjyStoreRepositoryConfig.java (-57 lines)
Lines 1-57 Link Here
1
/**
2
 * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    Eike Stepper - initial API and implementation
10
 */
11
package org.eclipse.emf.cdo.tests.objectivity;
12
13
import org.eclipse.emf.cdo.server.IStore;
14
import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStoreConfig;
15
import org.eclipse.emf.cdo.server.objectivity.ObjyStoreUtil;
16
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
17
18
/**
19
 * @author Eike Stepper
20
 */
21
public abstract class ObjyStoreRepositoryConfig extends RepositoryConfig
22
{
23
  private static final long serialVersionUID = 1L;
24
25
  private static ObjectivityStoreConfig storeConfig = new ObjectivityStoreConfig();
26
27
  public ObjyStoreRepositoryConfig(String name)
28
  {
29
    super(name);
30
  }
31
32
  @Override
33
  public void setUp() throws Exception
34
  {
35
    // System.out.println("ObjyStoreRepositry.setup() - STARTED");
36
    // long sTime = System.currentTimeMillis();
37
    super.setUp();
38
    // long eTime = System.currentTimeMillis();
39
    // System.out.println("ObjyStoreRepositry.setup() time: " + (eTime - sTime));
40
  }
41
42
  @Override
43
  protected void deactivateRepositories()
44
  {
45
    super.deactivateRepositories();
46
    // System.out.println(">>>>IS:<<<< We need to remove all data created here....");
47
    storeConfig.resetFD();
48
  }
49
50
  public IStore createStore(String repoName)
51
  {
52
    // We might need to use the repoName to our advantage!!!
53
    System.out.println("************* ObjyStore creation ****************\n");
54
    return ObjyStoreUtil.createStore(storeConfig);
55
  }
56
57
}
(-)src/org/eclipse/emf/cdo/tests/objectivity/AllTestsObjyBranching.java (-55 / +1 lines)
Lines 11-22 Link Here
11
 */
11
 */
12
package org.eclipse.emf.cdo.tests.objectivity;
12
package org.eclipse.emf.cdo.tests.objectivity;
13
13
14
import org.eclipse.emf.cdo.server.IRepository;
15
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
16
17
import java.util.List;
18
import java.util.Map;
19
20
import junit.framework.Test;
14
import junit.framework.Test;
21
import junit.framework.TestSuite;
15
import junit.framework.TestSuite;
22
16
Lines 33-86 Link Here
33
  @Override
27
  @Override
34
  protected void initConfigSuites(TestSuite parent)
28
  protected void initConfigSuites(TestSuite parent)
35
  {
29
  {
36
    ObjyStoreRepositoryConfig repoConfig = ObjyBranchingConfig.INSTANCE;
30
    addScenario(parent, COMBINED, new ObjyConfig(true, true), JVM, NATIVE);
37
    addScenario(parent, COMBINED, repoConfig, JVM, NATIVE);
38
  }
39
40
  @Override
41
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
42
  {
43
    super.initTestClasses(testClasses);
44
45
    // // add branching tests for this testsuite
46
    // testClasses.add(BranchingTest.class);
47
    // testClasses.add(BranchingSameSessionTest.class);
48
    // testClasses.add(MergingTest.class);
49
  }
50
51
  @Override
52
  protected boolean hasAuditSupport()
53
  {
54
    return true;
55
  }
56
57
  @Override
58
  protected boolean hasBranchingSupport()
59
  {
60
    return true;
61
  }
62
63
  public static class ObjyBranchingConfig extends ObjyStoreRepositoryConfig
64
  {
65
    private static final long serialVersionUID = 1L;
66
67
    public static final AllTestsObjyBranching.ObjyBranchingConfig INSTANCE = new ObjyBranchingConfig(
68
        "ObjectivityStore: (branching)"); //$NON-NLS-1$
69
70
    public ObjyBranchingConfig(String name)
71
    {
72
      super(name);
73
74
      org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.DEBUG.setEnabled(true);
75
      org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.INFO.setEnabled(true);
76
    }
77
78
    @Override
79
    protected void initRepositoryProperties(Map<String, String> props)
80
    {
81
      super.initRepositoryProperties(props);
82
      props.put(IRepository.Props.SUPPORTING_AUDITS, "true"); //$NON-NLS-1$
83
      props.put(IRepository.Props.SUPPORTING_BRANCHES, "true"); //$NON-NLS-1$
84
    }
85
  }
31
  }
86
}
32
}
(-)src/org/eclipse/emf/cdo/tests/objectivity/ObjyConfig.java (-13 / +6 lines)
Lines 10-15 Link Here
10
 */
10
 */
11
package org.eclipse.emf.cdo.tests.objectivity;
11
package org.eclipse.emf.cdo.tests.objectivity;
12
12
13
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
13
import org.eclipse.emf.cdo.server.IStore;
14
import org.eclipse.emf.cdo.server.IStore;
14
import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStoreConfig;
15
import org.eclipse.emf.cdo.server.internal.objectivity.ObjectivityStoreConfig;
15
import org.eclipse.emf.cdo.server.objectivity.ObjyStoreUtil;
16
import org.eclipse.emf.cdo.server.objectivity.ObjyStoreUtil;
Lines 18-42 Link Here
18
/**
19
/**
19
 * @author Eike Stepper
20
 * @author Eike Stepper
20
 */
21
 */
21
public abstract class ObjyStoreRepositoryConfig extends RepositoryConfig
22
public class ObjyConfig extends RepositoryConfig
22
{
23
{
23
  private static final long serialVersionUID = 1L;
24
  private static final long serialVersionUID = 1L;
24
25
25
  private static ObjectivityStoreConfig storeConfig = new ObjectivityStoreConfig();
26
  private static ObjectivityStoreConfig storeConfig = new ObjectivityStoreConfig();
26
27
27
  public ObjyStoreRepositoryConfig(String name)
28
  public ObjyConfig(boolean supportingAudits, boolean supportingBranches)
28
  {
29
  {
29
    super(name);
30
    super("Objy", supportingAudits, supportingBranches, IDGenerationLocation.STORE);
30
  }
31
31
32
  @Override
32
    org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.DEBUG.setEnabled(true);
33
  public void setUp() throws Exception
33
    org.eclipse.emf.cdo.server.internal.objectivity.bundle.OM.INFO.setEnabled(true);
34
  {
35
    // System.out.println("ObjyStoreRepositry.setup() - STARTED");
36
    // long sTime = System.currentTimeMillis();
37
    super.setUp();
38
    // long eTime = System.currentTimeMillis();
39
    // System.out.println("ObjyStoreRepositry.setup() time: " + (eTime - sTime));
40
  }
34
  }
41
35
42
  @Override
36
  @Override
Lines 53-57 Link Here
53
    System.out.println("************* ObjyStore creation ****************\n");
47
    System.out.println("************* ObjyStore creation ****************\n");
54
    return ObjyStoreUtil.createStore(storeConfig);
48
    return ObjyStoreUtil.createStore(storeConfig);
55
  }
49
  }
56
57
}
50
}
(-)src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4O.java (-95 / +9 lines)
Lines 10-35 Link Here
10
 */
10
 */
11
package org.eclipse.emf.cdo.tests.db4o;
11
package org.eclipse.emf.cdo.tests.db4o;
12
12
13
import org.eclipse.emf.cdo.server.IRepository;
14
import org.eclipse.emf.cdo.server.IStore;
15
import org.eclipse.emf.cdo.server.internal.db4o.DB4OStore;
16
import org.eclipse.emf.cdo.tests.AllConfigs;
13
import org.eclipse.emf.cdo.tests.AllConfigs;
17
import org.eclipse.emf.cdo.tests.BranchingSameSessionTest;
14
import org.eclipse.emf.cdo.tests.BranchingSameSessionTest;
18
import org.eclipse.emf.cdo.tests.BranchingTest;
15
import org.eclipse.emf.cdo.tests.BranchingTest;
19
import org.eclipse.emf.cdo.tests.BranchingWithCacheClearTest;
16
import org.eclipse.emf.cdo.tests.BranchingWithCacheClearTest;
20
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_261218_Test;
17
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_261218_Test;
21
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_324585_Test;
18
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_324585_Test;
19
import org.eclipse.emf.cdo.tests.config.IScenario;
22
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
20
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
23
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
24
25
import org.eclipse.net4j.util.io.TMPUtil;
26
21
27
import java.io.File;
28
import java.io.IOException;
29
import java.net.ServerSocket;
30
import java.util.List;
22
import java.util.List;
31
import java.util.Map;
32
import java.util.Random;
33
23
34
import junit.framework.Test;
24
import junit.framework.Test;
35
import junit.framework.TestSuite;
25
import junit.framework.TestSuite;
Lines 45-53 Link Here
45
  }
35
  }
46
36
47
  @Override
37
  @Override
48
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
38
  protected void initConfigSuites(TestSuite parent)
39
  {
40
    addScenario(parent, COMBINED, new DB4OConfig(false), JVM, NATIVE);
41
  }
42
43
  @Override
44
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
49
  {
45
  {
50
    super.initTestClasses(testClasses);
46
    super.initTestClasses(testClasses, scenario);
51
47
52
    // Added here testcases to skip
48
    // Added here testcases to skip
53
    // takes too much
49
    // takes too much
Lines 59-144 Link Here
59
    testClasses.remove(BranchingSameSessionTest.class);
55
    testClasses.remove(BranchingSameSessionTest.class);
60
    testClasses.remove(BranchingWithCacheClearTest.class);
56
    testClasses.remove(BranchingWithCacheClearTest.class);
61
  }
57
  }
62
63
  @Override
64
  protected void initConfigSuites(TestSuite parent)
65
  {
66
    addScenario(parent, COMBINED, DB4ORepositoryConfig.INSTANCE, JVM, NATIVE);
67
  }
68
69
  /**
70
   * @author Victor Roldan Betancort
71
   */
72
  public static class DB4ORepositoryConfig extends RepositoryConfig
73
  {
74
    private static final Random RANDOM = new Random(System.currentTimeMillis());
75
76
    public static final DB4ORepositoryConfig INSTANCE = new DB4ORepositoryConfig("DB4O");
77
78
    private static final long serialVersionUID = 1L;
79
80
    private transient boolean optimizing = true;
81
82
    public DB4ORepositoryConfig(String name)
83
    {
84
      super(name);
85
    }
86
87
    @Override
88
    protected void initRepositoryProperties(Map<String, String> props)
89
    {
90
      super.initRepositoryProperties(props);
91
      props.put(IRepository.Props.SUPPORTING_AUDITS, "false");
92
      props.put(IRepository.Props.SUPPORTING_BRANCHES, "false");
93
    }
94
95
    public IStore createStore(String repoName)
96
    {
97
      File tempFolder = TMPUtil.getTempFolder();
98
      File file = new File(tempFolder, "cdodb_" + repoName + ".db4o");
99
      if (file.exists() && !isRestarting())
100
      {
101
        file.delete();
102
      }
103
104
      int port = 0;
105
      boolean ok = false;
106
      do
107
      {
108
        ServerSocket sock = null;
109
        try
110
        {
111
          port = 1024 + RANDOM.nextInt(65536 - 1024);
112
          sock = new ServerSocket(port);
113
          ok = true;
114
        }
115
        catch (IOException e)
116
        {
117
        }
118
        finally
119
        {
120
          try
121
          {
122
            if (sock != null)
123
            {
124
              sock.close();
125
            }
126
          }
127
          catch (IOException e)
128
          {
129
          }
130
        }
131
      } while (!ok);
132
133
      IStore store = new DB4OStore(file.getPath(), port);
134
      return store;
135
    }
136
137
    @Override
138
    protected boolean isOptimizing()
139
    {
140
      // Do NOT replace this with a hardcoded value!
141
      return optimizing;
142
    }
143
  }
144
}
58
}
(-)src/org/eclipse/emf/cdo/tests/db4o/DB4OConfig.java (+97 lines)
Line 0 Link Here
1
package org.eclipse.emf.cdo.tests.db4o;
2
3
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
4
import org.eclipse.emf.cdo.server.IStore;
5
import org.eclipse.emf.cdo.server.internal.db4o.DB4OStore;
6
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
7
8
import org.eclipse.net4j.util.io.TMPUtil;
9
10
import java.io.File;
11
import java.io.IOException;
12
import java.net.ServerSocket;
13
import java.util.Random;
14
15
/**
16
 * @author Victor Roldan Betancort
17
 */
18
public class DB4OConfig extends RepositoryConfig
19
{
20
  private static final Random RANDOM = new Random(System.currentTimeMillis());
21
22
  private static final long serialVersionUID = 1L;
23
24
  private boolean mem;
25
26
  private transient boolean optimizing = true;
27
28
  public DB4OConfig(boolean mem)
29
  {
30
    super("DB4O", false, false, IDGenerationLocation.STORE);
31
    this.mem = mem;
32
  }
33
34
  public boolean isMem()
35
  {
36
    return mem;
37
  }
38
39
  public IStore createStore(String repoName)
40
  {
41
    if (mem)
42
    {
43
      if (!isRestarting())
44
      {
45
        MEMDB4OStore.clearContainer();
46
      }
47
48
      return new MEMDB4OStore();
49
    }
50
51
    File tempFolder = TMPUtil.getTempFolder();
52
    File file = new File(tempFolder, "cdodb_" + repoName + ".db4o");
53
    if (file.exists() && !isRestarting())
54
    {
55
      file.delete();
56
    }
57
58
    int port = 0;
59
    boolean ok = false;
60
    do
61
    {
62
      ServerSocket sock = null;
63
64
      try
65
      {
66
        port = 1024 + RANDOM.nextInt(65536 - 1024);
67
        sock = new ServerSocket(port);
68
        ok = true;
69
      }
70
      catch (IOException e)
71
      {
72
      }
73
      finally
74
      {
75
        try
76
        {
77
          if (sock != null)
78
          {
79
            sock.close();
80
          }
81
        }
82
        catch (IOException e)
83
        {
84
        }
85
      }
86
    } while (!ok);
87
88
    return new DB4OStore(file.getPath(), port);
89
  }
90
91
  @Override
92
  protected boolean isOptimizing()
93
  {
94
    // Do NOT replace this with a hardcoded value!
95
    return optimizing;
96
  }
97
}
(-)src/org/eclipse/emf/cdo/tests/db4o/AllTestsMEMDB4O.java (-65 lines)
Lines 1-65 Link Here
1
package org.eclipse.emf.cdo.tests.db4o;
2
3
import org.eclipse.emf.cdo.server.IRepository;
4
import org.eclipse.emf.cdo.server.IStore;
5
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
6
7
import java.util.Map;
8
9
import junit.framework.Test;
10
import junit.framework.TestSuite;
11
12
public class AllTestsMEMDB4O extends AllTestsDB4O
13
{
14
15
  public static Test suite()
16
  {
17
    return new AllTestsMEMDB4O().getTestSuite("CDO Tests (MEMDB4O)");
18
  }
19
20
  @Override
21
  protected void initConfigSuites(TestSuite parent)
22
  {
23
    addScenario(parent, COMBINED, MemDB4ORepositoryConfig.INSTANCE, JVM, NATIVE);
24
  }
25
26
  public static class MemDB4ORepositoryConfig extends RepositoryConfig
27
  {
28
    public static final MemDB4ORepositoryConfig INSTANCE = new MemDB4ORepositoryConfig("DB4O");
29
30
    private static final long serialVersionUID = 1L;
31
32
    private transient boolean optimizing = false;
33
34
    public MemDB4ORepositoryConfig(String name)
35
    {
36
      super(name);
37
    }
38
39
    @Override
40
    protected void initRepositoryProperties(Map<String, String> props)
41
    {
42
      super.initRepositoryProperties(props);
43
      props.put(IRepository.Props.SUPPORTING_AUDITS, "false");
44
      props.put(IRepository.Props.SUPPORTING_BRANCHES, "false");
45
    }
46
47
    public IStore createStore(String repoName)
48
    {
49
      if (!isRestarting())
50
      {
51
        MEMDB4OStore.clearContainer();
52
      }
53
54
      return new MEMDB4OStore();
55
    }
56
57
    @Override
58
    protected boolean isOptimizing()
59
    {
60
      // Do NOT replace this with a hardcoded value!
61
      return optimizing;
62
    }
63
  }
64
65
}
(-)CDO AllTests (MEMDB4O).launch (-2 / +2 lines)
Lines 1-7 Link Here
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
2
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
3
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
3
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
4
<listEntry value="/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsMEMDB4O.java"/>
4
<listEntry value="/org.eclipse.emf.cdo.tests.db4o/src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4OMem.java"/>
5
</listAttribute>
5
</listAttribute>
6
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
6
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
7
<listEntry value="1"/>
7
<listEntry value="1"/>
Lines 10-16 Link Here
10
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
10
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
11
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
11
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
12
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
12
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
13
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db4o.AllTestsMEMDB4O"/>
13
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.emf.cdo.tests.db4o.AllTestsDB4OMem"/>
14
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db4o"/>
14
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.emf.cdo.tests.db4o"/>
15
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-XX:MaxPermSize=128m&#10;-Xmx1024m"/>
15
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-XX:MaxPermSize=128m&#10;-Xmx1024m"/>
16
</launchConfiguration>
16
</launchConfiguration>
(-)src/org/eclipse/emf/cdo/tests/db4o/AllTestsDB4OMem.java (-50 / +16 lines)
Lines 1-65 Link Here
1
/**
2
 * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    Victor Roldan Betancort - initial API and implementation
10
 */
1
package org.eclipse.emf.cdo.tests.db4o;
11
package org.eclipse.emf.cdo.tests.db4o;
2
12
3
import org.eclipse.emf.cdo.server.IRepository;
4
import org.eclipse.emf.cdo.server.IStore;
5
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
6
7
import java.util.Map;
8
9
import junit.framework.Test;
13
import junit.framework.Test;
10
import junit.framework.TestSuite;
14
import junit.framework.TestSuite;
11
15
12
public class AllTestsMEMDB4O extends AllTestsDB4O
16
/**
17
 * @author Victor Roldan Betancort
18
 */
19
public class AllTestsDB4OMem extends AllTestsDB4O
13
{
20
{
14
15
  public static Test suite()
21
  public static Test suite()
16
  {
22
  {
17
    return new AllTestsMEMDB4O().getTestSuite("CDO Tests (MEMDB4O)");
23
    return new AllTestsDB4OMem().getTestSuite("CDO Tests (DB4OMem)");
18
  }
24
  }
19
25
20
  @Override
26
  @Override
21
  protected void initConfigSuites(TestSuite parent)
27
  protected void initConfigSuites(TestSuite parent)
22
  {
28
  {
23
    addScenario(parent, COMBINED, MemDB4ORepositoryConfig.INSTANCE, JVM, NATIVE);
29
    addScenario(parent, COMBINED, new DB4OConfig(true), JVM, NATIVE);
24
  }
25
26
  public static class MemDB4ORepositoryConfig extends RepositoryConfig
27
  {
28
    public static final MemDB4ORepositoryConfig INSTANCE = new MemDB4ORepositoryConfig("DB4O");
29
30
    private static final long serialVersionUID = 1L;
31
32
    private transient boolean optimizing = false;
33
34
    public MemDB4ORepositoryConfig(String name)
35
    {
36
      super(name);
37
    }
38
39
    @Override
40
    protected void initRepositoryProperties(Map<String, String> props)
41
    {
42
      super.initRepositoryProperties(props);
43
      props.put(IRepository.Props.SUPPORTING_AUDITS, "false");
44
      props.put(IRepository.Props.SUPPORTING_BRANCHES, "false");
45
    }
46
47
    public IStore createStore(String repoName)
48
    {
49
      if (!isRestarting())
50
      {
51
        MEMDB4OStore.clearContainer();
52
      }
53
54
      return new MEMDB4OStore();
55
    }
56
57
    @Override
58
    protected boolean isOptimizing()
59
    {
60
      // Do NOT replace this with a hardcoded value!
61
      return optimizing;
62
    }
63
  }
30
  }
64
65
}
31
}
66
  + text/plain
32
  + text/plain
(-)src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndVersionImpl.java (-1 / +1 lines)
Lines 28-34 Link Here
28
28
29
  public CDOIDAndVersionImpl(CDOID id, int version)
29
  public CDOIDAndVersionImpl(CDOID id, int version)
30
  {
30
  {
31
    CheckUtil.checkNull(id, "id");
31
    CheckUtil.checkArg(id, "id");
32
32
33
    this.id = id;
33
    this.id = id;
34
    this.version = version;
34
    this.version = version;
(-)src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndBranchImpl.java (-2 / +2 lines)
Lines 30-37 Link Here
30
30
31
  public CDOIDAndBranchImpl(CDOID id, CDOBranch branch)
31
  public CDOIDAndBranchImpl(CDOID id, CDOBranch branch)
32
  {
32
  {
33
    CheckUtil.checkNull(id, "id");
33
    CheckUtil.checkArg(id, "id");
34
    CheckUtil.checkNull(branch, "branch");
34
    CheckUtil.checkArg(branch, "branch");
35
35
36
    this.id = id;
36
    this.id = id;
37
    this.branch = branch;
37
    this.branch = branch;
(-)src/org/eclipse/emf/cdo/spi/common/revision/CDOReferenceAdjustable.java (-1 lines)
Lines 11-17 Link Here
11
 */
11
 */
12
package org.eclipse.emf.cdo.spi.common.revision;
12
package org.eclipse.emf.cdo.spi.common.revision;
13
13
14
15
/**
14
/**
16
 * @author Simon McDuff
15
 * @author Simon McDuff
17
 * @since 4.0
16
 * @since 4.0
(-)src/org/eclipse/emf/cdo/tests/hibernate/AllTestsHibernate.java (-2 / +3 lines)
Lines 44-49 Link Here
44
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_316444_Test;
44
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_316444_Test;
45
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_319836_Test;
45
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_319836_Test;
46
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_322804_Test;
46
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_322804_Test;
47
import org.eclipse.emf.cdo.tests.config.IScenario;
47
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
48
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
48
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
49
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig;
49
import org.eclipse.emf.cdo.util.CommitException;
50
import org.eclipse.emf.cdo.util.CommitException;
Lines 72-78 Link Here
72
  }
73
  }
73
74
74
  @Override
75
  @Override
75
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
76
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
76
  {
77
  {
77
    // testClasses.clear();
78
    // testClasses.clear();
78
    // testClasses.add(XRefTest.class);
79
    // testClasses.add(XRefTest.class);
Lines 100-106 Link Here
100
    testClasses.add(Hibernate_PartialCommitTest.class);
101
    testClasses.add(Hibernate_PartialCommitTest.class);
101
    testClasses.add(Hibernate_Bugzilla_316444_Test.class);
102
    testClasses.add(Hibernate_Bugzilla_316444_Test.class);
102
103
103
    super.initTestClasses(testClasses);
104
    super.initTestClasses(testClasses, scenario);
104
105
105
    // Teneo does not yet support lists of int arrays:
106
    // Teneo does not yet support lists of int arrays:
106
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=330212
107
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=330212
(-)src/org/eclipse/emf/cdo/tests/hibernate/HibernateConfig.java (-4 / +2 lines)
Lines 10-16 Link Here
10
 */
10
 */
11
package org.eclipse.emf.cdo.tests.hibernate;
11
package org.eclipse.emf.cdo.tests.hibernate;
12
12
13
import org.eclipse.emf.cdo.server.IRepository.Props;
13
import org.eclipse.emf.cdo.common.CDOCommonRepository.IDGenerationLocation;
14
import org.eclipse.emf.cdo.server.IStore;
14
import org.eclipse.emf.cdo.server.IStore;
15
import org.eclipse.emf.cdo.server.hibernate.CDOHibernateUtil;
15
import org.eclipse.emf.cdo.server.hibernate.CDOHibernateUtil;
16
import org.eclipse.emf.cdo.server.hibernate.IHibernateMappingProvider;
16
import org.eclipse.emf.cdo.server.hibernate.IHibernateMappingProvider;
Lines 38-52 Link Here
38
38
39
  public HibernateConfig()
39
  public HibernateConfig()
40
  {
40
  {
41
    super("Hibernate");
41
    super("Hibernate", false, false, IDGenerationLocation.STORE);
42
  }
42
  }
43
43
44
  @Override
44
  @Override
45
  protected void initRepositoryProperties(Map<String, String> props)
45
  protected void initRepositoryProperties(Map<String, String> props)
46
  {
46
  {
47
    super.initRepositoryProperties(props);
47
    super.initRepositoryProperties(props);
48
    props.put(Props.SUPPORTING_AUDITS, "false");
49
    props.put(Props.SUPPORTING_BRANCHES, "false");
50
48
51
    try
49
    try
52
    {
50
    {
(-)META-INF/MANIFEST.MF (-3 / +3 lines)
Lines 1-7 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-SymbolicName: org.eclipse.emf.cdo.tests.ui;singleton:=true
3
Bundle-SymbolicName: org.eclipse.emf.cdo.tests.ui;singleton:=true
4
Bundle-Version: 4.0.0.qualifier
4
Bundle-Version: 4.0.100.qualifier
5
Bundle-Name: %pluginName
5
Bundle-Name: %pluginName
6
Bundle-Vendor: %providerName
6
Bundle-Vendor: %providerName
7
Bundle-Localization: plugin
7
Bundle-Localization: plugin
Lines 19-23 Link Here
19
 org.eclipse.emf.cdo.ui;bundle-version="[4.0.0,5.0.0)",
19
 org.eclipse.emf.cdo.ui;bundle-version="[4.0.0,5.0.0)",
20
 org.eclipse.emf.cdo.tests;bundle-version="[4.0.0,5.0.0)"
20
 org.eclipse.emf.cdo.tests;bundle-version="[4.0.0,5.0.0)"
21
Eclipse-BuddyPolicy: 
21
Eclipse-BuddyPolicy: 
22
Export-Package: org.eclipse.emf.cdo.tests.ui;version="4.0.0";x-friends:="org.eclipse.emf.cdo.dawn.tests",
22
Export-Package: org.eclipse.emf.cdo.tests.ui;version="4.0.100";x-friends:="org.eclipse.emf.cdo.dawn.tests",
23
 org.eclipse.emf.cdo.tests.ui.bundle;version="4.0.0";x-internal:=true
23
 org.eclipse.emf.cdo.tests.ui.bundle;version="4.0.100";x-internal:=true
(-)src/org/eclipse/emf/cdo/tests/ui/AllTestsCDOUISWTBot.java (-1 / +2 lines)
Lines 11-16 Link Here
11
package org.eclipse.emf.cdo.tests.ui;
11
package org.eclipse.emf.cdo.tests.ui;
12
12
13
import org.eclipse.emf.cdo.tests.AllTests;
13
import org.eclipse.emf.cdo.tests.AllTests;
14
import org.eclipse.emf.cdo.tests.config.IScenario;
14
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
15
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
15
import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
16
import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
16
17
Lines 42-48 Link Here
42
  }
43
  }
43
44
44
  @Override
45
  @Override
45
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses)
46
  protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
46
  {
47
  {
47
    testClasses.add(CDOSessionsViewTest.class);
48
    testClasses.add(CDOSessionsViewTest.class);
48
  }
49
  }
(-)src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java (-3 / +2 lines)
Lines 12-17 Link Here
12
 */
12
 */
13
package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
13
package org.eclipse.emf.cdo.server.internal.db.mapping.horizontal;
14
14
15
import org.eclipse.emf.cdo.server.db.CDODBUtil;
15
import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
16
import org.eclipse.emf.cdo.server.db.mapping.IClassMapping;
16
import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
17
import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
17
import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
18
import org.eclipse.emf.cdo.server.internal.db.CDODBSchema;
Lines 25-32 Link Here
25
 */
26
 */
26
public class HorizontalBranchingMappingStrategyWithRanges extends AbstractHorizontalMappingStrategy
27
public class HorizontalBranchingMappingStrategyWithRanges extends AbstractHorizontalMappingStrategy
27
{
28
{
28
  private static final String PROP_COPY_ON_BRANCH = "copyOnBranch";
29
30
  private boolean copyOnBranch;
29
  private boolean copyOnBranch;
31
30
32
  public HorizontalBranchingMappingStrategyWithRanges()
31
  public HorizontalBranchingMappingStrategyWithRanges()
Lines 90-96 Link Here
90
  {
89
  {
91
    super.doAfterActivate();
90
    super.doAfterActivate();
92
91
93
    String value = getProperties().get(PROP_COPY_ON_BRANCH);
92
    String value = getProperties().get(CDODBUtil.PROP_COPY_ON_BRANCH);
94
    copyOnBranch = value == null ? false : Boolean.valueOf(value);
93
    copyOnBranch = value == null ? false : Boolean.valueOf(value);
95
  }
94
  }
96
}
95
}
(-)src/org/eclipse/emf/cdo/server/db/CDODBUtil.java (-7 / +49 lines)
Lines 18-24 Link Here
18
import org.eclipse.emf.cdo.server.internal.db.SmartPreparedStatementCache;
18
import org.eclipse.emf.cdo.server.internal.db.SmartPreparedStatementCache;
19
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
19
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
20
import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategy;
20
import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategy;
21
import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalAuditMappingStrategyWithRanges;
21
import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingMappingStrategy;
22
import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingMappingStrategy;
23
import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingMappingStrategyWithRanges;
24
import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalMappingStrategy;
22
import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalNonAuditMappingStrategy;
25
import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalNonAuditMappingStrategy;
23
26
24
import org.eclipse.net4j.db.IDBAdapter;
27
import org.eclipse.net4j.db.IDBAdapter;
Lines 47-52 Link Here
47
   */
50
   */
48
  public static final String EXT_POINT_MAPPING_STRATEGIES = "mappingStrategies"; //$NON-NLS-1$
51
  public static final String EXT_POINT_MAPPING_STRATEGIES = "mappingStrategies"; //$NON-NLS-1$
49
52
53
  /**
54
   * @since 4.1
55
   */
56
  public static final String PROP_WITH_RANGES = "withRanges";
57
58
  /**
59
   * @since 4.1
60
   */
61
  public static final String PROP_COPY_ON_BRANCH = "copyOnBranch";
62
50
  private CDODBUtil()
63
  private CDODBUtil()
51
  {
64
  {
52
  }
65
  }
Lines 77-88 Link Here
77
   */
90
   */
78
  public static IMappingStrategy createHorizontalMappingStrategy(boolean auditing)
91
  public static IMappingStrategy createHorizontalMappingStrategy(boolean auditing)
79
  {
92
  {
80
    if (auditing)
93
    return createHorizontalMappingStrategy(auditing, false, false);
81
    {
82
      return new HorizontalAuditMappingStrategy();
83
    }
84
85
    return new HorizontalNonAuditMappingStrategy();
86
  }
94
  }
87
95
88
  /**
96
  /**
Lines 90-106 Link Here
90
   */
98
   */
91
  public static IMappingStrategy createHorizontalMappingStrategy(boolean auditing, boolean branching)
99
  public static IMappingStrategy createHorizontalMappingStrategy(boolean auditing, boolean branching)
92
  {
100
  {
101
    return createHorizontalMappingStrategy(auditing, branching, false);
102
  }
103
104
  /**
105
   * @since 4.1
106
   */
107
  public static IMappingStrategy createHorizontalMappingStrategy(boolean auditing, boolean branching, boolean withRanges)
108
  {
93
    if (branching)
109
    if (branching)
94
    {
110
    {
95
      if (auditing)
111
      if (auditing)
96
      {
112
      {
113
        if (withRanges)
114
        {
115
          return new HorizontalBranchingMappingStrategyWithRanges();
116
        }
117
97
        return new HorizontalBranchingMappingStrategy();
118
        return new HorizontalBranchingMappingStrategy();
98
      }
119
      }
99
120
100
      throw new IllegalArgumentException("Misconfiguration: Branching requires Auditing!");
121
      throw new IllegalArgumentException("Misconfiguration: Branching requires Auditing!");
101
    }
122
    }
102
123
103
    return createHorizontalMappingStrategy(auditing);
124
    if (auditing)
125
    {
126
      if (withRanges)
127
      {
128
        return new HorizontalAuditMappingStrategyWithRanges();
129
      }
130
131
      return new HorizontalAuditMappingStrategy();
132
    }
133
134
    return new HorizontalNonAuditMappingStrategy();
135
  }
136
137
  /**
138
   * Creates a horizontal {@link IMappingStrategy mapping strategy} that supports all valid combinations of auditing and
139
   * branching.
140
   * 
141
   * @since 4.1
142
   */
143
  public static IMappingStrategy createHorizontalMappingStrategy()
144
  {
145
    return new HorizontalMappingStrategy();
104
  }
146
  }
105
147
106
  /**
148
  /**
(-)src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java (-2 / +8 lines)
Lines 1321-1328 Link Here
1321
  {
1321
  {
1322
    IRepository repository = accessor.getStore().getRepository();
1322
    IRepository repository = accessor.getStore().getRepository();
1323
    CDOBranchPoint base = repository.getBranchManager().getBranch(branchID).getBase();
1323
    CDOBranchPoint base = repository.getBranchManager().getBranch(branchID).getBase();
1324
    InternalCDORevision baseRevision = (InternalCDORevision)repository.getRevisionManager()
1324
    InternalCDORevision baseRevision = (InternalCDORevision)repository.getRevisionManager().getRevision(id, base, /*
1325
        .getRevision(id, base, /* referenceChunk = */0, /* prefetchDepth = */CDORevision.DEPTH_NONE, true);
1325
                                                                                                                   * referenceChunk
1326
                                                                                                                   * =
1327
                                                                                                                   */0, /*
1328
                                                                                                                         * prefetchDepth
1329
                                                                                                                         * =
1330
                                                                                                                         */
1331
        CDORevision.DEPTH_NONE, true);
1326
    IStoreChunkReader chunkReader = accessor.createChunkReader(baseRevision, getFeature());
1332
    IStoreChunkReader chunkReader = accessor.createChunkReader(baseRevision, getFeature());
1327
    return chunkReader;
1333
    return chunkReader;
1328
  }
1334
  }
(-)src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalMappingStrategy.java (-1 / +7 lines)
Lines 240-246 Link Here
240
    boolean auditing = getBooleanProperty(Props.SUPPORTING_AUDITS);
240
    boolean auditing = getBooleanProperty(Props.SUPPORTING_AUDITS);
241
    boolean branching = getBooleanProperty(Props.SUPPORTING_BRANCHES);
241
    boolean branching = getBooleanProperty(Props.SUPPORTING_BRANCHES);
242
242
243
    delegate = CDODBUtil.createHorizontalMappingStrategy(auditing, branching);
243
    boolean withRanges = false;
244
    if (auditing || branching)
245
    {
246
      withRanges = getBooleanProperty(CDODBUtil.PROP_WITH_RANGES);
247
    }
248
249
    delegate = CDODBUtil.createHorizontalMappingStrategy(auditing, branching, withRanges);
244
    delegate.setStore(store);
250
    delegate.setStore(store);
245
    delegate.setProperties(properties);
251
    delegate.setProperties(properties);
246
    LifecycleUtil.activate(delegate);
252
    LifecycleUtil.activate(delegate);

Return to bug 352696