You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by ma...@apache.org on 2019/08/18 18:57:30 UTC
[netbeans] branch master updated: Fix SaasUtilTest in
websvc.saas.api module
This is an automated email from the ASF dual-hosted git repository.
matthiasblaesing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new ea155ad Fix SaasUtilTest in websvc.saas.api module
new d688f6d Merge pull request #1429 from blackleg/websvc_saas_api_tests
ea155ad is described below
commit ea155adc30dfed25afbc25844436e2cc59cd1391
Author: Hector Espert <he...@gmail.com>
AuthorDate: Thu Aug 15 20:26:19 2019 +0200
Fix SaasUtilTest in websvc.saas.api module
---
.../netbeans/modules/websvc/saas/util/FakeSaas.xml | 42 +++++++++++++++++
.../modules/websvc/saas/util/SaasUtilTest.java | 55 +++++++++++-----------
.../netbeans/modules/websvc/saas/util/testwadl.xml | 3 ++
3 files changed, 73 insertions(+), 27 deletions(-)
diff --git a/websvccommon/websvc.saas.api/test/unit/src/org/netbeans/modules/websvc/saas/util/FakeSaas.xml b/websvccommon/websvc.saas.api/test/unit/src/org/netbeans/modules/websvc/saas/util/FakeSaas.xml
new file mode 100644
index 0000000..1bd5ccf
--- /dev/null
+++ b/websvccommon/websvc.saas.api/test/unit/src/org/netbeans/modules/websvc/saas/util/FakeSaas.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+
+ 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.
+
+-->
+
+<saas-services xmlns="http://xml.netbeans.org/websvc/saas/services/1.0"
+ xmlns:tns="http://xml.netbeans.org/websvc/saas/services/1.0/fakesaas"
+ xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+ xsi:schemaLocation='http://xml.netbeans.org/websvc/saas/services/1.0
+ ../../../../../../../../../../websvc.saas.api/src/org/netbeans/modules/websvc/saas/model/SaasServices.xsd'
+ type="http://research.sun.com/wadl/2006/10"
+ api-doc="http://www.fakesaas.com/howto/api/APIOverview.html"
+ url="org/netbeans/modules/websvc/saas/services/zillow/resources/FakeSaasWadl.xml">
+ <display-name>Fake Saas Service</display-name>
+ <saas-metadata>
+ <localizing-bundle>org.netbeans.modules.websvc.saas.services.fakesaas.Bundle</localizing-bundle>
+ <group name="FakeSaas">
+ <group name="Videos"></group>
+ </group>
+ <authentication>
+ <api-key id="zws-id"/>
+ </authentication>
+ </saas-metadata>
+</saas-services>
diff --git a/websvccommon/websvc.saas.api/test/unit/src/org/netbeans/modules/websvc/saas/util/SaasUtilTest.java b/websvccommon/websvc.saas.api/test/unit/src/org/netbeans/modules/websvc/saas/util/SaasUtilTest.java
index 6d2981a..4f36c3f 100644
--- a/websvccommon/websvc.saas.api/test/unit/src/org/netbeans/modules/websvc/saas/util/SaasUtilTest.java
+++ b/websvccommon/websvc.saas.api/test/unit/src/org/netbeans/modules/websvc/saas/util/SaasUtilTest.java
@@ -23,7 +23,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.List;
-import javax.xml.bind.JAXBElement;
import org.netbeans.junit.NbTestCase;
import org.netbeans.modules.websvc.saas.model.Saas;
import org.netbeans.modules.websvc.saas.model.SaasGroup;
@@ -32,14 +31,14 @@ import org.netbeans.modules.websvc.saas.model.jaxb.SaasMetadata;
import org.netbeans.modules.websvc.saas.model.jaxb.SaasServices;
import org.netbeans.modules.websvc.saas.model.wadl.Application;
import org.netbeans.modules.websvc.saas.model.wadl.Method;
+import org.netbeans.modules.websvc.saas.model.wadl.Representation;
+import org.netbeans.modules.websvc.saas.model.wadl.Response;
/**
*
* @author nam
*/
public class SaasUtilTest extends NbTestCase {
-
- File output;
public SaasUtilTest(String testName) {
super(testName);
@@ -53,9 +52,6 @@ public class SaasUtilTest extends NbTestCase {
@Override
protected void tearDown() throws Exception {
super.tearDown();
- if (output != null && output.isFile()) {
- output.delete();
- }
}
public void testLoadSaasGroup() throws Exception {
@@ -81,7 +77,7 @@ public class SaasUtilTest extends NbTestCase {
assertEquals("test3", result.getChildrenGroups().get(2).getName());
}
- /*public void testXpath() throws Exception {
+ public void testXpath() throws Exception {
InputStream in = this.getClass().getResourceAsStream("testwadl.xml");
Application app = SaasUtil.loadJaxbObject(in, Application.class);
assertNotNull(SaasUtil.wadlMethodFromXPath(app, "//resource[1]/method[1]"));
@@ -95,49 +91,54 @@ public class SaasUtilTest extends NbTestCase {
InputStream in = this.getClass().getResourceAsStream("testwadl.xml");
Application app = SaasUtil.loadJaxbObject(in, Application.class);
Method method = SaasUtil.wadlMethodFromXPath(app, "//resource[1]/method[1]");
- List<JAXBElement<RepresentationType>> elements = method.getResponse().getRepresentationOrFault();
- //TODO none of the wadl's has response representation
- //assertEquals(1, SaasUtil.getMediaTypesFromJAXBElement(elements).size());
- }*/
+ List<Response> resposes = method.getResponse();
+ assertEquals(1, resposes.size());
+
+ List<Representation> representation = resposes.get(0).getRepresentation();
+ assertEquals(1, representation.size());
+
+ assertEquals(1, SaasUtil.getMediaTypes(representation).size());
+ }
public void testSaveSaasGroup() throws Exception {
- output = new File(getWorkDir(), "testSaveSaasGroup");
+ File output = new File(getWorkDir(), "testSaveSaasGroup");
InputStream in = this.getClass().getResourceAsStream("rootGroup.xml");
SaasGroup rootGroup = SaasUtil.loadSaasGroup(in);
- SaasGroup test2 = rootGroup.getChildrenGroups().get(1);
- test2.addService(new Saas(test2, new SaasServices()));
- test2.getServices().get(0).getDelegate().setDisplayName("Test2Service1");
- SaasUtil.saveSaasGroup(rootGroup, output);
+ SaasGroup test2Group = rootGroup.getChildrenGroups().get(1);
+ SaasServices newSaasServices = new SaasServices();
+ newSaasServices.setDisplayName("Test2Service1");
+ Saas newSaas = new Saas(test2Group, newSaasServices);
+ test2Group.addService(newSaas);
+
+ SaasUtil.saveSaasGroup(rootGroup, output);
+
verifyRootGroup(new FileInputStream(output));
+ output.delete();
}
public void testSaasMetaData() throws Exception {
SetupUtil.commonSetUp(super.getWorkDir());
- InputStream in = this.getClass().getResourceAsStream("/org/netbeans/modules/websvc/saas/services/zillow/resources/Zillow.xml");
+ InputStream in = this.getClass().getResourceAsStream("FakeSaas.xml");
SaasServices service = SaasUtil.loadJaxbObject(in, SaasServices.class);
SaasMetadata metadata = service.getSaasMetadata();
- assertEquals("Zillow", metadata.getGroup().getName());
- assertEquals("Zillow", metadata.getGroup().getName());
- assertEquals("org.netbeans.modules.websvc.saas.services.zillow.Bundle", metadata.getLocalizingBundle());
- //assertEquals("SaaSServices/Zillow/profile.properties", metadata.getAuthentication().getProfile());
+ assertEquals("FakeSaas", metadata.getGroup().getName());
+ assertEquals("org.netbeans.modules.websvc.saas.services.fakesaas.Bundle", metadata.getLocalizingBundle());
assertEquals("zws-id", metadata.getAuthentication().getApiKey().getId());
-
+
SetupUtil.commonTearDown();
}
public void testSaasServices() throws Exception {
SetupUtil.commonSetUp(super.getWorkDir());
- InputStream in = this.getClass().getResourceAsStream("/org/netbeans/modules/websvc/saas/services/zillow/resources/Zillow.xml");
+ InputStream in = this.getClass().getResourceAsStream("FakeSaas.xml");
SaasServices ss = SaasUtil.loadSaasServices(in);
- assertEquals("Real Estate Service", ss.getDisplayName());
+ assertEquals("Fake Saas Service", ss.getDisplayName());
- //TODO fixme this only works if we have absolute include/href=<absolute-URI>
assertNotNull(ss.getSaasMetadata());
- //No Sub-group for now
- //assertEquals("Videos", ss.getSaasMetadata().getGroup().getGroup().get(0).getName());
+ assertEquals("Videos", ss.getSaasMetadata().getGroup().getGroup().get(0).getName());
SetupUtil.commonTearDown();
}
diff --git a/websvccommon/websvc.saas.api/test/unit/src/org/netbeans/modules/websvc/saas/util/testwadl.xml b/websvccommon/websvc.saas.api/test/unit/src/org/netbeans/modules/websvc/saas/util/testwadl.xml
index 436f796..ff2a459 100644
--- a/websvccommon/websvc.saas.api/test/unit/src/org/netbeans/modules/websvc/saas/util/testwadl.xml
+++ b/websvccommon/websvc.saas.api/test/unit/src/org/netbeans/modules/websvc/saas/util/testwadl.xml
@@ -63,6 +63,9 @@
</param>
</request>
<response>
+ <representation>
+ <mediaType></mediaType>
+ </representation>
</response>
</method>
<method name="GET" id="youtube.listFeatured">
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists