Skip to main content
summaryrefslogtreecommitdiffstats
blob: 17e1960ff065a65e24e38a44491d08c9e5088246 (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*******************************************************************************
 * Copyright (c) 2006 Oracle Corporation.
 * 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:
 *    Gerry Kessler/Oracle - initial API and implementation
 *    
 ********************************************************************************/
package org.eclipse.jst.jsf.metadata.tests.taglibprocessing;

import java.util.List;

import junit.framework.TestCase;

import org.eclipse.jface.text.IDocument;
import org.eclipse.jst.jsf.common.metadata.tests.AbstractBaseMetaDataTestCase;
import org.eclipse.jst.jsf.context.structureddocument.internal.provisional.IStructuredDocumentContext;
import org.eclipse.jst.jsf.context.structureddocument.internal.provisional.IStructuredDocumentContextFactory;
import org.eclipse.jst.jsf.metadata.tests.MetadataTestsPlugin;
import org.eclipse.jst.jsf.metadataprocessors.internal.provisional.MetaDataEnabledProcessingFactory;
import org.eclipse.jst.jsf.metadataprocessors.internal.provisional.features.ICreateValues;
import org.eclipse.jst.jsf.metadataprocessors.internal.provisional.features.IDefaultValue;
import org.eclipse.jst.jsf.metadataprocessors.internal.provisional.features.IPossibleValues;
import org.eclipse.jst.jsf.metadataprocessors.internal.provisional.features.IValidValues;

public abstract class TaglibProcessingTestCase extends AbstractBaseMetaDataTestCase {
//	protected IStructuredDocumentContext docContext;
	protected String uri = "http://org.eclipse.jsf/tagprocessing";
	protected String bundle = "org.eclipse.jst.jsf.core";
	protected String barkerBundle = MetadataTestsPlugin.ID_BUNDLE;
	protected String tag = "MyTag";
	protected String attributeName;
	
	protected List possibleValueAdapters;
	protected List validValuesAdapters;
	protected List defaultValueAdapters;
	protected List createValuesAdapters;
	
	public void setUp() throws Exception{
		super.setUp();
		
		// TODO: This won't work currently docContext = getTestDocContext();
		possibleValueAdapters = getProcessorAdapters(IPossibleValues.class);
		validValuesAdapters = getProcessorAdapters(IValidValues.class);
		defaultValueAdapters = getProcessorAdapters(IDefaultValue.class);
		createValuesAdapters = getProcessorAdapters(ICreateValues.class);
	}
	
//	private IStructuredDocumentContext getTestDocContext() {
//		//IJavaProject jproj = getProject();
//		IDocument doc = null;//figure it out
//		return IStructuredDocumentContextFactory.INSTANCE.getContext(doc, 0);
//	}
//
//	private IJavaProject getProject() {
//		if (ResourcesPlugin.getWorkspace().getRoot().getProject("testProject")==null){
//			//do we import??? or create new???
//			Impor
//			IJavaProject jp = new JavaProject(
//		}
//		return JavaCore.create(ResourcesPlugin.getWorkspace().getRoot().getProject("testProject"));
//		return null;
//	}

	private String getAttributeNameFromTest(){
		if (attributeName == null){
			String test = this.getClass().getName();
			test = test.substring(test.lastIndexOf(".") + 1);
			test = test.substring(0,test.length() - 4);
			return test;
		}
        return attributeName;
	}
	
	protected List getProcessorAdapters(Class featureClass) {
		return MetaDataEnabledProcessingFactory.getInstance().
			getAttributeValueRuntimeTypeFeatureProcessors(featureClass, docContext, 
					uri, tag , getAttributeNameFromTest());
	}

//	private IMetaDataEnabledFeature getProcessorForBundle(List processors, String bundleID){
//		IMetaDataEnabledFeature ret = null;
//		Iterator it = processors.iterator();
//		while(it.hasNext()){
//			IMetaDataEnabledFeature feature = (IMetaDataEnabledFeature)it.next();
//			if (feature.getBundleID().equals(bundleID)){
//				ret = feature;
//				break;
//			}
//		}
//		return ret;
//	}
//	private ITypeDescriptor getType(String typeId){
//		return AttributeValueRuntimeTypeFactory.getInstance().getType(typeId);
//	}
	
//	protected IMetaDataEnabledFeature getBarkProcessingBundle(List processors) {
//		return getProcessorForBundle(processors, barkerBundle);		
//	}
//	
//	protected IMetaDataEnabledFeature getProcessorForTaglibProcessingBundle(List processors) {
//		return getProcessorForBundle(processors, bundle);
//	}
}

Back to the top