Search in sources :

Example 1 with FileSystemResource

use of org.apache.ignite.resources.FileSystemResource in project ignite by apache.

the class IgfsSecondaryFileSystemInjectionSelfTest method testInjectPrimaryByField.

/**
     * @throws Exception If failed.
     */
@SuppressWarnings({ "UnusedDeclaration" })
public void testInjectPrimaryByField() throws Exception {
    secondary = new TestBaseSecondaryFsMock() {

        @FileSystemResource
        private IgfsImpl igfs;

        @LoggerResource
        private IgniteLogger log;

        @IgniteInstanceResource
        private Ignite ig;

        @Override
        boolean checkInjection(Ignite ignite, IgniteFileSystem primary) {
            return igfs == primary && log instanceof IgniteLogger && ig == ignite;
        }
    };
    Ignite ig = startGrid(0);
    IgniteFileSystem igfs = ig.fileSystem(IGFS_NAME);
    assert secondary.checkInjection(ig, igfs);
}
Also used : LoggerResource(org.apache.ignite.resources.LoggerResource) IgniteInstanceResource(org.apache.ignite.resources.IgniteInstanceResource) Ignite(org.apache.ignite.Ignite) IgniteFileSystem(org.apache.ignite.IgniteFileSystem) FileSystemResource(org.apache.ignite.resources.FileSystemResource) IgniteLogger(org.apache.ignite.IgniteLogger)

Example 2 with FileSystemResource

use of org.apache.ignite.resources.FileSystemResource in project ignite by apache.

the class IgfsSecondaryFileSystemInjectionSelfTest method testInjectPrimaryByMethods.

/**
     * @throws Exception If failed.
     */
@SuppressWarnings({ "UnusedDeclaration" })
public void testInjectPrimaryByMethods() throws Exception {
    secondary = new TestBaseSecondaryFsMock() {

        /** Ignite instance. */
        private Ignite ig;

        /** IGFS instance. */
        private IgniteFileSystem igfs;

        /** Logger injected flag */
        private boolean logSet;

        /**
             * @param igfs Primary IGFS.
             */
        @FileSystemResource
        void setPrimaryIgfs(IgfsImpl igfs) {
            this.igfs = igfs;
        }

        /**
             * @param log Ignite logger.
             */
        @LoggerResource
        void setIgLogger(IgniteLogger log) {
            logSet = log instanceof IgniteLogger;
        }

        /**
             * @param ig Ignite instance.
             */
        @IgniteInstanceResource
        void setIgniteInst(Ignite ig) {
            this.ig = ig;
        }

        @Override
        boolean checkInjection(Ignite ignite, IgniteFileSystem primary) {
            return ignite == ig && primary == igfs && logSet;
        }
    };
    Ignite ig = startGrid(0);
    IgniteFileSystem igfs = ig.fileSystem(IGFS_NAME);
    assert secondary.checkInjection(ig, igfs);
}
Also used : LoggerResource(org.apache.ignite.resources.LoggerResource) IgniteInstanceResource(org.apache.ignite.resources.IgniteInstanceResource) Ignite(org.apache.ignite.Ignite) IgniteFileSystem(org.apache.ignite.IgniteFileSystem) FileSystemResource(org.apache.ignite.resources.FileSystemResource) IgniteLogger(org.apache.ignite.IgniteLogger)

Aggregations

Ignite (org.apache.ignite.Ignite)2 IgniteFileSystem (org.apache.ignite.IgniteFileSystem)2 IgniteLogger (org.apache.ignite.IgniteLogger)2 FileSystemResource (org.apache.ignite.resources.FileSystemResource)2 IgniteInstanceResource (org.apache.ignite.resources.IgniteInstanceResource)2 LoggerResource (org.apache.ignite.resources.LoggerResource)2