You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by GitBox <gi...@apache.org> on 2018/11/06 08:30:08 UTC

[GitHub] philipmundt commented on a change in pull request #10: SLING-8047 ExportServlet does not write to output stream

philipmundt commented on a change in pull request #10: SLING-8047 ExportServlet does not write to output stream
URL: https://github.com/apache/sling-org-apache-sling-models-impl/pull/10#discussion_r231033150
 
 

 ##########
 File path: src/test/java/org/apache/sling/models/impl/ExportServletTest.java
 ##########
 @@ -0,0 +1,129 @@
+/*
+ * 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.sling.models.impl;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.request.RequestPathInfo;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.models.factory.ModelFactory;
+import org.apache.sling.models.testmodels.classes.DefaultStringModel;
+import org.apache.sling.scripting.api.BindingsValuesProvidersByContext;
+import org.hamcrest.CoreMatchers;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.osgi.framework.BundleContext;
+
+import javax.json.Json;
+import javax.json.JsonReader;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+import java.io.StringReader;
+import java.util.Collections;
+import java.util.Map;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ExportServletTest {
+
+    private static final String SELECTOR = "model";
+
+    private ExportServlet exportServlet;
+
+    @Mock
+    private BundleContext bundleContext;
+
+    @Mock
+    private ModelFactory modelFactory;
+
+    @Mock
+    private BindingsValuesProvidersByContext bindingsValueProviderByContext;
+
+    @Mock
+    private SlingModelsScriptEngineFactory scriptFactory;
+
+    @Mock
+    private ExportServlet.ExportedObjectAccessor exportedObjectAccessor;
+
+    @Mock
+    private SlingHttpServletRequest slingHttpServletRequest;
+
+    @Mock
+    private SlingHttpServletResponse slingHttpServletResponse;
+
+    @Mock
+    private RequestPathInfo requestPathInfo;
+
+    @Mock
+    private Resource resource;
+
+    @Mock
+    private ResourceResolver resourceResolver;
+
+    private Map<String, String> baseOption = Collections.emptyMap();
+    private Class<?> annotatedClass = DefaultStringModel.class;
+    private String registeredSelector = SELECTOR;
+    private String exporterName = "exporterName";
+
+    @Before
+    public void setUp() {
+        Mockito.when(resource.getResourceResolver()).thenReturn(resourceResolver);
 
 Review comment:
   @paul-bjorkstrand would have been no issue what so ever, but the underlying fix is not correct. I'm therefore closing the PR for the time being. I'm not sure how I'm supposed to  test/verify the new fix in `sling-org-apache-sling-engine`, class `org.apache.sling.engine.impl.SlingRequestProcessorImpl` in the realm of the export servlet!

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services