Search in sources :

Example 6 with com.tvd12.ezyfoxserver.client.handler

use of com.tvd12.ezyfoxserver.client.handler in project ezyhttp by youngmonkeys.

the class ApplicationContextBuilderTest method test.

@Test
public void test() {
    // given
    EzyBeanContext internalBeanContext = EzyBeanContext.builder().addSingleton(new InternalSingleton1()).build();
    Properties properties = new Properties();
    properties.put("b", 2);
    ApplicationContext applicationContext = new ApplicationContextBuilder().scan("com.tvd12.ezyhttp.server.core.test.component", "com.tvd12.ezyhttp.server.core.test.config", "com.tvd12.ezyhttp.server.core.test.controller").scan(Arrays.asList("com.tvd12.ezyhttp.server.core.test.reflect", "com.tvd12.ezyhttp.server.core.test.request", "com.tvd12.ezyhttp.server.core.test.resources", "com.tvd12.ezyhttp.server.core.test.service")).addComponentClasses(Collections.singletonList(SourceService.class)).addPropertiesSources(Collections.singletonList("application3.yaml")).addPropertiesSource("application-enable.yaml").addProperty("a", "1").addProperties(properties).addProperties(Collections.singletonMap("c", "3")).beanContext(internalBeanContext).addSingleton(new InternalSingleton2()).addSingleton(Collections.singletonMap("internalSingleton3", new InternalSingleton3())).addSingleton(mock(AbsentMessageResolver.class)).addComponentClass(InternalSingleton1.class).addPropertiesSources().build();
    EzyBeanContext beanContext = applicationContext.getBeanContext();
    // when
    int actualOneProp = beanContext.getProperty("one", int.class);
    boolean managementEnable = beanContext.getProperty("management.enable", boolean.class);
    Boolean resourceEnable = beanContext.getProperty("resources.enable", boolean.class);
    Boolean resourceUploadEnable = beanContext.getProperty("resources.upload.enable", boolean.class);
    UserService userService = beanContext.getSingleton(UserService.class);
    UserService0 userService0 = beanContext.getSingleton(UserService0.class);
    ViewContextBuilder viewContextBuilder = beanContext.getSingleton(ViewContextBuilder.class);
    ResourceResolver resourceResolver = beanContext.getSingleton(ResourceResolver.class);
    ResourceDownloadManager resourceDownloadManager = beanContext.getSingleton(ResourceDownloadManager.class);
    Set<String> packagesToScan = beanContext.getPackagesToScan();
    EventService eventService = beanContext.getSingleton(EventService.class);
    SourceService sourceService = beanContext.getSingleton(SourceService.class);
    String helloValue = beanContext.getProperty("hello", String.class);
    InternalSingleton1 internalSingleton1 = beanContext.getBeanCast(InternalSingleton1.class);
    InternalSingleton2 internalSingleton2 = beanContext.getBeanCast(InternalSingleton2.class);
    InternalSingleton3 internalSingleton3 = beanContext.getBeanCast(InternalSingleton3.class);
    // then
    Asserts.assertEquals(1, actualOneProp);
    Asserts.assertTrue(managementEnable);
    Asserts.assertTrue(resourceEnable);
    Asserts.assertTrue(resourceUploadEnable);
    Asserts.assertNotNull(userService);
    Asserts.assertNotNull(userService0);
    Asserts.assertNotNull(viewContextBuilder);
    Asserts.assertNotNull(resourceDownloadManager);
    Asserts.assertEquals(4, resourceResolver.getResources().size());
    Asserts.assertNotNull(eventService);
    Asserts.assertNotNull(sourceService);
    Asserts.assertNotNull(helloValue);
    Asserts.assertEquals("1", beanContext.getProperty("a", String.class));
    Asserts.assertEquals(2, beanContext.getProperty("b", int.class));
    Asserts.assertEquals("3", beanContext.getProperty("c", String.class));
    Asserts.assertEquals("3", applicationContext.getProperty("c", String.class));
    Asserts.assertEquals(packagesToScan, Sets.newHashSet("com.tvd12.ezyhttp.server", "com.tvd12.ezyhttp.server.core.test", "com.tvd12.ezyhttp.server.core.test.component", "com.tvd12.ezyhttp.server.core.test.config", "com.tvd12.ezyhttp.server.core.test.controller", "com.tvd12.ezyhttp.server.core.test.event", "com.tvd12.ezyhttp.server.core.test.api", "com.tvd12.ezyhttp.server.core.test.reflect", "com.tvd12.ezyhttp.server.core.test.request", "com.tvd12.ezyhttp.server.core.test.resources", "com.tvd12.ezyhttp.server.core.test.service"));
    Asserts.assertNotNull(internalSingleton1);
    Asserts.assertNotNull(internalSingleton2);
    Asserts.assertNotNull(internalSingleton3);
    ComponentManager componentManager = ComponentManager.getInstance();
    Asserts.assertEquals(componentManager.getAsyncDefaultTimeout(), 10000);
    System.out.println(applicationContext);
    applicationContext.destroy();
}
Also used : EzyBeanContext(com.tvd12.ezyfox.bean.EzyBeanContext) UserService(com.tvd12.ezyhttp.server.core.test.service.UserService) EventService(com.tvd12.ezyhttp.server.core.test.event.EventService) Properties(java.util.Properties) ViewContextBuilder(com.tvd12.ezyhttp.server.core.view.ViewContextBuilder) ApplicationContext(com.tvd12.ezyhttp.server.core.ApplicationContext) ResourceDownloadManager(com.tvd12.ezyhttp.core.resources.ResourceDownloadManager) ResourceResolver(com.tvd12.ezyhttp.server.core.resources.ResourceResolver) ComponentManager(com.tvd12.ezyhttp.server.core.manager.ComponentManager) UserService0(com.tvd12.ezyhttp.server.core.test.service.UserService0) ApplicationContextBuilder(com.tvd12.ezyhttp.server.core.ApplicationContextBuilder) SourceService(com.tvd12.ezyhttp.server.core.test.event.SourceService) Test(org.testng.annotations.Test)

Example 7 with com.tvd12.ezyfoxserver.client.handler

use of com.tvd12.ezyfoxserver.client.handler in project ezyhttp by youngmonkeys.

the class GraphQLConfigurationTest method test.

@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void test() throws NoSuchFieldException, IllegalAccessException {
    // given
    EzyBeanContextBuilder builder = new EzySimpleBeanContext.Builder();
    Set<String> packagesToScan = RandomUtil.randomSet(8, String.class);
    packagesToScan.add("com.tvd12.ezyhttp.server.graphql.test.config");
    for (String p : packagesToScan) {
        builder.scan(p);
    }
    EzyBeanContext context = builder.build();
    GraphQLConfiguration sut = new GraphQLConfiguration();
    EzySingletonFactory singletonFactory = context.getSingletonFactory();
    sut.setSingletonFactory(singletonFactory);
    sut.setObjectMapper(new ObjectMapper());
    sut.setGraphQLEnable(true);
    // when
    sut.config();
    GraphQLController controller = (GraphQLController) singletonFactory.getSingleton(GraphQLController.class);
    Field dataFetcherManagerField = GraphQLController.class.getDeclaredField("dataFetcherManager");
    dataFetcherManagerField.setAccessible(true);
    GraphQLDataFetcherManager dataFetcherManager = (GraphQLDataFetcherManager) dataFetcherManagerField.get(controller);
    Field dataFetchersField = GraphQLDataFetcherManager.class.getDeclaredField("dataFetchers");
    dataFetchersField.setAccessible(true);
    Map<String, GraphQLDataFetcher> dataFetchers = (Map<String, GraphQLDataFetcher>) dataFetchersField.get(dataFetcherManager);
    // then
    Asserts.assertNotNull(controller);
    Asserts.assertTrue(dataFetchers.containsKey("A"));
}
Also used : GraphQLDataFetcher(com.tvd12.ezyhttp.server.graphql.GraphQLDataFetcher) EzyBeanContext(com.tvd12.ezyfox.bean.EzyBeanContext) EzyBeanContextBuilder(com.tvd12.ezyfox.bean.EzyBeanContextBuilder) GraphQLController(com.tvd12.ezyhttp.server.graphql.controller.GraphQLController) EzySingletonFactory(com.tvd12.ezyfox.bean.EzySingletonFactory) Field(java.lang.reflect.Field) EzyBeanContextBuilder(com.tvd12.ezyfox.bean.EzyBeanContextBuilder) GraphQLDataFetcherManager(com.tvd12.ezyhttp.server.graphql.GraphQLDataFetcherManager) Map(java.util.Map) GraphQLConfiguration(com.tvd12.ezyhttp.server.graphql.GraphQLConfiguration) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.testng.annotations.Test)

Example 8 with com.tvd12.ezyfoxserver.client.handler

use of com.tvd12.ezyfoxserver.client.handler in project ezyfox-examples by tvd12.

the class KafkaConsumer method main.

public static void main(String[] args) throws Exception {
    EzyKafkaProxy kafkaProxy = EzyKafkaProxy.builder().scan("com.tvd12.ezymq.example.kafka").build();
    EzyKafkaConsumer consumer = kafkaProxy.getConsumer("hello-world");
    consumer.start();
    while (true) {
        Thread.sleep(1000);
    }
}
Also used : EzyKafkaConsumer(com.tvd12.ezymq.kafka.EzyKafkaConsumer) EzyKafkaProxy(com.tvd12.ezymq.kafka.EzyKafkaProxy)

Example 9 with com.tvd12.ezyfoxserver.client.handler

use of com.tvd12.ezyfoxserver.client.handler in project ezyfox-examples by tvd12.

the class HelloWorldRpcClientExample method main.

public static void main(String[] args) throws Exception {
    QuickRpcClient client = QuickRpcClient.builder().scan("com.tvd12.quick.rpc.examples.hello_world.data").build();
    GreetResponse response = client.call(new GreetRequest("World"), GreetResponse.class);
    System.out.println(response.getMessage());
}
Also used : GreetResponse(com.tvd12.quick.rpc.examples.hello_world.data.GreetResponse) GreetRequest(com.tvd12.quick.rpc.examples.hello_world.data.GreetRequest) QuickRpcClient(com.tvd12.quick.rpc.client.QuickRpcClient)

Example 10 with com.tvd12.ezyfoxserver.client.handler

use of com.tvd12.ezyfoxserver.client.handler in project ezyfox-server-android-client by youngmonkeys.

the class EzyArrayList method toList.

/*
     * (non-Javadoc)
     * @see com.tvd12.ezyfox.entity.EzyRoArray#toList()
     */
@Override
public List toList() {
    EzyArrayToList arrayToList = EzyArrayToList.getInstance();
    List list = arrayToList.toList(this);
    return list;
}
Also used : EzyArrayToList(com.tvd12.ezyfoxserver.client.util.EzyArrayToList) List(java.util.List) EzyArrayToList(com.tvd12.ezyfoxserver.client.util.EzyArrayToList) ArrayList(java.util.ArrayList)

Aggregations

Test (org.testng.annotations.Test)9 EzyBeanContext (com.tvd12.ezyfox.bean.EzyBeanContext)8 EzyBeanContextBuilder (com.tvd12.ezyfox.bean.EzyBeanContextBuilder)3 EzyServerContext (com.tvd12.ezyfoxserver.context.EzyServerContext)3 EzySimpleSettings (com.tvd12.ezyfoxserver.setting.EzySimpleSettings)3 MongoClient (com.mongodb.MongoClient)2 EzySingleton (com.tvd12.ezyfox.bean.annotation.EzySingleton)2 EzyBindingContext (com.tvd12.ezyfox.binding.EzyBindingContext)2 EzyXmlReader (com.tvd12.ezyfox.mapping.jaxb.EzyXmlReader)2 EzyZoneContext (com.tvd12.ezyfoxserver.context.EzyZoneContext)2 ResourceDownloadManager (com.tvd12.ezyhttp.core.resources.ResourceDownloadManager)2 ApplicationContext (com.tvd12.ezyhttp.server.core.ApplicationContext)2 ApplicationContextBuilder (com.tvd12.ezyhttp.server.core.ApplicationContextBuilder)2 ResourceResolver (com.tvd12.ezyhttp.server.core.resources.ResourceResolver)2 Map (java.util.Map)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 HomeController (com.tvd12.example.reactive.HomeController)1 RxHomeController (com.tvd12.example.reactive.RxHomeController)1 HomeData (com.tvd12.example.reactive.data.HomeData)1 BookService (com.tvd12.example.spring_core.service.BookService)1