Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2009-09-11 17:01:23 +0000
committerslewis2009-09-11 17:01:23 +0000
commit887d89014c8c387867ba4b20d0cdd042bed7d3b6 (patch)
treed4767e5b2815e4c0f2590e500b86cb6b881b328e
parent9ccd593403985d518253dda4598a52960444cbbd (diff)
downloadorg.eclipse.ecf-887d89014c8c387867ba4b20d0cdd042bed7d3b6.tar.gz
org.eclipse.ecf-887d89014c8c387867ba4b20d0cdd042bed7d3b6.tar.xz
org.eclipse.ecf-887d89014c8c387867ba4b20d0cdd042bed7d3b6.zip
Initial checkin of REST api tests work from google soc project 2009 from Holger Staudacher. CQ for IP review/approval of contribution: http://dev.eclipse.org/ipzilla/show_bug.cgi?id=3504
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/.classpath7
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/.project28
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/.settings/org.eclipse.jdt.core.prefs70
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/META-INF/MANIFEST.MF18
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/Rest API Test.launch46
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/build.properties5
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestContainerInstantiatorTest.java57
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestContainerTest.java188
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestIDTest.java89
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestNamespaceTest.java56
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestRemoteServiceAdapterTest.java106
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestRemoteServiceContainerTest.java101
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestRemoteServiceTest.java96
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestResourceTest.java37
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestServiceRegistrationTest.java90
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/service/RestServiceTest.java155
-rw-r--r--tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/service/SimpleRestService.java100
17 files changed, 1249 insertions, 0 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/.classpath b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/.classpath
new file mode 100644
index 000000000..2fbb7a23e
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/.project b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/.project
new file mode 100644
index 000000000..7be670f13
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.ecf.tests.remoteservice.rest</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/.settings/org.eclipse.jdt.core.prefs b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..5a7551c7f
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,70 @@
+#Wed Aug 19 11:44:18 PDT 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
+org.eclipse.jdt.core.compiler.problem.deadCode=warning
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=ignore
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=warning
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
+org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.3
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/META-INF/MANIFEST.MF b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/META-INF/MANIFEST.MF
new file mode 100644
index 000000000..d21c78715
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: REST API Tests
+Bundle-SymbolicName: org.eclipse.ecf.tests.remoteservice.rest;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Require-Bundle: org.eclipse.ecf.remoteservice.rest;bundle-version="1.0.0",
+ org.junit;bundle-version="3.8.2",
+ org.eclipse.ecf.tests;bundle-version="2.0.0",
+ org.eclipse.ecf.tests.remoteservice;bundle-version="2.0.0",
+ org.eclipse.ecf;bundle-version="3.0.0",
+ org.eclipse.equinox.app;bundle-version="1.2.0",
+ org.eclipse.core.runtime;bundle-version="3.5.0",
+ org.eclipse.ecf.remoteservice;bundle-version="3.0.0",
+ org.eclipse.equinox.concurrent;bundle-version="1.0.0",
+ org.json;bundle-version="1.0.0"
+Import-Package: org.apache.commons.httpclient;version="3.0.1",
+ org.apache.commons.httpclient.server
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/Rest API Test.launch b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/Rest API Test.launch
new file mode 100644
index 000000000..a8ea1448c
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/Rest API Test.launch
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
+<booleanAttribute key="append.args" value="true"/>
+<stringAttribute key="application" value="org.eclipse.pde.junit.runtime.coretestapplication"/>
+<booleanAttribute key="askclear" value="false"/>
+<booleanAttribute key="automaticAdd" value="false"/>
+<booleanAttribute key="automaticValidate" value="true"/>
+<stringAttribute key="bootstrap" value=""/>
+<stringAttribute key="checked" value="[NONE]"/>
+<booleanAttribute key="clearConfig" value="true"/>
+<booleanAttribute key="clearws" value="true"/>
+<booleanAttribute key="clearwslog" value="false"/>
+<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/pde-junit"/>
+<booleanAttribute key="default" value="false"/>
+<booleanAttribute key="includeOptional" value="true"/>
+<stringAttribute key="location" value="${workspace_loc}/../junit-workspace"/>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/org.eclipse.ecf.tests.remoteservice.rest"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="4"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
+<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
+<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=org.eclipse.ecf.tests.remoteservice.rest"/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit3"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.ecf.tests.remoteservice.rest"/>
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
+<stringAttribute key="pde.version" value="3.3"/>
+<stringAttribute key="product" value="org.eclipse.equinox.p2.director.app.product"/>
+<booleanAttribute key="run_in_ui_thread" value="true"/>
+<stringAttribute key="selected_target_plugins" value="org.apache.lucene.analysis@default:default,org.eclipse.team.cvs.core@default:default,org.eclipse.jdt.core@default:default,org.eclipse.text@default:default,org.apache.jasper@default:default,org.eclipse.pde.build@default:default,org.eclipse.equinox.p2.directorywatcher@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.runtime.compatibility@default:default,org.eclipse.equinox.p2.jarprocessor@default:default,org.eclipse.equinox.simpleconfigurator@1:true,org.eclipse.equinox.p2.updatechecker@default:default,org.eclipse.ui.navigator@default:default,org.eclipse.ant.core@default:default,org.eclipse.core.net.linux.x86@default:false,org.eclipse.compare@default:default,org.eclipse.core.databinding@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.team.cvs.ssh2@default:default,javax.servlet@default:default,org.eclipse.core.databinding.beans@default:default,org.mortbay.jetty.server@default:default,org.eclipse.equinox.simpleconfigurator.manipulator@default:default,org.eclipse.help.base@default:default,org.eclipse.ui.views.log@default:default,org.eclipse.equinox.http.registry@default:default,org.eclipse.ui.console@default:default,org.eclipse.jdt.debug.ui@default:default,org.apache.commons.lang*2.3.0.v200803061910@default:default,org.eclipse.equinox.p2.console@default:default,org.eclipse.jdt.core.manipulation@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.update.core.linux@default:false,org.hamcrest.core@default:default,org.eclipse.ui.externaltools@default:default,org.eclipse.equinox.p2.ui@default:default,org.eclipse.core.variables@default:default,org.eclipse.equinox.p2.exemplarysetup@default:default,org.apache.commons.logging@default:default,org.eclipse.ui.cheatsheets@default:default,org.eclipse.jdt.junit@default:default,org.eclipse.ui.navigator.resources@default:default,javax.xml@default:default,org.eclipse.core.resources@default:default,org.eclipse.equinox.p2.metadata.generator@default:default,org.eclipse.jdt.apt.pluggable.core@default:default,org.eclipse.update.ui@default:default,org.eclipse.jdt.doc.user@default:default,org.eclipse.search@default:default,org.eclipse.debug.core@default:default,org.eclipse.equinox.p2.publisher@default:default,org.eclipse.core.resources.compatibility@default:false,org.eclipse.core.databinding.observable@default:default,org.eclipse.equinox.p2.director.app@default:default,org.eclipse.core.runtime.compatibility.auth@default:default,com.jcraft.jsch@default:default,org.apache.commons.codec@default:default,org.eclipse.update.scheduler@default:default,org.eclipse.pde.runtime@default:default,org.sat4j.pb@default:default,org.eclipse.help.webapp@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.team.core@default:default,org.eclipse.help.ui@default:default,org.eclipse.pde@default:default,org.mortbay.jetty.util@default:default,org.eclipse.ui.workbench.texteditor@default:default,org.eclipse.equinox.util@default:default,org.eclipse.jdt.junit.runtime@default:default,org.eclipse.core.expressions@default:default,org.apache.lucene@default:default,org.eclipse.core.runtime@default:true,org.eclipse.jdt.doc.isv@default:default,org.eclipse.equinox.p2.extensionlocation@default:default,org.eclipse.ui.presentations.r21@default:default,org.eclipse.swt.gtk.linux.x86@default:false,org.eclipse.equinox.p2.repository@default:default,org.eclipse.jdt.ui@default:default,org.objectweb.asm@default:default,javax.transaction@default:false,org.eclipse.equinox.common@2:true,org.eclipse.ui.ide@default:default,org.eclipse.jface.text@default:default,org.eclipse.ecf.ssl@default:false,org.eclipse.equinox.jsp.jasper@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.ecf.provider.remoteservice@default:default,org.eclipse.ecf.identity@default:default,org.eclipse.pde.ui@default:default,org.eclipse.jsch.ui@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.osgi@-1:true,org.junit@default:default,org.eclipse.cvs@default:default,org.eclipse.ui.browser@default:default,org.apache.commons.el@default:default,org.eclipse.ui.net@default:default,org.eclipse.team.ui@default:default,org.eclipse.equinox.launcher.gtk.linux.x86@default:false,org.eclipse.ui.intro@default:default,org.eclipse.jdt.debug@default:default,org.sat4j.core@default:default,org.eclipse.help.appserver@default:default,org.eclipse.jdt.compiler.tool@default:false,org.eclipse.jdt.launching@default:default,org.eclipse.ltk.ui.refactoring@default:default,org.eclipse.ecf.provider@default:default,org.eclipse.pde.ua.ui@default:default,org.eclipse.rcp@default:default,org.eclipse.jsch.core@default:default,org.eclipse.update.configurator@3:true,org.eclipse.pde.core@default:default,org.eclipse.ui@default:default,org.eclipse.ui.ide.application@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.jdt.apt.ui@default:default,org.eclipse.persistence.jpa.equinox.weaving@default:false,org.eclipse.update.core@default:default,org.eclipse.equinox.http.servlet@default:default,org.eclipse.osgi.services@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.jdt@default:default,org.eclipse.jdt.compiler.apt@default:false,org.eclipse.equinox.security.ui@default:default,org.eclipse.ui.views@default:default,org.eclipse.pde.api.tools@default:default,org.eclipse.pde.api.tools.ui@default:default,org.eclipse.equinox.launcher@default:default,org.eclipse.core.jobs@default:default,org.eclipse.jdt.apt.core@default:default,org.eclipse.ui.forms@default:default,org.eclipse.pde.doc.user@default:default,org.eclipse.equinox.frameworkadmin.equinox@default:default,org.eclipse.ltk.core.refactoring@default:default,org.eclipse.ui.intro.universal@default:default,org.eclipse.ecf.sharedobject@default:default,org.eclipse.ui.editors@default:default,org.eclipse.debug.ui@default:default,org.eclipse.osgi.util@default:default,org.eclipse.pde.ds.core@default:default,org.eclipse.pde.ds.ui@default:default,org.eclipse.equinox.jsp.jasper.registry@default:default,org.eclipse.jdt.junit4.runtime@default:default,org.eclipse.ecf.server.generic@default:default,org.eclipse.swt@default:default,org.eclipse.pde.junit.runtime@default:default,org.eclipse.equinox.p2.repository.tools@default:default,org.eclipse.equinox.p2.reconciler.dropins@default:default,org.eclipse.ecf@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.filesystem@default:default,org.eclipse.core.boot@default:default,org.apache.ant@default:default,org.apache.commons.httpclient@default:default,org.eclipse.equinox.p2.updatesite@default:default,com.ibm.icu@default:default,org.eclipse.ant.ui@default:default,org.eclipse.core.filebuffers@default:default,org.eclipse.equinox.p2.director@default:default,org.eclipse.equinox.p2.ui.sdk.scheduler@default:default,org.eclipse.core.databinding.property@default:default,org.junit4@default:default,org.eclipse.team.cvs.ui@default:default,org.eclipse.pde.ua.core@default:default,org.apache.commons.lang*2.4.0.v20081016-1030@default:default,org.eclipse.equinox.p2.garbagecollector@default:default,org.eclipse.equinox.concurrent@default:default,org.eclipse.ui.workbench.compatibility@default:false,org.eclipse.jface@default:default,org.eclipse.equinox.p2.ui.sdk@default:default,org.eclipse.equinox.p2.touchpoint.eclipse@default:default,org.eclipse.equinox.app@default:default,org.eclipse.platform.doc.user@default:default,org.eclipse.core.filesystem.linux.x86@default:false,org.eclipse.equinox.http.jetty@default:default,org.eclipse.core.net@default:default,org.eclipse.equinox.security@default:default,org.eclipse.platform.doc.isv@default:default,javax.servlet.jsp@default:default,org.eclipse.ecf.remoteservice@default:default,org.eclipse.team.cvs.ssh@default:default,org.eclipse.ui.views.properties.tabbed@default:default,org.eclipse.pde.ui.templates@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.help@default:default,org.eclipse.equinox.p2.core@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.ecf.discovery@default:default,org.eclipse.sdk@default:default,org.eclipse.platform@default:default,org.eclipse.equinox.p2.touchpoint.natives@default:default,org.eclipse.compare.core@default:default,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.p2.metadata.repository@default:default"/>
+<stringAttribute key="selected_workspace_plugins" value="org.eclipse.ecf.tests.remoteservice.rest@default:default,org.eclipse.ecf.remoteservice.rest.resource.json.jackson@default:true,org.json@default:default,org.eclipse.ecf.remoteservice.rest.resource.rss@default:true,org.eclipse.ecf.remoteservice.rest@default:default,org.eclipse.ecf.tests.remoteservice@default:default,org.eclipse.ecf.tests.apache.httpclient.server@default:default,org.codehaus.jackson@default:default,org.eclipse.ecf.remoteservice.rest.resource.json.org@default:true,com.springsource.org.apache.commons.logging@default:default,org.eclipse.ecf.tests@default:default"/>
+<booleanAttribute key="show_selected_only" value="false"/>
+<stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/>
+<booleanAttribute key="tracing" value="false"/>
+<booleanAttribute key="useDefaultConfig" value="true"/>
+<booleanAttribute key="useDefaultConfigArea" value="false"/>
+<booleanAttribute key="useProduct" value="false"/>
+</launchConfiguration>
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/build.properties b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/build.properties
new file mode 100644
index 000000000..01c615963
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestContainerInstantiatorTest.java b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestContainerInstantiatorTest.java
new file mode 100644
index 000000000..4ddb1dbce
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestContainerInstantiatorTest.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource and others. All rights reserved. This
+* program and the accompanying materials are made available under the terms of
+* the Eclipse Public License v1.0 which accompanies this distribution, and is
+* available at http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* EclipseSource - initial API and implementation
+*******************************************************************************/
+package org.eclipse.ecf.tests.remoteservice.rest;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.eclipse.ecf.core.ContainerCreateException;
+import org.eclipse.ecf.core.ContainerTypeDescription;
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.remoteservice.rest.RestContainer;
+import org.eclipse.ecf.remoteservice.rest.RestContainerInstantiatior;
+
+public class RestContainerInstantiatorTest extends TestCase {
+ private RestContainerInstantiatior instantiator;
+ private ContainerTypeDescription description;
+
+ protected void setUp() throws Exception {
+ instantiator = new RestContainerInstantiatior();
+ description = new ContainerTypeDescription(RestContainer.NAME, instantiator, null);
+ }
+
+ public void testSupportedParameterTypes() {
+ Class[][] types = instantiator.getSupportedParameterTypes(description);
+ assertEquals(types.length, 1);
+ assertEquals(types[0].length, 1);
+ Class supportedType = types[0][0];
+ assertEquals(URL.class, supportedType);
+ }
+
+ public void testCreateInstance() {
+ try {
+ IContainer container = instantiator.createInstance(description, new Object[]{new URL("http://test.de")});
+ assertTrue(container instanceof RestContainer);
+ ID connectedID = container.getConnectedID();
+ assertNull(connectedID);
+ URL baseUrl = new URL("http://www.twitter.com");
+ container = instantiator.createInstance(description, new Object[]{baseUrl});
+ assertTrue(container instanceof RestContainer);
+ } catch (ContainerCreateException e) {
+ fail();
+ } catch (MalformedURLException e) {
+ fail();
+ }
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestContainerTest.java b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestContainerTest.java
new file mode 100644
index 000000000..f2f15990e
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestContainerTest.java
@@ -0,0 +1,188 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource and others. All rights reserved. This
+* program and the accompanying materials are made available under the terms of
+* the Eclipse Public License v1.0 which accompanies this distribution, and is
+* available at http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* EclipseSource - initial API and implementation
+*******************************************************************************/
+package org.eclipse.ecf.tests.remoteservice.rest;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import junit.framework.TestCase;
+
+import org.eclipse.ecf.core.ContainerConnectException;
+import org.eclipse.ecf.core.ContainerCreateException;
+import org.eclipse.ecf.core.ContainerFactory;
+import org.eclipse.ecf.core.ContainerTypeDescription;
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.core.IContainerListener;
+import org.eclipse.ecf.core.events.IContainerDisconnectedEvent;
+import org.eclipse.ecf.core.events.IContainerDisconnectingEvent;
+import org.eclipse.ecf.core.events.IContainerDisposeEvent;
+import org.eclipse.ecf.core.events.IContainerEvent;
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.core.identity.IDCreateException;
+import org.eclipse.ecf.core.identity.Namespace;
+import org.eclipse.ecf.remoteservice.IRemoteService;
+import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter;
+import org.eclipse.ecf.remoteservice.IRemoteServiceRegistration;
+import org.eclipse.ecf.remoteservice.rest.RestContainer;
+import org.eclipse.ecf.remoteservice.rest.RestContainerInstantiatior;
+import org.eclipse.ecf.remoteservice.rest.RestService;
+import org.eclipse.ecf.remoteservice.rest.identity.RestID;
+import org.eclipse.ecf.remoteservice.rest.identity.RestNamespace;
+
+public class RestContainerTest extends TestCase {
+
+ private RestContainer container;
+
+ protected void setUp() throws Exception {
+ container = ( RestContainer ) createRestContainer();
+ }
+
+ protected void tearDown() throws Exception {
+ container.disconnect();
+ container.dispose();
+ container = null;
+ }
+
+ public void testContainerCreation() {
+ IContainer container = createRestContainer();
+ assertNotNull(container);
+ }
+
+ public void testContainerCreation2() {
+ RestNamespace namespace = new RestNamespace(RestNamespace.NAME, "desc");
+ try {
+ IContainer container = ContainerFactory.getDefault().createContainer(new RestID(namespace, new URL("http://www.twitter.com")));
+ assertNotNull(container);
+ } catch (ContainerCreateException e) {
+ e.printStackTrace();
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void testRegisterService() {
+ IContainer container = createRestContainer();
+ assertTrue(container instanceof IRemoteServiceContainerAdapter);
+ IRemoteServiceContainerAdapter adapter = (IRemoteServiceContainerAdapter) container;
+ String[] clazzes = new String[] {IRemoteService.class.getName()};
+ RestService service = createRestService();
+ Dictionary properties = new Hashtable();
+ properties.put("user", "null");
+ IRemoteServiceRegistration registration = adapter.registerRemoteService(clazzes, service, properties);
+ assertNotNull(registration);
+ }
+
+ public void testConnect() {
+ RestNamespace namespace = new RestNamespace(RestNamespace.NAME, null);
+ ID id;
+ try {
+ id = namespace.createInstance(new Object[]{new URL("http://test.de")});
+ assertNotNull(id);
+ container.connect(id, null);
+ Namespace connectNamespace = container.getConnectNamespace();
+ assertEquals(namespace, connectNamespace);
+ } catch (IDCreateException e) {
+ fail();
+ } catch (MalformedURLException e) {
+ fail();
+ } catch (ContainerConnectException e) {
+ fail();
+ }
+ }
+
+ public void testGetId() {
+ ID id = container.getID();
+ assertNotNull(id);
+ Namespace namespace = new RestNamespace(RestNamespace.NAME, null);
+ try {
+ ContainerTypeDescription desc = new ContainerTypeDescription(RestContainer.NAME, new RestContainerInstantiatior(), null);
+ id = new RestID(namespace, new URL("http://test.de"));
+ container = (RestContainer) ContainerFactory.getDefault().createContainer(desc, id);
+ ID id2 = container.getID();
+ assertEquals(id, id2);
+ } catch (ContainerCreateException e) {
+ fail();
+ } catch (MalformedURLException e) {
+ fail();
+ }
+ }
+
+ public void testGetRemoteServiceNamespace() {
+ Namespace namespace = new RestNamespace(RestNamespace.NAME, null);
+ try {
+ ContainerTypeDescription desc = new ContainerTypeDescription(RestContainer.NAME, new RestContainerInstantiatior(), null);
+ ID id = new RestID(namespace, new URL("http://test.de"));
+ container = (RestContainer) ContainerFactory.getDefault().createContainer(desc, id);
+ Namespace remoteServiceNamespace = container.getRemoteServiceNamespace();
+ assertEquals(namespace, remoteServiceNamespace);
+ } catch (ContainerCreateException e) {
+ fail();
+ } catch (MalformedURLException e) {
+ fail();
+ }
+ }
+
+ public void testGetContainer() {
+ IContainer container2 = container.getContainer();
+ assertEquals(container, container2);
+ }
+
+ public void testGetContainerAdapter() {
+ IRemoteServiceContainerAdapter containerAdapter = container.getContainerAdapter();
+ assertEquals(container, containerAdapter);
+ }
+
+ public void testDispose() {
+ Namespace namespace = new RestNamespace(RestNamespace.NAME, null);
+ try {
+ RestID id = new RestID(namespace, new URL("http://test.de"));
+ container.connect(id, null);
+ assertEquals(id, container.getConnectedID());
+ container.addListener(new IContainerListener() {
+ public void handleEvent(IContainerEvent event) {
+ assertTrue(event instanceof IContainerDisposeEvent
+ || event instanceof IContainerDisconnectingEvent
+ || event instanceof IContainerDisconnectedEvent);
+ }
+ });
+ container.dispose();
+ assertNull(container.getConnectedID());
+ } catch (ContainerConnectException e) {
+ fail();
+ } catch (MalformedURLException e) {
+ fail();
+ }
+ }
+
+
+
+ private RestService createRestService() {
+ return new RestService();
+ }
+
+ static IContainer createRestContainer() {
+ IContainer container = null;
+ try {
+ Namespace namespace = new RestNamespace(RestNamespace.NAME, null);
+ ID id = namespace.createInstance(new Object[]{new URL("http://www.test.de")});;
+ container = ContainerFactory.getDefault().createContainer(RestContainer.NAME, id);
+ } catch (ContainerCreateException e) {
+ e.printStackTrace();
+ } catch (IDCreateException e) {
+ e.printStackTrace();
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ return container;
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestIDTest.java b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestIDTest.java
new file mode 100644
index 000000000..76a91d993
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestIDTest.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource and others. All rights reserved. This
+* program and the accompanying materials are made available under the terms of
+* the Eclipse Public License v1.0 which accompanies this distribution, and is
+* available at http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* EclipseSource - initial API and implementation
+*******************************************************************************/
+package org.eclipse.ecf.tests.remoteservice.rest;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.eclipse.ecf.remoteservice.rest.identity.RestID;
+import org.eclipse.ecf.remoteservice.rest.identity.RestNamespace;
+
+public class RestIDTest extends TestCase {
+
+ public void testCompareToNamespace() {
+ RestNamespace namespace = new RestNamespace(RestNamespace.NAME, null);
+ try {
+ RestID id = new RestID(namespace, new URL("http://www.twitter.com"));
+ RestID id2 = new RestID(namespace, new URL("http://www.eclipse.org"));
+ int comparedId = id.namespaceCompareTo(id2);
+ int comparedId2 = id2.namespaceCompareTo(id);
+ assertEquals(comparedId, comparedId2);
+ } catch (MalformedURLException e) {
+ fail();
+ }
+ }
+
+ public void testNamespaceEquals() {
+ RestNamespace namespace = new RestNamespace(RestNamespace.NAME, null);
+ try {
+ RestID id = new RestID(namespace, new URL("http://www.twitter.com"));
+ RestID id2 = new RestID(namespace, new URL("http://www.eclipse.org"));
+ assertFalse(id.namespaceEquals(id2));
+ assertFalse(id2.namespaceEquals(id));
+ id2 = new RestID(namespace, new URL("http://www.twitter.com"));
+ assertTrue(id.namespaceEquals(id2));
+ assertTrue(id2.namespaceEquals(id));
+ } catch (MalformedURLException e) {
+ fail();
+ }
+ }
+
+ public void testNamespaceGetName() {
+ RestNamespace namespace = new RestNamespace(RestNamespace.NAME, null);
+ try {
+ String url = "http://www.twitter.com";
+ RestID id = new RestID(namespace, new URL(url));
+ assertEquals(url, id.namespaceGetName());
+ } catch (MalformedURLException e) {
+ fail();
+ }
+ }
+
+ public void testNamespaceHashCode() {
+ RestNamespace namespace = new RestNamespace(RestNamespace.NAME, null);
+ try {
+ RestID id = new RestID(namespace, new URL("http://www.twitter.com"));
+ RestID id2 = new RestID(namespace, new URL("http://www.eclipse.org"));
+ int hash1 = id.namespaceHashCode();
+ int hash2 = id2.namespaceHashCode();
+ assertFalse(hash1 == hash2);
+ id2 = new RestID(namespace, new URL("http://www.twitter.com"));
+ hash2 = id2.namespaceHashCode();
+ assertEquals(hash1, hash2);
+ } catch (MalformedURLException e) {
+ fail();
+ }
+ }
+
+ public void testGetBaseUrl() {
+ RestNamespace namespace = new RestNamespace(RestNamespace.NAME, null);
+ try {
+ String baseUrl = "http://www.twitter.com";
+ RestID id = new RestID(namespace, new URL(baseUrl));
+ URL url = id.getBaseURL();
+ assertEquals(new URL(baseUrl), url);
+ } catch (MalformedURLException e) {
+ fail();
+ }
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestNamespaceTest.java b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestNamespaceTest.java
new file mode 100644
index 000000000..b067c6a49
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestNamespaceTest.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource and others. All rights reserved. This
+* program and the accompanying materials are made available under the terms of
+* the Eclipse Public License v1.0 which accompanies this distribution, and is
+* available at http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* EclipseSource - initial API and implementation
+*******************************************************************************/
+package org.eclipse.ecf.tests.remoteservice.rest;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.eclipse.ecf.core.identity.ID;
+import org.eclipse.ecf.remoteservice.rest.identity.RestNamespace;
+
+public class RestNamespaceTest extends TestCase {
+
+ public void testCreation() {
+ String desc = "description";
+ RestNamespace namespace = new RestNamespace(RestNamespace.NAME, desc);
+ assertEquals(RestNamespace.NAME, namespace.getName());
+ assertEquals(desc, namespace.getDescription());
+ }
+
+ public void testCreateInstance() {
+ RestNamespace namespace = new RestNamespace(RestNamespace.NAME, null);
+ Object[] parameters;
+ try {
+ String url = "http://www.twitter.com";
+ parameters = new Object[] {new URL(url)};
+ ID id = namespace.createInstance(parameters);
+ assertEquals(url, id.getName());
+ } catch (MalformedURLException e) {
+ fail();
+ }
+ }
+
+ public void testGetScheme() {
+ RestNamespace namespace = new RestNamespace(RestNamespace.NAME, null);
+ assertEquals(RestNamespace.SCHEME, namespace.getScheme());
+ }
+
+ public void testGetSupportedParameterTypes() {
+ RestNamespace namespace = new RestNamespace(RestNamespace.NAME, null);
+ Class[][] types = namespace.getSupportedParameterTypes();
+ assertEquals(types.length, 1);
+ assertEquals(types[0].length, 1);
+ Class supportedType = types[0][0];
+ assertEquals(URL.class, supportedType);
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestRemoteServiceAdapterTest.java b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestRemoteServiceAdapterTest.java
new file mode 100644
index 000000000..23c1a0267
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestRemoteServiceAdapterTest.java
@@ -0,0 +1,106 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource and others. All rights reserved. This
+* program and the accompanying materials are made available under the terms of
+* the Eclipse Public License v1.0 which accompanies this distribution, and is
+* available at http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* EclipseSource - initial API and implementation
+*******************************************************************************/
+package org.eclipse.ecf.tests.remoteservice.rest;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import junit.framework.TestCase;
+
+import org.eclipse.ecf.remoteservice.Constants;
+import org.eclipse.ecf.remoteservice.IRemoteFilter;
+import org.eclipse.ecf.remoteservice.IRemoteService;
+import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter;
+import org.eclipse.ecf.remoteservice.IRemoteServiceID;
+import org.eclipse.ecf.remoteservice.IRemoteServiceListener;
+import org.eclipse.ecf.remoteservice.IRemoteServiceReference;
+import org.eclipse.ecf.remoteservice.IRemoteServiceRegistration;
+import org.eclipse.ecf.remoteservice.events.IRemoteServiceEvent;
+import org.eclipse.ecf.remoteservice.events.IRemoteServiceRegisteredEvent;
+import org.eclipse.ecf.remoteservice.rest.RestContainer;
+import org.eclipse.ecf.remoteservice.rest.RestService;
+import org.eclipse.ecf.remoteservice.rest.RestServiceRegistration;
+import org.osgi.framework.InvalidSyntaxException;
+
+public class RestRemoteServiceAdapterTest extends TestCase {
+
+ private IRemoteServiceRegistration registration;
+ private RestContainer container;
+
+ protected void setUp() throws Exception {
+ registration = getServiceRegistration();
+ }
+
+ protected void tearDown() throws Exception {
+ registration = null;
+ }
+
+ public void testGetRemoteService() {
+ IRemoteServiceReference reference = registration.getReference();
+ IRemoteService remoteService = ((IRemoteServiceContainerAdapter)container).getRemoteService(reference);
+ RestServiceRegistration reg = (RestServiceRegistration)registration;
+ assertEquals(reg.getService(), remoteService);
+ }
+
+ public void testGetRemoteServiceReference() {
+ IRemoteServiceReference remoteServiceReference = container.getRemoteServiceReference(registration.getID());
+ assertEquals(registration.getReference(), remoteServiceReference);
+ }
+
+ public void testUngetRemoteService() {
+ container.getRemoteService(registration.getReference());
+ assertTrue(container.ungetRemoteService(registration.getReference()));
+ }
+
+ public void testRemoteServiceRegisteredEvent() {
+ container.addRemoteServiceListener(new IRemoteServiceListener() {
+
+ public void handleServiceEvent(IRemoteServiceEvent event) {
+ assertTrue(event instanceof IRemoteServiceRegisteredEvent);
+ }
+ });
+ String[] clazzes = new String[] {IRemoteService.class.getName()};
+ RestService service = new RestService();
+ Dictionary properties = new Hashtable();
+ properties.put("user", "null");
+ container.registerRemoteService(clazzes, service, properties);
+
+ }
+
+ public void testCreateRemoteFilter() {
+ String filter = "(" + Constants.OBJECTCLASS + "=" + IRemoteService.class.getName() + ")";
+ try {
+ IRemoteFilter remoteFilter = container.createRemoteFilter(filter);
+ assertNotNull(remoteFilter);
+ } catch (InvalidSyntaxException e) {
+ fail();
+ }
+ }
+
+ public void testGetRemoteServiceID() {
+ long containerRelativeID = registration.getID().getContainerRelativeID();
+ IRemoteServiceID remoteServiceID = container.getRemoteServiceID(container.getID(), containerRelativeID);
+ assertEquals(registration.getID(), remoteServiceID);
+ }
+
+
+
+
+ private IRemoteServiceRegistration getServiceRegistration() {
+ container = (RestContainer)RestContainerTest.createRestContainer();
+ IRemoteServiceContainerAdapter adapter = (IRemoteServiceContainerAdapter) container;
+ String[] clazzes = new String[] {IRemoteService.class.getName()};
+ RestService service = new RestService();
+ Dictionary properties = new Hashtable();
+ properties.put("user", "null");
+ return adapter.registerRemoteService(clazzes, service, properties);
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestRemoteServiceContainerTest.java b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestRemoteServiceContainerTest.java
new file mode 100644
index 000000000..d89bdc80e
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestRemoteServiceContainerTest.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource and others. All rights reserved. This
+* program and the accompanying materials are made available under the terms of
+* the Eclipse Public License v1.0 which accompanies this distribution, and is
+* available at http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* EclipseSource - initial API and implementation
+*******************************************************************************/
+package org.eclipse.ecf.tests.remoteservice.rest;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import junit.framework.TestCase;
+
+import org.eclipse.ecf.core.ContainerConnectException;
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.remoteservice.IRemoteService;
+import org.eclipse.ecf.remoteservice.IRemoteServiceContainer;
+import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter;
+import org.eclipse.ecf.remoteservice.IRemoteServiceRegistration;
+import org.eclipse.ecf.remoteservice.rest.RestService;
+import org.eclipse.ecf.remoteservice.rest.RestServiceRegistration;
+
+public class RestRemoteServiceContainerTest extends TestCase {
+
+ private IRemoteServiceContainer container;
+
+ protected void setUp() throws Exception {
+ if(container == null) {
+ createRemoteServiceContainer();
+ }
+ }
+
+ public void testCreation(){
+ assertNotNull(container);
+ }
+
+ public void testGetRemoteServiceContainerAdapter(){
+ IRemoteServiceContainerAdapter containerAdapter = container.getContainerAdapter();
+ assertEquals(container, containerAdapter);
+ }
+
+ public void testGetContainer(){
+ IContainer iContainer = container.getContainer();
+ assertEquals(container, iContainer);
+ }
+
+ public void testGetRemoteService(){
+ IRemoteService remoteService = container.getRemoteService(IRemoteService.class.getName());
+ assertNull(remoteService);
+
+ IRemoteServiceContainerAdapter adapter = container.getContainerAdapter();
+ String[] clazzes = new String[] {IRemoteService.class.getName()};
+ RestService service = new RestService();
+ Dictionary properties = new Hashtable();
+ properties.put("user", "null");
+ IRemoteServiceRegistration registration = adapter.registerRemoteService(clazzes, service, properties);
+ assertNotNull(registration);
+
+ remoteService = container.getRemoteService(IRemoteService.class.getName());
+ assertNotNull(remoteService);
+ assertTrue(registration instanceof RestServiceRegistration);
+ RestServiceRegistration restRegistration = (RestServiceRegistration)registration;
+ assertEquals(restRegistration.getService(), remoteService);
+ }
+
+ public void testGetRemoteServiceWithIDFilter() {
+ IRemoteService remoteService = container.getRemoteService(IRemoteService.class.getName());
+ assertNull(remoteService);
+
+ IRemoteServiceContainerAdapter adapter = container.getContainerAdapter();
+ String[] clazzes = new String[] {IRemoteService.class.getName()};
+ RestService service = new RestService();
+ Dictionary properties = new Hashtable();
+ properties.put("user", "null");
+ IRemoteServiceRegistration registration = adapter.registerRemoteService(clazzes, service, properties);
+ assertNotNull(registration);
+
+ try {
+ remoteService = container.getRemoteService(null, IRemoteService.class.getName());
+ } catch (ContainerConnectException e) {
+ e.printStackTrace();
+ }
+ assertNotNull(remoteService);
+ assertTrue(registration instanceof RestServiceRegistration);
+ RestServiceRegistration restRegistration = (RestServiceRegistration)registration;
+ assertEquals(restRegistration.getService(), remoteService);
+
+ }
+
+ private void createRemoteServiceContainer() {
+ IContainer restContainer = RestContainerTest.createRestContainer();
+ if(restContainer instanceof IRemoteServiceContainer)
+ container = (IRemoteServiceContainer)restContainer;
+ }
+
+
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestRemoteServiceTest.java b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestRemoteServiceTest.java
new file mode 100644
index 000000000..399f6bd03
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestRemoteServiceTest.java
@@ -0,0 +1,96 @@
+/*******************************************************************************
+ * Copyright (c) 2009 EclipseSource and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * EclipseSource - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ecf.tests.remoteservice.rest;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.ecf.core.util.ECFException;
+import org.eclipse.ecf.remoteservice.IRemoteCallListener;
+import org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent;
+import org.eclipse.ecf.remoteservice.events.IRemoteCallEvent;
+import org.eclipse.ecf.remoteservice.rest.IRestCall;
+import org.eclipse.ecf.remoteservice.rest.RestService;
+import org.eclipse.ecf.remoteservice.rest.util.RestCallFactory;
+import org.eclipse.ecf.tests.remoteservice.rest.service.SimpleRestService;
+import org.eclipse.equinox.concurrent.future.IFuture;
+import org.w3c.dom.Document;
+
+public class RestRemoteServiceTest extends TestCase {
+
+ private SimpleRestService service;
+
+ protected void setUp() throws Exception {
+ if (service == null) {
+ service = new SimpleRestService();
+ }
+ }
+
+ protected void tearDown() throws Exception {
+ service.shutdown();
+ }
+
+ public void testServiceCreation() {
+ RestService restService = new RestService();
+ assertNotNull(restService);
+ }
+
+ public void testSyncCall() {
+ RestService restService = new RestService();
+ try {
+ Object result = restService.callSync(getRestXMLCall());
+ assertNotNull(result);
+ } catch (ECFException e) {
+ fail("Could not contact the service");
+ }
+ }
+
+ public void testAsynCall() {
+ RestService restService = new RestService();
+ IFuture future = restService.callAsync(getRestXMLCall());
+ try {
+ Object response = future.get();
+ assertTrue(response instanceof Document);
+ } catch (OperationCanceledException e) {
+ fail(e.getMessage());
+ } catch (InterruptedException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ public void testAsyncCallWithListener() {
+ RestService restService = new RestService();
+ restService.callAsync(getRestXMLCall(), new IRemoteCallListener() {
+ public void handleEvent(IRemoteCallEvent event) {
+ if (event instanceof IRemoteCallCompleteEvent) {
+ // TODO: test async
+ // assertEquals(SimpleRestService.XML_RESPONSE,
+ // completeEvent.getResponse());
+ }
+ }
+ });
+
+ }
+
+ private IRestCall getRestXMLCall() {
+ try {
+ return RestCallFactory.createRestCall(IRestCall.HTTP_GET, new URI(
+ service.getServerUrl() + "/test.xml"),
+ "ecf.rest.resource.xml", null, 10000);
+ } catch (URISyntaxException e) {
+ fail();
+ }
+ return null;
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestResourceTest.java b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestResourceTest.java
new file mode 100644
index 000000000..eb10a179c
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestResourceTest.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource and others. All rights reserved. This
+* program and the accompanying materials are made available under the terms of
+* the Eclipse Public License v1.0 which accompanies this distribution, and is
+* available at http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* EclipseSource - initial API and implementation
+*******************************************************************************/
+package org.eclipse.ecf.tests.remoteservice.rest;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.ecf.internal.remoteservice.rest.ResourceRepresentationFactory;
+
+public class RestResourceTest extends TestCase {
+
+ private ResourceRepresentationFactory resourceFactory;
+
+ protected void setUp() throws Exception {
+ resourceFactory = ResourceRepresentationFactory.getDefault();
+ }
+
+ public void testCreation() {
+ assertNotNull(resourceFactory);
+ }
+
+ public void testResourceCreation() {
+ Object adapter = resourceFactory.getAdapter(List.class);
+ assertTrue(adapter instanceof List);
+ List resources = (List) adapter;
+ assertTrue(resources.size()>=1);
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestServiceRegistrationTest.java b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestServiceRegistrationTest.java
new file mode 100644
index 000000000..be0fdeb8a
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/RestServiceRegistrationTest.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource and others. All rights reserved. This
+* program and the accompanying materials are made available under the terms of
+* the Eclipse Public License v1.0 which accompanies this distribution, and is
+* available at http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* EclipseSource - initial API and implementation
+*******************************************************************************/
+package org.eclipse.ecf.tests.remoteservice.rest;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import junit.framework.TestCase;
+
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.remoteservice.IRemoteService;
+import org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter;
+import org.eclipse.ecf.remoteservice.IRemoteServiceID;
+import org.eclipse.ecf.remoteservice.IRemoteServiceRegistration;
+import org.eclipse.ecf.remoteservice.rest.RestService;
+import org.eclipse.ecf.remoteservice.rest.identity.RestID;
+
+public class RestServiceRegistrationTest extends TestCase {
+
+ private IRemoteServiceRegistration registration;
+ private IContainer container;
+
+ protected void setUp() throws Exception {
+ registration = getServiceRegistration();
+ }
+
+ protected void tearDown() throws Exception {
+ registration = null;
+ }
+
+ public void testCreateServiceRegistration() {
+ assertNotNull(registration);
+ }
+
+ public void testGetProperty() {
+ Object property = registration.getProperty("user");
+ assertTrue(property instanceof String);
+ String prop = (String) property;
+ assertEquals("null", prop);
+ }
+
+ public void testGetPropertyKeys() {
+ String[] keys = registration.getPropertyKeys();
+ assertEquals(1, keys.length);
+ assertEquals(keys[0], "user");
+ }
+
+ public void testSetProperties() {
+ Dictionary properties = new Hashtable();
+ properties.put("user", "holger");
+ properties.put("pass", "null");
+ Object property = registration.getProperty("user");
+ assertEquals("null", property);
+ registration.setProperties(properties);
+ property = registration.getProperty("user");
+ assertEquals("holger", property);
+ }
+
+ public void testGetId() {
+ IRemoteServiceID id = registration.getID();
+ assertTrue(id instanceof RestID);
+ assertEquals(container.getID(), id.getContainerID());
+ }
+
+ public void testGetContainerId() {
+ assertEquals(container.getID(), registration.getContainerID());
+ }
+
+
+
+
+
+ private IRemoteServiceRegistration getServiceRegistration() {
+ container = RestContainerTest.createRestContainer();
+ IRemoteServiceContainerAdapter adapter = (IRemoteServiceContainerAdapter) container;
+ String[] clazzes = new String[] {IRemoteService.class.getName()};
+ RestService service = new RestService();
+ Dictionary properties = new Hashtable();
+ properties.put("user", "null");
+ return adapter.registerRemoteService(clazzes, service, properties);
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/service/RestServiceTest.java b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/service/RestServiceTest.java
new file mode 100644
index 000000000..8d28584b8
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/service/RestServiceTest.java
@@ -0,0 +1,155 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource and others. All rights reserved. This
+* program and the accompanying materials are made available under the terms of
+* the Eclipse Public License v1.0 which accompanies this distribution, and is
+* available at http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* EclipseSource - initial API and implementation
+*******************************************************************************/
+package org.eclipse.ecf.tests.remoteservice.rest.service;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.HttpMethodBase;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.NoHttpResponseException;
+import org.apache.commons.httpclient.server.SimpleHttpServer;
+
+
+public class RestServiceTest extends TestCase {
+
+ private SimpleRestService service;
+
+ protected void setUp() throws Exception {
+ if( service == null ) {
+ service = new SimpleRestService();
+ }
+ }
+
+ protected void tearDown() throws Exception {
+ service.shutdown();
+ }
+
+ public void testServerCreation() {
+ assertNotNull( service );
+ SimpleHttpServer server = service.getServer();
+ assertNotNull( server );
+ assertTrue( server.isRunning() );
+ }
+
+ public void testStart() {
+ SimpleHttpServer server = service.getServer();
+ assertNotNull( server );
+ service.run();
+ assertTrue( server.isRunning() );
+ }
+
+ public void testStop() {
+ SimpleHttpServer server = service.getServer();
+ assertNotNull( server );
+ service.shutdown();
+ server = service.getServer();
+ assertNull( server );
+ }
+
+ public void testServerUrl() {
+ String url = service.getServerUrl();
+ assertEquals( "http://localhost:" + service.getServer().getLocalPort(), url );
+ }
+
+ public void testSimpleRequest() {
+ String serverUrl = service.getServerUrl();
+ HttpClient client = new HttpClient();
+ HttpMethod method = new HttpMethodBase( serverUrl + "/getTest" ) {
+ public String getName() {
+ return "GET";
+ }
+ };
+ int responseCode = 0;
+ try {
+ responseCode = client.executeMethod( method );
+ } catch( HttpException e ) {
+ e.printStackTrace();
+ } catch( IOException e ) {
+ e.printStackTrace();
+ }
+ assertEquals( HttpStatus.SC_OK, responseCode );
+ }
+
+ public void testXMLRequest() {
+ String serverUrl = service.getServerUrl();
+ HttpClient client = new HttpClient();
+ HttpMethod method = new HttpMethodBase( serverUrl+"/test.xml") {
+ public String getName() {
+ return "GET";
+ }
+ };
+ int responseCode = 0;
+ try {
+ responseCode = client.executeMethod(method);
+ } catch (HttpException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ assertEquals(HttpStatus.SC_OK, responseCode);
+ try {
+ String body = method.getResponseBodyAsString();
+ assertEquals(SimpleRestService.XML_RESPONSE, body);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("body was not set correctly");
+ }
+ }
+
+ public void testJsonResponse() {
+ String serverUrl = service.getServerUrl();
+ HttpClient client = new HttpClient();
+ HttpMethod method = new HttpMethodBase( serverUrl+"/test.json") {
+ public String getName() {
+ return "GET";
+ }
+ };
+ int responseCode = 0;
+ try {
+ responseCode = client.executeMethod(method);
+ } catch (HttpException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ assertEquals(HttpStatus.SC_OK, responseCode);
+ try {
+ String body = method.getResponseBodyAsString();
+ assertEquals(SimpleRestService.JSON_RESPONSE, body);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("body was not set correctly");
+ }
+ }
+
+ public void testPost() {
+ String serverUrl = service.getServerUrl();
+ HttpClient client = new HttpClient();
+ HttpMethod method = new HttpMethodBase( serverUrl+"/test.json") {
+ public String getName() {
+ return "POST";
+ }
+ };
+ try {
+ client.executeMethod(method);
+ } catch (HttpException e) {
+ e.printStackTrace();
+ fail();
+ } catch (IOException e) {
+ assertTrue(e instanceof NoHttpResponseException);
+ }
+ }
+
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/service/SimpleRestService.java b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/service/SimpleRestService.java
new file mode 100644
index 000000000..3ea6127c8
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.remoteservice.rest/src/org/eclipse/ecf/tests/remoteservice/rest/service/SimpleRestService.java
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2009 EclipseSource and others. All rights reserved. This
+ * program and the accompanying materials are made available under the terms of
+ * the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: EclipseSource - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.ecf.tests.remoteservice.rest.service;
+
+import java.io.IOException;
+
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.HttpVersion;
+import org.apache.commons.httpclient.server.HttpRequestHandler;
+import org.apache.commons.httpclient.server.SimpleHttpServer;
+import org.apache.commons.httpclient.server.SimpleHttpServerConnection;
+import org.apache.commons.httpclient.server.SimpleRequest;
+import org.apache.commons.httpclient.server.SimpleResponse;
+
+public class SimpleRestService {
+
+ public static final int PORT = 12550;
+ private SimpleHttpServer server;
+ private HttpRequestHandler reqHandler = new HttpRequestHandler() {
+
+ public boolean processRequest(SimpleHttpServerConnection conn, SimpleRequest request) throws IOException {
+ String uri = request.getRequestLine().getUri();
+ request.getBodyBytes();
+ boolean get = request.getRequestLine().getMethod().equals("GET");
+
+ if (uri.equals("/getTest") && get) {
+ // normal response
+ hookResponse(conn, "success");
+ return true;
+ } else if (uri.equals( "/test.xml") && get) {
+ // XML Response
+ hookResponse(conn, XML_RESPONSE);
+ return true;
+ } else if (uri.equals("/test.json") && get) {
+ // JSON Response
+ hookResponse(conn, JSON_RESPONSE);
+ return true;
+ }
+ return false;
+ }
+ };
+
+ public static final String XML_RESPONSE = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
+ "<root><aNode param=\"ok\"/></root>";
+ public static final String JSON_RESPONSE = "{\"aNode\":\"aValue\"}";
+
+ public SimpleRestService() {
+ run();
+ }
+
+ protected void hookResponse(SimpleHttpServerConnection conn, String body) throws IOException {
+ SimpleResponse res = new SimpleResponse();
+ res.setStatusLine(HttpVersion.HTTP_1_1, HttpStatus.SC_OK);
+ res.setBodyString(body);
+ conn.setKeepAlive(false);
+ conn.writeResponse(res);
+ }
+
+ public void shutdown() {
+ if (server != null) {
+ server.destroy();
+ server = null;
+ }
+ }
+
+ public void run() {
+ if (server == null) {
+ createServer();
+ } else {
+ if (!server.isRunning()) {
+ server.destroy();
+ server = null;
+ createServer();
+ }
+ }
+ }
+
+ private void createServer() {
+ try {
+ server = new SimpleHttpServer();
+ server.setRequestHandler(reqHandler);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public SimpleHttpServer getServer() {
+ return server;
+ }
+
+ public String getServerUrl() {
+ return "http://localhost:" + server.getLocalPort();
+ }
+}

Back to the top