001: /*
002: * Copyright 2007 Google Inc.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License. You may obtain a copy of
006: * the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013: * License for the specific language governing permissions and limitations under
014: * the License.
015: */
016: package com.google.gwt.core.ext.typeinfo;
017:
018: import com.google.gwt.core.ext.TreeLogger;
019: import com.google.gwt.core.ext.UnableToCompleteException;
020: import com.google.gwt.core.ext.typeinfo.test.MyCustomList;
021: import com.google.gwt.core.ext.typeinfo.test.MyIntegerList;
022: import com.google.gwt.core.ext.typeinfo.test.MyList;
023: import com.google.gwt.dev.util.log.PrintWriterTreeLogger;
024:
025: import java.util.ArrayList;
026:
027: /**
028: * Test for {@link JRawType}.
029: */
030: public class JRawTypeTest extends JDelegatingClassTypeTestBase {
031: private final boolean logToConsole = false;
032:
033: private final ModuleContext moduleContext = new ModuleContext(
034: logToConsole ? new PrintWriterTreeLogger()
035: : TreeLogger.NULL,
036: "com.google.gwt.core.ext.typeinfo.TypeOracleTest");
037:
038: public JRawTypeTest() throws UnableToCompleteException {
039: }
040:
041: @Override
042: public void testFindNestedType() {
043: // TODO Auto-generated method stub
044: }
045:
046: @Override
047: public void testGetEnclosingType() {
048: // TODO Auto-generated method stub
049: }
050:
051: @Override
052: public void testGetNestedType() {
053: // TODO Auto-generated method stub
054: }
055:
056: @Override
057: public void testGetNestedTypes() {
058: // TODO Auto-generated method stub
059: }
060:
061: @Override
062: public void testGetOverridableMethods() {
063: // TODO Auto-generated method stub
064: }
065:
066: @Override
067: public void testGetSubtypes() throws NotFoundException {
068: TypeOracle oracle = moduleContext.getOracle();
069: JClassType testType = oracle.getType(MyList.class.getName());
070: JGenericType genericTestType = testType.isGenericType();
071: assertNotNull(genericTestType);
072:
073: JRawType rawTestType = genericTestType.getRawType();
074: JClassType[] expectedTypes = new JClassType[] {
075: oracle.getType(MyCustomList.class.getName())
076: .isGenericType().getRawType(),
077: oracle.getType(MyIntegerList.class.getName()) };
078: JClassType[] actualSubtypes = rawTestType.getSubtypes();
079:
080: validateEquals(oracle, expectedTypes, actualSubtypes);
081: }
082:
083: @Override
084: public void testIsAssignableFrom() throws NotFoundException {
085: JRawType rawType = getTestType();
086: assertTrue(rawType.isAssignableFrom(rawType.getBaseType()));
087: }
088:
089: @Override
090: public void testIsAssignableTo() throws NotFoundException {
091: JRawType rawType = getTestType();
092: assertTrue(rawType.getBaseType().isAssignableTo(rawType));
093: }
094:
095: @Override
096: protected Substitution getSubstitution() throws NotFoundException {
097: return new Substitution() {
098: public JType getSubstitution(JType type) {
099: return type.getErasedType();
100: }
101: };
102: }
103:
104: /**
105: * Returns the RawType for {@link ArrayList}.
106: */
107: @Override
108: protected JRawType getTestType() throws NotFoundException {
109: TypeOracle oracle = moduleContext.getOracle();
110: JClassType testType = oracle.getType(ArrayList.class.getName());
111: return testType.isGenericType().getRawType();
112: }
113: }
|