Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.maven.cli.transfer;

import java.io.PrintStream;
import java.util.Locale;

import org.apache.maven.api.services.MessageBuilder;
import org.apache.maven.api.services.MessageBuilderFactory;
Expand Down Expand Up @@ -72,7 +71,7 @@ public void transferSucceeded(TransferEvent event) {

TransferResource resource = event.getResource();
long contentLength = event.getTransferredBytes();
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

MessageBuilder message = messageBuilderFactory.builder();
message.append(action).style(STYLE).append(' ').append(direction).append(' ');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.io.PrintStream;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;

import org.apache.maven.api.services.MessageBuilderFactory;
Expand All @@ -37,7 +36,7 @@
public class ConsoleMavenTransferListener extends AbstractMavenTransferListener {

private final Map<TransferResourceIdentifier, TransferResourceAndSize> transfers = new LinkedHashMap<>();
private final FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH); // use in a synchronized fashion
private final FileSizeFormat format = new FileSizeFormat(); // use in a synchronized fashion
private final StringBuilder buffer = new StringBuilder(128); // use in a synchronized fashion

private final boolean printResourceNames;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package org.apache.maven.cli.transfer;

import java.util.Locale;

import org.apache.maven.api.services.MessageBuilder;

/**
Expand Down Expand Up @@ -101,8 +99,6 @@ public static ScaleUnit getScaleUnit(long size) {
}
}

public FileSizeFormat(Locale locale) {}

public String format(long size) {
return format(size, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package org.apache.maven.cli.transfer;

import java.util.Locale;

import org.eclipse.aether.transfer.AbstractTransferListener;
import org.eclipse.aether.transfer.TransferCancelledException;
import org.eclipse.aether.transfer.TransferEvent;
Expand Down Expand Up @@ -75,7 +73,7 @@ public void transferSucceeded(TransferEvent event) {

TransferResource resource = event.getResource();
long contentLength = event.getTransferredBytes();
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

StringBuilder message = new StringBuilder();
message.append(action).append(' ').append(direction).append(' ').append(resource.getRepositoryId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
*/
package org.apache.maven.cli.transfer;

import java.util.Locale;

import org.apache.maven.cli.transfer.FileSizeFormat.ScaleUnit;
import org.junit.jupiter.api.Test;

Expand All @@ -30,15 +28,15 @@ class FileSizeFormatTest {

@Test
void testNegativeSize() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

long negativeSize = -100L;
assertThrows(IllegalArgumentException.class, () -> format.format(negativeSize));
}

@Test
void testSize() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

long _0_bytes = 0L;
assertEquals("0 B", format.format(_0_bytes));
Expand Down Expand Up @@ -103,7 +101,7 @@ void testSize() {

@Test
void testSizeWithSelectedScaleUnit() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

long _0_bytes = 0L;
assertEquals("0 B", format.format(_0_bytes));
Expand Down Expand Up @@ -206,22 +204,22 @@ void testSizeWithSelectedScaleUnit() {

@Test
void testNegativeProgressedSize() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

long negativeProgressedSize = -100L;
assertThrows(IllegalArgumentException.class, () -> format.formatProgress(negativeProgressedSize, 10L));
}

@Test
void testNegativeProgressedSizeBiggerThanSize() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

assertThrows(IllegalArgumentException.class, () -> format.formatProgress(100L, 10L));
}

@Test
void testProgressedSizeWithoutSize() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

long _0_bytes = 0L;
assertEquals("0 B", format.formatProgress(_0_bytes, -1L));
Expand All @@ -238,15 +236,15 @@ void testProgressedSizeWithoutSize() {

@Test
void testProgressedBothZero() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

long _0_bytes = 0L;
assertEquals("0 B", format.formatProgress(_0_bytes, _0_bytes));
}

@Test
void testProgressedSizeWithSize() {
FileSizeFormat format = new FileSizeFormat(Locale.ENGLISH);
FileSizeFormat format = new FileSizeFormat();

long _0_bytes = 0L;
long _400_bytes = 400L;
Expand Down