Skip to content

Commit faaa3f3

Browse files
authored
Upgrade Scala, JMockit version (#4376)
* Upgrade Scale, JMockit version * Fix for review comment
1 parent 80bada9 commit faaa3f3

File tree

42 files changed

+234
-870
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+234
-870
lines changed

common/src/main/java/org/apache/carbondata/common/logging/impl/AuditExtendedRollingFileAppender.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.apache.carbondata.common.logging.impl;
1919

20+
import org.apache.log4j.helpers.QuietWriter;
2021
import org.apache.log4j.spi.LoggingEvent;
2122

2223
/**
@@ -36,4 +37,24 @@ protected void subAppend(LoggingEvent event) {
3637
super.subAppend(event);
3738
}
3839
}
40+
41+
public void setFileName(String fileName) {
42+
this.fileName = fileName;
43+
}
44+
45+
public void setMaxBackupIndex(int maxBackupIndex) {
46+
this.maxBackupIndex = maxBackupIndex;
47+
}
48+
49+
public void setMaxFileSize(long maxFileSize) {
50+
this.maxFileSize = maxFileSize;
51+
}
52+
53+
public void setQuiteWriter(QuietWriter qw) {
54+
this.qw = qw;
55+
}
56+
57+
public QuietWriter getQuiteWriter() {
58+
return this.qw;
59+
}
3960
}

common/src/test/java/org/apache/carbondata/common/logging/impl/AuditExtendedRollingFileAppenderTest_UT.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717

1818
package org.apache.carbondata.common.logging.impl;
1919

20+
import java.lang.reflect.InvocationTargetException;
21+
import java.lang.reflect.Method;
22+
23+
import org.apache.log4j.helpers.QuietWriter;
2024
import org.junit.Assert;
21-
import mockit.Deencapsulation;
2225
import org.apache.log4j.Logger;
2326
import org.apache.log4j.spi.LoggingEvent;
2427
import org.junit.Before;
@@ -30,10 +33,9 @@ public class AuditExtendedRollingFileAppenderTest_UT {
3033

3134
@Before public void setUp() {
3235
rAppender = new AuditExtendedRollingFileAppender();
33-
Deencapsulation.setField(rAppender, "fileName", "audit.log");
34-
Deencapsulation.setField(rAppender, "maxBackupIndex", 1);
35-
Deencapsulation.setField(rAppender, "maxFileSize", 1000L);
36-
36+
rAppender.setFile("audit.log");
37+
rAppender.setMaxBackupIndex(1);
38+
rAppender.setMaxFileSize(1000L);
3739
}
3840

3941
@Test public void testRollOver() {
@@ -43,26 +45,31 @@ public class AuditExtendedRollingFileAppenderTest_UT {
4345
Assert.assertTrue(true);
4446
}
4547

46-
@Test public void testCleanLogs() {
48+
@Test public void testCleanLogs()
49+
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
4750
final String startName = "audit";
4851
final String folderPath = "./";
4952
int maxBackupIndex = 1;
5053

51-
Deencapsulation.invoke(rAppender, "cleanLogs", startName, folderPath, maxBackupIndex);
54+
Method cleanLogsMethod = ExtendedRollingFileAppender.class.getDeclaredMethod("cleanLogs",
55+
String.class, String.class, int.class);
56+
cleanLogsMethod.setAccessible(true);
57+
cleanLogsMethod.invoke(rAppender, startName, folderPath, maxBackupIndex);
5258
Assert.assertTrue(true);
5359
}
5460

5561
@Test public void testSubAppendLoggingEvent() {
5662
Logger logger = Logger.getLogger(this.getClass());
5763
LoggingEvent event = new LoggingEvent(null, logger, 0L, AuditLevel.AUDIT, null, null);
58-
59-
Deencapsulation.setField(rAppender, "qw", null);
64+
QuietWriter qw = rAppender.getQuiteWriter();
65+
rAppender.setQuiteWriter(null);
6066
try {
6167
rAppender.subAppend(event);
6268
} catch (Exception e) {
6369
//
6470
}
6571
Assert.assertTrue(true);
72+
rAppender.setQuiteWriter(qw);
6673
}
6774

6875
}

common/src/test/java/org/apache/carbondata/common/logging/impl/ExtendedRollingFileAppenderTest_UT.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717

1818
package org.apache.carbondata.common.logging.impl;
1919

20+
import java.lang.reflect.InvocationTargetException;
21+
import java.lang.reflect.Method;
22+
2023
import org.junit.Assert;
21-
import mockit.Deencapsulation;
2224
import org.apache.log4j.Logger;
2325
import org.apache.log4j.spi.LoggingEvent;
2426
import org.junit.Before;
@@ -30,9 +32,9 @@ public class ExtendedRollingFileAppenderTest_UT {
3032

3133
@Before public void setUp() {
3234
rAppender = new ExtendedRollingFileAppender();
33-
Deencapsulation.setField(rAppender, "fileName", "dummy.log");
34-
Deencapsulation.setField(rAppender, "maxBackupIndex", 1);
35-
Deencapsulation.setField(rAppender, "maxFileSize", 1000L);
35+
rAppender.setFile("dummy.log");
36+
rAppender.setMaxBackupIndex(1);
37+
rAppender.setMaxFileSize("1000");
3638
}
3739

3840
@Test public void testRollOver() {
@@ -42,12 +44,16 @@ public class ExtendedRollingFileAppenderTest_UT {
4244
Assert.assertTrue(true);
4345
}
4446

45-
@Test public void testCleanLogs() {
47+
@Test public void testCleanLogs()
48+
throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
4649
final String startName = "dummy";
4750
final String folderPath = "./";
4851
int maxBackupIndex = 1;
4952

50-
Deencapsulation.invoke(rAppender, "cleanLogs", startName, folderPath, maxBackupIndex);
53+
Method cleanLogsMethod = ExtendedRollingFileAppender.class.getDeclaredMethod("cleanLogs",
54+
String.class, String.class, int.class);
55+
cleanLogsMethod.setAccessible(true);
56+
cleanLogsMethod.invoke(rAppender, startName, folderPath, maxBackupIndex);
5157
}
5258

5359
@Test public void testSubAppendLoggingEvent() {

core/src/main/java/org/apache/carbondata/core/indexstore/blockletindex/BlockletDataRefNode.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public class BlockletDataRefNode implements DataRefNode {
4747

4848
private BlockletSerializer blockletSerializer;
4949

50+
public BlockletDataRefNode() { }
51+
5052
BlockletDataRefNode(List<TableBlockInfo> blockInfos, int index) {
5153
this.blockInfos = blockInfos;
5254
// Update row count and page count to blocklet info

core/src/main/java/org/apache/carbondata/core/indexstore/blockletindex/BlockletIndexFactory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,4 +760,9 @@ public IndexInputSplitWrapper toDistributableSegment(Segment segment,
760760
}
761761
}
762762

763+
public void setCache(
764+
Cache<TableBlockIndexUniqueIdentifierWrapper, BlockletIndexWrapper> cache) {
765+
this.cache = cache;
766+
}
767+
763768
}

core/src/main/java/org/apache/carbondata/core/metadata/schema/table/CarbonTable.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,4 +1289,7 @@ public String getTableStatusVersion() {
12891289
return this.tableInfo.getFactTable().getTableProperties().getOrDefault("latestversion", "");
12901290
}
12911291

1292+
public void setTableInfo(TableInfo tableInfo) {
1293+
this.tableInfo = tableInfo;
1294+
}
12921295
}

core/src/main/java/org/apache/carbondata/core/metadata/schema/table/TableInfo.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,4 +323,9 @@ public boolean hasColumnDrift() {
323323
public String getTablePath() {
324324
return tablePath;
325325
}
326+
327+
public void setIdentifier(AbsoluteTableIdentifier identifier) {
328+
this.identifier = identifier;
329+
}
330+
326331
}

core/src/main/java/org/apache/carbondata/core/scan/filter/executer/RangeValueFilterExecutorImpl.java

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public class RangeValueFilterExecutorImpl implements FilterExecutor {
6666
private boolean isRangeFullyCoverBlock;
6767
private boolean isNaturalSorted;
6868

69+
public RangeValueFilterExecutorImpl() { }
70+
6971
public RangeValueFilterExecutorImpl(DimColumnResolvedFilterInfo dimColEvaluatorInfo,
7072
Expression exp, byte[][] filterRangeValues, SegmentProperties segmentProperties) {
7173

@@ -732,4 +734,45 @@ public void readColumnChunks(RawBlockletColumnChunks rawBlockletColumnChunks) th
732734
}
733735
}
734736
}
737+
738+
public void setIsDimensionPresentInCurrentBlock(boolean isDimensionPresentInCurrentBlock) {
739+
this.isDimensionPresentInCurrentBlock = isDimensionPresentInCurrentBlock;
740+
}
741+
742+
public void setLessThanExp(boolean lessThanExp) {
743+
this.lessThanExp = lessThanExp;
744+
}
745+
746+
public void setGreaterThanExp(boolean greaterThanExp) {
747+
this.greaterThanExp = greaterThanExp;
748+
}
749+
750+
public void setDimColEvaluatorInfo(
751+
DimColumnResolvedFilterInfo dimColEvaluatorInfo) {
752+
this.dimColEvaluatorInfo = dimColEvaluatorInfo;
753+
}
754+
755+
/**
756+
* For testcase purpose
757+
* @return endBlockMaxisDefaultEnd
758+
*/
759+
public boolean isEndBlockMaxisDefaultEnd() {
760+
return endBlockMaxisDefaultEnd;
761+
}
762+
763+
/**
764+
* For testcase purpose
765+
* @return startBlockMinIsDefaultStart
766+
*/
767+
public boolean isStartBlockMinIsDefaultStart() {
768+
return startBlockMinIsDefaultStart;
769+
}
770+
771+
/**
772+
* For testcase purpose
773+
* @return isRangeFullyCoverBlock
774+
*/
775+
public boolean isRangeFullyCoverBlock() {
776+
return isRangeFullyCoverBlock;
777+
}
735778
}

core/src/main/java/org/apache/carbondata/core/scan/processor/RawBlockletColumnChunks.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class RawBlockletColumnChunks {
5050

5151
private BitSetGroup bitSetGroup;
5252

53-
private RawBlockletColumnChunks() { }
53+
public RawBlockletColumnChunks() { }
5454

5555
public static RawBlockletColumnChunks newInstance(int numberOfDimensionChunk,
5656
int numberOfMeasureChunk, FileReader fileReader, DataRefNode dataBlock) {

core/src/test/java/org/apache/carbondata/core/cache/CarbonLRUCacheTest.java

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,32 @@ public class CarbonLRUCacheTest {
3434

3535
@BeforeClass public static void setUp() {
3636
carbonLRUCache = new CarbonLRUCache("prop1", "2");
37-
cacheable = new MockUp<Cacheable>() {
38-
@SuppressWarnings("unused") @Mock long getMemorySize() {
37+
new MockUp<Cacheable>(Cacheable.class) {
38+
@SuppressWarnings("unused")
39+
@Mock
40+
long getMemorySize() {
3941
return 15L;
4042
}
41-
}.getMockInstance();
43+
44+
@SuppressWarnings("unused")
45+
@Mock
46+
void invalidate() {
47+
}
48+
49+
};
50+
cacheable = new Cacheable() {
51+
@Override public int getAccessCount() {
52+
return 0;
53+
}
54+
55+
@Override public long getMemorySize() {
56+
return 0;
57+
}
58+
59+
@Override public void invalidate() {
60+
61+
}
62+
};
4263
}
4364

4465
@Test public void testPut() {
@@ -51,11 +72,6 @@ public class CarbonLRUCacheTest {
5172
assertFalse(result);
5273
}
5374

54-
@Test public void testPutWhenKeysHaveToBeRemoved() {
55-
boolean result = carbonLRUCache.put("Column3", cacheable, 2097153L, 5);
56-
assertTrue(result);
57-
}
58-
5975
@Test public void testRemove() {
6076
carbonLRUCache.remove("Column2");
6177
assertNull(carbonLRUCache.get("Column2"));

0 commit comments

Comments
 (0)