Author: deepal
Date: Mon Dec 10 02:33:48 2007
New Revision: 10822
Log:
adding a jetty based test case
Added:
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/JettBasedServertest.java
Modified:
trunk/registry/modules/core/pom.xml
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
trunk/registry/modules/documentation/pom.xml
trunk/registry/pom.xml
Modified: trunk/registry/modules/core/pom.xml
==============================================================================
--- trunk/registry/modules/core/pom.xml (original)
+++ trunk/registry/modules/core/pom.xml Mon Dec 10 02:33:48 2007
@@ -126,6 +126,12 @@
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>6.1.5</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
==============================================================================
---
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
(original)
+++
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
Mon Dec 10 02:33:48 2007
@@ -148,7 +148,6 @@
}
}
ClientResponse resp = abderaClient.post(COLLECTION_ROOT + path, entry);
- System.out.println(resp.getStatusText());
if (resp.getType() == Response.ResponseType.SUCCESS) {
log.info("Resource added " + path);
} else {
@@ -161,7 +160,6 @@
Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
ClientResponse resp = abderaClient.delete(ENTRY_ROOT + path);
- System.out.println(resp.getStatusText());
if (resp.getType() == Response.ResponseType.SUCCESS) {
log.info("Resource deleted " + path);
} else {
@@ -194,7 +192,6 @@
entry.setContent(versionPath);
entry.setAttributeValue("directory", "false");
ClientResponse resp = abderaClient.put(ENTRY_ROOT, entry);
- System.out.println(resp.getStatusText());
if (resp.getType() == Response.ResponseType.SUCCESS) {
log.info("Resource restored " + versionPath);
} else {
@@ -275,7 +272,6 @@
entry.setContent(tag);
entry.setSummary(RegistryConstants.PARAMETER_TAGS_REMOVED);
ClientResponse resp = abderaClient.put(ENTRY_ROOT, entry);
- System.out.println(resp.getStatusText());
if (resp.getType() == Response.ResponseType.SUCCESS) {
log.info("Tag removed " + path);
} else {
@@ -435,39 +431,4 @@
}
return logs;
}
-
- public static void main(String[] args) throws Exception {
- RemoteRegistry remoteRegistry = new RemoteRegistry();
-// Resource resource = remoteRegistry.get("/wso2/esb");
-// String content[] = (String[]) resource.getContent();
-// for (int i = 0; i < content.length; i++) {
-// String s = content[i];
-// System.out.println(s);
-// }
-// resource = remoteRegistry.get("/wso2/esb/r1");
-// System.out.println(new String((byte[]) resource.getContent()));
-// Resource rs = new Resource();
-// rs.setDirectory(true);
-// remoteRegistry.put("/wso2/deepal", rs);
-//
-// Resource r2 = new Resource();
-// r2.setDirectory(false);
-// byte[] r1content = "R1 content".getBytes();
-// r2.setContent(r1content);
-// r2.setMediaType("text/xml");
-// r2.setAuthorUserName("Glen");
-// remoteRegistry.put("/wso2/esb/r2", r2);
-// remoteRegistry.delete("/wso2/wsas");
-// String[] versions = remoteRegistry.getVersions("/wso2");
-// for (int i = 0; i < versions.length; i++) {
-// String version = versions[i];
-// System.out.println("version = " + version);
-// }
-// remoteRegistry.restoreVersion("/wso2?v=1");
-// remoteRegistry.removeTag("/wso2/esb/r2", "Deepal");
- String str = "wso2/wsa/userName";
- int ld = str.lastIndexOf("/");
- System.out.println(str.substring(ld + 1));
- System.out.println(str.substring(0, ld));
- }
}
Added:
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/JettBasedServertest.java
==============================================================================
--- (empty file)
+++
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/JettBasedServertest.java
Mon Dec 10 02:33:48 2007
@@ -0,0 +1,99 @@
+/*
+ * 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.wso2.registry.app;
+
+import org.apache.abdera.protocol.server.ServiceContext;
+import org.apache.abdera.protocol.server.impl.AbstractSingletonProviderManager;
+import org.apache.abdera.protocol.server.impl.DefaultServiceContext;
+import org.apache.abdera.protocol.server.servlet.AbderaServlet;
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
+import org.wso2.registry.RegistryConstants;
+import org.wso2.registry.RegistryException;
+import org.wso2.registry.jdbc.JDBCRegistry;
+import org.wso2.registry.jdbc.JDBCRegistryTest;
+import org.wso2.registry.secure.RegistryRealm;
+import org.wso2.usermanager.Realm;
+
+import javax.servlet.ServletException;
+
+//This test case run all the test cases that there in JDBCRegistry using
RemoteRegistry
+
+public class JettBasedServerTest extends JDBCRegistryTest {
+ private Server server;
+ private DefaultServiceContext abderaServiceContext;
+
+
+ public void setUp() {
+ try {
+ if (registry == null) {
+ initJetty();
+ registry = new RemoteRegistry();
+ }
+ } catch (Exception e) {
+ fail("Failed to initialize the registry.");
+ }
+ }
+
+// protected void tearDown() throws Exception {
+// if (server != null) server.stop();
+// }
+
+ private void initJetty() throws Exception {
+ abderaServiceContext = new RegistryAPPServiceContext();
+ RegistryAPPTargetResolver resolver = new RegistryAPPTargetResolver();
+ abderaServiceContext.setTargetResolver(resolver);
+ AbstractSingletonProviderManager pm = new
RegistryAtomProviderManager();
+ abderaServiceContext.setProviderManager(pm);
+
+ server = new Server(8080);
+ Context root = new Context(server, "/wso2registry",
Context.NO_SESSIONS);
+ root.addServlet(new ServletHolder(new AbderaServlet() {
+
+ @Override
+ protected ServiceContext createServiceContext() {
+
abderaServiceContext.setDefaultProviderManager(RegistryAtomProviderManager.class.getName());
+
abderaServiceContext.setDefaultTargetResolver(RegistryAPPTargetResolver.class.getName());
+ abderaServiceContext.init(getAbdera(),
getProperties(getServletConfig()));
+ JDBCRegistry jdbcRegistry = null;
+ try {
+ Realm registryRealm =
+ RegistryRealm.createInMemoryRegistryRealm();
+ jdbcRegistry = new JDBCRegistry();
+ jdbcRegistry.init(registryRealm);
+ System.getProperties().put(RegistryConstants.REGISTRY,
jdbcRegistry);
+ } catch (RegistryException e) {
+ e.printStackTrace();
+ }
+ registry = jdbcRegistry;
+ return abderaServiceContext;
+ }
+
+ public void init() throws ServletException {
+ super.init();
+ System.out.println("done");
+ }
+ }), "/*");
+ server.start();
+
+ }
+
+
+}
Modified:
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
==============================================================================
---
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
(original)
+++
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
Mon Dec 10 02:33:48 2007
@@ -33,7 +33,7 @@
* Registry instance for use in tests. Note that there should be only one
Registry instance
* in a JVM.
*/
- private static Registry registry = null;
+ protected static Registry registry = null;
public void setUp() {
try {
Modified: trunk/registry/modules/documentation/pom.xml
==============================================================================
--- trunk/registry/modules/documentation/pom.xml (original)
+++ trunk/registry/modules/documentation/pom.xml Mon Dec 10 02:33:48 2007
@@ -37,14 +37,14 @@
<xdocDirectory>${basedir}/xdocs</xdocDirectory>
<resourcesDirectory>${basedir}/xdocs/resources</resourcesDirectory>
</configuration>
- <executions>
- <execution>
- <phase>install</phase>
- <goals>
-
<goal>site</goal>
- </goals>
- </execution>
- </executions>
+ <executions>
+ <execution>
+ <phase>install</phase>
+ <goals>
+ <goal>site</goal>
+ </goals>
+ </execution>
+ </executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -58,22 +58,23 @@
<configuration>
<tasks>
- <mkdir
dir="${basedir}/target/apidocs"/>
- <javadoc
packagenames="org.wso2.registry.*"
-
destdir="${basedir}/target/apidocs"
-
classpathref="maven.runtime.classpath"
-
author="true"
-
version="true"
-
use="true"
-
windowtitle="WSO2 Registry API"
-
doctitle="WSO2 Registry"
-
bottom="Copyright © 2007 Apache Web Services Project. All Rights Reserved."
- >
- <packageset
dir="../../modules/core/src/main/java" defaultexcludes="yes">
- <include
name="org/wso2/registry/**"/>
- <include
name="javax/**"/>
- </packageset>
- </javadoc>
+ <mkdir dir="${basedir}/target/apidocs"/>
+ <javadoc packagenames="org.wso2.registry.*"
+ destdir="${basedir}/target/apidocs"
+ classpathref="maven.runtime.classpath"
+ author="true"
+ version="true"
+ use="true"
+ windowtitle="WSO2 Registry API"
+ doctitle="WSO2 Registry"
+ bottom="Copyright © 2007 Apache
Web Services Project. All Rights Reserved."
+ >
+ <packageset
dir="../../modules/core/src/main/java"
+ defaultexcludes="yes">
+ <include name="org/wso2/registry/**"/>
+ <include name="javax/**"/>
+ </packageset>
+ </javadoc>
</tasks>
</configuration>
<goals>
@@ -81,17 +82,22 @@
</goals>
</execution>
</executions>
- </plugin>
+ </plugin>
</plugins>
</build>
<dependencies>
<!-- Junit testing environment-->
<!--<dependency>-->
- <!--<groupId>junit</groupId>-->
- <!--<artifactId>junit</artifactId>-->
- <!--<scope>test</scope>-->
+ <!--<groupId>junit</groupId>-->
+ <!--<artifactId>junit</artifactId>-->
+ <!--<scope>test</scope>-->
<!--</dependency>-->
<dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
@@ -112,8 +118,71 @@
<artifactId>commons-fileupload</artifactId>
</dependency>
<dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.wso2.commons.usermanager</groupId>
<artifactId>usermanager-core</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-protocol</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-parser</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-server</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.commons.axiom</groupId>
+ <artifactId>axiom-impl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>stax</groupId>
+ <artifactId>stax-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.woodstox</groupId>
+ <artifactId>wstx-asl</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>jaxen</groupId>
+ <artifactId>jaxen</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>6.1.5</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
Modified: trunk/registry/pom.xml
==============================================================================
--- trunk/registry/pom.xml (original)
+++ trunk/registry/pom.xml Mon Dec 10 02:33:48 2007
@@ -242,6 +242,11 @@
<artifactId>hsqldb</artifactId>
<version>${hsqldb.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>${jetty.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
@@ -339,6 +344,7 @@
<woodstox.version>3.2.1</woodstox.version>
<jaxen.version>1.1.1</jaxen.version>
<xmlapi.version>1.3.04</xmlapi.version>
+ <jetty.version>6.1.5</jetty.version>
</properties>
<repositories>
_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev