You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lens.apache.org by am...@apache.org on 2015/02/09 05:44:53 UTC
incubator-lens git commit: LENS-276 : Add dependency required for
json response (Raju Bairishetti via amareshwari)
Repository: incubator-lens
Updated Branches:
refs/heads/master 1eb9b6150 -> 76fd84185
LENS-276 : Add dependency required for json response (Raju Bairishetti via amareshwari)
Project: http://git-wip-us.apache.org/repos/asf/incubator-lens/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-lens/commit/76fd8418
Tree: http://git-wip-us.apache.org/repos/asf/incubator-lens/tree/76fd8418
Diff: http://git-wip-us.apache.org/repos/asf/incubator-lens/diff/76fd8418
Branch: refs/heads/master
Commit: 76fd8418567b9f20a44620a528c8b987bc406070
Parents: 1eb9b61
Author: Amareshwari Sriramdasu <am...@inmobi.com>
Authored: Mon Feb 9 10:14:40 2015 +0530
Committer: Amareshwari Sriramdasu <am...@inmobi.com>
Committed: Mon Feb 9 10:14:40 2015 +0530
----------------------------------------------------------------------
lens-server/pom.xml | 4 +
.../src/main/webapp/static/js/models/session.js | 3 +
.../lens/server/ui/TestSessionUIResource.java | 136 +++++++++++++++++++
pom.xml | 5 +
4 files changed, 148 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/76fd8418/lens-server/pom.xml
----------------------------------------------------------------------
diff --git a/lens-server/pom.xml b/lens-server/pom.xml
index 048e42e..f119ef1 100644
--- a/lens-server/pom.xml
+++ b/lens-server/pom.xml
@@ -116,6 +116,10 @@
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.media</groupId>
+ <artifactId>jersey-media-moxy</artifactId>
+ </dependency>
<dependency>
<groupId>org.glassfish.grizzly</groupId>
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/76fd8418/lens-server/src/main/webapp/static/js/models/session.js
----------------------------------------------------------------------
diff --git a/lens-server/src/main/webapp/static/js/models/session.js b/lens-server/src/main/webapp/static/js/models/session.js
index 0fac8ec..5f916b7 100644
--- a/lens-server/src/main/webapp/static/js/models/session.js
+++ b/lens-server/src/main/webapp/static/js/models/session.js
@@ -49,6 +49,9 @@ var Session = function() {
url: util.SESSION_URL,
type: 'POST',
dataType: 'json',
+ headers: {
+ Accept : "application/json",
+ },
contentType: false,
processData: false,
cache: false,
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/76fd8418/lens-server/src/test/java/org/apache/lens/server/ui/TestSessionUIResource.java
----------------------------------------------------------------------
diff --git a/lens-server/src/test/java/org/apache/lens/server/ui/TestSessionUIResource.java b/lens-server/src/test/java/org/apache/lens/server/ui/TestSessionUIResource.java
new file mode 100644
index 0000000..02a6515
--- /dev/null
+++ b/lens-server/src/test/java/org/apache/lens/server/ui/TestSessionUIResource.java
@@ -0,0 +1,136 @@
+/**
+ * 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.lens.server.ui;
+
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.WebTarget;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.lens.api.LensConf;
+import org.apache.lens.api.LensSessionHandle;
+import org.apache.lens.server.LensJerseyTest;
+
+import org.glassfish.jersey.client.ClientConfig;
+import org.glassfish.jersey.media.multipart.FormDataBodyPart;
+import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
+import org.glassfish.jersey.media.multipart.FormDataMultiPart;
+import org.glassfish.jersey.media.multipart.MultiPartFeature;
+
+import org.testng.Assert;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+/**
+ * The Class TestSessionUIResource.
+ */
+@Test(groups = "unit-test")
+public class TestSessionUIResource extends LensJerseyTest {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.glassfish.jersey.test.JerseyTest#setUp()
+ */
+ @BeforeTest
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.glassfish.jersey.test.JerseyTest#tearDown()
+ */
+ @AfterTest
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.glassfish.jersey.test.JerseyTest#configure()
+ */
+ @Override
+ protected Application configure() {
+ return new UIApp();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.glassfish.jersey.test.JerseyTest#configureClient(org.glassfish.jersey.client.ClientConfig)
+ */
+ @Override
+ protected void configureClient(ClientConfig config) {
+ config.register(MultiPartFeature.class);
+ }
+
+ private FormDataMultiPart getMultiFormData(String username, String password) {
+ final FormDataMultiPart mp = new FormDataMultiPart();
+
+ mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("username").build(), username));
+ mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("password").build(), password));
+ mp.bodyPart(new FormDataBodyPart(FormDataContentDisposition.name("sessionconf").fileName("sessionconf").build(),
+ new LensConf(), MediaType.APPLICATION_XML_TYPE));
+ return mp;
+ }
+
+ /**
+ * Test ui session
+ */
+ @Test
+ public void testUISession() {
+ final WebTarget target = target().path("uisession");
+ FormDataMultiPart mp = getMultiFormData("foo", "bar");
+
+ LensSessionHandle lensSessionHandle = target.request().post(
+ Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE), LensSessionHandle.class);
+ Assert.assertTrue(lensSessionHandle != null);
+
+ Response deleteResponse = target.path(lensSessionHandle.getPublicId().toString()).request().delete();
+ Assert.assertEquals(deleteResponse.getStatus(), 200);
+ }
+
+ @Test
+ public void testJsonResponsesFromServer() {
+ final WebTarget target = target().path("uisession");
+ FormDataMultiPart mp = getMultiFormData("foo", "bar");
+
+ Response response = target.request().accept(MediaType.APPLICATION_JSON).
+ post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE));
+ Assert.assertEquals(response.getStatus(), 200);
+ Assert.assertEquals(response.getMediaType().toString(), "application/json");
+ }
+
+ @Test
+ public void testXMLResponsesFromServer() {
+ final WebTarget target = target().path("uisession");
+ FormDataMultiPart mp = getMultiFormData("foo", "bar");
+
+ Response response = target.request().accept(MediaType.APPLICATION_XML).
+ post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA_TYPE));
+ Assert.assertEquals(response.getStatus(), 200);
+ Assert.assertEquals(response.getMediaType().toString(), "application/xml");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-lens/blob/76fd8418/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 4c58b9b..ba86189 100644
--- a/pom.xml
+++ b/pom.xml
@@ -742,6 +742,11 @@
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.media</groupId>
+ <artifactId>jersey-media-moxy</artifactId>
+ <version>${jersey.version}</version>
+ </dependency>
<dependency>
<groupId>org.glassfish.grizzly</groupId>