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