001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * Portions Copyrighted 2007 Sun Microsystems, Inc.
027: */
028:
029: package org.netbeans.api.project.ant;
030:
031: import java.io.File;
032: import java.net.URI;
033: import java.util.Arrays;
034: import java.util.Collections;
035: import java.util.logging.Level;
036: import org.netbeans.junit.Log;
037: import org.netbeans.junit.NbTestCase;
038:
039: public class AntArtifactTest extends NbTestCase {
040:
041: public AntArtifactTest(String n) {
042: super (n);
043: }
044:
045: protected @Override
046: Level logLevel() {
047: return Level.WARNING;
048: }
049:
050: public void testMethodOverride() throws Exception { // #72308
051: final URI nowhere = URI.create("nowhere:man");
052: class Bogus1 extends AntArtifact {
053: @SuppressWarnings("deprecation")
054: public @Override
055: URI getArtifactLocation() {
056: return nowhere;
057: }
058:
059: public @Override
060: String getType() {
061: return null;
062: }
063:
064: public @Override
065: File getScriptLocation() {
066: return null;
067: }
068:
069: public @Override
070: String getTargetName() {
071: return null;
072: }
073:
074: public @Override
075: String getCleanTargetName() {
076: return null;
077: }
078: }
079: CharSequence log = Log.enable(AntArtifact.class.getName(),
080: Level.WARNING);
081: assertEquals(Collections.singletonList(nowhere), Arrays
082: .asList(new Bogus1().getArtifactLocations()));
083: assertTrue(log.toString(), log.toString().contains(
084: Bogus1.class.getName()));
085: class Bogus2 extends AntArtifact {
086: public @Override
087: String getType() {
088: return null;
089: }
090:
091: public @Override
092: File getScriptLocation() {
093: return null;
094: }
095:
096: public @Override
097: String getTargetName() {
098: return null;
099: }
100:
101: public @Override
102: String getCleanTargetName() {
103: return null;
104: }
105: }
106: try {
107: new Bogus2().getArtifactLocations();
108: fail();
109: } catch (IllegalStateException ise) {
110: // OK, this is what we want now.
111: }
112: class OK extends AntArtifact {
113: public @Override
114: URI[] getArtifactLocations() {
115: return new URI[] { nowhere };
116: }
117:
118: public @Override
119: String getType() {
120: return null;
121: }
122:
123: public @Override
124: File getScriptLocation() {
125: return null;
126: }
127:
128: public @Override
129: String getTargetName() {
130: return null;
131: }
132:
133: public @Override
134: String getCleanTargetName() {
135: return null;
136: }
137: }
138: new OK();
139: }
140:
141: }
|