directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r1715070 [2/2] - in /directory/shared/trunk: ./ dsml/engine/src/main/java/org/apache/directory/api/dsmlv2/engine/ dsml/parser/src/main/java/org/apache/directory/api/dsmlv2/ dsml/parser/src/test/java/org/apache/directory/api/dsmlv2/compareRe...
Date Wed, 18 Nov 2015 21:23:43 GMT
Modified: directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/UnixCrypt.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/UnixCrypt.java?rev=1715070&r1=1715069&r2=1715070&view=diff
==============================================================================
--- directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/UnixCrypt.java
(original)
+++ directory/shared/trunk/util/src/main/java/org/apache/directory/api/util/UnixCrypt.java
Wed Nov 18 21:23:43 2015
@@ -652,7 +652,6 @@ public class UnixCrypt extends Object
      * @param setting the salt to be used
      * @return the encrypted String
      */
-    @SuppressWarnings("deprecation")
     public static String crypt( String key, String setting )
     {
         /* encryption constant */
@@ -697,7 +696,7 @@ public class UnixCrypt extends Object
             rsltblock >>= 6;
         }
 
-        return new String( cryptresult, 0x00, 0, 13 );
+        return Strings.asciiBytesToString( cryptresult );
     }
 
 

Modified: directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/GeneralizedTimeTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/GeneralizedTimeTest.java?rev=1715070&r1=1715069&r2=1715070&view=diff
==============================================================================
--- directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/GeneralizedTimeTest.java
(original)
+++ directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/GeneralizedTimeTest.java
Wed Nov 18 21:23:43 2015
@@ -19,7 +19,7 @@
  */
 package org.apache.directory.api.util;
 
-
+import static org.apache.directory.api.util.TimeZones.GMT;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -33,6 +33,8 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.Locale;
 import java.util.TimeZone;
 
 import com.mycila.junit.concurrent.Concurrency;
@@ -1054,7 +1056,7 @@ public class GeneralizedTimeTest
     @Test
     public void testCalendar() throws ParseException
     {
-        Calendar calendar = Calendar.getInstance();
+        Calendar calendar = new GregorianCalendar( GMT, Locale.ROOT );
         calendar.set( Calendar.YEAR, 2008 );
         calendar.set( Calendar.MONTH, 0 );
         calendar.set( Calendar.DAY_OF_MONTH, 2 );
@@ -1076,7 +1078,7 @@ public class GeneralizedTimeTest
     @Test
     public void testRoundTrip() throws ParseException
     {
-        Calendar calendar = Calendar.getInstance( TimeZone.getTimeZone( "GMT" ) );
+        Calendar calendar = new GregorianCalendar( GMT, Locale.ROOT );
         calendar.setTimeInMillis( 123456789000L ); // default format is without millis
 
         // create form calendar
@@ -1197,7 +1199,7 @@ public class GeneralizedTimeTest
         LOG.info( "milliseconds lost = {}", millisLost );
 
         // Set time on new Calendar instance, and generate the GT string
-        Calendar calendar = Calendar.getInstance();
+        Calendar calendar = new GregorianCalendar( GMT, Locale.ROOT );
         calendar.setTime( date );
         GeneralizedTime gt = new GeneralizedTime( calendar );
         assertEquals( "calendar time must equal the date time", date.getTime(), calendar.getTime().getTime()
);
@@ -1213,9 +1215,9 @@ public class GeneralizedTimeTest
         assertEquals( "The time after round trip GeneralizedTime generation should stay the
same",
             originalTime, recalculatedTime );
     }
-    
-    static DateFormat format = new SimpleDateFormat( "dd/MM/yyyy HH:mm:ss.SSSS z" );
-    
+
+    static DateFormat format = new SimpleDateFormat( "dd/MM/yyyy HH:mm:ss.SSSS z", Locale.ROOT
);
+
     @Test
     public void fractionCloseToOne() throws ParseException
     {

Modified: directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/StringsTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/StringsTest.java?rev=1715070&r1=1715069&r2=1715070&view=diff
==============================================================================
--- directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/StringsTest.java
(original)
+++ directory/shared/trunk/util/src/test/java/org/apache/directory/api/util/StringsTest.java
Wed Nov 18 21:23:43 2015
@@ -23,6 +23,7 @@ package org.apache.directory.api.util;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -45,6 +46,9 @@ import com.mycila.junit.concurrent.Concu
 @Concurrency()
 public class StringsTest
 {
+    private static final byte[] AZERTY = "azerty".getBytes( StandardCharsets.US_ASCII );
+
+
     @Test
     public void testTrimConsecutiveToOne()
     {
@@ -208,7 +212,7 @@ public class StringsTest
     public void testAreEqualsFull()
     {
         // Full compare
-        assertEquals( 6, Strings.areEquals( "azerty".getBytes(), 0, "azerty" ) );
+        assertEquals( 6, Strings.areEquals( AZERTY, 0, "azerty" ) );
     }
 
 
@@ -219,7 +223,7 @@ public class StringsTest
     public void testAreEqualsDiff()
     {
         // First character is !=
-        assertEquals( -1, Strings.areEquals( "azerty".getBytes(), 0, "Azerty" ) );
+        assertEquals( -1, Strings.areEquals( AZERTY, 0, "Azerty" ) );
     }
 
 
@@ -230,7 +234,7 @@ public class StringsTest
     public void testAreEqualsEmpty()
     {
         // Compare to an empty string
-        assertEquals( -1, Strings.areEquals( "azerty".getBytes(), 0, "" ) );
+        assertEquals( -1, Strings.areEquals( AZERTY, 0, "" ) );
     }
 
 
@@ -241,7 +245,7 @@ public class StringsTest
     public void testAreEqualsFirstCharDiff()
     {
         // First character is !=
-        assertEquals( -1, Strings.areEquals( "azerty".getBytes(), 0, "Azerty" ) );
+        assertEquals( -1, Strings.areEquals( AZERTY, 0, "Azerty" ) );
     }
 
 
@@ -252,7 +256,7 @@ public class StringsTest
     public void testAreEqualsMiddleCharDiff()
     {
         // First character is !=
-        assertEquals( -1, Strings.areEquals( "azerty".getBytes(), 0, "azeRty" ) );
+        assertEquals( -1, Strings.areEquals( AZERTY, 0, "azeRty" ) );
     }
 
 
@@ -263,7 +267,7 @@ public class StringsTest
     public void testAreEqualsLastCharDiff()
     {
         // First character is !=
-        assertEquals( -1, Strings.areEquals( "azerty".getBytes(), 0, "azertY" ) );
+        assertEquals( -1, Strings.areEquals( AZERTY, 0, "azertY" ) );
     }
 
 
@@ -274,12 +278,12 @@ public class StringsTest
     public void testAreEqualsCharByChar()
     {
         // Index must be incremented after each comparison
-        assertEquals( 1, Strings.areEquals( "azerty".getBytes(), 0, "a" ) );
-        assertEquals( 2, Strings.areEquals( "azerty".getBytes(), 1, "z" ) );
-        assertEquals( 3, Strings.areEquals( "azerty".getBytes(), 2, "e" ) );
-        assertEquals( 4, Strings.areEquals( "azerty".getBytes(), 3, "r" ) );
-        assertEquals( 5, Strings.areEquals( "azerty".getBytes(), 4, "t" ) );
-        assertEquals( 6, Strings.areEquals( "azerty".getBytes(), 5, "y" ) );
+        assertEquals( 1, Strings.areEquals( AZERTY, 0, "a" ) );
+        assertEquals( 2, Strings.areEquals( AZERTY, 1, "z" ) );
+        assertEquals( 3, Strings.areEquals( AZERTY, 2, "e" ) );
+        assertEquals( 4, Strings.areEquals( AZERTY, 3, "r" ) );
+        assertEquals( 5, Strings.areEquals( AZERTY, 4, "t" ) );
+        assertEquals( 6, Strings.areEquals( AZERTY, 5, "y" ) );
     }
 
 
@@ -290,7 +294,7 @@ public class StringsTest
     public void testAreEqualsTooShort()
     {
         // length too short
-        assertEquals( -1, Strings.areEquals( "azerty".getBytes(), 0, "azertyiop" ) );
+        assertEquals( -1, Strings.areEquals( AZERTY, 0, "azertyiop" ) );
     }
 
 
@@ -301,7 +305,7 @@ public class StringsTest
     public void testAreEqualsTooShortMiddle()
     {
         // length too short
-        assertEquals( -1, Strings.areEquals( "azerty".getBytes(), 0, "ertyiop" ) );
+        assertEquals( -1, Strings.areEquals( AZERTY, 0, "ertyiop" ) );
     }
 
 
@@ -312,7 +316,7 @@ public class StringsTest
     public void testAreEqualsLastChar()
     {
         // last character
-        assertEquals( 6, Strings.areEquals( "azerty".getBytes(), 5, "y" ) );
+        assertEquals( 6, Strings.areEquals( AZERTY, 5, "y" ) );
     }
 
 
@@ -323,6 +327,6 @@ public class StringsTest
     public void testAreEqualsMiddle()
     {
         // In the middle
-        assertEquals( 4, Strings.areEquals( "azerty".getBytes(), 2, "er" ) );
+        assertEquals( 4, Strings.areEquals( AZERTY, 2, "er" ) );
     }
 }



Mime
View raw message