Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatible old ReportUtil usage and supply test cases #14

Merged
merged 18 commits into from
Jun 5, 2018
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/Ask_Question.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Ask Question
about: Ask a question about usage or feature

---

### Your question

describe your question clearly

### Your scenes

describe your use scenes (why need this feature)

### Your advice

describe the advice or solution you'd like

### Environment

- sofa-common-tools version:
- JVM version (e.g. `java -version`):
- OS version (e.g. `uname -a`):
- Maven version:
- IDE version:



26 changes: 26 additions & 0 deletions .github/ISSUE_TEMPLATE/Bug_Report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Bug Report
about: Create a report to help us improve

---

### Describe the bug

A clear and concise description of what the bug is.

### Expected behavior

### Actual behavior

### Steps to reproduce

### Minimal yet complete reproducer code (or GitHub URL to code)

### Environment

- sofa-common-tools version:
- JVM version (e.g. `java -version`):
- OS version (e.g. `uname -a`):
- Maven version:
- IDE version:

15 changes: 15 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
### Motivation:

Explain the context, and why you're making that change.
To make others understand what is the problem you're trying to solve.

### Modification:

Describe the idea and modifications you've done.

### Result:

Fixes #<GitHub issue number>.

If there is no issue then describe the changes introduced by this PR.

31 changes: 31 additions & 0 deletions src/main/java/com/alipay/sofa/common/log/ReportUtil.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.alipay.sofa.common.log;

/**
* ReportUtil Compatible history usage
* <p>
* Output logs to console and default logger
* <p>
* Created by yangguanchao on 18/06/04.
*/
@Deprecated
public class ReportUtil extends com.alipay.sofa.common.utils.ReportUtil{

}


40 changes: 40 additions & 0 deletions src/test/java/com/alipay/sofa/common/utils/AssertUtilTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.alipay.sofa.common.utils;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this test case? It seems that it is not related to this issue.

Copy link
Member Author

@guanchao-yang guanchao-yang Jun 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#16 only litte cases and should provide more test cases after 。 PR additional remarks

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please only do one thing in on PR next time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok


import org.junit.Test;

/**
* AssertUtil Tester.
*
* @author <guanchao.ygc>
* @version 1.0
* @since 18/06/04
*/
public class AssertUtilTest {


/**
* Method: isTrue(boolean expression, String message)
*/
@Test
public void testIsTrueForExpressionMessage() throws Exception {
boolean isSuccess = false;
AssertUtil.isTrue(!isSuccess, "isTrue");
boolean isException = false;
try {
AssertUtil.isTrue(isSuccess, "isTrue");
} catch (Exception ex) {
isException = true;
}
AssertUtil.isTrue(isException);
}

/**
* Method: isNull(Object object, String message)
*/
@Test
public void testIsNullForObjectMessage() throws Exception {
Object object = null;
AssertUtil.isNull(object, "null");
AssertUtil.isNull(object);
}
}
28 changes: 28 additions & 0 deletions src/test/java/com/alipay/sofa/common/utils/ReportUtilTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.alipay.sofa.common.utils;

import com.alipay.sofa.common.log.ReportUtil;
import org.junit.Test;

import static org.junit.Assert.assertFalse;

/**
* ReportUtil Tester.
*
* @author <guanchao.ygc>
* @version 1.0
* @since 18/06/04
*/
public class ReportUtilTest {

@Test
public void testUtils() {
String errMsg = "Some Error Msg";
boolean isException = false;
try {
ReportUtil.reportError("RuntimeException", new RuntimeException());
} catch (Exception ex) {
isException = true;
}
assertFalse(isException);
}
}