Skip to content
This repository was archived by the owner on Feb 15, 2024. It is now read-only.

Commit b41d0ed

Browse files
author
weissarn
committed
Copy aasx-creation from deserializer-test and call validation on it.
1 parent 987a514 commit b41d0ed

1 file changed

Lines changed: 62 additions & 0 deletions

File tree

  • dataformat-aasx/src/test/java/io/adminshell/aas/v3/dataformat/aasx/deserialization
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright (c) 2021 Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e. V.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.adminshell.aas.v3.dataformat.aasx.deserialization;
17+
18+
import static org.junit.Assert.assertEquals;
19+
import static org.junit.Assert.assertNull;
20+
21+
import io.adminshell.aas.v3.dataformat.DeserializationException;
22+
import io.adminshell.aas.v3.dataformat.SerializationException;
23+
import io.adminshell.aas.v3.dataformat.aasx.AASXDeserializer;
24+
import io.adminshell.aas.v3.dataformat.aasx.AASXSerializer;
25+
import io.adminshell.aas.v3.dataformat.aasx.AASXValidator;
26+
import io.adminshell.aas.v3.dataformat.aasx.InMemoryFile;
27+
import io.adminshell.aas.v3.dataformat.aasx.serialization.AASSimple;
28+
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
29+
import org.junit.Rule;
30+
import org.junit.Test;
31+
import org.junit.rules.TemporaryFolder;
32+
import org.xml.sax.SAXException;
33+
34+
import javax.xml.parsers.ParserConfigurationException;
35+
import java.io.*;
36+
import java.util.ArrayList;
37+
import java.util.List;
38+
import java.util.Set;
39+
40+
public class ValidationTest {
41+
42+
@Rule
43+
public TemporaryFolder tempFolder = new TemporaryFolder();
44+
45+
@Test
46+
public void validateXmlInsideAasx() throws SerializationException, IOException, InvalidFormatException, DeserializationException, ParserConfigurationException, SAXException {
47+
List<InMemoryFile> fileList = new ArrayList<>();
48+
byte[] operationManualContent = { 0, 1, 2, 3, 4 };
49+
InMemoryFile inMemoryFile = new InMemoryFile(operationManualContent, "/aasx/OperatingManual.pdf");
50+
fileList.add(inMemoryFile);
51+
52+
File file = tempFolder.newFile("output.aasx");
53+
54+
new AASXSerializer().write(AASSimple.ENVIRONMENT, fileList, new FileOutputStream(file));
55+
56+
InputStream in = new FileInputStream(file);
57+
AASXValidator v = new AASXValidator(in);
58+
Set<String> validationResult = v.validateSchema();
59+
System.out.println(validationResult);
60+
assertEquals(validationResult.size(),0);
61+
}
62+
}

0 commit comments

Comments
 (0)