Files
alfresco-community-repo/source/test-java/org/alfresco/util/schemacomp/SchemaReferenceFileTest.java
Alan Davis 91eb2644ad Merged 5.2.N (5.2.1) to HEAD (5.2)
125781 rmunteanu: Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
      125603 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2)
         125484 slanglois: MNT-16155 Update source headers - remove old Copyrights from Java and JSP dource files


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@127808 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2016-06-03 16:40:56 +00:00

69 lines
2.1 KiB
Java

package org.alfresco.util.schemacomp;
import static org.junit.Assert.fail;
import java.io.ByteArrayOutputStream;
import java.io.PrintWriter;
import org.alfresco.repo.domain.schema.SchemaBootstrap;
import org.alfresco.test_category.OwnJVMTestsCategory;
import org.alfresco.util.ApplicationContextHelper;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Test intended for use in the continuous integration system that checks whether the
* schema reference file (for whichever database the tests are being run against)
* is in sync with the actual schema. If the test fails (and the schema comparator is
* in working order) then the most likely cause is that a new up-to-date schema reference file
* needs to be created.
* <p>
* Schema reference files are created using the {@link DbToXML} tool.
* <p>
* Note: if no reference file exists then the test will pass, this is to allow piece meal
* introduction of schmea reference files.
*
* @see DbToXML
* @author Matt Ward
*/
@Category(OwnJVMTestsCategory.class)
public class SchemaReferenceFileTest
{
private ClassPathXmlApplicationContext ctx;
private SchemaBootstrap schemaBootstrap;
@Before
public void setUp() throws Exception
{
ctx = (ClassPathXmlApplicationContext) ApplicationContextHelper.getApplicationContext();
schemaBootstrap = (SchemaBootstrap) ctx.getBean("schemaBootstrap");
}
@After
public void tearDown()
{
if(ctx != null)
{
ctx.close();
}
}
@Test
public void checkReferenceFile()
{
ByteArrayOutputStream buff = new ByteArrayOutputStream();
PrintWriter out = new PrintWriter(buff);
int numProblems = schemaBootstrap.validateSchema(null, out);
out.flush();
if (numProblems > 0)
{
fail(buff.toString());
}
}
}