Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ea83c9b1203c4a5716313fe4b197144f99ea94e5 (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
/***************************************************************************
 * Copyright (c) 2004 - 2008 Eike Stepper, Germany.
 * 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 java.util.HashMap;
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 HibernatePackageRegistryTest extends PackageRegistryTest
{

  private String hbm2ddlValue = null;

  // allows a testcase to pass specific properties
  @Override
  protected Map<String, String> getTestProperties()
  {
    final Map<String, String> testProperties = new HashMap<String, String>();
    if (getHbm2ddlValue() != null)
    {
      testProperties.put("hibernate.hbm2ddl.auto", getHbm2ddlValue());
    }
    return testProperties;
  }

  @Override
  // this testcase can't handle create-drop because in the middle of the
  // testcase a new package is written to the db
  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
  {
    System.err.println("Called dosetup");
    super.doSetUp();
  }

  @Override
  protected void doTearDown() throws Exception
  {
    System.err.println("Called doteardown");
    super.doTearDown();
  }

  public String getHbm2ddlValue()
  {
    return hbm2ddlValue;
  }

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

Back to the top