Changeset 671


Ignore:
Timestamp:
09/06/10 11:27:45 (14 years ago)
Author:
patdui
Message:
  • added forceUpdate test
Location:
ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/CMDComponentSpecExpanderTest.java

    r622 r671  
    2424    @Test
    2525    public void testExpandProfileWithNestedComponents() throws Exception {
    26         ComponentRegistryImpl registry = ComponentRegistryImplTest.getTestRegistry(getRegistryDir());
     26        ComponentRegistryImpl registry = ComponentRegistryTestCase.getTestRegistry(getRegistryDir());
    2727
    2828        String content = "";
     
    8686    @Test
    8787    public void testExpandProfileWithNestedComponentsFromUserRegistry() throws Exception {
    88         ComponentRegistryImpl registry = ComponentRegistryImplTest.getTestRegistry(getRegistryDir());
     88        ComponentRegistryImpl registry = ComponentRegistryTestCase.getTestRegistry(getRegistryDir());
    8989        ComponentRegistryImpl userRegistry = (ComponentRegistryImpl) ComponentRegistryFactory.getInstance().getComponentRegistry(true,
    9090                DummyPrincipal.DUMMY_CREDENTIALS);
     
    146146    @Test
    147147    public void testExpandEmbeddedWithNested() throws Exception {
    148         ComponentRegistryImpl registry = ComponentRegistryImplTest.getTestRegistry(getRegistryDir());
     148        ComponentRegistryImpl registry = ComponentRegistryTestCase.getTestRegistry(getRegistryDir());
    149149
    150150        String content = "";
     
    204204    private File getRegistryDir() {
    205205        if (tmpRegistryDir == null)
    206             tmpRegistryDir = ComponentRegistryImplTest.createTempRegistryDir();
     206            tmpRegistryDir = ComponentRegistryTestCase.createTempRegistryDir();
    207207        return tmpRegistryDir;
    208208    }
     
    210210    @After
    211211    public void cleanupRegistryDir() {
    212         ComponentRegistryImplTest.cleanUpRegistryDir(tmpRegistryDir);
     212        ComponentRegistryTestCase.cleanUpRegistryDir(tmpRegistryDir);
    213213        tmpRegistryDir = null;
    214214    }
  • ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/ComponentRegistryFactoryTest.java

    r622 r671  
    101101    @Before
    102102    public void startClean() {
    103         registryDir = ComponentRegistryImplTest.createTempRegistryDir();
     103        registryDir = ComponentRegistryTestCase.createTempRegistryDir();
    104104        Configuration.getInstance().setRegistryRoot(registryDir);
    105105        Configuration.getInstance().init();
     
    109109    @After
    110110    public void cleanup() {
    111         ComponentRegistryImplTest.cleanUpRegistryDir(registryDir);
     111        ComponentRegistryTestCase.cleanUpRegistryDir(registryDir);
    112112    }
    113113}
  • ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/ComponentRegistryImplTest.java

    r666 r671  
    1111import java.io.File;
    1212import java.io.OutputStream;
    13 import java.security.Principal;
    1413import java.util.Calendar;
    15 import java.util.HashSet;
    1614import java.util.List;
    17 import java.util.Set;
    1815import java.util.regex.Matcher;
    1916import java.util.regex.Pattern;
     
    2118import javax.xml.bind.JAXBException;
    2219
    23 import org.apache.commons.io.FileUtils;
    2420import org.apache.commons.lang.time.DateFormatUtils;
    25 import org.junit.After;
    2621import org.junit.Test;
    2722
     
    3328import clarin.cmdi.componentregistry.rest.RegistryTestHelper;
    3429
    35 public class ComponentRegistryImplTest {
    36 
    37     private File tmpRegistryDir;
    38     private final static UserCredentials USER_CREDS = DummyPrincipal.DUMMY_CREDENTIALS;
    39     private static final Principal PRINCIPAL_ADMIN = new DummyPrincipal("admin");
     30public class ComponentRegistryImplTest extends ComponentRegistryTestCase {
    4031
    4132    @Test
     
    420411        assertEquals(0, registry.getComponentDescriptions().size());
    421412    }
    422    
    423     //TODO PD make test for still in use component
    424413
    425414    @Test
     
    536525    }
    537526
    538     private File getRegistryDir() {
    539         if (tmpRegistryDir == null)
    540             tmpRegistryDir = createTempRegistryDir();
    541         return tmpRegistryDir;
    542     }
    543 
    544     @After
    545     public void cleanupRegistryDir() {
    546         ComponentRegistryFactory.getInstance().reset();
    547         cleanUpRegistryDir(tmpRegistryDir);
    548         tmpRegistryDir = null;
    549     }
    550 
    551     public static ComponentRegistryImpl getTestRegistry(File registryRoot) {
    552         Configuration config = Configuration.getInstance();
    553         config.setRegistryRoot(registryRoot);
    554         Set<String> adminUsers = new HashSet<String>();
    555         adminUsers.add(PRINCIPAL_ADMIN.getName());
    556         config.setAdminUsers(adminUsers);
    557         config.init();
    558         ComponentRegistryFactory.getInstance().reset();
    559         ComponentRegistryImpl register = (ComponentRegistryImpl) ComponentRegistryFactory.getInstance().getPublicRegistry();
    560         register.setResourceConfig(config.getPublicResourceConfig()); //LOADS cache again but is necessary for tests normally we wouldn't have this
    561         return register;
    562     }
    563 
    564     public static File createTempRegistryDir() {
    565         final String baseTempPath = System.getProperty("java.io.tmpdir");
    566         File tempDir = new File(baseTempPath + File.separator + "testRegistry_" + System.currentTimeMillis());
    567         tempDir.mkdir();
    568         tempDir.deleteOnExit();
    569         return tempDir;
    570     }
    571 
    572     public static void cleanUpRegistryDir(File registryDir) {
    573         if (registryDir != null && registryDir.exists()) {
    574             assertTrue(FileUtils.deleteQuietly(registryDir));
    575         }
    576     }
    577 
    578527    /**
    579528     * Testing a big xsd string is a bit hard, so doing a best effort by checking the xs:element which represent the nested components used
  • ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/frontend/FileInfoTest.java

    r537 r671  
    1212
    1313import clarin.cmdi.componentregistry.ComponentRegistryImplTest;
     14import clarin.cmdi.componentregistry.ComponentRegistryTestCase;
    1415import clarin.cmdi.componentregistry.Configuration;
    1516
     
    2021    @Test
    2122    public void testGetUserDir() throws Exception {
    22         rootDir = ComponentRegistryImplTest.createTempRegistryDir();
     23        rootDir = ComponentRegistryTestCase.createTempRegistryDir();
    2324        Configuration.getInstance().setRegistryRoot(rootDir);
    2425        FileInfo info = new FileInfo();
  • ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestServiceTestCase.java

    r653 r671  
    1010
    1111import clarin.cmdi.componentregistry.ComponentRegistry;
    12 import clarin.cmdi.componentregistry.ComponentRegistryImplTest;
     12import clarin.cmdi.componentregistry.ComponentRegistryTestCase;
    1313import clarin.cmdi.componentregistry.model.ComponentDescription;
    1414import clarin.cmdi.componentregistry.model.ProfileDescription;
     
    6060    @Before
    6161    public void setUpTestRegistry() throws Exception {
    62         registryDir = ComponentRegistryImplTest.createTempRegistryDir();
    63         testRegistry = ComponentRegistryImplTest.getTestRegistry(registryDir);
     62        registryDir = ComponentRegistryTestCase.createTempRegistryDir();
     63        testRegistry = ComponentRegistryTestCase.getTestRegistry(registryDir);
    6464    }
    6565
     
    7373    @After
    7474    public void deleteAndRecreateEmptyRegistry() {
    75         ComponentRegistryImplTest.cleanUpRegistryDir(registryDir);
     75        ComponentRegistryTestCase.cleanUpRegistryDir(registryDir);
    7676    }
    7777
  • ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/MDValidatorTest.java

    r622 r671  
    1818import clarin.cmdi.componentregistry.ComponentRegistry;
    1919import clarin.cmdi.componentregistry.ComponentRegistryFactory;
    20 import clarin.cmdi.componentregistry.ComponentRegistryImplTest;
     20import clarin.cmdi.componentregistry.ComponentRegistryTestCase;
    2121import clarin.cmdi.componentregistry.model.ComponentDescription;
    2222import clarin.cmdi.componentregistry.model.ProfileDescription;
     
    2929    @Before
    3030    public void setUpTestRegistry() throws ParseException, JAXBException {
    31         registryDir = ComponentRegistryImplTest.createTempRegistryDir();
    32         testRegistry = ComponentRegistryImplTest.getTestRegistry(registryDir);
     31        registryDir = ComponentRegistryTestCase.createTempRegistryDir();
     32        testRegistry = ComponentRegistryTestCase.getTestRegistry(registryDir);
    3333    }
    3434
    3535    @After
    3636    public void deleteRegistry() {
    37         ComponentRegistryImplTest.cleanUpRegistryDir(registryDir);
     37        ComponentRegistryTestCase.cleanUpRegistryDir(registryDir);
    3838    }
    3939
     
    114114        String id1 = "component1";
    115115        String id2 = "component2";
    116         ComponentRegistry userRegistry = ComponentRegistryFactory.getInstance().getComponentRegistry(true, DummyPrincipal.DUMMY_CREDENTIALS);
     116        ComponentRegistry userRegistry = ComponentRegistryFactory.getInstance()
     117                .getComponentRegistry(true, DummyPrincipal.DUMMY_CREDENTIALS);
    117118
    118119        String profileContent = "";
Note: See TracChangeset for help on using the changeset viewer.