You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/04/17 17:31:28 UTC

[1/2] git commit: Enable simple logging on FIT

Repository: olingo-odata4
Updated Branches:
  refs/heads/master b157e26ca -> fe8df96fe


Enable simple logging on FIT


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/811f0bfc
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/811f0bfc
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/811f0bfc

Branch: refs/heads/master
Commit: 811f0bfcc7defd0d93eb3d07537247494047933e
Parents: b157e26
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Thu Apr 17 16:27:54 2014 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Thu Apr 17 16:27:54 2014 +0200

----------------------------------------------------------------------
 fit/pom.xml                                    |  9 +++++++--
 fit/src/main/resources/simplelogger.properties | 19 +++++++++++++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/811f0bfc/fit/pom.xml
----------------------------------------------------------------------
diff --git a/fit/pom.xml b/fit/pom.xml
index e6030f5..b7e4043 100644
--- a/fit/pom.xml
+++ b/fit/pom.xml
@@ -51,7 +51,7 @@
         </exclusion>
       </exclusions>
     </dependency>
-    
+
     <!-- Stax -->
     <dependency>
       <groupId>stax</groupId>
@@ -95,7 +95,12 @@
       <artifactId>commons-logging</artifactId>
       <scope>provided</scope>
     </dependency>
-    
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <scope>compile</scope>
+    </dependency>
+                  
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-vfs2</artifactId>

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/811f0bfc/fit/src/main/resources/simplelogger.properties
----------------------------------------------------------------------
diff --git a/fit/src/main/resources/simplelogger.properties b/fit/src/main/resources/simplelogger.properties
new file mode 100644
index 0000000..fcde843
--- /dev/null
+++ b/fit/src/main/resources/simplelogger.properties
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+#
+org.slf4j.simpleLogger.defaultLogLevel=debug


[2/2] git commit: (Finally) Fixing incorrect millis <-> nanos conversion (with Timestamp) in EdmDateTimeOffset

Posted by il...@apache.org.
(Finally) Fixing incorrect millis <-> nanos conversion (with Timestamp) in EdmDateTimeOffset


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/fe8df96f
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/fe8df96f
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/fe8df96f

Branch: refs/heads/master
Commit: fe8df96fe990f616c08b7b9e9d03b6ccbd9d781c
Parents: 811f0bf
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Thu Apr 17 17:31:18 2014 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Thu Apr 17 17:31:18 2014 +0200

----------------------------------------------------------------------
 .../client/core/it/v4/EntityUpdateTestITCase.java  |  6 +++---
 .../olingo/client/core/v3/PrimitiveValueTest.java  |  2 +-
 .../core/edm/primitivetype/EdmDateTimeOffset.java  | 17 +++++++++++++----
 .../edm/primitivetype/EdmDateTimeOffsetTest.java   |  3 +++
 4 files changed, 20 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fe8df96f/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityUpdateTestITCase.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityUpdateTestITCase.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityUpdateTestITCase.java
index 36a9e65..30e6607 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityUpdateTestITCase.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/it/v4/EntityUpdateTestITCase.java
@@ -18,6 +18,9 @@
  */
 package org.apache.olingo.client.core.it.v4;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
 import java.net.URI;
 import java.util.Calendar;
 import java.util.UUID;
@@ -30,9 +33,6 @@ import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException;
 import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind;
 import org.apache.olingo.commons.api.edm.FullQualifiedName;
 import org.apache.olingo.commons.api.format.ODataPubFormat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
 import org.junit.Test;
 
 public class EntityUpdateTestITCase extends AbstractTestITCase {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fe8df96f/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PrimitiveValueTest.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PrimitiveValueTest.java b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PrimitiveValueTest.java
index 260f9a4..db0b7b7 100644
--- a/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PrimitiveValueTest.java
+++ b/lib/client-core/src/test/java/org/apache/olingo/client/core/v3/PrimitiveValueTest.java
@@ -158,7 +158,7 @@ public class PrimitiveValueTest extends AbstractTest {
 
     final ODataValue parsed = getClient().getObjectFactory().newPrimitiveValueBuilder().
             setType(EdmPrimitiveTypeKind.DateTimeOffset).setText(value.asPrimitive().toString()).build();
-    assertEquals("2013-01-10T03:00:00.022+01:00", parsed.asPrimitive().toString());
+    assertEquals(22, parsed.asPrimitive().toCastValue(Calendar.class).get(Calendar.MILLISECOND));
   }
 
   @Test

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fe8df96f/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTimeOffset.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTimeOffset.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTimeOffset.java
index 2e7ab98..44dc72d 100644
--- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTimeOffset.java
+++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTimeOffset.java
@@ -103,7 +103,7 @@ public final class EdmDateTimeOffset extends SingletonPrimitiveType {
       dateTimeValue.set(Calendar.MILLISECOND, Short.parseShort(milliSeconds));
 
       if (!decimals.isEmpty()) {
-        final int fractionalSecs = Integer.parseInt(decimals);
+        final int fractionalSecs = dateTimeValue.get(Calendar.MILLISECOND);
         // if fractional are just milliseconds, convert to nanoseconds
         timestamp.setNanos(fractionalSecs < 1000 ? fractionalSecs * 1000000 : fractionalSecs);
       }
@@ -296,10 +296,19 @@ public final class EdmDateTimeOffset extends SingletonPrimitiveType {
         throw new IllegalArgumentException();
       }
 
+      // Keep output similar to Calendar's, if possible            
       String fractionals = NANO_FORMAT.get().format(fractionalSeconds);
-      // Keep output similar to Calendar's, if possible
-      if ("000000".equals(fractionals.substring(3))) {
-        fractionals = fractionals.substring(0, 3);
+      boolean canStart = false;
+      int firstZeroAfterNonZeroIdx = -1;
+      for (int i = 0; i < fractionals.length() && firstZeroAfterNonZeroIdx == -1; i++) {
+        if ('0' != fractionals.charAt(i)) {
+          canStart = true;
+        } else if (canStart && '0' == fractionals.charAt(i)) {
+          firstZeroAfterNonZeroIdx = i;
+        }
+      }
+      if (firstZeroAfterNonZeroIdx != -1 && 0 == Integer.valueOf(fractionals.substring(firstZeroAfterNonZeroIdx))) {
+        fractionals = fractionals.substring(0, firstZeroAfterNonZeroIdx);
       }
       result.append('.').append(fractionals);
     }

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/fe8df96f/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTimeOffsetTest.java
----------------------------------------------------------------------
diff --git a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTimeOffsetTest.java b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTimeOffsetTest.java
index 2a1e7d5..4e49a62 100644
--- a/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTimeOffsetTest.java
+++ b/lib/commons-core/src/test/java/org/apache/olingo/commons/core/edm/primitivetype/EdmDateTimeOffsetTest.java
@@ -18,6 +18,7 @@
  */
 package org.apache.olingo.commons.core.edm.primitivetype;
 
+import java.sql.Timestamp;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
@@ -104,6 +105,8 @@ public class EdmDateTimeOffsetTest extends PrimitiveTypeBaseTest {
     dateTime.add(Calendar.MILLISECOND, 7);
     assertEquals(dateTime, instance.valueOfString("2012-02-29T01:02:03.007+11:00", null, null, 3, null, null,
         Calendar.class));
+    assertEquals(530000000, instance.valueOfString("2012-02-29T01:02:03.53+11:00", null, null, 9, null, null,
+        Timestamp.class).getNanos());
 
     assertEquals(Long.valueOf(120000L), instance.valueOfString("1970-01-01T00:02", null, null, null, null, null,
         Long.class));