Package com.volantis.devrep.repository.accessors

Examples of com.volantis.devrep.repository.accessors.MDPRArchiveAccessor


        TemporaryFileManager manager = new TemporaryFileManager(
                new TestDeviceRepositoryCreator());
        manager.executeWith(new TemporaryFileExecutor() {
            public void execute(File repository) throws Exception {

                MDPRArchiveAccessor archiveAccessor = new MDPRArchiveAccessor(
                        repository.getPath(), transformerMetaFactory);
                final EclipseDeviceRepository writeRepository =
                        new EclipseDeviceRepository(archiveAccessor,
                                jdomFactory,
                                false,
                                true,
                                null);

                // There should not be a pre-existing custom policy properties
                // file.
                boolean existsBefore =
                        archiveAccessor.getArchive().exists(customPolicyProps);
                assertFalse("Custom policies.properties should not exist",
                        existsBefore);

                // Set the custom properties on the accessor.
                PrivateAccessor.setField(writeRepository, "properties", properties);

                // Write out the properties, standard and custom, and save the
                // repository.
                writeRepository.writeProperties();

                if (logger.isDebugEnabled()) {
                    // Print out details about the original repository archive
                    // and copy it to /tmp/r1.zip. This was added to help debug
                    // problems with committing VBM:2004110904.
                    dumpFile(repository, new File("/tmp/r1.zip"));
                }

                writeRepository.saveRepositoryArchive();

                if (logger.isDebugEnabled()) {
                    // Print out details about the modifed repository archive
                    // and copy it to /tmp/r2.zip. This was added to help debug
                    // problems with committing VBM:2004110904.
                    dumpFile(repository, new File("/tmp/r2.zip"));
                }

                // Create a brand new accessor to read the saved modified
                // repository. This ensures starting from a "clean slate".
                final EclipseDeviceRepository readRepository =
                        new EclipseDeviceRepository(archiveAccessor,
                                jdomFactory,
                                false,
                                true,
                                null);

                // The custom policy properties file should now exist, and be the
                // "default".
                boolean existsAfter =
                        archiveAccessor.getArchive().exists(customPolicyProps);
                assertTrue("Custom policies.properties should exist",
                        existsAfter);

                // Check that the customPropertiesPath field is set correctly.
                String actualPath =
View Full Code Here


        final String[] result = new String[1];
        TemporaryFileManager manager = new TemporaryFileManager(
                new TestDeviceRepositoryCreator());
        manager.executeWith(new TemporaryFileExecutor() {
            public void execute(File file) throws Exception {
                MDPRArchiveAccessor archiveAccessor = new MDPRArchiveAccessor(
                        file.getPath(), transformerMetaFactory);
                EclipseDeviceRepository accessor =
                        new EclipseDeviceRepository(archiveAccessor,
                                jdomFactory,
                                false,
                                true,
                                null);
                try {
                    result[0] = (String) PrivateAccessor.invoke(accessor,
                            "populateProperties",
                            new Class[]{ZipArchive.class,
                                        String.class,
                                        Properties.class},
                            new Object[]{archiveAccessor.getArchive(),
                                         prefix,
                                         properties});
                } catch (Throwable throwable) {
                    throw new Exception(throwable);
                }
View Full Code Here

                upgradeableRepositoryCreator);
        manager.executeWith(new TemporaryFileExecutor() {
            public void execute(File repository) throws Exception {

                String filename = repository.getPath();
                MDPRArchiveAccessor accessor = new MDPRArchiveAccessor(filename,
                        transformerMetaFactory);
                assertTrue(accessor.isCompatible());
                assertTrue(accessor.willBeModifiedOnLoad());
                ZipArchive oa = new ZipArchive(filename);
                assertFalse(
                        "tac-identification.xml should not exist in unmodified file.",
                        oa.exists("tac-identification-xml"));
                ZipArchive za = accessor.getArchive();
                assertTrue("tac-identification.xml should exist in modified file.",
                        za.exists("tac-identification.xml"));

                // Check that the new tac-identification file contains the expected
                // data...
View Full Code Here

                upgradeableRepositoryCreator);
        manager.executeWith(new TemporaryFileExecutor() {
            public void execute(File repository) throws Exception {

                String filename = repository.getPath();
                MDPRArchiveAccessor accessor = new MDPRArchiveAccessor(filename,
                        transformerMetaFactory);

                // Check that non-existent file returns null.
                InputStream is = accessor.getArchiveEntryInputStream("monkey.xml");
                assertNull("Non-existent file should return null", is);

                // Check that a previously non-existent file returns a stream if it's
                // created by the upgrade
                is = accessor.getArchiveEntryInputStream("tac-identification.xml");
                assertNotNull(is);

                // Check that an unmodified file returns a stream
                is = accessor.getArchiveEntryInputStream("version.txt");
                assertNotNull(is);
            }
        });
    }
View Full Code Here

        ODOMEditorContext context = null;
        try {
            final JAXPTransformerMetaFactory transformerMetaFactory =
                    new JAXPTransformerMetaFactory();
            MDPRArchiveAccessor archiveAccessor =
                    new MDPRArchiveAccessor(file.getLocation().toOSString(),
                            transformerMetaFactory);

            boolean ok = true;
            if (archiveAccessor.willBeModifiedOnLoad()) {
                // Inform the user that the device repository will need
                // to be modified and have them give permission.
                ok = confirmAndModify(archiveAccessor);
            }
            if (ok) {
View Full Code Here

TOP

Related Classes of com.volantis.devrep.repository.accessors.MDPRArchiveAccessor

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.