Changeset 671
- Timestamp:
- 09/06/10 11:27:45 (14 years ago)
- 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 24 24 @Test 25 25 public void testExpandProfileWithNestedComponents() throws Exception { 26 ComponentRegistryImpl registry = ComponentRegistry ImplTest.getTestRegistry(getRegistryDir());26 ComponentRegistryImpl registry = ComponentRegistryTestCase.getTestRegistry(getRegistryDir()); 27 27 28 28 String content = ""; … … 86 86 @Test 87 87 public void testExpandProfileWithNestedComponentsFromUserRegistry() throws Exception { 88 ComponentRegistryImpl registry = ComponentRegistry ImplTest.getTestRegistry(getRegistryDir());88 ComponentRegistryImpl registry = ComponentRegistryTestCase.getTestRegistry(getRegistryDir()); 89 89 ComponentRegistryImpl userRegistry = (ComponentRegistryImpl) ComponentRegistryFactory.getInstance().getComponentRegistry(true, 90 90 DummyPrincipal.DUMMY_CREDENTIALS); … … 146 146 @Test 147 147 public void testExpandEmbeddedWithNested() throws Exception { 148 ComponentRegistryImpl registry = ComponentRegistry ImplTest.getTestRegistry(getRegistryDir());148 ComponentRegistryImpl registry = ComponentRegistryTestCase.getTestRegistry(getRegistryDir()); 149 149 150 150 String content = ""; … … 204 204 private File getRegistryDir() { 205 205 if (tmpRegistryDir == null) 206 tmpRegistryDir = ComponentRegistry ImplTest.createTempRegistryDir();206 tmpRegistryDir = ComponentRegistryTestCase.createTempRegistryDir(); 207 207 return tmpRegistryDir; 208 208 } … … 210 210 @After 211 211 public void cleanupRegistryDir() { 212 ComponentRegistry ImplTest.cleanUpRegistryDir(tmpRegistryDir);212 ComponentRegistryTestCase.cleanUpRegistryDir(tmpRegistryDir); 213 213 tmpRegistryDir = null; 214 214 } -
ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/ComponentRegistryFactoryTest.java
r622 r671 101 101 @Before 102 102 public void startClean() { 103 registryDir = ComponentRegistry ImplTest.createTempRegistryDir();103 registryDir = ComponentRegistryTestCase.createTempRegistryDir(); 104 104 Configuration.getInstance().setRegistryRoot(registryDir); 105 105 Configuration.getInstance().init(); … … 109 109 @After 110 110 public void cleanup() { 111 ComponentRegistry ImplTest.cleanUpRegistryDir(registryDir);111 ComponentRegistryTestCase.cleanUpRegistryDir(registryDir); 112 112 } 113 113 } -
ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/ComponentRegistryImplTest.java
r666 r671 11 11 import java.io.File; 12 12 import java.io.OutputStream; 13 import java.security.Principal;14 13 import java.util.Calendar; 15 import java.util.HashSet;16 14 import java.util.List; 17 import java.util.Set;18 15 import java.util.regex.Matcher; 19 16 import java.util.regex.Pattern; … … 21 18 import javax.xml.bind.JAXBException; 22 19 23 import org.apache.commons.io.FileUtils;24 20 import org.apache.commons.lang.time.DateFormatUtils; 25 import org.junit.After;26 21 import org.junit.Test; 27 22 … … 33 28 import clarin.cmdi.componentregistry.rest.RegistryTestHelper; 34 29 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"); 30 public class ComponentRegistryImplTest extends ComponentRegistryTestCase { 40 31 41 32 @Test … … 420 411 assertEquals(0, registry.getComponentDescriptions().size()); 421 412 } 422 423 //TODO PD make test for still in use component424 413 425 414 @Test … … 536 525 } 537 526 538 private File getRegistryDir() {539 if (tmpRegistryDir == null)540 tmpRegistryDir = createTempRegistryDir();541 return tmpRegistryDir;542 }543 544 @After545 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 this561 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 578 527 /** 579 528 * 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 12 12 13 13 import clarin.cmdi.componentregistry.ComponentRegistryImplTest; 14 import clarin.cmdi.componentregistry.ComponentRegistryTestCase; 14 15 import clarin.cmdi.componentregistry.Configuration; 15 16 … … 20 21 @Test 21 22 public void testGetUserDir() throws Exception { 22 rootDir = ComponentRegistry ImplTest.createTempRegistryDir();23 rootDir = ComponentRegistryTestCase.createTempRegistryDir(); 23 24 Configuration.getInstance().setRegistryRoot(rootDir); 24 25 FileInfo info = new FileInfo(); -
ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestServiceTestCase.java
r653 r671 10 10 11 11 import clarin.cmdi.componentregistry.ComponentRegistry; 12 import clarin.cmdi.componentregistry.ComponentRegistry ImplTest;12 import clarin.cmdi.componentregistry.ComponentRegistryTestCase; 13 13 import clarin.cmdi.componentregistry.model.ComponentDescription; 14 14 import clarin.cmdi.componentregistry.model.ProfileDescription; … … 60 60 @Before 61 61 public void setUpTestRegistry() throws Exception { 62 registryDir = ComponentRegistry ImplTest.createTempRegistryDir();63 testRegistry = ComponentRegistry ImplTest.getTestRegistry(registryDir);62 registryDir = ComponentRegistryTestCase.createTempRegistryDir(); 63 testRegistry = ComponentRegistryTestCase.getTestRegistry(registryDir); 64 64 } 65 65 … … 73 73 @After 74 74 public void deleteAndRecreateEmptyRegistry() { 75 ComponentRegistry ImplTest.cleanUpRegistryDir(registryDir);75 ComponentRegistryTestCase.cleanUpRegistryDir(registryDir); 76 76 } 77 77 -
ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/MDValidatorTest.java
r622 r671 18 18 import clarin.cmdi.componentregistry.ComponentRegistry; 19 19 import clarin.cmdi.componentregistry.ComponentRegistryFactory; 20 import clarin.cmdi.componentregistry.ComponentRegistry ImplTest;20 import clarin.cmdi.componentregistry.ComponentRegistryTestCase; 21 21 import clarin.cmdi.componentregistry.model.ComponentDescription; 22 22 import clarin.cmdi.componentregistry.model.ProfileDescription; … … 29 29 @Before 30 30 public void setUpTestRegistry() throws ParseException, JAXBException { 31 registryDir = ComponentRegistry ImplTest.createTempRegistryDir();32 testRegistry = ComponentRegistry ImplTest.getTestRegistry(registryDir);31 registryDir = ComponentRegistryTestCase.createTempRegistryDir(); 32 testRegistry = ComponentRegistryTestCase.getTestRegistry(registryDir); 33 33 } 34 34 35 35 @After 36 36 public void deleteRegistry() { 37 ComponentRegistry ImplTest.cleanUpRegistryDir(registryDir);37 ComponentRegistryTestCase.cleanUpRegistryDir(registryDir); 38 38 } 39 39 … … 114 114 String id1 = "component1"; 115 115 String id2 = "component2"; 116 ComponentRegistry userRegistry = ComponentRegistryFactory.getInstance().getComponentRegistry(true, DummyPrincipal.DUMMY_CREDENTIALS); 116 ComponentRegistry userRegistry = ComponentRegistryFactory.getInstance() 117 .getComponentRegistry(true, DummyPrincipal.DUMMY_CREDENTIALS); 117 118 118 119 String profileContent = "";
Note: See TracChangeset
for help on using the changeset viewer.