Java Code Examples for com.alibaba.dubbo.common.utils.LogUtil#start()

The following examples show how to use com.alibaba.dubbo.common.utils.LogUtil#start() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExtensionLoader_Adaptive_Test.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_getAdaptiveExtension_inject() throws Exception {
    LogUtil.start();
    Ext6 ext = ExtensionLoader.getExtensionLoader(Ext6.class).getAdaptiveExtension();

    URL url = new URL("p1", "1.2.3.4", 1010, "path1");
    url = url.addParameters("ext6", "impl1");
    
    assertEquals("Ext6Impl1-echo-Ext1Impl1-echo", ext.echo(url, "ha"));
    
    Assert.assertTrue("can not find error.", LogUtil.checkNoError());
    LogUtil.stop();
    
    url = url.addParameters("simple.ext", "impl2");
    assertEquals("Ext6Impl1-echo-Ext1Impl2-echo", ext.echo(url, "ha"));
    
}
 
Example 2
Source File: FailSafeClusterInvokerTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test()
public void testNoInvoke() {
    dic = EasyMock.createMock(Directory.class);
    
    EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
    EasyMock.expect(dic.list(invocation)).andReturn(null).anyTimes();
    EasyMock.expect(dic.getInterface()).andReturn(DemoService.class).anyTimes();
    
    invocation.setMethodName("method1");
    EasyMock.replay(dic);
    
    resetInvokerToNoException();
    
    FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
    LogUtil.start();
    invoker.invoke(invocation);
    assertTrue(LogUtil.findMessage("No provider") > 0);
    LogUtil.stop();
}
 
Example 3
Source File: ExtensionLoader_Adaptive_Test.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_getAdaptiveExtension_inject() throws Exception {
    LogUtil.start();
    Ext6 ext = ExtensionLoader.getExtensionLoader(Ext6.class).getAdaptiveExtension();

    URL url = new URL("p1", "1.2.3.4", 1010, "path1");
    url = url.addParameters("ext6", "impl1");
    
    assertEquals("Ext6Impl1-echo-Ext1Impl1-echo", ext.echo(url, "ha"));
    
    Assert.assertTrue("can not find error.", LogUtil.checkNoError());
    LogUtil.stop();
    
    url = url.addParameters("simple.ext", "impl2");
    assertEquals("Ext6Impl1-echo-Ext1Impl2-echo", ext.echo(url, "ha"));
    
}
 
Example 4
Source File: FailSafeClusterInvokerTest.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test()
public void testNoInvoke() {
    dic = EasyMock.createMock(Directory.class);
    
    EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
    EasyMock.expect(dic.list(invocation)).andReturn(null).anyTimes();
    EasyMock.expect(dic.getInterface()).andReturn(DemoService.class).anyTimes();
    
    invocation.setMethodName("method1");
    EasyMock.replay(dic);
    
    resetInvokerToNoException();
    
    FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
    LogUtil.start();
    invoker.invoke(invocation);
    assertTrue(LogUtil.findMessage("No provider") > 0);
    LogUtil.stop();
}
 
Example 5
Source File: FailSafeClusterInvokerTest.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
@Test()
public void testNoInvoke() {
    dic = EasyMock.createMock(Directory.class);
    
    EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
    EasyMock.expect(dic.list(invocation)).andReturn(null).anyTimes();
    EasyMock.expect(dic.getInterface()).andReturn(DemoService.class).anyTimes();
    
    invocation.setMethodName("method1");
    EasyMock.replay(dic);
    
    resetInvokerToNoException();
    
    FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
    LogUtil.start();
    invoker.invoke(invocation);
    assertTrue(LogUtil.findMessage("No provider") > 0);
    LogUtil.stop();
}
 
Example 6
Source File: ExtensionLoader_Adaptive_Test.java    From dubbox-hystrix with Apache License 2.0 6 votes vote down vote up
@Test
public void test_getAdaptiveExtension_inject() throws Exception {
    LogUtil.start();
    Ext6 ext = ExtensionLoader.getExtensionLoader(Ext6.class).getAdaptiveExtension();

    URL url = new URL("p1", "1.2.3.4", 1010, "path1");
    url = url.addParameters("ext6", "impl1");
    
    assertEquals("Ext6Impl1-echo-Ext1Impl1-echo", ext.echo(url, "ha"));
    
    Assert.assertTrue("can not find error.", LogUtil.checkNoError());
    LogUtil.stop();
    
    url = url.addParameters("simple.ext", "impl2");
    assertEquals("Ext6Impl1-echo-Ext1Impl2-echo", ext.echo(url, "ha"));
    
}
 
Example 7
Source File: FailSafeClusterInvokerTest.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Test()
public void testNoInvoke() {
    dic = mock(Directory.class);

    given(dic.getUrl()).willReturn(url);
    given(dic.list(invocation)).willReturn(null);
    given(dic.getInterface()).willReturn(DemoService.class);

    invocation.setMethodName("method1");

    resetInvokerToNoException();

    FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
    LogUtil.start();
    invoker.invoke(invocation);
    assertTrue(LogUtil.findMessage("No provider") > 0);
    LogUtil.stop();
}
 
Example 8
Source File: ExtensionLoader_Adaptive_Test.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_getAdaptiveExtension_inject() throws Exception {
    LogUtil.start();
    Ext6 ext = ExtensionLoader.getExtensionLoader(Ext6.class).getAdaptiveExtension();

    URL url = new URL("p1", "1.2.3.4", 1010, "path1");
    url = url.addParameters("ext6", "impl1");
    
    assertEquals("Ext6Impl1-echo-Ext1Impl1-echo", ext.echo(url, "ha"));
    
    Assert.assertTrue("can not find error.", LogUtil.checkNoError());
    LogUtil.stop();
    
    url = url.addParameters("simple.ext", "impl2");
    assertEquals("Ext6Impl1-echo-Ext1Impl2-echo", ext.echo(url, "ha"));
    
}
 
Example 9
Source File: ExtensionLoader_Adaptive_Test.java    From dubbox with Apache License 2.0 6 votes vote down vote up
@Test
public void test_getAdaptiveExtension_inject() throws Exception {
    LogUtil.start();
    Ext6 ext = ExtensionLoader.getExtensionLoader(Ext6.class).getAdaptiveExtension();

    URL url = new URL("p1", "1.2.3.4", 1010, "path1");
    url = url.addParameters("ext6", "impl1");
    
    assertEquals("Ext6Impl1-echo-Ext1Impl1-echo", ext.echo(url, "ha"));
    
    Assert.assertTrue("can not find error.", LogUtil.checkNoError());
    LogUtil.stop();
    
    url = url.addParameters("simple.ext", "impl2");
    assertEquals("Ext6Impl1-echo-Ext1Impl2-echo", ext.echo(url, "ha"));
    
}
 
Example 10
Source File: ExtensionLoader_Adaptive_Test.java    From dubbo-2.6.5 with Apache License 2.0 6 votes vote down vote up
@Test
public void test_getAdaptiveExtension_inject() throws Exception {
    LogUtil.start();
    Ext6 ext = ExtensionLoader.getExtensionLoader(Ext6.class).getAdaptiveExtension();

    URL url = new URL("p1", "1.2.3.4", 1010, "path1");
    url = url.addParameters("ext6", "impl1");

    assertEquals("Ext6Impl1-echo-Ext1Impl1-echo", ext.echo(url, "ha"));

    Assert.assertTrue("can not find error.", LogUtil.checkNoError());
    LogUtil.stop();

    url = url.addParameters("simple.ext", "impl2");
    assertEquals("Ext6Impl1-echo-Ext1Impl2-echo", ext.echo(url, "ha"));

}
 
Example 11
Source File: AccessLogFilterTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Test
public void testInvokeException() {
    Invoker<AccessLogFilterTest> invoker = new MyInvoker<AccessLogFilterTest>(null);
    Invocation invocation = new MockInvocation();
    LogUtil.start();
    accessLogFilter.invoke(invoker, invocation);
    assertEquals(1, LogUtil.findMessage("Exception in AcessLogFilter of service"));
    LogUtil.stop();
}
 
Example 12
Source File: RegistryDirectoryTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * 测试推送只有router的情况
 */
@Test
public void testNotified_Normal_withRouters() {
    LogUtil.start();
    RegistryDirectory registryDirectory = getRegistryDirectory();
    test_Notified1invokers(registryDirectory);
    test_Notified_only_routers(registryDirectory);
    Assert.assertEquals(true, registryDirectory.isAvailable());
    Assert.assertTrue("notify no invoker urls ,should not error", LogUtil.checkNoError());
    LogUtil.stop();
    test_Notified2invokers(registryDirectory);
    
}
 
Example 13
Source File: DeprecatedFilterTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeprecatedFilter() {
    URL url = URL.valueOf("test://test:11/test?group=dubbo&version=1.1&echo." + Constants.DEPRECATED_KEY + "=true");
    LogUtil.start();
    deprecatedFilter.invoke(new MyInvoker<DemoService>(url), new MockInvocation());
    assertEquals(1,
                 LogUtil.findMessage("The service method com.alibaba.dubbo.rpc.support.DemoService.echo(String) is DEPRECATED"));
    LogUtil.stop();
}
 
Example 14
Source File: DeprecatedFilterTest.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeprecatedFilter() {
    URL url = URL.valueOf("test://test:11/test?group=dubbo&version=1.1&echo." + Constants.DEPRECATED_KEY + "=true");
    LogUtil.start();
    deprecatedFilter.invoke(new MyInvoker<DemoService>(url), new MockInvocation());
    assertEquals(1,
                 LogUtil.findMessage("The service method com.alibaba.dubbo.rpc.support.DemoService.echo(String) is DEPRECATED"));
    LogUtil.stop();
}
 
Example 15
Source File: AccessLogFilterTest.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
@Test
public void testInvokeException() {
    Invoker<AccessLogFilterTest> invoker = new MyInvoker<AccessLogFilterTest>(null);
    Invocation invocation = new MockInvocation();
    LogUtil.start();
    accessLogFilter.invoke(invoker, invocation);
    assertEquals(1, LogUtil.findMessage("Exception in AcessLogFilter of service"));
    LogUtil.stop();
}
 
Example 16
Source File: AccessLogFilterTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Test
public void testInvokeException() {
    Invoker<AccessLogFilterTest> invoker = new MyInvoker<AccessLogFilterTest>(null);
    Invocation invocation = new MockInvocation();
    LogUtil.start();
    accessLogFilter.invoke(invoker, invocation);
    assertEquals(1, LogUtil.findMessage("Exception in AcessLogFilter of service"));
    LogUtil.stop();
}
 
Example 17
Source File: DeprecatedFilterTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeprecatedFilter() {
    URL url = URL.valueOf("test://test:11/test?group=dubbo&version=1.1&echo." + Constants.DEPRECATED_KEY + "=true");
    LogUtil.start();
    deprecatedFilter.invoke(new MyInvoker<DemoService>(url), new MockInvocation());
    assertEquals(1,
                 LogUtil.findMessage("The service method com.alibaba.dubbo.rpc.support.DemoService.echo(String) is DEPRECATED"));
    LogUtil.stop();
}
 
Example 18
Source File: RegistryDirectoryTest.java    From dubbox with Apache License 2.0 5 votes vote down vote up
/**
 * 测试推送只有router的情况
 */
@Test
public void testNotified_Normal_withRouters() {
    LogUtil.start();
    RegistryDirectory registryDirectory = getRegistryDirectory();
    test_Notified1invokers(registryDirectory);
    test_Notified_only_routers(registryDirectory);
    Assert.assertEquals(true, registryDirectory.isAvailable());
    Assert.assertTrue("notify no invoker urls ,should not error", LogUtil.checkNoError());
    LogUtil.stop();
    test_Notified2invokers(registryDirectory);
    
}
 
Example 19
Source File: AccessLogFilterTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Test
public void testInvokeException() {
    Invoker<AccessLogFilterTest> invoker = new MyInvoker<AccessLogFilterTest>(null);
    Invocation invocation = new MockInvocation();
    LogUtil.start();
    accessLogFilter.invoke(invoker, invocation);
    assertEquals(1, LogUtil.findMessage("Exception in AcessLogFilter of service"));
    LogUtil.stop();
}
 
Example 20
Source File: DeprecatedFilterTest.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeprecatedFilter() {
    URL url = URL.valueOf("test://test:11/test?group=dubbo&version=1.1&echo." + Constants.DEPRECATED_KEY + "=true");
    LogUtil.start();
    deprecatedFilter.invoke(new MyInvoker<DemoService>(url), new MockInvocation());
    assertEquals(1,
            LogUtil.findMessage("The service method com.alibaba.dubbo.rpc.support.DemoService.echo(String) is DEPRECATED"));
    LogUtil.stop();
}