Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1f6f0602b43f8df7f72a97ad2801acb751f4d890 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
 * Copyright (c) 2004 - 2009 Eike Stepper (Berlin, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Simon McDuff - initial API and implementation
 *    Eike Stepper - maintenance
 */
package org.eclipse.emf.cdo.tests.hibernate;

import org.eclipse.emf.cdo.tests.PackageRegistryTest;
import org.eclipse.emf.cdo.tests.StoreRepositoryProvider;

import java.util.Map;

/**
 * Overrides the real testclass because it needs some specific create-drop settings for specific testcases. This is not
 * the nicest way of doing this but it is short and easy to understand.
 */
public class HbPackageRegistryTest extends PackageRegistryTest
{
  private String hbm2ddlValue = null;

  public HbPackageRegistryTest()
  {
    StoreRepositoryProvider.setInstance(HbStoreRepositoryProvider.getInstance());
  }

  @Override
  public Map<String, Object> getTestProperties()
  {
    Map<String, Object> testProperties = super.getTestProperties();
    if (getHbm2ddlValue() != null)
    {
      testProperties.put("hibernate.hbm2ddl.auto", getHbm2ddlValue());
    }

    return testProperties;
  }

  public void testRereadPackages() throws Exception
  {
    setHbm2ddlValue("update");
    super.testCommitTwoPackages();
    doTearDown();
    doSetUp();
    super.testCommitTwoPackages();
    doTearDown();
    setHbm2ddlValue(null);
  }

  // this testcase can't handle create-drop because in the middle of the
  // testcase a new package is written to the db
  @Override
  public void testCommitUnrelatedPackage() throws Exception
  {
    setHbm2ddlValue("update");
    // this needs to be extra because in doSetup it is unknown which testcase is being run
    doTearDown();
    doSetUp();
    try
    {
      super.testCommitUnrelatedPackage();
    }
    finally
    {
      setHbm2ddlValue(null);
    }
  }

  @Override
  protected void doSetUp() throws Exception
  {
    super.doSetUp();
  }

  @Override
  protected void doTearDown() throws Exception
  {
    super.doTearDown();
  }

  public String getHbm2ddlValue()
  {
    return hbm2ddlValue;
  }

  public void setHbm2ddlValue(String hbm2ddlValue)
  {
    this.hbm2ddlValue = hbm2ddlValue;
  }
}

Back to the top