Author: dpp
Date: Tue Nov 10 19:20:14 2009
New Revision: 834618
URL: http://svn.apache.org/viewvc?rev=834618&view=rev
Log:
Created basic API tests
Added:
incubator/esme/trunk/server/src/test/scala/org/apache/esme/JettySetup.scala
incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/
incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/ApiTest.scala
Modified:
incubator/esme/trunk/server/pom.xml
incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala
incubator/esme/trunk/server/src/test/scala/org/apache/esme/lib/MsgParseTest.scala
Modified: incubator/esme/trunk/server/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/esme/trunk/server/pom.xml?rev=834618&r1=834617&r2=834618&view=diff
==============================================================================
--- incubator/esme/trunk/server/pom.xml (original)
+++ incubator/esme/trunk/server/pom.xml Tue Nov 10 19:20:14 2009
@@ -1,322 +1,323 @@
<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.esme</groupId>
- <artifactId>esme-server</artifactId>
- <version>0.3.0-SNAPSHOT</version>
- <packaging>war</packaging>
- <name>ESME</name>
- <inceptionYear>2008</inceptionYear>
- <properties>
- <lift.version>1.1-SNAPSHOT</lift.version>
- <scala.version>2.7.5</scala.version>
- <compass.version>2.1.1</compass.version>
- <lucene.version>2.4.0</lucene.version>
- <netbeans.hint.deploy.server>gfv3</netbeans.hint.deploy.server>
- <scala.stats.version>1.3</scala.stats.version>
- </properties>
-
- <repositories>
- <repository>
- <id>scala-tools.org</id>
- <name>Scala-Tools Maven2 Repository</name>
- <url>http://scala-tools.org/repo-releases</url>
- </repository>
- <repository>
- <id>scala-tools.org.snapshots</id>
- <name>Scala-Tools Maven2 Repository for Snapshots</name>
- <url>http://scala-tools.org/repo-snapshots</url>
- <snapshots />
- </repository>
- <repository>
- <id>compass-project.org</id>
- <name>Compass</name>
- <url>http://repo.compass-project.org</url>
- </repository>
- <repository>
- <id>scala-stats</id>
- <name>Twitter Repo</name>
- <url>http://www.lag.net/nest</url>
- </repository>
- <repository>
- <id>configgy</id>
- <name>Another Twitter Repo</name>
- <url>http://www.lag.net/repo</url>
- </repository>
- <repository>
- <id>opendmk</id>
- <name>Java Dynamic Management Kit</name>
- <url>http://maven.tigase.org/</url>
- </repository>
- </repositories>
-
- <pluginRepositories>
- <pluginRepository>
- <id>scala-tools.org</id>
- <name>Scala-Tools Maven2 Repository</name>
- <url>http://scala-tools.org/repo-releases</url>
- </pluginRepository>
- </pluginRepositories>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.esme</groupId>
+ <artifactId>esme-server</artifactId>
+ <version>0.3.0-SNAPSHOT</version>
+ <packaging>war</packaging>
+ <name>ESME</name>
+ <inceptionYear>2008</inceptionYear>
+ <properties>
+ <lift.version>1.1-SNAPSHOT</lift.version>
+ <scala.version>2.7.7</scala.version>
+ <compass.version>2.1.1</compass.version>
+ <lucene.version>2.4.0</lucene.version>
+ <netbeans.hint.deploy.server>gfv3</netbeans.hint.deploy.server>
+ <scala.stats.version>1.3</scala.stats.version>
+ </properties>
+
+ <repositories>
+ <repository>
+ <id>scala-tools.org</id>
+ <name>Scala-Tools Maven2 Repository</name>
+ <url>http://scala-tools.org/repo-releases</url>
+ </repository>
+ <repository>
+ <id>scala-tools.org.snapshots</id>
+ <name>Scala-Tools Maven2 Repository for Snapshots</name>
+ <url>http://scala-tools.org/repo-snapshots</url>
+ <snapshots/>
+ </repository>
+ <repository>
+ <id>compass-project.org</id>
+ <name>Compass</name>
+ <url>http://repo.compass-project.org</url>
+ </repository>
+ <repository>
+ <id>scala-stats</id>
+ <name>Twitter Repo</name>
+ <url>http://www.lag.net/nest</url>
+ </repository>
+ <repository>
+ <id>configgy</id>
+ <name>Another Twitter Repo</name>
+ <url>http://www.lag.net/repo</url>
+ </repository>
+ <repository>
+ <id>opendmk</id>
+ <name>Java Dynamic Management Kit</name>
+ <url>http://maven.tigase.org/</url>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>scala-tools.org</id>
+ <name>Scala-Tools Maven2 Repository</name>
+ <url>http://scala-tools.org/repo-releases</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-library</artifactId>
+ <version>${scala.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.ibm.icu</groupId>
+ <artifactId>icu4j</artifactId>
+ <version>3.4.4</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
- <dependencyManagement>
<dependencies>
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-library</artifactId>
+ <version>${scala.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.ibm.icu</groupId>
+ <artifactId>icu4j</artifactId>
+ <version>3.4.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openid4java</groupId>
+ <artifactId>openid4java</artifactId>
+ <version>0.9.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>net.liftweb</groupId>
+ <artifactId>lift-util</artifactId>
+ <version>${lift.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>net.liftweb</groupId>
+ <artifactId>lift-webkit</artifactId>
+ <version>${lift.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>net.liftweb</groupId>
+ <artifactId>lift-mapper</artifactId>
+ <version>${lift.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>net.liftweb</groupId>
+ <artifactId>lift-testkit</artifactId>
+ <version>${lift.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>net.liftweb</groupId>
+ <artifactId>lift-openid</artifactId>
+ <version>${lift.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>net.liftweb</groupId>
+ <artifactId>lift-textile</artifactId>
+ <version>${lift.version}</version>
+ </dependency>
+ <!--
<dependency>
- <groupId>org.scala-lang</groupId>
- <artifactId>scala-library</artifactId>
- <version>${scala.version}</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>com.ibm.icu</groupId>
- <artifactId>icu4j</artifactId>
- <version>3.4.4</version>
+ <groupId>com.socialmaterial</groupId>
+ <artifactId>social</artifactId>
+ <version>0.1-SNAPSHOT</version>
</dependency>
+ -->
+ <dependency>
+ <groupId>org.compass-project</groupId>
+ <artifactId>compass</artifactId>
+ <version>${compass.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>8.2-507.jdbc3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.2.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ <version>2.1_3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.objenesis</groupId>
+ <artifactId>objenesis</artifactId>
+ <version>1.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>net.sourceforge.jwebunit</groupId>
+ <artifactId>jwebunit-htmlunit-plugin</artifactId>
+ <version>1.4.1</version>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>[6.1.6,)</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- for LiftConsole -->
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-compiler</artifactId>
+ <version>${scala.version}</version>
+ <!--<scope>test</scope>-->
+ </dependency>
+ <dependency>
+ <groupId>org.apache.lucene</groupId>
+ <artifactId>lucene-snowball</artifactId>
+ <version>${lucene.version}</version>
+ </dependency>
+ <!-- for stats gathering and jmx -->
+ <dependency>
+ <groupId>com.twitter</groupId>
+ <artifactId>stats</artifactId>
+ <version>${scala.stats.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>openDMK</groupId>
+ <artifactId>jdmkrt</artifactId>
+ <version>1.0-b02</version>
+ </dependency>
+ <!-- end stats and jmx -->
+ <dependency>
+ <groupId>org.scala-tools.testing</groupId>
+ <artifactId>specs</artifactId>
+ <version>1.6.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
- </dependencyManagement>
-
- <dependencies>
- <dependency>
- <groupId>org.scala-lang</groupId>
- <artifactId>scala-library</artifactId>
- <version>${scala.version}</version>
- </dependency>
-
- <dependency>
- <groupId>com.ibm.icu</groupId>
- <artifactId>icu4j</artifactId>
- <version>3.4.4</version>
- </dependency>
- <dependency>
- <groupId>org.openid4java</groupId>
- <artifactId>openid4java</artifactId>
- <version>0.9.5</version>
- </dependency>
-
- <dependency>
- <groupId>net.liftweb</groupId>
- <artifactId>lift-util</artifactId>
- <version>${lift.version}</version>
- </dependency>
- <dependency>
- <groupId>net.liftweb</groupId>
- <artifactId>lift-webkit</artifactId>
- <version>${lift.version}</version>
- </dependency>
- <dependency>
- <groupId>net.liftweb</groupId>
- <artifactId>lift-mapper</artifactId>
- <version>${lift.version}</version>
- </dependency>
- <dependency>
- <groupId>net.liftweb</groupId>
- <artifactId>lift-testkit</artifactId>
- <version>${lift.version}</version>
- </dependency>
- <dependency>
- <groupId>net.liftweb</groupId>
- <artifactId>lift-openid</artifactId>
- <version>${lift.version}</version>
- </dependency>
- <dependency>
- <groupId>net.liftweb</groupId>
- <artifactId>lift-textile</artifactId>
- <version>${lift.version}</version>
- </dependency>
- <!--
- <dependency>
- <groupId>com.socialmaterial</groupId>
- <artifactId>social</artifactId>
- <version>0.1-SNAPSHOT</version>
- </dependency>
- -->
- <dependency>
- <groupId>org.compass-project</groupId>
- <artifactId>compass</artifactId>
- <version>${compass.version}</version>
- </dependency>
-
- <dependency>
- <groupId>postgresql</groupId>
- <artifactId>postgresql</artifactId>
- <version>8.2-507.jdbc3</version>
- </dependency>
- <dependency>
- <groupId>org.apache.derby</groupId>
- <artifactId>derby</artifactId>
- <version>10.2.2.0</version>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <scope>provided</scope>
- </dependency>
-
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>cglib</groupId>
- <artifactId>cglib</artifactId>
- <version>2.1_3</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.objenesis</groupId>
- <artifactId>objenesis</artifactId>
- <version>1.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>net.sourceforge.jwebunit</groupId>
- <artifactId>jwebunit-htmlunit-plugin</artifactId>
- <version>1.4.1</version>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
- <version>[6.1.6,)</version>
- <scope>test</scope>
- </dependency>
- <!-- for LiftConsole -->
- <dependency>
- <groupId>org.scala-lang</groupId>
- <artifactId>scala-compiler</artifactId>
- <version>${scala.version}</version>
- <!--<scope>test</scope>-->
- </dependency>
- <dependency>
- <groupId>org.apache.lucene</groupId>
- <artifactId>lucene-snowball</artifactId>
- <version>${lucene.version}</version>
- </dependency>
- <!-- for stats gathering and jmx -->
- <dependency>
- <groupId>com.twitter</groupId>
- <artifactId>stats</artifactId>
- <version>${scala.stats.version}</version>
- </dependency>
- <dependency>
- <groupId>openDMK</groupId>
- <artifactId>jdmkrt</artifactId>
- <version>1.0-b02</version>
- </dependency>
- <!-- end stats and jmx -->
- <dependency>
- <groupId>org.scala-tools.testing</groupId>
- <artifactId>specs</artifactId>
- <version>1.5.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.4</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <sourceDirectory>src/main/scala</sourceDirectory>
- <testSourceDirectory>src/test/scala</testSourceDirectory>
-
- <plugins>
-
- <plugin>
- <groupId>org.scala-tools</groupId>
- <artifactId>maven-scala-plugin</artifactId>
- <version>2.9</version>
- <executions>
- <execution>
- <goals>
- <goal>compile</goal>
- <goal>testCompile</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <jvmArgs>
- <jvmArg>-Xmx1024m</jvmArg>
- </jvmArgs>
- <scalaVersion>${scala.version}</scalaVersion>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-plugin</artifactId>
- <configuration>
- <contextPath>/</contextPath>
- <scanIntervalSeconds>0</scanIntervalSeconds>
- </configuration>
- </plugin>
- <plugin>
- <groupId>net.sf.alchim</groupId>
- <artifactId>yuicompressor-maven-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>compress</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <nosuffix>true</nosuffix>
- <jswarn>false</jswarn>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-eclipse-plugin</artifactId>
- <configuration>
- <downloadSources>true</downloadSources>
- <excludes>
- <exclude>org.scala-lang:scala-library</exclude>
- </excludes>
- <classpathContainers>
-
<classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
- </classpathContainers>
- <projectnatures>
-
<java.lang.String>ch.epfl.lamp.sdt.core.scalanature</java.lang.String>
-
<java.lang.String>org.eclipse.jdt.core.javanature</java.lang.String>
- </projectnatures>
- <buildcommands>
-
<java.lang.String>ch.epfl.lamp.sdt.core.scalabuilder</java.lang.String>
- </buildcommands>
- </configuration>
- </plugin>
- </plugins>
- </build>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.scala-tools</groupId>
- <artifactId>maven-scala-plugin</artifactId>
- <configuration>
- <jvmArgs>
- <jvmArg>-Xmx1024m</jvmArg>
- </jvmArgs>
-
- <scalaVersion>${scala.version}</scalaVersion>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
+ <build>
+ <sourceDirectory>src/main/scala</sourceDirectory>
+ <testSourceDirectory>src/test/scala</testSourceDirectory>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.scala-tools</groupId>
+ <artifactId>maven-scala-plugin</artifactId>
+ <version>2.9</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ <goal>testCompile</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <jvmArgs>
+ <jvmArg>-Xmx1024m</jvmArg>
+ </jvmArgs>
+ <scalaVersion>${scala.version}</scalaVersion>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <configuration>
+ <contextPath>/</contextPath>
+ <scanIntervalSeconds>0</scanIntervalSeconds>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>net.sf.alchim</groupId>
+ <artifactId>yuicompressor-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compress</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <nosuffix>true</nosuffix>
+ <jswarn>false</jswarn>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ <excludes>
+ <exclude>org.scala-lang:scala-library</exclude>
+ </excludes>
+ <classpathContainers>
+
<classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER</classpathContainer>
+ </classpathContainers>
+ <projectnatures>
+
<java.lang.String>ch.epfl.lamp.sdt.core.scalanature</java.lang.String>
+
<java.lang.String>org.eclipse.jdt.core.javanature</java.lang.String>
+ </projectnatures>
+ <buildcommands>
+
<java.lang.String>ch.epfl.lamp.sdt.core.scalabuilder</java.lang.String>
+ </buildcommands>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.scala-tools</groupId>
+ <artifactId>maven-scala-plugin</artifactId>
+ <configuration>
+ <jvmArgs>
+ <jvmArg>-Xmx1024m</jvmArg>
+ </jvmArgs>
+
+ <scalaVersion>${scala.version}</scalaVersion>
+ </configuration>
+ </plugin>
+ </plugins>
+ </reporting>
</project>
Modified:
incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala
URL:
http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala?rev=834618&r1=834617&r2=834618&view=diff
==============================================================================
--- incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala
(original)
+++ incubator/esme/trunk/server/src/main/scala/bootstrap/liftweb/Boot.scala Tue
Nov 10 19:20:14 2009
@@ -47,7 +47,7 @@
import org.compass.core._
import org.compass.core.config.CompassConfiguration
-import net.liftweb.widgets.tablesorter._
+import net.liftweb.widgets.tablesorter._
import com.twitter.stats._
/**
@@ -67,48 +67,48 @@
if (Props.mode == Props.RunModes.Test) {
Schemifier.destroyTables_!!(Log.infoF _, User, ExtSession,
- Message, Mailbox, Tag,
- Relationship, MessageTag,
- AuthToken, UrlStore, Tracking,
- Action, DidPerform, AccessPool,
- Privilege, UserAuth, UserCryptoSig)
+ Message, Mailbox, Tag,
+ Relationship, MessageTag,
+ AuthToken, UrlStore, Tracking,
+ Action, DidPerform, AccessPool,
+ Privilege, UserAuth, UserCryptoSig)
}
Schemifier.schemify(true, Log.infoF _, User, ExtSession, Message,
- Mailbox, Tag,
- Relationship, MessageTag, AuthToken,
- UrlStore, Tracking, Action, DidPerform,
- AccessPool, Privilege, UserAuth, UserCryptoSig)
+ Mailbox, Tag,
+ Relationship, MessageTag, AuthToken,
+ UrlStore, Tracking, Action, DidPerform,
+ AccessPool, Privilege, UserAuth, UserCryptoSig)
LiftRules.statelessDispatchTable.append {
- case r @ Req("api" :: "send_msg" :: Nil, "", PostRequest)
- if r.param("token").isDefined =>
+ case r...@req("api" :: "send_msg" :: Nil, "", PostRequest)
+ if r.param("token").isDefined =>
() => RestAPI.sendMsgWithToken(r)
}
LiftRules.dispatch.append(ESMEOpenIDVendor.dispatchPF)
-
+
//Resources for Internationalization
LiftRules.resourceNames = "ESMECustom" :: "ESMEBase" :: "ESMEUI" :: Nil
-
+
//Jquery functions
-
+
TableSorter.init
LiftRules.siteMapFailRedirectLocation = List("static", "about")
LiftRules.rewrite.prepend {
- case RewriteRequest(ParsePath("user" :: user :: Nil,"", _,_), _, _) =>
- RewriteResponse( List("info_view", "user"), Map("uid" -> user))
- case RewriteRequest(ParsePath("tag" :: tag :: Nil,"", _,_), _, _) =>
- RewriteResponse( List("info_view", "tag"), Map("tag" -> tag))
+ case RewriteRequest(ParsePath("user" :: user :: Nil, "", _, _), _, _) =>
+ RewriteResponse(List("info_view", "user"), Map("uid" -> user))
+ case RewriteRequest(ParsePath("tag" :: tag :: Nil, "", _, _), _, _) =>
+ RewriteResponse(List("info_view", "tag"), Map("tag" -> tag))
case RewriteRequest(ParsePath("conversation" :: cid :: Nil, "", _, _),
- _, _) =>
+ _, _) =>
RewriteResponse(List("info_view", "conversation"), Map("cid" -> cid))
- case RewriteRequest(ParsePath("search" :: term :: Nil,"", _,_), _, _) =>
- RewriteResponse( List("user_view", "search"), Map("term" -> term))
+ case RewriteRequest(ParsePath("search" :: term :: Nil, "", _, _), _, _)
=>
+ RewriteResponse(List("user_view", "search"), Map("term" -> term))
}
LiftRules.dispatch.append(UrlStore.redirectizer)
@@ -118,30 +118,30 @@
UserAuth.register(UserPwdAuthModule)
UserAuth.register(OpenIDAuthModule)
-
- // Build SiteMap
+
+ // Build SiteMap
val entries = Menu(Loc("Home", List("index"), "Home")) ::
- Menu(Loc("user", List("info_view", "user"), "User Info", Hidden,
- Loc.Snippet("user_info", TagDisplay.userInfo))) ::
- Menu(Loc("about", List("static", "about"), S.?("base_menu_about"),
Hidden)) ::
- Menu(Loc("tag", List("info_view", "tag"), "Tag", Hidden,
Loc.Snippet("tag_display", TagDisplay.display))) ::
- Menu(Loc("search", List("user_view", "search"), S.?("base_menu_search"),
Hidden)) ::
- Menu(Loc("sign_up", List("signup"), S.?("base_menu_signup"),
- Snippet("signup", User.signupForm),
- Unless(User.loggedIn_? _, S.?("base_menu_sign_up_error")))) ::
- Menu(Loc("logout", List("logout"), S.?("base_menu_logout"),
- EarlyResponse(() => {User.logUserOut; S.redirectTo(S.referer
openOr "/")}),
- If(User.loggedIn_? _, S.?("base_menu_logout_error")))) ::
- // User.sitemap :::
- UserMgr.menuItems :::
- TrackMgr.menuItems :::
- ActionMgr.menuItems :::
- AuthMgr.menuItems :::
- AccessPoolMgr.menuItems :::
- StreamMgr.menuItems :::
- ConversationMgr.menuItems
+ Menu(Loc("user", List("info_view", "user"), "User Info", Hidden,
+ Loc.Snippet("user_info", TagDisplay.userInfo))) ::
+ Menu(Loc("about", List("static", "about"), S.?("base_menu_about"),
Hidden)) ::
+ Menu(Loc("tag", List("info_view", "tag"), "Tag", Hidden,
Loc.Snippet("tag_display", TagDisplay.display))) ::
+ Menu(Loc("search", List("user_view", "search"),
S.?("base_menu_search"), Hidden)) ::
+ Menu(Loc("sign_up", List("signup"), S.?("base_menu_signup"),
+ Snippet("signup", User.signupForm),
+ Unless(User.loggedIn_? _, S.?("base_menu_sign_up_error")))) ::
+ Menu(Loc("logout", List("logout"), S.?("base_menu_logout"),
+ EarlyResponse(() => {User.logUserOut; S.redirectTo(S.referer openOr
"/")}),
+ If(User.loggedIn_? _, S.?("base_menu_logout_error")))) ::
+ // User.sitemap :::
+ UserMgr.menuItems :::
+ TrackMgr.menuItems :::
+ ActionMgr.menuItems :::
+ AuthMgr.menuItems :::
+ AccessPoolMgr.menuItems :::
+ StreamMgr.menuItems :::
+ ConversationMgr.menuItems
- LiftRules.setSiteMap(SiteMap(entries:_*))
+ LiftRules.setSiteMap(SiteMap(entries: _*))
S.addAround(ExtSession.requestLoans)
@@ -163,19 +163,19 @@
LiftRules.dispatch.append(TwitterJsonAPI.dispatch)
LiftRules.early.append(makeUtf8)
-
+
//JMX
if (Props.getBool("jmx.enable", false))
- StatsMBean("org.apache.esme.stats")
+ StatsMBean("org.apache.esme.stats")
Distributor.touch
SchedulerActor.touch
MessagePullActor.touch
// ScalaInterpreter.touch
-
- Stats.makeGauge("users"){Distributor.getUsersCount}
- Stats.makeGauge("listener"){Distributor.getListenersCount}
-
+
+ Stats.makeGauge("users") {Distributor.getUsersCount}
+ Stats.makeGauge("listener") {Distributor.getListenersCount}
+
val resentPeriod = Props.getLong("stats.resent.period", 1 week)
val resentRefreshInterval: Long = Props.getLong("stats.resent.refresh")
match {
case Full(interval) if interval > (1 minute) => interval
@@ -202,30 +202,31 @@
* Show the spinny image when an Ajax call starts
*/
LiftRules.ajaxStart =
- Full(() => LiftRules.jsArtifacts.show("ajax-loader").cmd)
+ Full(() => LiftRules.jsArtifacts.show("ajax-loader").cmd)
/*
* Make the spinny image go away when it ends
*/
LiftRules.ajaxEnd =
- Full(() => LiftRules.jsArtifacts.hide("ajax-loader").cmd)
+ Full(() => LiftRules.jsArtifacts.hide("ajax-loader").cmd)
- // Dump information about session every 10 minutes
+ // Dump information about session every 10 minutes
SessionMaster.sessionWatchers = SessionInfoDumper ::
SessionMaster.sessionWatchers
}
+
private def makeUtf8(req: HTTPRequest) = {req.setCharacterEncoding("UTF-8")}
}
object Compass {
// Set up Compass for search
val conf = tryo(new CompassConfiguration()
- .configure(Props.get("compass_config_file") openOr
"/props/compass.cfg.xml")
- .addClass((new Message).clazz))
+ .configure(Props.get("compass_config_file") openOr
"/props/compass.cfg.xml")
+ .addClass((new Message).clazz))
val compass = conf.map(_.buildCompass())
for (c <- compass if !c.getSearchEngineIndexManager.indexExists)
- tryo(c.getSearchEngineIndexManager().createIndex())
+ tryo(c.getSearchEngineIndexManager().createIndex())
}
@@ -233,8 +234,8 @@
def analyze(req: Box[Req], time: Long, queries: List[(String, Long)]): Unit
= {
val longQueries = (queries.filter(_._2 > 30))
if (time > 50 || longQueries.?) {
- Log.info("Request "+req.map(_.uri).openOr("No Request")+
- " took "+time+" query "+longQueries.comma)
+ Log.info("Request " + req.map(_.uri).openOr("No Request") +
+ " took " + time + " query " + longQueries.comma)
}
}
}
@@ -248,16 +249,16 @@
if (Props.getBool("use_prod_psql", false)) {
Class.forName("org.postgresql.Driver")
val dm = DriverManager.
- getConnection("jdbc:postgresql://localhost/esme_prod",
- Props.get("db_user", "dpp"),
- Props.get("db_pwd", ""))
+ getConnection("jdbc:postgresql://localhost/esme_prod",
+ Props.get("db_user", "dpp"),
+ Props.get("db_pwd", ""))
Full(dm)
} else if (Props.getBool("use_local_psql", false)) {
Class.forName("org.postgresql.Driver")
val dm = DriverManager.
- getConnection("jdbc:postgresql://localhost/esme_dev",
- Props.get("db_user", "dpp"),
- Props.get("db_pwd", ""))
+ getConnection("jdbc:postgresql://localhost/esme_dev",
+ Props.get("db_user", "dpp"),
+ Props.get("db_pwd", ""))
Full(dm)
} else {
val driverName = Props.mode match {
@@ -269,29 +270,30 @@
Full(dm)
}
} catch {
- case e : Exception => e.printStackTrace; Empty
+ case e: Exception => e.printStackTrace; Empty
}
def newConnection(name: ConnectionIdentifier): Box[Connection] =
synchronized {
pool match {
case Nil if poolSize < maxPoolSize => val ret = createOne
- poolSize = poolSize + 1
- ret.foreach(c => pool = c :: pool)
- ret
+ poolSize = poolSize + 1
+ // ret.foreach(c => pool = c :: pool)
+ ret
case Nil => wait(1000L); newConnection(name)
- case x :: xs => try {
+ case x :: xs =>
+ pool = xs
+ try {
x.setAutoCommit(false)
Full(x)
} catch {
case e => try {
- pool = xs
- poolSize = poolSize - 1
- x.close
- newConnection(name)
- } catch {
- case e => newConnection(name)
- }
+ poolSize = poolSize - 1
+ x.close
+ newConnection(name)
+ } catch {
+ case e => newConnection(name)
+ }
}
}
}
@@ -306,23 +308,24 @@
private var lastTime = millis
val tenMinutes: Long = 10 minutes
+
protected def messageHandler = {
case SessionWatcherInfo(sessions) =>
- Stats.getCounter("liftSessions").update(sessions.size)
+ Stats.getCounter("liftSessions").update(sessions.size)
if ((millis - tenMinutes) > lastTime) {
lastTime = millis
val rt = Runtime.getRuntime
rt.gc
-
+
val dateStr: String = timeNow.toString
- Log.info("[MEMDEBUG] At "+dateStr+" Number of open sessions:
"+sessions.size)
- Log.info("[MEMDEBUG] Free Memory: "+pretty(rt.freeMemory))
- Log.info("[MEMDEBUG] Total Memory: "+pretty(rt.totalMemory))
+ Log.info("[MEMDEBUG] At " + dateStr + " Number of open sessions: " +
sessions.size)
+ Log.info("[MEMDEBUG] Free Memory: " + pretty(rt.freeMemory))
+ Log.info("[MEMDEBUG] Total Memory: " + pretty(rt.totalMemory))
}
-
+
}
private def pretty(in: Long): String =
- if (in > 1000L) pretty(in / 1000L)+","+(in % 1000L)
- else in.toString
+ if (in > 1000L) pretty(in / 1000L) + "," + (in % 1000L)
+ else in.toString
}
Added:
incubator/esme/trunk/server/src/test/scala/org/apache/esme/JettySetup.scala
URL:
http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/test/scala/org/apache/esme/JettySetup.scala?rev=834618&view=auto
==============================================================================
--- incubator/esme/trunk/server/src/test/scala/org/apache/esme/JettySetup.scala
(added)
+++ incubator/esme/trunk/server/src/test/scala/org/apache/esme/JettySetup.scala
Tue Nov 10 19:20:14 2009
@@ -0,0 +1,91 @@
+/**
+ * Copyright 2008-2009 WorldWide Conferencing, LLC
+ *
+ * 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.
+ */
+
+package org.apache.esme
+
+import _root_.junit.framework.AssertionFailedError
+import org.specs._
+import org.specs.runner.JUnit3
+import org.specs.runner.ConsoleRunner
+import net.liftweb.util._
+import net.liftweb.common._
+import org.specs.matcher._
+import Helpers._
+import net.sourceforge.jwebunit.junit.WebTester
+import org.mortbay.jetty.Server
+import org.mortbay.jetty.servlet.{Context, FilterHolder}
+import org.mortbay.jetty.servlet.ServletHolder
+import org.mortbay.jetty.webapp.WebAppContext
+import org.apache.esme._
+import model._
+import net.liftweb.http._
+
+
+object JettyTestServer {
+ private val serverPort_ = System.getProperty("SERVLET_PORT", "8989").toInt
+ private var baseUrl_ = "http://127.0.0.1:" + serverPort_
+
+ System.setProperty("run.mode", "test")
+
+ private val server_ : Server = {
+ val server = new Server(serverPort_)
+
+ val context = new WebAppContext()
+ context.setServer(server)
+ context.setContextPath("/")
+ context.setWar("src/main/webapp")
+
+ server.addHandler(context)
+
+ server
+ }
+
+ def urlFor(path: String) = baseUrl_ + path
+
+ lazy val start = {
+ server_.start()
+ User.create.nickname("hash").save
+ }
+
+ def stop() = {
+ server_.stop()
+ server_.join()
+ }
+
+ def browse(startPath: String, f:(WebTester) => Unit) = {
+ val wc = new WebTester()
+ try {
+ wc.setScriptingEnabled(false)
+ wc.beginAt(JettyTestServer.urlFor(startPath))
+ f(wc)
+ } catch {
+ case exc: AssertionFailedError => {
+ System.err.println("serveur response: ", wc.getServeurResponse())
+ throw exc
+ }
+ } finally {
+ wc.closeBrowser()
+ }
+ }
+
+}
+
+
Added:
incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/ApiTest.scala
URL:
http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/ApiTest.scala?rev=834618&view=auto
==============================================================================
---
incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/ApiTest.scala
(added)
+++
incubator/esme/trunk/server/src/test/scala/org/apache/esme/api/ApiTest.scala
Tue Nov 10 19:20:14 2009
@@ -0,0 +1,77 @@
+/**
+ * Copyright 2008-2009 WorldWide Conferencing, LLC
+ *
+ * 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.
+ */
+
+package org.apache.esme.api
+
+import org.specs._
+import org.specs.runner.JUnit3
+import org.specs.runner.ConsoleRunner
+import net.liftweb.util._
+import net.liftweb.common._
+import org.specs.matcher._
+import Helpers._
+import net.sourceforge.jwebunit.junit.WebTester
+import org.mortbay.jetty.Server
+import org.mortbay.jetty.servlet.{Context, FilterHolder}
+import org.mortbay.jetty.servlet.ServletHolder
+import org.mortbay.jetty.webapp.WebAppContext
+import org.apache.esme._
+import model._
+import net.liftweb.http._
+
+import net.sourceforge.jwebunit.junit.WebTester
+import _root_.junit.framework.AssertionFailedError
+import testing.{HttpResponse, TestFramework}
+class ApiSpecsAsTest extends JUnit3(ApiSpecs)
+object ApiSpecsRunner extends ConsoleRunner(ApiSpecs)
+
+object ApiSpecs extends Specification with TestFramework {
+ JettyTestServer.start
+
+ def buildRunner = null
+ def tests = Nil
+
+ def baseUrl = JettyTestServer.urlFor("")
+
+ val theUser = User.createAndPopulate.nickname("api_test").saveMe
+ val token = {
+ val toke = AuthToken.create.user(theUser).saveMe
+ toke.uniqueId.is
+ }
+
+ "API" should {
+ "Login" in {
+ post("/api/login", "token" -> token) match {
+ case hr: HttpResponse => hr.code must_== 200
+
+ hr.get("/api/status") match {
+ case h2: HttpResponse =>
+ (h2.xml \ "user" \ "@id").text must_== theUser.id.toString
+
+ case x => true must_== false
+ }
+
+
+ case _ => true must_== false
+ }
+ }
+ }
+}
Modified:
incubator/esme/trunk/server/src/test/scala/org/apache/esme/lib/MsgParseTest.scala
URL:
http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/test/scala/org/apache/esme/lib/MsgParseTest.scala?rev=834618&r1=834617&r2=834618&view=diff
==============================================================================
---
incubator/esme/trunk/server/src/test/scala/org/apache/esme/lib/MsgParseTest.scala
(original)
+++
incubator/esme/trunk/server/src/test/scala/org/apache/esme/lib/MsgParseTest.scala
Tue Nov 10 19:20:14 2009
@@ -1,6 +1,6 @@
/**
* Copyright 2008-2009 WorldWide Conferencing, LLC
- *
+ *
* 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
@@ -45,21 +45,19 @@
object MsgParserSpecsRunner extends ConsoleRunner(MsgParserSpecs)
object MsgParserSpecs extends Specification {
- (new bootstrap.liftweb.Boot).boot
-
- JettyTestServer.start()
-
+ JettyTestServer.start
+
type PFT = MsgParser.ParseResult[_]
def parseMatch(name: String, matchr: PartialFunction[PFT, Any]) = new
Matcher[PFT] {
- def apply(v: => PFT) = (matchr.isDefinedAt(v),
+ def apply(v: => PFT) = (matchr.isDefinedAt(v),
name+" succeeded parsing",
name+" failed parsing")
}
-
+
"Msg Parser Parse" should {
"parse top label" in {
val ret = MsgParser.toplabel("www")
-
+
ret must
parseMatch("www", {
case MsgParser.Success("www", _) =>
@@ -72,10 +70,10 @@
case MsgParser.Success("http://www.google.com", _) =>
})
}
-
+
"parse a complex simple URL" in {
val Str = "http://www.google.com:8080/Foo/bar"
-
+
val ret = MsgParser.httpUrl(Str)
ret must
@@ -83,10 +81,10 @@
case MsgParser.Success(Str, _) =>
})
}
-
+
"parse a complex URL with query params" in {
val Str = "https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/10754"
-
+
val ret = MsgParser.httpUrl(Str)
ret must
@@ -94,50 +92,50 @@
case MsgParser.Success(Str, _) =>
})
}
-
+
"Fail for an empty string" in {
MsgParser.begin("") must
parseMatch("Empty",
{case MsgParser.Error(_, _) =>
case MsgParser.Failure(_, _) =>
})
-
+
}
-
+
"Find only text" in {
MsgParser.begin("This is a message") must
parseMatch("only test",
{case MsgParser.Success(MsgText(_) :: Nil, _) =>
-
+
})
-
+
}
-
+
"Find only text" in {
MsgParser.begin("This is http://$$$ a message") must
parseMatch("only test",
{case MsgParser.Success(MsgText(_) :: Nil, _) =>
-
+
})
-
+
}
"Find only text" in {
MsgParser.begin("This is #,hello a message") must
parseMatch("only test",
{case MsgParser.Success(MsgText(_) :: Nil, _) =>
-
+
})
-
+
}
"Find only text" in {
MsgParser.begin("This is @--Moose a message") must
parseMatch("only test",
{case MsgParser.Success(MsgText(_) :: Nil, _) =>
-
+
})
-
+
}
"Find a hash tag" in {
@@ -149,7 +147,7 @@
if tag.name.equalsIgnoreCase("hash") =>
}
)
-
+
}
"Find a @msg tag" in {
@@ -162,9 +160,9 @@
MsgText(_) :: Nil, _) =>
}
)
-
+
}
-
+
"Find a url tag" in {
MsgParser.begin("This is http://www.moo.com a message") must
parseMatch("only test",
@@ -173,9 +171,9 @@
MsgText(_) :: Nil, _) =>
}
)
-
+
}
-
+
"Find a https url tag" in {
MsgParser.begin("This is https://www.moo.com a message") must
parseMatch("only test",
@@ -184,9 +182,9 @@
MsgText(_) :: Nil, _) =>
}
)
-
+
}
-
+
"match 'any'" in {
val ret = MsgParser._testMessage("any")
@@ -195,10 +193,10 @@
{case MsgParser.Success(AnyAction, _) =>
}
)
-
+
}
-
-
+
+
"match '54%'" in {
val ret = MsgParser._testMessage(" 54% ")
@@ -207,9 +205,9 @@
{case MsgParser.Success(PercentAction(54), _) =>
}
)
-
+
}
-
+
"match '#foo'" in {
val ret = MsgParser._testMessage(" #foo ")
@@ -218,11 +216,11 @@
{case MsgParser.Success(HashAction(_, _), _) =>
}
)
-
+
}
/*
-
+
"match '@hash'" in {
println("About to test @hash")
val ret = MsgParser._testMessage(" @hash ")
@@ -234,7 +232,7 @@
{case MsgParser.Success(AtUserAction(_), _) =>
}
)
-
+
}
*/
@@ -246,9 +244,9 @@
{case MsgParser.Failure(_ , _) =>
}
)
-
+
}
-
+
"match 'day = 4'" in {
val ret = MsgParser._testMessage(" day = 4 ")
@@ -257,9 +255,9 @@
{case MsgParser.Success(DateTestAction(DayDateType, EqOpr,
List(4)), _) =>
}
)
-
+
}
-
+
"match 'month = (1,2,4)'" in {
val ret = MsgParser._testMessage(" month = (1, 2, 4 ) ")
@@ -268,9 +266,9 @@
{case MsgParser.Success(DateTestAction(MonthDateType, EqOpr,
List(1, 2, 4)), _) =>
}
)
-
+
}
-
+
"match 'month = (1,2,4) | 74%'" in {
val ret = MsgParser._testMessage(" month = (1, 2, 4 )|74% ")
@@ -279,9 +277,9 @@
{case
MsgParser.Success(OrAction(DateTestAction(MonthDateType, EqOpr, List(1, 2, 4)),
PercentAction(74)), _) =>
}
)
-
+
}
-
+
"match '( month = (1, 2, 4 )|74%) & #frog'" in {
val ret = MsgParser._testMessage("( month = (1, 2, 4 )|74%) &
#frog ")
@@ -291,63 +289,9 @@
ParenAction(OrAction(DateTestAction(MonthDateType, EqOpr,
List(1, 2, 4)), PercentAction(74))),
HashAction(_, _)), _) =>
})
-
- }
-
- }
-}
-
-
-object JettyTestServer {
- private val serverPort_ = System.getProperty("SERVLET_PORT", "8989").toInt
- private var baseUrl_ = "http://127.0.0.1:" + serverPort_
-
- System.setProperty("run.mode", "test")
-
- private val server_ : Server = {
- val server = new Server(serverPort_)
-
- val context = new WebAppContext()
- context.setServer(server)
- context.setContextPath("/")
- context.setWar("target/esme-server-0.3.0-SNAPSHOT")
-
- //val context = new Context(server, "/", Context.SESSIONS)
- //context.addFilter(new FilterHolder(new LiftFilter()), "/");
- //new LiftFilter()
- //server.addHandler(context)
- server
- }
-
- def urlFor(path: String) = baseUrl_ + path
-
- def start() = {
- server_.start()
- User.create.nickname("hash").save
- }
-
- def stop() = {
- server_.stop()
- server_.join()
- }
-
- def browse(startPath: String, f:(WebTester) => Unit) = {
- val wc = new WebTester()
- try {
- wc.setScriptingEnabled(false)
- wc.beginAt(JettyTestServer.urlFor(startPath))
- f(wc)
- } catch {
- case exc: AssertionFailedError => {
- System.err.println("serveur response: ", wc.getServeurResponse())
- throw exc
- }
- } finally {
- wc.closeBrowser()
}
+
}
}
-
-