Skip to content

Commit

Permalink
Compatible old ReportUtil usage and supply test cases (#14)
Browse files Browse the repository at this point in the history
## Motivation

Before some alipay users use ReportUtil with the full package com.alipay.sofa.common.log.ReportUtil but in this version ReportUtil has been moved to com.alipay.sofa.common.utils.ReportUtil. Consider many users has used, so we should be compatible with it

## Modification

com.alipay.sofa.common.log.ReportUtil extends com.alipay.sofa.common.utils.ReportUtil for compatible

## Result

Fixes #14

#16 only litte cases and after should provide more test cases
  • Loading branch information
guanchao-yang authored and khotyn committed Jun 5, 2018
1 parent 4f6abfa commit 8bb9f92
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 0 deletions.
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;

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);
}
}

0 comments on commit 8bb9f92

Please sign in to comment.