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

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


       
    }
   
    @Test
    public void testExecuteWithSignatureFilesPresent() {
        SignatureFileInfo info1 = new SignatureFileInfo(33, false, SignatureType.BINARY);
        info1.setFile(new File("foo/bar/version_33.xml"));
        SignatureFileInfo info2 = new SignatureFileInfo(45, false, SignatureType.BINARY);
        info2.setFile(new File("foo/bar/version_45.xml"));
        SignatureFileInfo info3 = new SignatureFileInfo(78, true, SignatureType.BINARY);
        info3.setFile(new File("foo/bar/version_78.xml"));
       
        SignatureFileInfo info4 = new SignatureFileInfo(133, false, SignatureType.CONTAINER);
        info4.setFile(new File("foo/bar/version_133.xml"));
        SignatureFileInfo info5 = new SignatureFileInfo(145, false, SignatureType.CONTAINER);
        info5.setFile(new File("foo/bar/version_145.xml"));

        SortedMap<String, SignatureFileInfo> binSigFiles = new TreeMap<String, SignatureFileInfo>();
        binSigFiles.put("33", info1);
        binSigFiles.put("45", info2);
        binSigFiles.put("78", info3);
View Full Code Here


    @Test
    public void testDisplayDefaultSignatureFileVersion() throws Exception {
        File sigFile1 = new File("foo/bar/myBinSigFile.xml");
        File sigFile2 = new File("foo/bar/myContainerSigFile.xml");

        SignatureFileInfo sigFileInfo1 = new SignatureFileInfo(69, false, SignatureType.BINARY);
        SignatureFileInfo sigFileInfo2 = new SignatureFileInfo(71, false, SignatureType.CONTAINER);
       
        Map<SignatureType, SignatureFileInfo> allSigFiles = new TreeMap<SignatureType, SignatureFileInfo>();
        allSigFiles.put(SignatureType.BINARY, sigFileInfo1);
        allSigFiles.put(SignatureType.CONTAINER, sigFileInfo2);
        sigFileInfo1.setFile(sigFile1);
        sigFileInfo2.setFile(sigFile2);
       
        when(signatureManager.getDefaultSignatures()).thenReturn(allSigFiles);
       
        command.execute();
       
View Full Code Here

    }
   
    @Test
    public void testCheckSignatureUpdateWhenUpdateIsAvailable() throws Exception {
       
        SignatureFileInfo sigFileInfo = new SignatureFileInfo(69, false, SignatureType.BINARY);
        Map<SignatureType, SignatureFileInfo> sigFiles = new HashMap<SignatureType, SignatureFileInfo>();
        sigFiles.put(SignatureType.BINARY, sigFileInfo);
        when(signatureManager.getLatestSignatureFiles()).thenReturn(sigFiles);
       
        command.execute();
View Full Code Here

        command = new DownloadSignatureUpdateCommand();
       
        signatureManager = mock(SignatureManager.class);
       
        Map<SignatureType, SignatureFileInfo> mockValues = new HashMap<SignatureType, SignatureFileInfo>();
        mockValues.put(SignatureType.BINARY, new SignatureFileInfo(69, false, SignatureType.BINARY));
        mockValues.put(SignatureType.CONTAINER, new SignatureFileInfo(69, false, SignatureType.CONTAINER));
        try {
            when(signatureManager.getLatestSignatureFiles()).thenReturn(mockValues);
        } catch (SignatureManagerException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
View Full Code Here

    }
   
    @Test
    public void testDownloadSignatureUpdate() throws Exception {
      
        SignatureFileInfo sigFileInfo = new SignatureFileInfo(69, false, SignatureType.BINARY);
        when(signatureManager.downloadLatest(SignatureType.BINARY)).thenReturn(sigFileInfo);
        when(signatureManager.downloadLatest(SignatureType.CONTAINER)).thenReturn(sigFileInfo);
        command.execute();
       
        verify(printWriter, times(2)).println("Signature update version 69 has been downloaded");
View Full Code Here

            "test2.txt",
        });
       
       
       
        SignatureFileInfo sig = mock(SignatureFileInfo.class);
        Map<SignatureType, SignatureFileInfo> sigs = new HashMap<SignatureType, SignatureFileInfo>();
        sigs.put(SignatureType.BINARY, sig);
       
        when(signatureManager.getDefaultSignatures()).thenReturn(sigs);
       
View Full Code Here

    }
   
    @Test
    public void testExecuteWithAValidVersion() throws Exception {
       
        SignatureFileInfo info1 = new SignatureFileInfo(33, false, SignatureType.BINARY);
        SignatureFileInfo info2 = new SignatureFileInfo(45, false, SignatureType.BINARY);
        info2.setFile(new File("foo/bar/version_45.xml"));

        SortedMap<String, SignatureFileInfo> binSigFileInfos = new TreeMap<String, SignatureFileInfo>();
        binSigFileInfos.put("v33", info1);
        binSigFileInfos.put("v45", info2);
       
View Full Code Here

    }
   
    @Test
    public void testExecuteWithAnUnknownVersion() {
       
        SignatureFileInfo info1 = new SignatureFileInfo(33, false, SignatureType.BINARY);
        SignatureFileInfo info2 = new SignatureFileInfo(45, false, SignatureType.BINARY);

        SortedMap<String, SignatureFileInfo> binSigFileInfos = new TreeMap<String, SignatureFileInfo>();
        binSigFileInfos.put("v33", info1);
        binSigFileInfos.put("v45", info2);
       
View Full Code Here

       
        Map<String, SignatureFileInfo> sigFileInfoForType = sigFileInfos.get(type);
       
        for (Map.Entry<String, SignatureFileInfo> entry : sigFileInfoForType.entrySet()) {
            String key = entry.getKey();
            SignatureFileInfo info = entry.getValue();
            if (info.getVersion() == signatureFileVersion) {
                validVersion = true;
                updateDefaultVersion(key);
                break;
            }
        }
View Full Code Here

    private void updateDefaultVersion(String key) throws CommandExecutionException {
        final PropertiesConfiguration properties = globalConfig.getProperties();
        properties.setProperty(mapping.get(type).getName(), key);
        try {
            properties.save();
            SignatureFileInfo sigFileInfo = signatureManager.getDefaultSignatures().get(type);
            printWriter.println(I18N.getResource(I18N.CONFIGURE_SIGNATURE_FILE_VERSION_SUCCESS,
                    sigFileInfo.getVersion(), sigFileInfo.getFile().getName()));
                   
        } catch (ConfigurationException e) {
            throw new CommandExecutionException(e);
        } catch (SignatureFileException e) {
            throw new CommandExecutionException(e);
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.