-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Config can now support Path and File types
- Loading branch information
Showing
3 changed files
with
69 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
blaze-core/src/test/java/com/fizzed/blaze/internal/ConverterTest.java
This file was deleted.
Oops, something went wrong.
62 changes: 62 additions & 0 deletions
62
blaze-core/src/test/java/com/fizzed/blaze/util/ConverterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2015 Fizzed, Inc. | ||
* | ||
* Licensed 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.fizzed.blaze.util; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.Assert.assertThat; | ||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
import java.net.MalformedURLException; | ||
import java.net.URI; | ||
import java.net.URL; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
/** | ||
* | ||
* @author joelauer | ||
*/ | ||
public class ConverterTest { | ||
|
||
@Test | ||
public void convert() throws MalformedURLException { | ||
assertThat(Converter.convert("1", Byte.class), is((byte)1)); | ||
assertThat(Converter.convert("1", byte.class), is((byte)1)); | ||
|
||
assertThat(Converter.convert("1", Short.class), is((short)1)); | ||
assertThat(Converter.convert("1", short.class), is((short)1)); | ||
|
||
assertThat(Converter.convert("1", Integer.class), is(1)); | ||
assertThat(Converter.convert("1", int.class), is(1)); | ||
|
||
assertThat(Converter.convert("1.2", Float.class), is(1.2f)); | ||
assertThat(Converter.convert("1.2", float.class), is(1.2f)); | ||
|
||
assertThat(Converter.convert("1.2", Double.class), is(1.2d)); | ||
assertThat(Converter.convert("1.2", double.class), is(1.2d)); | ||
|
||
assertThat(Converter.convert("true", Boolean.class), is(true)); | ||
assertThat(Converter.convert("false", boolean.class), is(false)); | ||
|
||
assertThat(Converter.convert("http://www.fizzed.com/", URI.class), is(URI.create("http://www.fizzed.com/"))); | ||
assertThat(Converter.convert("http://www.fizzed.com/", URL.class), is(new URL("http://www.fizzed.com/"))); | ||
|
||
assertThat(Converter.convert("./a", Path.class), is(Paths.get("./a"))); | ||
assertThat(Converter.convert("./a", File.class), is(Paths.get("./a").toFile())); | ||
} | ||
|
||
} |