Permalink
Browse files

Deprecation fixes

  • Loading branch information...
indrajitr committed Mar 23, 2012
1 parent a683fbf commit 6289a10a06397d51e1bb28cbef022d949cec43c6
@@ -275,7 +275,7 @@ class CustomSerializer[A: Manifest](
val Class = implicitly[Manifest[A]].erasure
def deserialize(implicit format: Formats) = {
- case (TypeInfo(Class, _), json) =>
+ case (TypeInfo(Class, _), json) =>
if (ser(format)._1.isDefinedAt(json)) ser(format)._1(json)
else throw new MappingException("Can't convert " + json + " to " + Class)
}
@@ -19,7 +19,7 @@ package json
import org.specs.Specification
-object FieldSerializerBugs extends Specification {
+object FieldSerializerBugs extends Specification {
import Serialization.{read, write => swrite}
implicit val formats = DefaultFormats + FieldSerializer[AnyRef]()
@@ -29,7 +29,7 @@ object FieldSerializerBugs extends Specification {
import java.util.concurrent.atomic.AtomicInteger
val ser = swrite(new AtomicInteger(1))
- val atomic = read[AtomicInteger](ser)
+ val atomic = read[AtomicInteger](ser)
atomic.get mustEqual 1
}
*/
@@ -44,7 +44,7 @@ object FieldSerializerBugs extends Specification {
}
"FieldSerialization should work with Options" in {
- implicit val formats = DefaultFormats + FieldSerializer[ClassWithOption]()
+ implicit val formats = DefaultFormats + FieldSerializer[ClassWithOption]()
val t = new ClassWithOption
t.field = Some(5)
@@ -53,8 +53,8 @@ object FieldSerializerBugs extends Specification {
case class WithSymbol(`a-b*c`: Int)
- class ClassWithOption {
- var field: Option[Int] = None
+ class ClassWithOption {
+ var field: Option[Int] = None
}
}
@@ -162,7 +162,7 @@ class PCDataXmlParser(val input: Source) extends ConstructingHandler with PCData
val report = curInput.descr + ":" + line + ":" + col + ": " + msg
System.err.println(report)
try {
- System.err.println(curInput.getLine(line))
+ System.err.println(curInput.getLines().toIndexedSeq(line))
} catch {
case e: Exception => // ignore
}
@@ -205,21 +205,21 @@ object PCDataXmlParser {
pos += 1
}
}
-
+
moveToLT()
// scan past <? ... ?>
if (pos + 1 < len && in.charAt(pos + 1) == '?') {
pos += 1
moveToLT()
- }
+ }
// scan past <!DOCTYPE ....>
if (pos + 1 < len && in.charAt(pos + 1) == '!') {
pos += 1
moveToLT()
}
-
+
apply(Source.fromString(in.substring(pos)))
}
}
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-package net.liftweb
-package util
+package net.liftweb
+package util
import org.apache.commons.codec.binary.Base64
import java.io.{InputStream, ByteArrayOutputStream, ByteArrayInputStream, Reader, File, FileInputStream, BufferedReader}
@@ -35,20 +35,20 @@ object SecurityHelpers extends StringHelpers with IoHelpers with SecurityHelpers
* <li> create SHA, SHA-256, MD5 hashs (can be hex encoded)
* </ul>
*/
-trait SecurityHelpers {
- self: StringHelpers with IoHelpers =>
+trait SecurityHelpers {
+ self: StringHelpers with IoHelpers =>
/** short alias for java.security.SecureRandom */
private val _random = new SecureRandom
- private def withRandom[T](f: SecureRandom => T): T =
+ private def withRandom[T](f: SecureRandom => T): T =
_random.synchronized(f(_random))
/** return a random Long modulo a number */
- def randomLong(mod: Long): Long = withRandom(random => Math.abs(random.nextLong) % mod)
+ def randomLong(mod: Long): Long = withRandom(random => math.abs(random.nextLong) % mod)
/** return a random int modulo a number */
- def randomInt(mod: Int): Int = withRandom(random => Math.abs(random.nextInt) % mod)
+ def randomInt(mod: Int): Int = withRandom(random => math.abs(random.nextInt) % mod)
/**
* return true only 'percent' times when asked repeatedly.
@@ -98,7 +98,7 @@ trait SecurityHelpers {
case (_, null) => false
case (a, b) => secureEquals(a.getBytes("UTF-8"), b.getBytes("UTF-8"))
}
-
+
/** Compare two byte arrays in a way that does not vary if the arrays
* are determined to be not equal early (test every byte... avoids
* timing attackes */
@@ -118,7 +118,7 @@ trait SecurityHelpers {
ret && la == lb
}
}
-
+
/** create a SHA-256 hash from a Byte array */
def hash256(in : Array[Byte]) : Array[Byte] = {
@@ -68,6 +68,7 @@ object MongoHost {
/*
* Wrapper for creating a Replica Pair
*/
+@deprecated("Use `MongoSet` with `List[ServerAddress]` as argument instead")
case class MongoPair(left: ServerAddress, right: ServerAddress, options: MongoOptions = new MongoOptions) extends MongoHostBase {
lazy val mongo = new Mongo(left, right, options)
}
@@ -56,15 +56,15 @@ import json.JsonAST._
*
* @param url The URL to extract from
* @param contextPath The context path for this request. Defaults to "" per the Servlet API.
- *
+ *
*/
class MockHttpServletRequest(val url : String = null, var contextPath : String = "") extends HttpServletRequest {
@deprecated("Use the \"attributes\" var instead")
def attr = attributes
@deprecated("Use the \"attributes\" var instead")
def attr_= (attrs : Map[String,Object]) = attributes = attrs
-
+
var attributes: Map[String, Object] = Map()
var authType: String = null
@@ -85,7 +85,7 @@ class MockHttpServletRequest(val url : String = null, var contextPath : String =
/**
* Sets the body to the given string. The content
* type is set to "text/plain".
- *
+ *
* Note that the String will be converted to bytes
* based on the current setting of charEncoding.
*/
@@ -105,15 +105,15 @@ class MockHttpServletRequest(val url : String = null, var contextPath : String =
/**
* Sets the body to the given elements. Also sets
* the contentType to "text/xml"
- *
+ *
* Note that the elements will be converted to bytes
* based on the current setting of charEncoding.
*/
def body_= (nodes : NodeSeq) : Unit = body_=(nodes, "text/xml")
/**
* Sets the body to the given elements and content type.
- *
+ *
* Note that the elements will be converted to bytes
* based on the current setting of charEncoding.
*/
@@ -210,7 +210,7 @@ class MockHttpServletRequest(val url : String = null, var contextPath : String =
if (q != null && q.length > 0) {
val newParams = ListBuffer[(String,String)]()
- q.split('&').foreach {
+ q.split('&').foreach {
pair => pair.split('=') match {
case Array(key,value) => {
// Append to the current key's value
@@ -219,7 +219,7 @@ class MockHttpServletRequest(val url : String = null, var contextPath : String =
case invalid => throw new IllegalArgumentException("Invalid query string: \"" + q + "\"")
}
}
-
+
parameters = newParams.toList
method = "GET"
}
@@ -249,7 +249,7 @@ class MockHttpServletRequest(val url : String = null, var contextPath : String =
var user : String = null
var userRoles : Set[String] = Set()
-
+
var userPrincipal : Principal = null
var scheme = "http"
@@ -339,7 +339,7 @@ class MockHttpServletRequest(val url : String = null, var contextPath : String =
* <li>The userinfo field isn't processed. If you want to mock BASIC authentication,
* use the addBasicAuth method</li>
* </ol>
- *
+ *
* @param url The URL to extract from
* @param contextPath The servlet context of the request. Defaults to ""
*/
@@ -367,11 +367,11 @@ class MockHttpServletRequest(val url : String = null, var contextPath : String =
queryString = url.getQuery
-
+
}
/** Compute the path portion after the contextPath */
- def computeRealPath (path : String) = {
+ def computeRealPath (path : String) = {
if (! path.startsWith(contextPath)) {
throw new IllegalArgumentException("Path \"%s\" doesn't begin with context path \"%s\"!".format(path, contextPath))
}
@@ -390,9 +390,9 @@ class MockHttpServletRequest(val url : String = null, var contextPath : String =
// ServletRequest methods
- def getAttribute(key: String): Object = attr.get(key).getOrElse(null)
+ def getAttribute(key: String): Object = attributes.get(key).getOrElse(null)
- def getAttributeNames(): JEnum[Object] = attr.keys.iterator
+ def getAttributeNames(): JEnum[Object] = attributes.keys.iterator
def getCharacterEncoding(): String = charEncoding
@@ -409,12 +409,12 @@ class MockHttpServletRequest(val url : String = null, var contextPath : String =
def getLocale(): Locale = locales.headOption.getOrElse(Locale.getDefault)
def getLocales(): JEnum[Object] = locales.iterator
-
+
def getLocalName(): String = localName
def getLocalPort(): Int = localPort
-
- def getParameter(key: String): String =
+
+ def getParameter(key: String): String =
parameters.find(_._1 == key).map(_._2) getOrElse null
def getParameterMap(): java.util.Map[Object, Object] = {
@@ -428,17 +428,17 @@ class MockHttpServletRequest(val url : String = null, var contextPath : String =
asMap(newMap.map{case (k,v) => (k,v.toArray)}.asInstanceOf[Map[Object,Object]])
}
- def getParameterNames(): JEnum[Object] =
+ def getParameterNames(): JEnum[Object] =
parameters.map(_._1).distinct.iterator
- def getParameterValues(key: String): Array[String] =
+ def getParameterValues(key: String): Array[String] =
parameters.filter(_._1 == key).map(_._2).toArray
def getProtocol(): String = protocol
-
- def getReader(): BufferedReader =
+
+ def getReader(): BufferedReader =
new BufferedReader(new InputStreamReader(new ByteArrayInputStream(body), charEncoding))
-
+
def getRealPath(s: String): String = s
def getRemoteAddr(): String = remoteAddr
@@ -457,9 +457,9 @@ class MockHttpServletRequest(val url : String = null, var contextPath : String =
def isSecure = secure
- def removeAttribute(key: String): Unit = attr -= key
+ def removeAttribute(key: String): Unit = attributes -= key
- def setAttribute(key: String, value: Object): Unit = attr += (key -> value)
+ def setAttribute(key: String, value: Object): Unit = attributes += (key -> value)
def setCharacterEncoding(enc: String): Unit = charEncoding = enc
@@ -477,7 +477,7 @@ class MockHttpServletRequest(val url : String = null, var contextPath : String =
Empty
}
}
-
+
Helpers.tryo(handler,{
// Have to use internetDateFormatter directly since parseInternetDate returns the epoch date on failure
Box.!!(getHeader(h)).map(Helpers.internetDateFormatter.parse(_).getTime)
@@ -509,14 +509,14 @@ class MockHttpServletRequest(val url : String = null, var contextPath : String =
def getRemoteUser(): String = user
def getRequestedSessionId(): String = null
-
+
def getRequestURI(): String = contextPath + path
def getRequestURL(): StringBuffer = {
val buffer = new StringBuffer(scheme + "://" + localName)
-
+
if (localPort != 80) buffer.append(":" + localPort)
-
+
if (contextPath != "") buffer.append(contextPath)
buffer.append(path)
Oops, something went wrong.

0 comments on commit 6289a10

Please sign in to comment.