42 * and/or other materials provided with the distribution. 43 * 44 * * Neither the name of JSR-310 nor the names of its contributors 45 * may be used to endorse or promote products derived from this software 46 * without specific prior written permission. 47 * 48 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 49 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 50 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 51 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 52 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 53 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 54 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 55 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 56 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 57 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 58 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 59 */ 60 package test.java.time.format; 61 62 import java.time.format.*; 63 64 import static java.time.temporal.ChronoField.DAY_OF_MONTH; 65 import static org.testng.Assert.assertSame; 66 67 import java.util.Locale; 68 69 import org.testng.annotations.BeforeMethod; 70 import org.testng.annotations.Test; 71 72 /** 73 * Test DateTimeFormatter. 74 */ 75 @Test 76 public class TestDateTimeFormatter { 77 // TODO these tests are not tck, as they refer to a non-public class 78 // rewrite whole test case to use BASIC_FORMATTER or similar 79 80 @BeforeMethod(groups={"tck"}) 81 public void setUp() { 82 } 83 84 @Test(groups={"implementation"}) 85 public void test_withLocale_same() throws Exception { 86 DateTimeFormatter base = 87 new DateTimeFormatterBuilder().appendLiteral("ONE") 88 .appendValue(DAY_OF_MONTH, 1, 2, SignStyle.NOT_NEGATIVE) 89 .toFormatter(Locale.ENGLISH) 90 .withSymbols(DateTimeFormatSymbols.STANDARD); 91 DateTimeFormatter test = base.withLocale(Locale.ENGLISH); 92 assertSame(test, base); 93 } 94 95 } | 42 * and/or other materials provided with the distribution. 43 * 44 * * Neither the name of JSR-310 nor the names of its contributors 45 * may be used to endorse or promote products derived from this software 46 * without specific prior written permission. 47 * 48 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 49 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 50 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 51 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 52 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 53 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 54 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 55 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 56 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 57 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 58 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 59 */ 60 package test.java.time.format; 61 62 import static java.time.temporal.ChronoField.DAY_OF_MONTH; 63 import static org.testng.Assert.assertSame; 64 65 import java.time.format.DateTimeFormatSymbols; 66 import java.time.format.DateTimeFormatter; 67 import java.time.format.DateTimeFormatterBuilder; 68 import java.time.format.SignStyle; 69 import java.util.Locale; 70 71 import org.testng.annotations.Test; 72 73 /** 74 * Test DateTimeFormatter. 75 */ 76 @Test 77 public class TestDateTimeFormatter { 78 79 @Test 80 public void test_withLocale_same() throws Exception { 81 DateTimeFormatter base = 82 new DateTimeFormatterBuilder().appendLiteral("ONE") 83 .appendValue(DAY_OF_MONTH, 1, 2, SignStyle.NOT_NEGATIVE) 84 .toFormatter(Locale.ENGLISH) 85 .withSymbols(DateTimeFormatSymbols.STANDARD); 86 DateTimeFormatter test = base.withLocale(Locale.ENGLISH); 87 assertSame(test, base); 88 } 89 90 } |