You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2017/01/27 12:22:21 UTC
svn commit: r1780546 - in /openmeetings/application:
branches/3.2.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/
branches/3.2.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/
trunk/openmeetings...
Author: solomax
Date: Fri Jan 27 12:22:21 2017
New Revision: 1780546
URL: http://svn.apache.org/viewvc?rev=1780546&view=rev
Log:
[OPENMEETINGS-1543] tests are fixed
Added:
openmeetings/application/branches/3.2.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyReader.java
openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyReader.java
Modified:
openmeetings/application/branches/3.2.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/AbstractWebServiceTest.java
openmeetings/application/branches/3.2.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyWriter.java
openmeetings/application/branches/3.2.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentParamConverter.java
openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/AbstractWebServiceTest.java
openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyWriter.java
openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentParamConverter.java
Modified: openmeetings/application/branches/3.2.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/AbstractWebServiceTest.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/AbstractWebServiceTest.java?rev=1780546&r1=1780545&r2=1780546&view=diff
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/AbstractWebServiceTest.java (original)
+++ openmeetings/application/branches/3.2.x/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/AbstractWebServiceTest.java Fri Jan 27 12:22:21 2017
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertEqu
import java.io.File;
import java.nio.file.Files;
+import java.util.Arrays;
import java.util.UUID;
import org.apache.catalina.LifecycleState;
@@ -31,6 +32,7 @@ import org.apache.cxf.jaxrs.client.WebCl
import org.apache.openmeetings.db.dto.basic.ServiceResult;
import org.apache.openmeetings.db.dto.basic.ServiceResult.Type;
import org.apache.openmeetings.test.AbstractJUnitDefaults;
+import org.apache.openmeetings.webservice.util.AppointmentMessageBodyReader;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -41,7 +43,8 @@ public class AbstractWebServiceTest exte
public final static String USER_SERVICE_URL = BASE_SERVICES_URL + "/user";
public static WebClient getClient(String url) {
- return WebClient.create(url).accept("application/json").type("application/json");
+ return WebClient.create(url, Arrays.asList(new AppointmentMessageBodyReader()))
+ .accept("application/json").type("application/json");
}
public static ServiceResult login() {
Added: openmeetings/application/branches/3.2.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyReader.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyReader.java?rev=1780546&view=auto
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyReader.java (added)
+++ openmeetings/application/branches/3.2.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyReader.java Fri Jan 27 12:22:21 2017
@@ -0,0 +1,59 @@
+/*
+ * 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.openmeetings.webservice.util;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.openmeetings.db.dto.calendar.AppointmentDTO;
+
+@Provider
+@Consumes({MediaType.APPLICATION_JSON})
+public class AppointmentMessageBodyReader implements MessageBodyReader<AppointmentDTO> {
+ @Override
+ public boolean isReadable(Class<?> clazz, Type type, Annotation[] annotations, MediaType mediaType) {
+ return type.equals(AppointmentDTO.class);
+ }
+
+ @Override
+ public AppointmentDTO readFrom(Class<AppointmentDTO> clazz, Type type, Annotation[] annotations,
+ MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
+ throws IOException, WebApplicationException
+ {
+ BufferedReader br = new BufferedReader(new InputStreamReader(entityStream));
+ String line = null;
+ StringBuilder sb = new StringBuilder();
+ while ((line = br.readLine()) != null) {
+ sb.append(line).append(System.lineSeparator());
+ }
+ return new AppointmentParamConverter().fromString(sb.toString());
+ }
+
+}
Modified: openmeetings/application/branches/3.2.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyWriter.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyWriter.java?rev=1780546&r1=1780545&r2=1780546&view=diff
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyWriter.java (original)
+++ openmeetings/application/branches/3.2.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyWriter.java Fri Jan 27 12:22:21 2017
@@ -56,7 +56,7 @@ public class AppointmentMessageBodyWrite
throws IOException, WebApplicationException
{
Writer writer = new PrintWriter(out);
- writer.write(new JSONObject().put(ROOT, AppointmentParamConverter.json(t)).toString().toString());
+ writer.write(new JSONObject().put(ROOT, AppointmentParamConverter.json(t)).toString());
writer.flush();
}
}
Modified: openmeetings/application/branches/3.2.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentParamConverter.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentParamConverter.java?rev=1780546&r1=1780545&r2=1780546&view=diff
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentParamConverter.java (original)
+++ openmeetings/application/branches/3.2.x/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentParamConverter.java Fri Jan 27 12:22:21 2017
@@ -40,6 +40,9 @@ public class AppointmentParamConverter i
@Override
public AppointmentDTO fromString(String val) {
JSONObject o = new JSONObject(val);
+ if (o.has(ROOT)) {
+ o = o.getJSONObject(ROOT);
+ }
AppointmentDTO a = new AppointmentDTO();
a.setId(optLong(o, "id"));
a.setTitle(o.optString("title"));
Modified: openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/AbstractWebServiceTest.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/AbstractWebServiceTest.java?rev=1780546&r1=1780545&r2=1780546&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/AbstractWebServiceTest.java (original)
+++ openmeetings/application/trunk/openmeetings-web/src/test/java/org/apache/openmeetings/test/webservice/AbstractWebServiceTest.java Fri Jan 27 12:22:21 2017
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertEqu
import java.io.File;
import java.nio.file.Files;
+import java.util.Arrays;
import java.util.UUID;
import org.apache.catalina.LifecycleState;
@@ -31,6 +32,7 @@ import org.apache.cxf.jaxrs.client.WebCl
import org.apache.openmeetings.db.dto.basic.ServiceResult;
import org.apache.openmeetings.db.dto.basic.ServiceResult.Type;
import org.apache.openmeetings.test.AbstractJUnitDefaults;
+import org.apache.openmeetings.webservice.util.AppointmentMessageBodyReader;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -41,7 +43,8 @@ public class AbstractWebServiceTest exte
public final static String USER_SERVICE_URL = BASE_SERVICES_URL + "/user";
public static WebClient getClient(String url) {
- return WebClient.create(url).accept("application/json").type("application/json");
+ return WebClient.create(url, Arrays.asList(new AppointmentMessageBodyReader()))
+ .accept("application/json").type("application/json");
}
public static ServiceResult login() {
Added: openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyReader.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyReader.java?rev=1780546&view=auto
==============================================================================
--- openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyReader.java (added)
+++ openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyReader.java Fri Jan 27 12:22:21 2017
@@ -0,0 +1,59 @@
+/*
+ * 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.openmeetings.webservice.util;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.openmeetings.db.dto.calendar.AppointmentDTO;
+
+@Provider
+@Consumes({MediaType.APPLICATION_JSON})
+public class AppointmentMessageBodyReader implements MessageBodyReader<AppointmentDTO> {
+ @Override
+ public boolean isReadable(Class<?> clazz, Type type, Annotation[] annotations, MediaType mediaType) {
+ return type.equals(AppointmentDTO.class);
+ }
+
+ @Override
+ public AppointmentDTO readFrom(Class<AppointmentDTO> clazz, Type type, Annotation[] annotations,
+ MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
+ throws IOException, WebApplicationException
+ {
+ BufferedReader br = new BufferedReader(new InputStreamReader(entityStream));
+ String line = null;
+ StringBuilder sb = new StringBuilder();
+ while ((line = br.readLine()) != null) {
+ sb.append(line).append(System.lineSeparator());
+ }
+ return new AppointmentParamConverter().fromString(sb.toString());
+ }
+
+}
Modified: openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyWriter.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyWriter.java?rev=1780546&r1=1780545&r2=1780546&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyWriter.java (original)
+++ openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentMessageBodyWriter.java Fri Jan 27 12:22:21 2017
@@ -56,7 +56,7 @@ public class AppointmentMessageBodyWrite
throws IOException, WebApplicationException
{
Writer writer = new PrintWriter(out);
- writer.write(new JSONObject().put(ROOT, AppointmentParamConverter.json(t)).toString().toString());
+ writer.write(new JSONObject().put(ROOT, AppointmentParamConverter.json(t)).toString());
writer.flush();
}
}
Modified: openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentParamConverter.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentParamConverter.java?rev=1780546&r1=1780545&r2=1780546&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentParamConverter.java (original)
+++ openmeetings/application/trunk/openmeetings-webservice/src/main/java/org/apache/openmeetings/webservice/util/AppointmentParamConverter.java Fri Jan 27 12:22:21 2017
@@ -40,6 +40,9 @@ public class AppointmentParamConverter i
@Override
public AppointmentDTO fromString(String val) {
JSONObject o = new JSONObject(val);
+ if (o.has(ROOT)) {
+ o = o.getJSONObject(ROOT);
+ }
AppointmentDTO a = new AppointmentDTO();
a.setId(optLong(o, "id"));
a.setTitle(o.optString("title"));