1 /*******************************************************************************
2 * Copyright (c) 2012-2013 University of Stuttgart.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * and the Apache License 2.0 which both accompany this distribution,
6 * and are available at http://www.eclipse.org/legal/epl-v10.html
7 * and http://www.apache.org/licenses/LICENSE-2.0
10 * Oliver Kopp - initial API and implementation
11 *******************************************************************************/
12 package org.eclipse.winery.repository.export;
14 import java.io.IOException;
15 import java.io.OutputStream;
16 import java.util.HashMap;
19 import javax.ws.rs.WebApplicationException;
20 import javax.ws.rs.core.StreamingOutput;
21 import javax.xml.bind.JAXBException;
23 import org.apache.commons.io.output.NullOutputStream;
24 import org.junit.Before;
25 import org.junit.BeforeClass;
26 import org.junit.Test;
27 import org.eclipse.winery.common.ids.definitions.ServiceTemplateId;
28 import org.eclipse.winery.repository.PrefsTestEnabledGitBackedRepository;
29 import org.eclipse.winery.repository.backend.Repository;
30 import org.eclipse.winery.repository.backend.filebased.GitBasedRepository;
32 public class TestToscaExporter {
34 //private static final TOSCAExportUtil toscaExporter = new TOSCAExportUtil();
35 private static final CSARExporter csarExporter = new CSARExporter();
37 private static final ServiceTemplateId serviceTemplateId = new ServiceTemplateId("http://www.example.com/tosca/ServiceTemplates/Moodle", "Moodle", false);
41 * Quick hack as we currently don't have a dedicated test service template
44 public static void setServiceTemplateId() throws Exception {
45 // Initialize preferences
46 // We do not need them, but constructing them has the side effect that Repository.INSTANCE is != null
47 new PrefsTestEnabledGitBackedRepository();
51 public void setRevision() throws Exception {
52 ((GitBasedRepository) Repository.INSTANCE).setRevisionTo("97fa997b92965d8bc84e86274b0203f1db7495c5");
56 public void checkTOSCAExport() throws Exception {
57 @SuppressWarnings("unused")
58 StreamingOutput so = new StreamingOutput() {
61 public void write(OutputStream output) throws IOException, WebApplicationException {
62 TOSCAExportUtil exporter = new TOSCAExportUtil();
63 // we include everything related
64 Map<String, Object> conf = new HashMap<>();
66 exporter.exportTOSCA(TestToscaExporter.serviceTemplateId, output, conf);
67 } catch (JAXBException e) {
68 throw new WebApplicationException(e);
73 // TODO: check output contained in SO
77 public void checkCSARExport() throws Exception {
78 NullOutputStream out = new NullOutputStream();
79 TestToscaExporter.csarExporter.writeCSAR(TestToscaExporter.serviceTemplateId, out);