Commits

Stephen Abrams  committed c2b2091

Fix aggregate identification regex

  • Participants
  • Parent commits 51a43b9

Comments (0)

Files changed (9)

File config/spring/module/aggrefy/jhove2-aggrefy-config.xml

 			</list>
 		</property>
 	 	<property name="formatIdentifier" ref="ShapefileIdentifier"/>
-	 	<property name="fileGroupingExpr" value="(.*)\.((?i:shp\.)?\w{3})$"/>
+	 	<property name="fileGroupingExpr" value="(.*?)\.((?i:shp\.)?\w{3})$"/>
 	 	<property name="mustHaveExpr" value="^((?i:shp)|(?i:shx)|(?i:dbf))$"/>
 	 	<property name="mayHaveExpr" 
 	 	          value="^((?i:shp.xml)|(?i:prj)|(?i:sbn)|(?i:sbx)|(?i:atx)|(?i:qix)|(?i:fix)|(?i:grx))$"/>

File src/main/java/org/jhove2/module/aggrefy/GlobPathRecognizer.java

 import static com.sleepycat.persist.model.DeleteAction.NULLIFY;
 import static com.sleepycat.persist.model.Relationship.MANY_TO_ONE;
 
+import java.io.File;
 import java.io.IOException;
 import java.util.Collection;
 import java.util.HashMap;
 import org.jhove2.core.format.FormatIdentification;
 import org.jhove2.core.format.FormatIdentification.Confidence;
 import org.jhove2.core.source.ClumpSource;
-import org.jhove2.core.source.NamedSource;
 import org.jhove2.core.source.Source;
 import org.jhove2.module.AbstractModule;
 import org.jhove2.persist.ModuleAccessor;
 		HashMap<String,  GlobPathMatchInfoGroup> groupMap = 
 			new HashMap<String, GlobPathMatchInfoGroup>();
 		for (Source childSource:source.getChildSources()){
-			//File sourceFile = childSource.getFile();
-			//if (sourceFile !=  null){
-				//String filePath = childSource.getFile().getPath();
-		    if (childSource instanceof NamedSource) {
-		        String filePath = ((NamedSource) childSource).getSourceName();
+			File sourceFile = childSource.getFile();
+			if (sourceFile !=  null){
+				String filePath = childSource.getFile().getPath();
 				// does the Source file path match the pattern that indicates a related file?
 				Matcher m = this.fileGroupingPattern.matcher(filePath);
 				if (m.matches()){

File src/test/java/org/jhove2/core/io/DirectInputTest.java

     private String testFile01;
     private File testFile;
 	private JHOVE2 jhove2;
+	
+	@Resource
+	public void setJHOVE2(JHOVE2 jhove2) {
+	    this.jhove2 = jhove2;
+	}
 
     @Before
     public void setUp() throws Exception {
         bufferSize = 100;
-        jhove2 = new JHOVE2();
         PersistenceManagerUtil.createPersistenceManagerFactory(jhove2.getConfigInfo());
         PersistenceManager persistenceManager = PersistenceManagerUtil.getPersistenceManagerFactory().getInstance();
         persistenceManager.initialize();

File src/test/java/org/jhove2/module/aggrefy/AggrefierModuleTest.java

 import org.jhove2.core.source.FileSetSource;
 import org.jhove2.core.source.FileSource;
 import org.jhove2.core.source.Source;
-import org.jhove2.core.source.SourceFactory;
 import org.jhove2.persist.PersistenceManager;
 import org.jhove2.persist.PersistenceManagerUtil;
-import org.jhove2.persist.inmemory.InMemorySourceFactory;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.test.context.ContextConfiguration;

File src/test/java/org/jhove2/module/identify/IdentifierModuleTest.java

 import javax.annotation.Resource;
 
 import org.jhove2.app.util.FeatureConfigurationUtil;
-import org.jhove2.core.Invocation;
 import org.jhove2.core.JHOVE2;
 import org.jhove2.core.JHOVE2Exception;
 import org.jhove2.core.format.FormatIdentification;
 import org.jhove2.core.format.FormatIdentification.Confidence;
 import org.jhove2.core.io.Input;
 import org.jhove2.core.source.FileSource;
+import org.jhove2.persist.PersistenceManager;
+import org.jhove2.persist.PersistenceManagerUtil;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.test.context.ContextConfiguration;
 		Input      input  = null;
 		Set<FormatIdentification> ids = null;
 		String droidDirPath = null;
-		Invocation inv = JHOVE2.getInvocation();
+        PersistenceManager persistenceManager = null;
 		try {
+            PersistenceManagerUtil.createPersistenceManagerFactory(JHOVE2.getConfigInfo());
+            persistenceManager = PersistenceManagerUtil.getPersistenceManagerFactory().getInstance();
+            persistenceManager.initialize();
 			droidDirPath = 
 				FeatureConfigurationUtil.getFilePathFromClasspath(droidDirBasePath, "droid dir");
 		} catch (JHOVE2Exception e1) {

File src/test/java/org/jhove2/persist/berkeleydpl/BerkeleyDbSourceAccessorTest.java

 		try {
 			source = sourceFactory.getSource(jhove2, tempDirBasePath);
 			TimerInfo timer = source.getTimerInfo();
-			assertEquals(1,timer.getElapsedTime().getDuration());
+			/* This test is dependent on the process load of the underlying OS.
+			 * Build in a sufficient threshold.
+			 */
+			/* assertEquals(1,timer.getElapsedTime().getDuration()); */
+			assertTrue(25 >= timer.getElapsedTime().getDuration());
 			source = source.startTimer();
 			Thread.sleep(500);
 			source = source.endTimer();

File src/test/resources/config/globpathrecognizer-config.xml

 				<value>ghi.dbf</value>
 				<value>ghi.shp</value>
 				<value>ghi.shp.xml</value>
-				<value>something-else.txt</value> <!--  will not be grouped; does not match grouping expression -->
+				<value>something-else.txt</value> 
 			</list>
 		</constructor-arg>
 	</bean>
 				<value>abc</value><!-- passes relaxed,passes strict (but not all files included in format Identification source) -->
 				<value>def</value><!-- passes relaxed, passes strict -->
 				<value>ghi</value><!-- passes relaxed, fails strict (missing required file extension) -->
+				<value>something-else</value> <!--  should fail relaxed and strict -->
 			</list>
 	 	</constructor-arg>
 	</bean> 
 
 	<bean id="expectedGroupCount" class="java.lang.Integer">
-		<constructor-arg type="java.lang.String" value="3"/>
+		<constructor-arg type="java.lang.String" value="4"/>
 	</bean>
 	
 	<bean id="failStrictKeys" class="java.util.ArrayList">
 	<constructor-arg type="java.util.Collection">
 			<list>
 				<value>ghi</value><!-- passes relaxed, fails strict (missing required file extension) -->
+				<value>something-else</value> <!--  should fail relaxed and strict -->
 			</list>
 	 	</constructor-arg>
 	</bean>
 	<bean id="failRelaxedKeys" class="java.util.ArrayList">
 		<constructor-arg type="java.util.Collection">
 			<list>
+				<value>something-else</value> <!--  should fail relaxed and strict -->
 			</list>
 	 	</constructor-arg>
 	</bean>

File src/test/resources/config/module/identify/test-config.xml

 			</list>
 		</property>
 	 	<property name="formatIdentifier" ref="ShapefileIdentifier"/>
-	 	<property name="fileGroupingExpr" value="(.*[\\/]\w+).((?i:shp\.)?\w{3})"/>
+	 	<property name="fileGroupingExpr" value="(.*?)\.((?i:shp\.)?\w{3})$"/>
 	 	<property name="mustHaveExpr" value="^((?i:shp)|(?i:shx)|(?i:dbf))$"/>
 	 	<property name="mayHaveExpr" 
 	 	          value="^((?i:shp.xml)|(?i:prj)|(?i:sbn)|(?i:sbx)|(?i:atx)|(?i:qix)|(?i:fix)|(?i:grx))$"/>
 			</list>
 		</property>
 	 	<property name="formatIdentifier" ref="ShapefileIdentifier"/>
-	 	<property name="fileGroupingExpr" value="(.*[\\/]\w+).((?i:shp\.)?\w{3})"/>
+	 	<property name="fileGroupingExpr" value="(.*?)\.((?i:shp\.)?\w{3})$"/>
 	 	<property name="mustHaveExpr" value="^((?i:shp)|(?i:shx)|(?i:dbf))$"/>
 	 	<property name="mayHaveExpr" 
 	 	          value="^((?i:shp.xml)|(?i:prj)|(?i:sbn)|(?i:sbx)|(?i:atx)|(?i:qix)|(?i:fix)|(?i:grx))$"/>
 			</list>
 		</property>
 	 	<property name="formatIdentifier" ref="QuickenIdentifier"/>
-	 	<property name="fileGroupingExpr" value="(.*[\\/]\w+).(\w{3})"/>
+	 	<property name="fileGroupingExpr" value="(.*[\\/]\w+)\.(\w{3})"/>
 	 	<property name="mustHaveExpr" value="^((?i:idx)|(?i:qel)|(?i:qph)|(?i:qdf)|(?i:ptx))$"/>
 	 	<property name="fileGroupingCaptureGroupIndex" value="1" />
 	 	<property name="mustHaveCaptureGroupIndex" value="2"/>

File src/test/resources/config/persist/berkeleydpl/test-config.xml

 			</list>
 		</property>
 	 	<property name="formatIdentifier" ref="bdbShapefileIdentifier"/>
-	 	<property name="fileGroupingExpr" value="(.*[\\/]\w+).((?i:shp\.)?\w{3})"/>
+	 	<property name="fileGroupingExpr" value="(.*?)\.((?i:shp\.)?\w{3})$"/>
 	 	<property name="mustHaveExpr" value="^((?i:shp)|(?i:shx)|(?i:dbf))$"/>
 	 	<property name="mayHaveExpr" 
 	 	          value="^((?i:shp.xml)|(?i:prj)|(?i:sbn)|(?i:sbx)|(?i:atx)|(?i:qix)|(?i:fix)|(?i:grx))$"/>