Package com.netflix.paas.rest.test

Source Code of com.netflix.paas.rest.test.PaasEurekaNodeDiscoveryTest

/*******************************************************************************
* /*
*  *
*  *  Copyright 2013 Netflix, Inc.
*  *
*  *     Licensed under the Apache License, Version 2.0 (the "License");
*  *     you may not use this file except in compliance with the License.
*  *     You may obtain a copy of the License at
*  *
*  *         http://www.apache.org/licenses/LICENSE-2.0
*  *
*  *     Unless required by applicable law or agreed to in writing, software
*  *     distributed under the License is distributed on an "AS IS" BASIS,
*  *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  *     See the License for the specific language governing permissions and
*  *     limitations under the License.
*  *
*  *
******************************************************************************/
package com.netflix.paas.rest.test;

import java.util.List;

import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.base.Supplier;
import com.google.common.collect.Lists;
import com.google.inject.AbstractModule;
import com.google.inject.Injector;
import com.google.inject.name.Names;
import com.netflix.astyanax.connectionpool.Host;
import com.netflix.governator.guice.LifecycleInjector;
import com.netflix.staash.cassandra.discovery.EurekaAstyanaxHostSupplier;
import com.netflix.staash.cassandra.discovery.EurekaModule;

public class PaasEurekaNodeDiscoveryTest {
    Logger LOG = LoggerFactory.getLogger(PaasEurekaNodeDiscoveryTest.class);

    @Test
    @Ignore
    public void testSupplier() {
        List<AbstractModule> modules = Lists.newArrayList(
                new AbstractModule() {
                    @Override
                    protected void configure() {
                        bind(String.class).annotatedWith(Names.named("groupName")).toInstance("testgroup");
                    }
                },
                new EurekaModule()
            );
           
            // Create the injector
            Injector injector = LifecycleInjector.builder()
                .withModules(modules)
                .createInjector();

            EurekaAstyanaxHostSupplier supplier = injector.getInstance(EurekaAstyanaxHostSupplier.class);
//        EurekaAstyanaxHostSupplier supplier = new EurekaAstyanaxHostSupplier();
            Supplier<List<Host>> list1 = supplier.getSupplier("c_sandbox");
            List<Host> hosts = list1.get();
            LOG.info("cass_sandbox");
            for (Host host:hosts) {
                LOG.info(host.getHostName());
            }
//            Supplier<List<Host>> list2 = supplier.getSupplier("ABCLOUD");
//            hosts = list2.get();
//            LOG.info("ABCLOUD");
//            for (Host host:hosts) {
//                LOG.info(host.getHostName());
//            }
           
            Supplier<List<Host>> list3 = supplier.getSupplier("C_PAAS");
            hosts = list3.get();
            LOG.info("c_paas");
            for (Host host:hosts) {
                LOG.info(host.getHostName());
            }

    }

}
TOP

Related Classes of com.netflix.paas.rest.test.PaasEurekaNodeDiscoveryTest

TOP
Copyright © 2018 www.massapi.com. 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.