Search in sources :

Example 11 with com.tvd12.ezyfoxserver.socket

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

the class EzyHashMap method toMap.

/*
	 * (non-Javadoc)
	 * @see com.tvd12.ezyfox.entity.EzyRoObject#toMap()
	 */
@Override
public Map toMap() {
    EzyObjectToMap objectToMap = EzyObjectToMap.getInstance();
    Map map = objectToMap.toMap(this);
    return map;
}
Also used : EzyObjectToMap(com.tvd12.ezyfoxserver.client.util.EzyObjectToMap) EzyObjectToMap(com.tvd12.ezyfoxserver.client.util.EzyObjectToMap) Map(java.util.Map) HashMap(java.util.HashMap)

Example 12 with com.tvd12.ezyfoxserver.socket

use of com.tvd12.ezyfoxserver.socket in project properties-file by tvd12.

the class BaseFileWriter method write.

/* (non-Javadoc)
     * @see com.tvd12.properties.file.writer.FileWriter#write(java.util.Properties, java.io.File)
     */
@Override
public void write(Properties properties, File file) {
    try (ByteArrayOutputStream out = write(properties)) {
        if (!file.exists()) {
            file.createNewFile();
        }
        byte[] bytes = encode(out);
        writeBytes0(file, bytes);
    } catch (IOException e) {
        throw new PropertiesFileException("Can not write properties to file", e);
    }
}
Also used : PropertiesFileException(com.tvd12.properties.file.exception.PropertiesFileException)

Example 13 with com.tvd12.ezyfoxserver.socket

use of com.tvd12.ezyfoxserver.socket in project ezyhttp by youngmonkeys.

the class ApplicationContextBuilderTest method testNotEnable.

@Test
public void testNotEnable() {
    // given
    System.setProperty(EzyBeanContext.ACTIVE_PROFILES_KEY, "disable");
    ApplicationContext applicationContext = new ApplicationContextBuilder().scan("i_dont_know").build();
    System.setProperty(EzyBeanContext.ACTIVE_PROFILES_KEY, "enable");
    EzyBeanContext beanContext = applicationContext.getBeanContext();
    // when
    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);
    ResourceResolver resourceResolver = beanContext.getSingleton(ResourceResolver.class);
    ResourceDownloadManager resourceDownloadManager = beanContext.getSingleton(ResourceDownloadManager.class);
    Set<String> packagesToScan = beanContext.getPackagesToScan();
    // then
    Asserts.assertFalse(managementEnable);
    Asserts.assertFalse(resourceEnable);
    Asserts.assertFalse(resourceUploadEnable);
    Asserts.assertNull(resourceResolver);
    Asserts.assertNull(resourceDownloadManager);
    Asserts.assertEquals(Sets.newHashSet("i_dont_know", "com.tvd12.ezyhttp.server", "com.tvd12.ezyhttp.server.core.test", "com.tvd12.ezyhttp.server.core.test.config", "com.tvd12.ezyhttp.server.core.test.event", "com.tvd12.ezyhttp.server.core.test.api"), packagesToScan);
    applicationContext.destroy();
}
Also used : ApplicationContext(com.tvd12.ezyhttp.server.core.ApplicationContext) ResourceDownloadManager(com.tvd12.ezyhttp.core.resources.ResourceDownloadManager) EzyBeanContext(com.tvd12.ezyfox.bean.EzyBeanContext) ResourceResolver(com.tvd12.ezyhttp.server.core.resources.ResourceResolver) ApplicationContextBuilder(com.tvd12.ezyhttp.server.core.ApplicationContextBuilder) Test(org.testng.annotations.Test)

Example 14 with com.tvd12.ezyfoxserver.socket

use of com.tvd12.ezyfoxserver.socket in project ezyfox-server by youngmonkeys.

the class EzySimpleXmlReaderTest method test3.

@Test
public void test3() {
    EzyXmlReader reader = EzySimpleXmlMapper.builder().contextPath("com.tvd12.ezyfoxserver").classLoader(getClass().getClassLoader()).build();
    EzySimpleSettings settings = reader.read(new File("src/main/resources/ezy-settings.xml"), EzySimpleSettings.class);
    System.out.println(new EzySimpleJsonWriter().writeAsString(settings));
}
Also used : EzyXmlReader(com.tvd12.ezyfox.mapping.jaxb.EzyXmlReader) EzySimpleJsonWriter(com.tvd12.ezyfox.json.EzySimpleJsonWriter) EzySimpleSettings(com.tvd12.ezyfoxserver.setting.EzySimpleSettings) File(java.io.File) BaseTest(com.tvd12.test.base.BaseTest) Test(org.testng.annotations.Test)

Example 15 with com.tvd12.ezyfoxserver.socket

use of com.tvd12.ezyfoxserver.socket in project ezyfox-server by youngmonkeys.

the class EzySimplePluginEntryTest method scanPackages.

@Test
public void scanPackages() {
    // given
    EzyPluginContext pluginContext = mock(EzyPluginContext.class);
    ScheduledExecutorService executorService = mock(ScheduledExecutorService.class);
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    EzyServerContext serverContext = mock(EzyServerContext.class);
    EzyPluginSetup pluginSetup = mock(EzyPluginSetup.class);
    EzyPlugin plugin = mock(EzyPlugin.class);
    when(pluginContext.getPlugin()).thenReturn(plugin);
    EzyPluginSetting pluginSetting = mock(EzyPluginSetting.class);
    when(plugin.getSetting()).thenReturn(pluginSetting);
    InternalPluginEntry sut = new InternalPluginEntry();
    // when
    when(pluginContext.get(ScheduledExecutorService.class)).thenReturn(executorService);
    when(pluginContext.getParent()).thenReturn(zoneContext);
    when(zoneContext.getParent()).thenReturn(serverContext);
    when(pluginContext.get(EzyPluginSetup.class)).thenReturn(pluginSetup);
    sut.config(pluginContext);
    // then
    EzyBeanContext beanContext = sut.beanContext;
    MongoConfig mongoConfig = (MongoConfig) beanContext.getBean(MongoConfig.class);
    Set<String> expectedPackages = Sets.newHashSet(EzySupportConstants.DEFAULT_PACKAGE_TO_SCAN, "com.tvd12.ezyfoxserver.support.v120.test.entry");
    Asserts.assertEquals(expectedPackages, mongoConfig.packagesToScan);
    Singleton singleton = (Singleton) beanContext.getBean(Singleton.class);
    Asserts.assertNotNull(singleton);
}
Also used : EzyPluginSetup(com.tvd12.ezyfoxserver.command.EzyPluginSetup) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyBeanContext(com.tvd12.ezyfox.bean.EzyBeanContext) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyPlugin(com.tvd12.ezyfoxserver.EzyPlugin) EzyPluginSetting(com.tvd12.ezyfoxserver.setting.EzyPluginSetting) EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzySingleton(com.tvd12.ezyfox.bean.annotation.EzySingleton) Test(org.testng.annotations.Test)

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