Skip to content

Commit

Permalink
Ensure EPersonTest extends AbstractUnitTest instead of doing its own …
Browse files Browse the repository at this point in the history
…thing
  • Loading branch information
tdonohue committed Aug 11, 2014
1 parent ceaed12 commit b4d2909
Showing 1 changed file with 16 additions and 44 deletions.
60 changes: 16 additions & 44 deletions dspace-api/src/test/java/org/dspace/eperson/EPersonTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@

import java.sql.SQLException;
import java.util.ArrayList;
import mockit.UsingMocksAndStubs;
import org.apache.commons.codec.DecoderException;
import org.dspace.MockConfigurationManager;
import org.dspace.AbstractUnitTest;
import org.dspace.core.Constants;
import org.dspace.core.Context;
import org.dspace.servicemanager.DSpaceKernelImpl;
import org.dspace.servicemanager.DSpaceKernelInit;
import org.dspace.services.ConfigurationService;
import org.dspace.storage.rdbms.MockDatabaseManager;
import org.dspace.storage.rdbms.TableRow;
import org.junit.*;
import static org.junit.Assert.*;
Expand All @@ -27,56 +22,35 @@
*
* @author mwood
*/
@UsingMocksAndStubs(value={MockDatabaseManager.class, MockConfigurationManager.class})
public class EPersonTest
public class EPersonTest extends AbstractUnitTest
{
private static TableRow row1;

private static DSpaceKernelImpl kernel;

private static ConfigurationService config;

public EPersonTest()
{
}

@BeforeClass
public static void setUpClass()
throws Exception
/**
* This method will be run before every test as per @Before. It will
* initialize resources required for the tests.
*
* Other methods can be annotated with @Before here or in subclasses
* but no execution order is guaranteed
*/
@Before
@Override
public void init()
{
super.init();

// Build a TableRow for an EPerson to wrap
final ArrayList<String> epersonColumns = new ArrayList<String>();
epersonColumns.add("eperson_id");
epersonColumns.add("password");
epersonColumns.add("salt");
epersonColumns.add("digest_algorithm");

row1 = new TableRow("EPerson", epersonColumns);

// Make certain that a default DSpaceKernel is started.
kernel = DSpaceKernelInit.getKernel(null);
kernel.start();

// Configure the kernel
config = kernel.getConfigurationService();
config.setProperty("db.name", "H2");
config.setProperty("db.driver", "org.h2.Driver");
}

@AfterClass
public static void tearDownClass()
throws Exception
{
}

@Before
public void setUp()
{
}

@After
public void tearDown()
{
row1 = new TableRow("EPerson", epersonColumns);
}

/**
Expand Down Expand Up @@ -689,10 +663,8 @@ public void testGetPasswordHash()
public void testCheckPassword()
throws SQLException, DecoderException
{
System.out.println("checkPassword");
final String attempt = "secret";
Context ctx = new Context();
EPerson instance = new EPerson(ctx, row1);
EPerson instance = new EPerson(context, row1);

// Test old unsalted MD5 hash
final String hash = "5ebe2294ecd0e0f08eab7690d2a6ee69"; // MD5("secret");
Expand Down

0 comments on commit b4d2909

Please sign in to comment.