test/java/time/test/java/time/format/TestCharLiteralParser.java

Print this page

        

@@ -57,15 +57,19 @@
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 package test.java.time.format;
 
+import static java.time.temporal.ChronoField.YEAR;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
 
-import java.time.format.DateTimeBuilder;
 import java.text.ParsePosition;
+import java.time.temporal.Queries;
+import java.time.temporal.TemporalAccessor;
+
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
 /**
  * Test CharLiteralPrinterParser.

@@ -99,17 +103,18 @@
     @Test(dataProvider="success")
     public void test_parse_success(char c, boolean caseSensitive,
                                    String text, int pos, int expectedPos) {
         setCaseSensitive(caseSensitive);
         ParsePosition ppos = new ParsePosition(pos);
-        DateTimeBuilder result =
-               getFormatter(c).parseToBuilder(text, ppos);
+        TemporalAccessor parsed = getFormatter(c).parseUnresolved(text, ppos);
         if (ppos.getErrorIndex() != -1) {
             assertEquals(ppos.getIndex(), expectedPos);
         } else {
             assertEquals(ppos.getIndex(), expectedPos);
-            assertEquals(result.getCalendricalList().size(), 0);
+            assertEquals(parsed.isSupported(YEAR), false);
+            assertEquals(parsed.query(Queries.chronology()), null);
+            assertEquals(parsed.query(Queries.zoneId()), null);
         }
     }
 
     //-----------------------------------------------------------------------
     @DataProvider(name="error")

@@ -121,13 +126,13 @@
     }
 
     @Test(dataProvider="error")
     public void test_parse_error(char c, String text, int pos, Class<?> expected) {
         try {
-            DateTimeBuilder result =
-               getFormatter(c).parseToBuilder(text, new ParsePosition(pos));
-            assertTrue(false);
+            ParsePosition ppos = new ParsePosition(pos);
+            getFormatter(c).parseUnresolved(text, ppos);
+            fail();
         } catch (RuntimeException ex) {
             assertTrue(expected.isInstance(ex));
         }
     }
 }