Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ def testSchemas = [
[dir:'build/schemas/sTRANXML',path:'tranxml',name:'sTRANXML'],
[dir:'src/test/resources/xbean/xmlobject',path:'CR192525.xsd defaults.xsd easypo.xsd easypo.xsdconfig enumtest.xsd enumtest.xsdconfig inttest.xsd listandunion.xsd nameworld.xsd numerals.xsd redefine2.xsd SelectAttribute.xsd SelectChildren.xsd selectChldAttTest.xsd soap-envelope.xsd soapfaults.xsd substgroup.xsd substgroup2.xsd Test.xsd Test36510.xsd Test40907.xsd version3.xsd', name:'sXMLOBJECT'],
[dir:'src/test/resources/xbean/misc/jira',path:'xmlbeans_33b.xsd xmlbeans_46.xsd xmlbeans_48.xsd xmlbeans_64.xsd xmlbeans_68.xsd xmlbeans_71.xsd xmlbeans_98.xsd xmlbeans_99.xsd xmlbeans_105.xsd xmlbeans_175.xsd xmlbeans_177.xsd xmlbeans_177a.xsd xmlbeans_208.xsd xmlbeans_228.xsd xmlbeans_307_maxallowedenum.xsd xmlbeans_307_morethanallowedenum.xsd', name:'sJIRA' ],
[dir:'src/test/resources/xbean',path:'xmltokensource',name:'sTOKENSOURCE']
[dir:'src/test/resources/xbean',path:'xmltokensource',name:'sTOKENSOURCE'],
[dir:'src/test/resources/xbean',path:'labkey',name:'sLABKEY']
] + xsdDirs(file('src/test/resources/xbean/extensions')).withIndex().collect { element, index ->
// the extensions need to be generated separately, because the *.xsdconfigs have overlapping definitions
[dir:'src/test/resources/xbean/extensions',path:element,name:"sEXT${index}"]
Expand Down
1 change: 1 addition & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@
<schemaComp schemaName="sVALIDATE" src="${cases.location}/xbean/ValidatingStream" dest="build/test-validate" classpathref="xmlbeans-test"/>
<schemaComp schemaName="sUSERTYPE" src="${cases.location}/xbean/usertype" dest="build/test-usertype" classpathref="xmlbeans-test"/>
<schemaComp schemaName="sLAX" src="${cases.location}/xbean/compile/scomp/detailed" dest="build/test-lax" classpathref="xmlbeans-test"/>
<schemaComp schemaName="sLABKEY" src="${cases.location}/xbean/labkey" dest="build/test-labkey" classpathref="xmlbeans-test"/>

<pathconvert property="xmlobjects" pathsep=" ">
<path>
Expand Down
56 changes: 56 additions & 0 deletions src/test/java/org/apache/xmlbeans/impl/schema/XmlBeans661Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/* Copyright 2004 The Apache Software Foundation
*
* Licensed 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.xmlbeans.impl.schema;

import org.junit.jupiter.api.Test;
import org.labkey.data.xml.queryCustomView.FilterType;
import org.labkey.etl.xml.EtlDocument;
import org.labkey.etl.xml.EtlType;
import org.labkey.etl.xml.SourceObjectType;
import org.labkey.etl.xml.TransformType;

import java.net.URL;
import java.util.Arrays;

import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

// test for https://issues.apache.org/jira/browse/XMLBEANS-661
// lots of classes and related xsds were copied into the test src
// to avoid the issue of having to regenerate them in the build
public class XmlBeans661Test {

@Test
public void testXmlBeans661() throws Exception {
URL dataUrl = XmlBeans661Test.class.getClassLoader()
.getResource("xbean/labkey/SourceToTarget2WithFilter.xml");
assertNotNull(dataUrl, "Test data file not found");
EtlDocument document = EtlDocument.Factory.parse(dataUrl.openStream());
EtlType etlXml = document.getEtl();
for (TransformType transformXml : etlXml.getTransforms().getTransformArray()) {
SourceObjectType source = transformXml.getSource();
assertNotNull(source, "Source not found");
assertTrue(source.isSetSourceFilters(), "Source filters not set");
// This is where the failure happened with the following error:
// Exception in thread "main" java.lang.ArrayStoreException: arraycopy: element type mismatch: can not cast one of the elements of java.lang.Object[] to the type of the destination array, org.labkey.data.xml.queryCustomView.FilterType
FilterType[] filterTypes = source.getSourceFilters().getSourceFilterArray();
assertNotNull(filterTypes, "Source filters should not be null");
assertNotEquals(0, filterTypes.length, "Source filters should not be empty");
Arrays.stream(filterTypes).map(Object::toString).forEach(System.out::println);
}
}
}
50 changes: 50 additions & 0 deletions src/test/resources/xbean/labkey/SourceToTarget2WithFilter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright 2004 The Apache Software Foundation

Licensed 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. -->
<etl xmlns="http://labkey.org/etl/xml" transactDestinationSchema="etltest">
<name>Source to target with sourceFilter</name>
<description>append rows from source to target with a sourceFilter</description>
<transforms>
<transform id="step1" type="org.labkey.di.pipeline.TransformTask">
<description>Copy to target</description>
<source schemaName="etltest" queryName="source">
<sourceFilters>
<sourceFilter column="name" value="Filter1" operator="eq"/>
</sourceFilters>
</source>
<destination schemaName="etltest" queryName="target" targetOption="merge">
<alternateKeys>
<column name="id"/>
</alternateKeys>
</destination>
</transform>
<transform id="step2" type="org.labkey.di.pipeline.TransformTask">
<description>Copy to target2</description>
<source schemaName="etltest" queryName="source">
<sourceFilters>
<sourceFilter column="name" value="Filter1;Filter2" operator="in" />
</sourceFilters>
</source>
<destination schemaName="etltest" queryName="target2" targetOption="merge">
<alternateKeys>
<column name="id"/>
</alternateKeys>
</destination>
</transform>
</transforms>
<incrementalFilter className="ModifiedSinceFilterStrategy" timestampColumnName="modified" />
<schedule>
<poll interval="15s" />
</schedule>
</etl>
Loading
Loading