move size value/unit to bytes size value/unit, and create a ten based size value/unit

This commit is contained in:
kimchy 2010-06-15 18:26:44 +03:00
parent a18e58b394
commit eb68891ae5
5 changed files with 11 additions and 14 deletions

View File

@ -33,7 +33,7 @@ public class JsonSettingsLoaderTests {
@Test public void testSimpleJsonSettings() throws Exception { @Test public void testSimpleJsonSettings() throws Exception {
Settings settings = settingsBuilder() Settings settings = settingsBuilder()
.loadFromClasspath("org/elasticsearch/util/settings/loader/test-settings.json") .loadFromClasspath("org/elasticsearch/common/settings/loader/test-settings.json")
.build(); .build();
assertThat(settings.get("test1.value1"), equalTo("value1")); assertThat(settings.get("test1.value1"), equalTo("value1"));

View File

@ -33,7 +33,7 @@ public class YamlSettingsLoaderTests {
@Test public void testSimpleYamlSettings() throws Exception { @Test public void testSimpleYamlSettings() throws Exception {
Settings settings = settingsBuilder() Settings settings = settingsBuilder()
.loadFromClasspath("org/elasticsearch/util/settings/loader/test-settings.yml") .loadFromClasspath("org/elasticsearch/common/settings/loader/test-settings.yml")
.build(); .build();
assertThat(settings.get("test1.value1"), equalTo("value1")); assertThat(settings.get("test1.value1"), equalTo("value1"));

View File

@ -17,7 +17,7 @@
* under the License. * under the License.
*/ */
package org.elasticsearch.util; package org.elasticsearch.common.unit;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -28,7 +28,7 @@ import static org.hamcrest.Matchers.*;
/** /**
* @author kimchy (Shay Banon) * @author kimchy (Shay Banon)
*/ */
public class SizeUnitTests { public class ByteSizeUnitTests {
@Test public void testBytes() { @Test public void testBytes() {
assertThat(BYTES.toBytes(1), equalTo(1l)); assertThat(BYTES.toBytes(1), equalTo(1l));

View File

@ -17,10 +17,8 @@
* under the License. * under the License.
*/ */
package org.elasticsearch.util; package org.elasticsearch.common.unit;
import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import static org.hamcrest.MatcherAssert.*; import static org.hamcrest.MatcherAssert.*;
@ -29,7 +27,7 @@ import static org.hamcrest.Matchers.*;
/** /**
* @author kimchy (Shay Banon) * @author kimchy (Shay Banon)
*/ */
public class SizeValueTests { public class ByteSizeValueTests {
@Test public void testActual() { @Test public void testActual() {
assertThat(new ByteSizeValue(4, ByteSizeUnit.GB).bytes(), equalTo(4294967296l)); assertThat(new ByteSizeValue(4, ByteSizeUnit.GB).bytes(), equalTo(4294967296l));
@ -44,9 +42,9 @@ public class SizeValueTests {
@Test public void testToString() { @Test public void testToString() {
assertThat("10", is(new ByteSizeValue(10, ByteSizeUnit.BYTES).toString())); assertThat("10", is(new ByteSizeValue(10, ByteSizeUnit.BYTES).toString()));
assertThat("1.5k", is(new ByteSizeValue((long) (1024 * 1.5), ByteSizeUnit.BYTES).toString())); assertThat("1.5kb", is(new ByteSizeValue((long) (1024 * 1.5), ByteSizeUnit.BYTES).toString()));
assertThat("1.5m", is(new ByteSizeValue((long) (1024 * 1.5), ByteSizeUnit.KB).toString())); assertThat("1.5mb", is(new ByteSizeValue((long) (1024 * 1.5), ByteSizeUnit.KB).toString()));
assertThat("1.5g", is(new ByteSizeValue((long) (1024 * 1.5), ByteSizeUnit.MB).toString())); assertThat("1.5gb", is(new ByteSizeValue((long) (1024 * 1.5), ByteSizeUnit.MB).toString()));
assertThat("1536g", is(new ByteSizeValue((long) (1024 * 1.5), ByteSizeUnit.GB).toString())); assertThat("1536gb", is(new ByteSizeValue((long) (1024 * 1.5), ByteSizeUnit.GB).toString()));
} }
} }

View File

@ -17,10 +17,9 @@
* under the License. * under the License.
*/ */
package org.elasticsearch.util; package org.elasticsearch.common.unit;
import org.elasticsearch.common.joda.time.PeriodType; import org.elasticsearch.common.joda.time.PeriodType;
import org.elasticsearch.common.unit.TimeValue;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;