Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @FrozenClockRule.TimeZone("Europe/Stockholm") public void shouldAcquireCurrentDateTime()
        public virtual void ShouldAcquireCurrentDateTime()
        {
            assertEqualTemporal(datetime(ZonedDateTime.now(Clock)), DateTimeValue.Now(Clock));

            assertEqualTemporal(datetime(ZonedDateTime.now(Clock.withZone("UTC"))), DateTimeValue.now(Clock, "UTC"));

            assertEqualTemporal(datetime(ZonedDateTime.now(Clock.withZone(UTC))), DateTimeValue.now(Clock, "Z"));
        }
Пример #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: static java.util.stream.Stream<RetrieveResult> retrieve(String graphToken, org.neo4j.internal.kernel.api.Kernel kernel, long numSilentQueryDrops) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException
        internal static Stream <RetrieveResult> Retrieve(string graphToken, Kernel kernel, long numSilentQueryDrops)
        {
            IDictionary <string, object> systemData = new Dictionary <string, object>();

            systemData["jvmMemoryFree"]                = Runtime.Runtime.freeMemory();
            systemData["jvmMemoryTotal"]               = Runtime.Runtime.totalMemory();
            systemData["jvmMemoryMax"]                 = Runtime.Runtime.maxMemory();
            systemData["systemTotalPhysicalMemory"]    = OsBeanUtil.TotalPhysicalMemory;
            systemData["systemFreePhysicalMemory"]     = OsBeanUtil.FreePhysicalMemory;
            systemData["systemCommittedVirtualMemory"] = OsBeanUtil.CommittedVirtualMemory;
            systemData["systemTotalSwapSpace"]         = OsBeanUtil.TotalSwapSpace;
            systemData["systemFreeSwapSpace"]          = OsBeanUtil.FreeSwapSpace;

            OperatingSystemMXBean os = ManagementFactory.OperatingSystemMXBean;

            systemData["osArch"]              = os.Arch;
            systemData["osName"]              = os.Name;
            systemData["osVersion"]           = os.Version;
            systemData["availableProcessors"] = os.AvailableProcessors;
            systemData["byteOrder"]           = ByteOrder.nativeOrder().ToString();

            RuntimeMXBean runtime = ManagementFactory.RuntimeMXBean;

            systemData["jvmName"]    = runtime.VmName;
            systemData["jvmVendor"]  = runtime.VmVendor;
            systemData["jvmVersion"] = runtime.VmVersion;
            CompilationMXBean compiler = ManagementFactory.CompilationMXBean;

            systemData["jvmJITCompiler"] = compiler == null ? "unknown" : compiler.Name;

            systemData["userLanguage"] = Locale.Default.Language;
            systemData["userCountry"]  = Locale.Default.Country;
            systemData["userTimezone"] = TimeZone.Default.ID;
            systemData["fileEncoding"] = System.getProperty("file.encoding");

            IDictionary <string, object> internalData = new Dictionary <string, object>();

            internalData["numSilentQueryCollectionMisses"] = numSilentQueryDrops;

            IDictionary <string, object> metaData = new Dictionary <string, object>();

            metaData["graphToken"]   = graphToken;
            metaData["retrieveTime"] = ZonedDateTime.now();
            metaData["system"]       = systemData;
            metaData["internal"]     = internalData;

            TokensSection.PutTokenCounts(metaData, kernel);

            return(Stream.of(new RetrieveResult(Sections.META, metaData)));
        }
Пример #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @FrozenClockRule.TimeZone({"Europe/Stockholm", "America/Los_Angeles"}) public void shouldCopyDateTime()
        public virtual void ShouldCopyDateTime()
        {
            assertEqualTemporal(datetime(ZonedDateTime.now(Clock)), builder(Clock).add("datetime", datetime(ZonedDateTime.now(Clock))).build());
            assertEqualTemporal(datetime(ZonedDateTime.now(Clock)), builder(Clock).add("datetime", localDateTime(DateTime.now(Clock))).build());
            assertEqualTemporal(datetime(ZonedDateTime.now(Clock).withZoneSameLocal(ZoneId.of("America/New_York"))), builder(Clock).add("datetime", localDateTime(DateTime.now(Clock))).add("timezone", stringValue("America/New_York")).build());
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @TestFactory Stream<org.junit.jupiter.api.DynamicTest> addGet()
        internal virtual Stream <DynamicTest> AddGet()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<org.eclipse.collections.api.tuple.Pair<String, org.neo4j.values.storable.Value[]>> inputs = asList(testInput("NoValue", System.Func.identity(), org.neo4j.values.storable.NoValue.NO_VALUE), testInput("Boolean", org.neo4j.values.storable.Values::booleanValue, true, false, true, false), testInput("BooleanArray", org.neo4j.values.storable.Values::booleanArray, new boolean[] {false, true, false}, EMPTY_BOOLEAN_ARRAY), testInput("Byte", org.neo4j.values.storable.Values::byteValue, (byte) 0, (byte) 1, (byte) -1, Byte.MIN_VALUE, Byte.MAX_VALUE), testInput("ByteArray", org.neo4j.values.storable.Values::byteArray, new byte[] {(byte) 0, (byte) 1, (byte) -1, Byte.MIN_VALUE, Byte.MAX_VALUE}, EMPTY_BYTE_ARRAY), testInput("Short", org.neo4j.values.storable.Values::shortValue, (short) 0, (short) 1, (short) -1, Short.MIN_VALUE, Short.MAX_VALUE), testInput("ShortArray", org.neo4j.values.storable.Values::shortArray, new short[] {(short) 0, (short) 1, (short) -1, Short.MIN_VALUE, Short.MAX_VALUE}, EMPTY_SHORT_ARRAY), testInput("Char", org.neo4j.values.storable.Values::charValue, 'a', '\uFFFF', '∂', '©'), testInput("CharArray", org.neo4j.values.storable.Values::charArray, new char[] {'a', '\uFFFF', '∂', '©'}, EMPTY_CHAR_ARRAY), testInput("Int", org.neo4j.values.storable.Values::intValue, 0, 1, -1, Integer.MIN_VALUE, Integer.MAX_VALUE), testInput("IntArray", org.neo4j.values.storable.Values::intArray, new int[] {0, 1, -1, Integer.MIN_VALUE, Integer.MAX_VALUE}, EMPTY_INT_ARRAY), testInput("Long", org.neo4j.values.storable.Values::longValue, 0L, 1L, -1L, Long.MIN_VALUE, Long.MAX_VALUE), testInput("LongArray", org.neo4j.values.storable.Values::longArray, new long[] {0L, 1L, -1L, Long.MIN_VALUE, Long.MAX_VALUE}, EMPTY_LONG_ARRAY), testInput("Double", org.neo4j.values.storable.Values::doubleValue, 0.0, 1.0, -1.0, Double.MIN_VALUE, Double.MAX_VALUE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY), testInput("DoubleArray", org.neo4j.values.storable.Values::doubleArray, new double[] {0.0, 1.0, -1.0, Double.MIN_VALUE, Double.MAX_VALUE, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY}, EMPTY_DOUBLE_ARRAY), testInput("Float", org.neo4j.values.storable.Values::floatValue, 0.0f, 1.0f, -1.0f, Float.MIN_VALUE, Float.MAX_VALUE, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY), testInput("FloatArray", org.neo4j.values.storable.Values::floatArray, new float[] {0.0f, 1.0f, -1.0f, Float.MIN_VALUE, Float.MAX_VALUE, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY}, EMPTY_FLOAT_ARRAY), testInput("String", org.neo4j.values.storable.Values::stringValue, "", "x", "foobar"), testInput("StringArray", org.neo4j.values.storable.Values::stringArray, new String[] {"", "x", "foobar"}, EMPTY_STRING_ARRAY), testInput("Point", input -> pointValue(input.getOne(), input.getTwo()), org.eclipse.collections.impl.tuple.Tuples.pair(org.neo4j.values.storable.CoordinateReferenceSystem.WGS84, new double[] {1.0, 2.0}), org.eclipse.collections.impl.tuple.Tuples.pair(org.neo4j.values.storable.CoordinateReferenceSystem.WGS84_3D, new double[] {1.0, 2.0, 3.0}), org.eclipse.collections.impl.tuple.Tuples.pair(org.neo4j.values.storable.CoordinateReferenceSystem.Cartesian, new double[] {1.0, 2.0}), org.eclipse.collections.impl.tuple.Tuples.pair(org.neo4j.values.storable.CoordinateReferenceSystem.Cartesian_3D, new double[] {1.0, 2.0, 3.0})), testInput("PointArray", org.neo4j.values.storable.Values::pointArray, new org.neo4j.graphdb.spatial.Point[] { pointValue(org.neo4j.values.storable.CoordinateReferenceSystem.WGS84, 1.0, 2.0), pointValue(org.neo4j.values.storable.CoordinateReferenceSystem.WGS84_3D, 1.0, 2.0, 3.0), pointValue(org.neo4j.values.storable.CoordinateReferenceSystem.Cartesian, 1.0, 2.0), pointValue(org.neo4j.values.storable.CoordinateReferenceSystem.Cartesian_3D, 1.0, 2.0, 3.0) }, new org.neo4j.graphdb.spatial.Point[0]), testInput("Duration", org.neo4j.values.storable.Values::durationValue, (java.time.temporal.TemporalAmount) java.time.Duration.parse("P2DT3H4M"), java.time.Period.parse("P1Y2M3W4D")), testInput("DurationArray", org.neo4j.values.storable.Values::durationArray, new java.time.temporal.TemporalAmount[] {java.time.Duration.parse("P2DT3H4M"), java.time.Period.parse("P1Y2M3W4D")}, new java.time.temporal.TemporalAmount[0]), testInput("Date", org.neo4j.values.storable.DateValue::date, java.time.LocalDate.now(), java.time.LocalDate.parse("1977-05-25")), testInput("DateArray", org.neo4j.values.storable.Values::dateArray, new java.time.LocalDate[] {java.time.LocalDate.now(), java.time.LocalDate.parse("1977-05-25")}, new java.time.LocalDate[0]), testInput("Time", org.neo4j.values.storable.TimeValue::time, java.time.OffsetTime.now(), java.time.OffsetTime.parse("19:28:34.123+02:00")), testInput("TimeArray", org.neo4j.values.storable.Values::timeArray, new java.time.OffsetTime[] {java.time.OffsetTime.now(), java.time.OffsetTime.parse("19:28:34.123+02:00")}, new java.time.OffsetTime[0]), testInput("LocalTime", org.neo4j.values.storable.LocalTimeValue::localTime, java.time.LocalTime.now(), java.time.LocalTime.parse("19:28:34.123")), testInput("LocalTimeArray", org.neo4j.values.storable.Values::localTimeArray, new java.time.LocalTime[] {java.time.LocalTime.now(), java.time.LocalTime.parse("19:28:34.123")}, new java.time.LocalTime[0]), testInput("LocalDateTime", org.neo4j.values.storable.LocalDateTimeValue::localDateTime, java.time.LocalDateTime.now(), java.time.LocalDateTime.parse("1956-10-04T19:28:34.123")), testInput("LocalDateTimeArray", org.neo4j.values.storable.Values::localDateTimeArray, new java.time.LocalDateTime[] {java.time.LocalDateTime.now(), java.time.LocalDateTime.parse("1956-10-04T19:28:34.123")}, new java.time.LocalDateTime[0]), testInput("DateTime", org.neo4j.values.storable.DateTimeValue::datetime, java.time.ZonedDateTime.now(), java.time.ZonedDateTime.parse("1956-10-04T19:28:34.123+01:00[Europe/Paris]"), java.time.ZonedDateTime.parse("1956-10-04T19:28:34.123+01:15"), java.time.ZonedDateTime.parse("2018-09-13T16:12:16.12345+14:00[Pacific/Kiritimati]"), java.time.ZonedDateTime.parse("2018-09-13T16:12:16.12345-12:00[Etc/GMT+12]"), java.time.ZonedDateTime.parse("2018-09-13T16:12:16.12345-18:00"), java.time.ZonedDateTime.parse("2018-09-13T16:12:16.12345+18:00")), testInput("DateTimeArray", org.neo4j.values.storable.Values::dateTimeArray, new java.time.ZonedDateTime[] { java.time.ZonedDateTime.parse("1956-10-04T19:28:34.123+01:00[Europe/Paris]"), java.time.ZonedDateTime.parse("1956-10-04T19:28:34.123+01:15"), java.time.ZonedDateTime.parse("2018-09-13T16:12:16.12345+14:00[Pacific/Kiritimati]"), java.time.ZonedDateTime.parse("2018-09-13T16:12:16.12345-12:00[Etc/GMT+12]"), java.time.ZonedDateTime.parse("2018-09-13T16:12:16.12345-18:00"), java.time.ZonedDateTime.parse("2018-09-13T16:12:16.12345+18:00") }, new java.time.ZonedDateTime[0]));
            IList <Pair <string, Value[]> > inputs = new IList <Pair <string, Value[]> > {
                TestInput("NoValue", System.Func.identity(), NoValue.NO_VALUE), TestInput("Boolean", Values.booleanValue, true, false, true, false), TestInput("BooleanArray", Values.booleanArray, new bool[] { false, true, false }, EMPTY_BOOLEAN_ARRAY), TestInput("Byte", Values.byteValue, (sbyte)0, (sbyte)1, (sbyte)-1, sbyte.MinValue, sbyte.MaxValue), TestInput("ByteArray", Values.byteArray, new sbyte[] { (sbyte)0, (sbyte)1, (sbyte)-1, sbyte.MinValue, sbyte.MaxValue }, EMPTY_BYTE_ARRAY), TestInput("Short", Values.shortValue, (short)0, (short)1, (short)-1, short.MinValue, short.MaxValue), TestInput("ShortArray", Values.shortArray, new short[] { (short)0, (short)1, (short)-1, short.MinValue, short.MaxValue }, EMPTY_SHORT_ARRAY), TestInput("Char", Values.charValue, 'a', '\uFFFF', '∂', '©'), TestInput("CharArray", Values.charArray, new char[] { 'a', '\uFFFF', '∂', '©' }, EMPTY_CHAR_ARRAY), TestInput("Int", Values.intValue, 0, 1, -1, int.MinValue, int.MaxValue), TestInput("IntArray", Values.intArray, new int[] { 0, 1, -1, int.MinValue, int.MaxValue }, EMPTY_INT_ARRAY), TestInput("Long", Values.longValue, 0L, 1L, -1L, long.MinValue, long.MaxValue), TestInput("LongArray", Values.longArray, new long[] { 0L, 1L, -1L, long.MinValue, long.MaxValue }, EMPTY_LONG_ARRAY), TestInput("Double", Values.doubleValue, 0.0, 1.0, -1.0, double.Epsilon, double.MaxValue, double.NegativeInfinity, double.PositiveInfinity), TestInput("DoubleArray", Values.doubleArray, new double[] { 0.0, 1.0, -1.0, double.Epsilon, double.MaxValue, double.NegativeInfinity, double.PositiveInfinity }, EMPTY_DOUBLE_ARRAY), TestInput("Float", Values.floatValue, 0.0f, 1.0f, -1.0f, float.Epsilon, float.MaxValue, float.NegativeInfinity, float.PositiveInfinity), TestInput("FloatArray", Values.floatArray, new float[] { 0.0f, 1.0f, -1.0f, float.Epsilon, float.MaxValue, float.NegativeInfinity, float.PositiveInfinity }, EMPTY_FLOAT_ARRAY), TestInput("String", Values.stringValue, "", "x", "foobar"), TestInput("StringArray", Values.stringArray, new string[] { "", "x", "foobar" }, EMPTY_STRING_ARRAY), TestInput("Point", input => pointValue(input.One, input.Two), Tuples.pair(CoordinateReferenceSystem.WGS84, new double[] { 1.0, 2.0 }), Tuples.pair(CoordinateReferenceSystem.WGS84_3D, new double[] { 1.0, 2.0, 3.0 }), Tuples.pair(CoordinateReferenceSystem.Cartesian, new double[] { 1.0, 2.0 }), Tuples.pair(CoordinateReferenceSystem.Cartesian_3D, new double[] { 1.0, 2.0, 3.0 })), TestInput("PointArray", Values.pointArray, new Point[] { pointValue(CoordinateReferenceSystem.WGS84, 1.0, 2.0), pointValue(CoordinateReferenceSystem.WGS84_3D, 1.0, 2.0, 3.0), pointValue(CoordinateReferenceSystem.Cartesian, 1.0, 2.0), pointValue(CoordinateReferenceSystem.Cartesian_3D, 1.0, 2.0, 3.0) }, new Point[0]), TestInput("Duration", Values.durationValue, (TemporalAmount)Duration.parse("P2DT3H4M"), Period.parse("P1Y2M3W4D")), TestInput("DurationArray", Values.durationArray, new TemporalAmount[] { Duration.parse("P2DT3H4M"), Period.parse("P1Y2M3W4D") }, new TemporalAmount[0]), TestInput("Date", DateValue.date, LocalDate.now(), LocalDate.parse("1977-05-25")), TestInput("DateArray", Values.dateArray, new LocalDate[] { LocalDate.now(), LocalDate.parse("1977-05-25") }, new LocalDate[0]), TestInput("Time", TimeValue.time, OffsetTime.now(), OffsetTime.parse("19:28:34.123+02:00")), TestInput("TimeArray", Values.timeArray, new OffsetTime[] { OffsetTime.now(), OffsetTime.parse("19:28:34.123+02:00") }, new OffsetTime[0]), TestInput("LocalTime", LocalTimeValue.localTime, LocalTime.now(), LocalTime.parse("19:28:34.123")), TestInput("LocalTimeArray", Values.localTimeArray, new LocalTime[] { LocalTime.now(), LocalTime.parse("19:28:34.123") }, new LocalTime[0]), TestInput("LocalDateTime", LocalDateTimeValue.localDateTime, DateTime.Now, DateTime.Parse("1956-10-04T19:28:34.123")), TestInput("LocalDateTimeArray", Values.localDateTimeArray, new DateTime[] { DateTime.Now, DateTime.Parse("1956-10-04T19:28:34.123") }, new DateTime[0]), TestInput("DateTime", DateTimeValue.datetime, ZonedDateTime.now(), ZonedDateTime.parse("1956-10-04T19:28:34.123+01:00[Europe/Paris]"), ZonedDateTime.parse("1956-10-04T19:28:34.123+01:15"), ZonedDateTime.parse("2018-09-13T16:12:16.12345+14:00[Pacific/Kiritimati]"), ZonedDateTime.parse("2018-09-13T16:12:16.12345-12:00[Etc/GMT+12]"), ZonedDateTime.parse("2018-09-13T16:12:16.12345-18:00"), ZonedDateTime.parse("2018-09-13T16:12:16.12345+18:00")), TestInput("DateTimeArray", Values.dateTimeArray, new ZonedDateTime[] { ZonedDateTime.parse("1956-10-04T19:28:34.123+01:00[Europe/Paris]"), ZonedDateTime.parse("1956-10-04T19:28:34.123+01:15"), ZonedDateTime.parse("2018-09-13T16:12:16.12345+14:00[Pacific/Kiritimati]"), ZonedDateTime.parse("2018-09-13T16:12:16.12345-12:00[Etc/GMT+12]"), ZonedDateTime.parse("2018-09-13T16:12:16.12345-18:00"), ZonedDateTime.parse("2018-09-13T16:12:16.12345+18:00") }, new ZonedDateTime[0])
            };

            return(DynamicTest.stream(inputs.GetEnumerator(), Pair.getOne, pair =>
            {
                Value[] values = pair.Two;
                long[] refs = values.Select(_container.add).ToArray();
                for (int i = 0; i < values.Length; i++)
                {
                    assertEquals(values[i], _container.get(refs[i]));
                }
            }));
        }
 private static Stream <AnyValue> UnsupportedValues()
 {
     return(Stream.of(nodeValue(42, stringArray("Person"), EMPTY_MAP), NewRelationshipValue(), pointValue(CoordinateReferenceSystem.WGS84, new double[2]), byteArray(new sbyte[] { 1, 2, 3 }), Values.of(Duration.ofHours(1)), Values.of(LocalDate.now()), Values.of(LocalTime.now()), Values.of(OffsetTime.now()), Values.of(DateTime.Now), Values.of(ZonedDateTime.now())));
 }
Пример #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldCallExternalErrorOnDateTimeWithZoneName() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldCallExternalErrorOnDateTimeWithZoneName()
        {
            assumeThat(PackerUnderTest.version(), equalTo(1L));

            TestUnpackableStructParametersWithKnownType(new Neo4jPackV2(), ValueUtils.of(ZonedDateTime.now()), "ZonedDateTime values cannot be unpacked with this version of bolt.");
        }
Пример #7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldFailWhenZonedDateTimeIsSentWithRun() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldFailWhenZonedDateTimeIsSentWithRun()
        {
            TestFailureWithV2Value(ValueUtils.of(ZonedDateTime.now()), "ZonedDateTime");
        }