blob: a32117f964a32c1267386842afd1a46ab53f505b (
plain) (
blame)
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
82
|
/*******************************************************************************
* Copyright (c) 2010, 2011 Oracle. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0, which accompanies this distribution
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Oracle - initial API and implementation
*******************************************************************************/
package org.eclipse.jpt.jaxb.core.tests.internal;
import org.eclipse.jpt.common.core.resource.java.JavaResourceAttribute;
import org.eclipse.jpt.common.core.resource.java.JavaResourceType;
import org.eclipse.jpt.common.core.tests.internal.projects.TestJavaProject;
import org.eclipse.jpt.common.core.tests.internal.utility.jdt.AnnotationTestCase;
import org.eclipse.jpt.jaxb.core.JaxbFacet;
import org.eclipse.jpt.jaxb.core.JaxbProject;
import org.eclipse.jpt.jaxb.core.JptJaxbCorePlugin;
import org.eclipse.jpt.jaxb.core.internal.facet.JaxbFacetDataModelProperties;
import org.eclipse.jpt.jaxb.core.internal.facet.JaxbFacetInstallDataModelProvider;
import org.eclipse.jpt.jaxb.core.platform.JaxbPlatformDescription;
import org.eclipse.jpt.jaxb.core.tests.internal.projects.TestJaxbProject;
import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetDataModelProperties;
import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
public class JaxbTestCase
extends AnnotationTestCase {
protected static final String BASE_PROJECT_NAME = "JaxbTestProject";
protected JaxbTestCase(String name) {
super(name);
}
@Override
protected TestJavaProject buildJavaProject(boolean autoBuild) throws Exception {
return buildJaxbProject(BASE_PROJECT_NAME, autoBuild, buildJaxbFacetInstallConfig());
}
protected TestJaxbProject buildJaxbProject(
String projectName, boolean autoBuild, IDataModel jaxbConfig)
throws Exception {
return TestJaxbProject.buildJaxbProject(projectName, autoBuild, jaxbConfig);
}
protected IDataModel buildJaxbFacetInstallConfig() {
IDataModel config = DataModelFactory.createDataModel(new JaxbFacetInstallDataModelProvider());
config.setProperty(IFacetDataModelProperties.FACET_VERSION, getProjectFacetVersion());
config.setProperty(JaxbFacetDataModelProperties.PLATFORM, getPlatform());
return config;
}
protected JaxbPlatformDescription getPlatform() {
return JptJaxbCorePlugin.getDefaultPlatform(getProjectFacetVersion());
}
protected IProjectFacetVersion getProjectFacetVersion() {
return JaxbFacet.VERSION_2_1;
}
@Override
protected TestJaxbProject getJavaProject() {
return (TestJaxbProject) super.getJavaProject();
}
protected JaxbProject getJaxbProject() {
return this.getJavaProject().getJaxbProject();
}
protected JavaResourceAttribute getFieldNamed(JavaResourceType resourceType, String attributeName) {
for (JavaResourceAttribute attribute : resourceType.getFields()) {
if (attribute.getName().equals(attributeName)) {
return attribute;
}
}
return null;
}
}
|