From 21b6c8cf10c23a7c79ac1a9e1a64bd61c97dfd00 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Mon, 8 Mar 2010 14:23:51 +0000 Subject: [PATCH] Tweak the minimal context to hopefully work on the build machine too, and then re-enable tests + combine one suite git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19122 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/minimal-context.xml | 1 + .../org/alfresco/RepositoryStartStopTest.java | 23 +--- ....java => ContentFullContextTestSuite.java} | 6 +- .../ContentMinimalContextTestSuite.java | 109 ++++++++++++++++++ .../AbstractMetadataExtracterTest.java | 3 +- .../content/metadata/MetadataTestSuite.java | 69 ----------- .../AbstractContentTransformerTest.java | 3 +- ...ntimeExecutableContentTransformerTest.java | 3 +- .../content/transform/TransformTestSuite.java | 76 ------------ 9 files changed, 125 insertions(+), 168 deletions(-) rename source/java/org/alfresco/repo/content/{ContentTestSuite.java => ContentFullContextTestSuite.java} (88%) create mode 100644 source/java/org/alfresco/repo/content/ContentMinimalContextTestSuite.java delete mode 100644 source/java/org/alfresco/repo/content/metadata/MetadataTestSuite.java delete mode 100644 source/java/org/alfresco/repo/content/transform/TransformTestSuite.java diff --git a/config/alfresco/minimal-context.xml b/config/alfresco/minimal-context.xml index 6ddda33d0f..7c3b2444b1 100644 --- a/config/alfresco/minimal-context.xml +++ b/config/alfresco/minimal-context.xml @@ -21,6 +21,7 @@ Import of the minimal extensions and bean overrides. --> + diff --git a/source/java/org/alfresco/RepositoryStartStopTest.java b/source/java/org/alfresco/RepositoryStartStopTest.java index 16fbaecd0d..ac718bfb08 100644 --- a/source/java/org/alfresco/RepositoryStartStopTest.java +++ b/source/java/org/alfresco/RepositoryStartStopTest.java @@ -54,30 +54,17 @@ public class RepositoryStartStopTest extends TestCase private TransactionService transactionService; private boolean writeTestWorked; - //TODO Turn this back on again - public void off_setUp() throws Exception + public void setUp() throws Exception { // Ensure there's nothing kicking about ApplicationContextHelper.closeApplicationContext(); } - //TODO Turn this back on again - public void off_tearDown() throws Exception + public void tearDown() throws Exception { AuthenticationUtil.clearCurrentSecurityContext(); } - /** - * This is a dummy test as the other tests in this class have all been temporarily - * disabled. - */ - public void testDummyTest() - { - //TODO When the other tests are re-enabled, this test can be deleted. - - // Intentionally empty - } - /** * Checks that the ApplicationContext cache on the * ApplicationContextHelper is empty @@ -110,8 +97,7 @@ public class RepositoryStartStopTest extends TestCase * Tests that we can open a context, use * it, and then close it again without error */ - //TODO Turn this back on again - public void off_testOpenClose() throws Exception + public void testOpenClose() throws Exception { assertNoCachedApplicationContext(); @@ -131,8 +117,7 @@ public class RepositoryStartStopTest extends TestCase * a context twice without error, using it * when running. */ - //TODO Turn this back on again - public void off_testOpenCloseOpenCloseNoAutostart() throws Exception + public void testOpenCloseOpenCloseNoAutostart() throws Exception { assertNoCachedApplicationContext(); diff --git a/source/java/org/alfresco/repo/content/ContentTestSuite.java b/source/java/org/alfresco/repo/content/ContentFullContextTestSuite.java similarity index 88% rename from source/java/org/alfresco/repo/content/ContentTestSuite.java rename to source/java/org/alfresco/repo/content/ContentFullContextTestSuite.java index c1cb207b61..8beabb2270 100644 --- a/source/java/org/alfresco/repo/content/ContentTestSuite.java +++ b/source/java/org/alfresco/repo/content/ContentFullContextTestSuite.java @@ -32,15 +32,19 @@ import org.alfresco.repo.content.replication.ReplicatingContentStoreTest; /** * Suite for content-related tests. * + * This includes all the tests that need a full context, the + * rest are in {@link ContentMinimalContextTestSuite} + * * @author Derek Hulley */ -public class ContentTestSuite extends TestSuite +public class ContentFullContextTestSuite extends TestSuite { @SuppressWarnings("unchecked") public static Test suite() { TestSuite suite = new TestSuite(); + // These tests need a full context, at least for now suite.addTestSuite(ContentStoreCleanerTest.class); suite.addTestSuite(CharsetFinderTest.class); suite.addTestSuite(FileContentStoreTest.class); diff --git a/source/java/org/alfresco/repo/content/ContentMinimalContextTestSuite.java b/source/java/org/alfresco/repo/content/ContentMinimalContextTestSuite.java new file mode 100644 index 0000000000..290e659bdb --- /dev/null +++ b/source/java/org/alfresco/repo/content/ContentMinimalContextTestSuite.java @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2005-2010 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.repo.content; + +import org.alfresco.repo.content.metadata.HtmlMetadataExtracterTest; +import org.alfresco.repo.content.metadata.MP3MetadataExtracterTest; +import org.alfresco.repo.content.metadata.MailMetadataExtracterTest; +import org.alfresco.repo.content.metadata.OfficeMetadataExtracterTest; +import org.alfresco.repo.content.metadata.OpenDocumentMetadataExtracterTest; +import org.alfresco.repo.content.metadata.OpenOfficeMetadataExtracterTest; +import org.alfresco.repo.content.metadata.PdfBoxMetadataExtracterTest; +import org.alfresco.repo.content.metadata.RFC822MetadataExtracterTest; +import org.alfresco.repo.content.transform.BinaryPassThroughContentTransformerTest; +import org.alfresco.repo.content.transform.ComplexContentTransformerTest; +import org.alfresco.repo.content.transform.ContentTransformerRegistryTest; +import org.alfresco.repo.content.transform.HtmlParserContentTransformerTest; +import org.alfresco.repo.content.transform.MailContentTransformerTest; +import org.alfresco.repo.content.transform.MediaWikiContentTransformerTest; +import org.alfresco.repo.content.transform.OpenOfficeContentTransformerTest; +import org.alfresco.repo.content.transform.PdfBoxContentTransformerTest; +import org.alfresco.repo.content.transform.PoiHssfContentTransformerTest; +import org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerTest; +import org.alfresco.repo.content.transform.StringExtractingContentTransformerTest; +import org.alfresco.repo.content.transform.TextMiningContentTransformerTest; +import org.alfresco.repo.content.transform.TextToPdfContentTransformerTest; +import org.alfresco.repo.content.transform.magick.ImageMagickContentTransformerTest; +import org.alfresco.util.ApplicationContextHelper; +import org.springframework.context.ApplicationContext; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * Metadata Extractor and Transform test suite + * + * @author Nick Burch + */ +public class ContentMinimalContextTestSuite extends TestSuite +{ + /** + * Asks {@link ApplicationContextHelper} to give us a + * suitable, perhaps cached context for use in our tests + */ + public static ApplicationContext getContext() { + ApplicationContextHelper.setUseLazyLoading(false); + ApplicationContextHelper.setNoAutoStart(true); + return ApplicationContextHelper.getApplicationContext( + new String[] { "classpath:alfresco/minimal-context.xml" } + ); + } + + /** + * Creates the test suite + * + * @return the test suite + */ + public static Test suite() + { + // Setup the context + getContext(); + + // Off we go + TestSuite suite = new TestSuite(); + + // Metadata tests + suite.addTestSuite( HtmlMetadataExtracterTest.class ); + suite.addTestSuite( MailMetadataExtracterTest.class ); + suite.addTestSuite( MP3MetadataExtracterTest.class ); + suite.addTestSuite( OfficeMetadataExtracterTest.class ); + suite.addTestSuite( OpenDocumentMetadataExtracterTest.class ); + suite.addTestSuite( OpenOfficeMetadataExtracterTest.class ); + suite.addTestSuite( PdfBoxMetadataExtracterTest.class ); + suite.addTestSuite( RFC822MetadataExtracterTest.class ); + + // Transform tests + suite.addTestSuite(BinaryPassThroughContentTransformerTest.class); + suite.addTestSuite(ComplexContentTransformerTest.class); + suite.addTestSuite(ContentTransformerRegistryTest.class); + suite.addTestSuite(HtmlParserContentTransformerTest.class); + suite.addTestSuite(MailContentTransformerTest.class); + suite.addTestSuite(MediaWikiContentTransformerTest.class); + suite.addTestSuite(OpenOfficeContentTransformerTest.class); + suite.addTestSuite(PdfBoxContentTransformerTest.class); + suite.addTestSuite(PoiHssfContentTransformerTest.class); + suite.addTestSuite(RuntimeExecutableContentTransformerTest.class); + suite.addTestSuite(StringExtractingContentTransformerTest.class); + suite.addTestSuite(TextMiningContentTransformerTest.class); + suite.addTestSuite(TextToPdfContentTransformerTest.class); + suite.addTestSuite(ImageMagickContentTransformerTest.class); + + return suite; + } +} diff --git a/source/java/org/alfresco/repo/content/metadata/AbstractMetadataExtracterTest.java b/source/java/org/alfresco/repo/content/metadata/AbstractMetadataExtracterTest.java index ef68cdfb3d..6627c6a21a 100644 --- a/source/java/org/alfresco/repo/content/metadata/AbstractMetadataExtracterTest.java +++ b/source/java/org/alfresco/repo/content/metadata/AbstractMetadataExtracterTest.java @@ -28,6 +28,7 @@ import java.util.Map; import junit.framework.TestCase; import org.alfresco.model.ContentModel; +import org.alfresco.repo.content.ContentMinimalContextTestSuite; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.filestore.FileContentReader; import org.alfresco.repo.content.filestore.FileContentWriter; @@ -75,7 +76,7 @@ public abstract class AbstractMetadataExtracterTest extends TestCase { // Grab the context, which will normally have been // cached by the ApplicationContextHelper - ctx = MetadataTestSuite.getContext(); + ctx = ContentMinimalContextTestSuite.getContext(); this.mimetypeMap = (MimetypeMap) ctx.getBean("mimetypeService"); this.dictionaryService = (DictionaryService) ctx.getBean("dictionaryService"); diff --git a/source/java/org/alfresco/repo/content/metadata/MetadataTestSuite.java b/source/java/org/alfresco/repo/content/metadata/MetadataTestSuite.java deleted file mode 100644 index 2c0ba2436e..0000000000 --- a/source/java/org/alfresco/repo/content/metadata/MetadataTestSuite.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.content.metadata; - -import org.alfresco.util.ApplicationContextHelper; -import org.springframework.context.ApplicationContext; - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * Metadata extractor test suite - * - * @author Nick Burch - */ -public class MetadataTestSuite extends TestSuite -{ - /** - * Asks {@link ApplicationContextHelper} to give us a - * suitable, perhaps cached context for use in our tests - */ - public static ApplicationContext getContext() { - ApplicationContextHelper.setUseLazyLoading(false); - ApplicationContextHelper.setNoAutoStart(true); - return ApplicationContextHelper.getApplicationContext( - new String[] { "classpath:alfresco/minimal-context.xml" } - ); - } - - /** - * Creates the test suite - * - * @return the test suite - */ - public static Test suite() - { - // Setup the context - getContext(); - - // Off we go - TestSuite suite = new TestSuite(); - suite.addTestSuite( HtmlMetadataExtracterTest.class ); - suite.addTestSuite( MailMetadataExtracterTest.class ); - suite.addTestSuite( MP3MetadataExtracterTest.class ); - suite.addTestSuite( OfficeMetadataExtracterTest.class ); - suite.addTestSuite( OpenDocumentMetadataExtracterTest.class ); - suite.addTestSuite( OpenOfficeMetadataExtracterTest.class ); - suite.addTestSuite( PdfBoxMetadataExtracterTest.class ); - suite.addTestSuite( RFC822MetadataExtracterTest.class ); - - return suite; - } -} diff --git a/source/java/org/alfresco/repo/content/transform/AbstractContentTransformerTest.java b/source/java/org/alfresco/repo/content/transform/AbstractContentTransformerTest.java index 90f18791c3..c0a6a3fb37 100644 --- a/source/java/org/alfresco/repo/content/transform/AbstractContentTransformerTest.java +++ b/source/java/org/alfresco/repo/content/transform/AbstractContentTransformerTest.java @@ -28,6 +28,7 @@ import java.util.TreeSet; import junit.framework.TestCase; +import org.alfresco.repo.content.ContentMinimalContextTestSuite; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.filestore.FileContentReader; import org.alfresco.repo.content.filestore.FileContentWriter; @@ -85,7 +86,7 @@ public abstract class AbstractContentTransformerTest extends TestCase protected void setUp() throws Exception { // Grab a suitably configured context - ctx = TransformTestSuite.getContext(); + ctx = ContentMinimalContextTestSuite.getContext(); // Grab other useful beans serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); diff --git a/source/java/org/alfresco/repo/content/transform/RuntimeExecutableContentTransformerTest.java b/source/java/org/alfresco/repo/content/transform/RuntimeExecutableContentTransformerTest.java index dc236f38f9..8fc5e7ad75 100644 --- a/source/java/org/alfresco/repo/content/transform/RuntimeExecutableContentTransformerTest.java +++ b/source/java/org/alfresco/repo/content/transform/RuntimeExecutableContentTransformerTest.java @@ -24,6 +24,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.alfresco.repo.content.ContentMinimalContextTestSuite; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.filestore.FileContentWriter; import org.alfresco.service.cmr.repository.ContentReader; @@ -44,7 +45,7 @@ public class RuntimeExecutableContentTransformerTest extends BaseAlfrescoTestCas @Override protected void setUpContext() { // We use a smaller context - ctx = TransformTestSuite.getContext(); + ctx = ContentMinimalContextTestSuite.getContext(); } @Override diff --git a/source/java/org/alfresco/repo/content/transform/TransformTestSuite.java b/source/java/org/alfresco/repo/content/transform/TransformTestSuite.java deleted file mode 100644 index 4c526024e4..0000000000 --- a/source/java/org/alfresco/repo/content/transform/TransformTestSuite.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2005-2010 Alfresco Software Limited. - * - * This file is part of Alfresco - * - * Alfresco is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Alfresco is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ -package org.alfresco.repo.content.transform; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.alfresco.repo.content.transform.magick.ImageMagickContentTransformerTest; -import org.alfresco.util.ApplicationContextHelper; -import org.springframework.context.ApplicationContext; - - -/** - * Content Transformation test suite - * - * @author Roy Wetherall - */ -public class TransformTestSuite extends TestSuite -{ - /** - * Asks {@link ApplicationContextHelper} to give us a - * suitable, perhaps cached context for use in our tests - */ - public static ApplicationContext getContext() { - ApplicationContextHelper.setUseLazyLoading(false); - ApplicationContextHelper.setNoAutoStart(true); - return ApplicationContextHelper.getApplicationContext( - new String[] { "classpath:alfresco/minimal-context.xml" } - ); - } - - /** - * Creates the test suite - * - * @return the test suite - */ - public static Test suite() - { - // Setup the context - getContext(); - - // Off we go - TestSuite suite = new TestSuite(); - suite.addTestSuite(BinaryPassThroughContentTransformerTest.class); - suite.addTestSuite(ComplexContentTransformerTest.class); - suite.addTestSuite(ContentTransformerRegistryTest.class); - suite.addTestSuite(HtmlParserContentTransformerTest.class); - suite.addTestSuite(MailContentTransformerTest.class); - suite.addTestSuite(MediaWikiContentTransformerTest.class); - suite.addTestSuite(OpenOfficeContentTransformerTest.class); - suite.addTestSuite(PdfBoxContentTransformerTest.class); - suite.addTestSuite(PoiHssfContentTransformerTest.class); - suite.addTestSuite(RuntimeExecutableContentTransformerTest.class); - suite.addTestSuite(StringExtractingContentTransformerTest.class); - suite.addTestSuite(TextMiningContentTransformerTest.class); - suite.addTestSuite(TextToPdfContentTransformerTest.class); - suite.addTestSuite(ImageMagickContentTransformerTest.class); - return suite; - } -}