Package uk.gov.nationalarchives.droid.core.interfaces.signature

Examples of uk.gov.nationalarchives.droid.core.interfaces.signature.SignatureFileInfo


                        String.format(ERROR_MESSAGE_PATTERN, endpointUrl, statusCode));
            }
           
            int version = getVersion(get);
           
            SignatureFileInfo signatureFileInfo = new SignatureFileInfo(version, false, SignatureType.CONTAINER);
            String fileName = String.format(FILENAME_PATTERN, version);

            final File targetFile = new File(targetDir, fileName);
            writer = new FileWriter(targetFile);
            IOUtils.copy(get.getResponseBodyAsStream(), writer);
           
            signatureFileInfo.setFile(targetFile);
            return signatureFileInfo;
           
        } catch (UnknownHostException e) {
            throw new SignatureServiceException(
                    String.format(COULD_NOT_FIND_SERVER, endpointUrl));
View Full Code Here


      FileUtils.forceDelete(new File("integration-test-files"));
   }
  
   @Before
   public void setup() {
      binarySignatureFileInfo = new SignatureFileInfo(26, false, SignatureType.BINARY);
      binarySignatureFileInfo.setFile(new File("test_sig_files/DROID_SignatureFile_V26.xml"));

      containerSignatureFileInfo = new SignatureFileInfo(26, false, SignatureType.CONTAINER);
      containerSignatureFileInfo.setFile(new File("test_sig_files/container-signature.xml"));
   }
View Full Code Here

    }
   
    @Test
    public void testCheckForNewSignatureFileWhenNewFileIsNotAvailable() throws SignatureServiceException {
       
        SignatureFileInfo signatureFileInfo = new SignatureFileInfo(26, false, SignatureType.BINARY);
        when(signatureService.getLatestVersion(20100101)).thenReturn(signatureFileInfo);
        when(containerSignatureService.getLatestVersion(20100101)).thenReturn(null);
        //when(textSignatureService.getLatestVersion(20100101)).thenReturn(null);
       
        Map<SignatureType, SignatureFileInfo> newSignatures = signatureManager.getLatestSignatureFiles();
        final SignatureFileInfo newSignature = newSignatures.get(SignatureType.BINARY);
        assertNull(newSignature);
       
        ArgumentCaptor<Long> captor = ArgumentCaptor.forClass(Long.class);
        verify(configuration).setProperty(eq(DroidGlobalProperty.LAST_UPDATE_CHECK.getName()),
                captor.capture());
View Full Code Here

*  setting the hardcoded latest version to the actual latest version (then
26)
*/
    public void testCheckForNewSignatureFileWhenNewFileIsAvailable() throws SignatureServiceException {
       
        SignatureFileInfo signatureFileInfo = new SignatureFileInfo(100, false, SignatureType.BINARY);
       
        when(signatureService.getLatestVersion(26)).thenReturn(signatureFileInfo);
       
        Map<SignatureType, SignatureFileInfo> newSignatures = signatureManager.getLatestSignatureFiles();
        assertNotNull(newSignatures.get(SignatureType.BINARY));
View Full Code Here

        when(configuration.getString(DroidGlobalProperty.DEFAULT_CONTAINER_SIG_FILE_VERSION.getName()))
            .thenReturn("container_sigs-20100927");
        when(configuration.getString(DroidGlobalProperty.DEFAULT_TEXT_SIG_FILE_VERSION.getName()))
            .thenReturn("text_sigs-20110827");
       
        SignatureFileInfo sigInfo = signatureManager.getDefaultSignatures().get(SignatureType.CONTAINER);
        assertEquals(new File(containerSigFileDir, "container_sigs-20100927.xml"), sigInfo.getFile());
        assertEquals(20100927, sigInfo.getVersion());
    }
View Full Code Here

    }
   
    @Test
    public void testGetLatestContainerSignatureFileWhenCurrentFileIsLatest() throws Exception {
       
        SignatureFileInfo latestContainerSigInfo = new SignatureFileInfo(20100929, false, SignatureType.CONTAINER);
        when(containerSignatureService.getLatestVersion(20100101)).thenReturn(latestContainerSigInfo);

        deleteSigDirs();
        createSigDirs();
       
        final File containerSigFile1 = new File(containerSigFileDir, "container_sigs-20100927.xml");
        final File containerSigFile2 = new File(containerSigFileDir, "container_sigs-20100929.xml");
       
        containerSigFile1.createNewFile();
        containerSigFile2.createNewFile();
       
        assertTrue(containerSigFile1.exists());
        assertTrue(containerSigFile2.exists());

        SignatureFileInfo sigFileInfo = signatureManager.getLatestSignatureFiles().get(SignatureType.CONTAINER);
        assertNull(sigFileInfo);
    }
View Full Code Here

        assertNull(sigFileInfo);
    }
   
    @Test
    public void testGetLatestConatinerSignatureFileWhenCurrentFileIsOutOfDate() throws Exception {
        SignatureFileInfo latestContainerSigInfo = new SignatureFileInfo(20100930, false, SignatureType.CONTAINER);
        when(containerSignatureService.getLatestVersion(20100828)).thenReturn(latestContainerSigInfo);
       
        deleteSigDirs();
        createSigDirs();
       
        final File containerSigFile1 = new File(containerSigFileDir, "container_sigs-20100827.xml");
        final File containerSigFile2 = new File(containerSigFileDir, "container_sigs-20100828.xml");
       
        containerSigFile1.createNewFile();
        containerSigFile2.createNewFile();
       
        assertTrue(containerSigFile1.exists());
        assertTrue(containerSigFile2.exists());

        SignatureFileInfo sigFileInfo = signatureManager.getLatestSignatureFiles().get(SignatureType.CONTAINER);
        assertEquals(latestContainerSigInfo, sigFileInfo);
    }
View Full Code Here

        }
       
        profileSpecDao = new JaxbProfileSpecDao();
        profileManager.setProfileSpecDao(profileSpecDao);
       
        SignatureFileInfo signatureFileInfo = new SignatureFileInfo(26, false, SignatureType.BINARY);
        signatureFileInfo.setFile(new File("test_sig_files/DROID_SignatureFile_V26.xml"));
       
        Map<SignatureType, SignatureFileInfo> signatureFiles = new HashMap<SignatureType, SignatureFileInfo>();
        signatureFiles.put(SignatureType.BINARY, signatureFileInfo);
        ProfileInstance instance = profileManager.createProfile(signatureFiles);
        String profileId = instance.getUuid();
View Full Code Here

        importer.onProxyChange(proxySettings);
       
        File[] sigFiles = sigFileDir.listFiles();
        assertEquals(0, sigFiles.length);
       
        SignatureFileInfo info = importer.importSignatureFile(sigFileDir);
       
        sigFiles = sigFileDir.listFiles();
        assertEquals(1, sigFiles.length);
       
//        File file = new File("tmp_sig_files/DROID_SignatureFile_V" + CURRENT_VER + ".xml");
//        assertTrue(file.exists());
//        assertEquals(CURRENT_VER, info.getVersion());
       
        assertTrue(info.getVersion() > 0);
        assertEquals(false, info.isDeprecated());
        assertEquals(SignatureType.BINARY, info.getType());
    }
View Full Code Here

    }

    @Test
    public void testGetLatestSigFileVersion() {
       
        SignatureFileInfo info = importer.getLatestVersion(1);
      
//        assertEquals(CURRENT_VER, info.getVersion());
        assertTrue(info.getVersion() > 0);
        assertEquals(false, info.isDeprecated());
        assertEquals(SignatureType.BINARY, info.getType());
    }
View Full Code Here

TOP

Related Classes of uk.gov.nationalarchives.droid.core.interfaces.signature.SignatureFileInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.