Skip to content
Snippets Groups Projects
Commit 94fc9092 authored by ribeaudc's avatar ribeaudc
Browse files

add:

- Test for 'NotImplementedException'.

SVN: 2735
parent 1d2eabb9
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,8 @@ import java.io.Serializable;
public final class NotImplementedException extends RuntimeException
{
static final String MESSAGE_TEMPLATE = "'%s' method not implemented in '%s'.";
private static final long serialVersionUID = 1L;
/** The error message for this exception. */
......@@ -40,16 +42,16 @@ public final class NotImplementedException extends RuntimeException
public NotImplementedException()
{
super();
StackTraceExtractor extractor = new StackTraceExtractor(this);
setMessage(extractor.getMethodName() + " method not implemented in " + extractor.getSimpleClassName());
final StackTraceExtractor extractor = new StackTraceExtractor(this);
setMessage(String.format(MESSAGE_TEMPLATE, extractor.getMethodName(), extractor.getSimpleClassName()));
}
public NotImplementedException(String message)
public NotImplementedException(final String message)
{
super(message);
}
public NotImplementedException(Throwable cause)
public NotImplementedException(final Throwable cause)
{
super(cause);
}
......@@ -65,6 +67,10 @@ public final class NotImplementedException extends RuntimeException
this.message = message;
}
//
// RuntimeException
//
/**
* Returns the error message for this exception. If the error message has not been defined in this class, returns
* the error message defined in the super class.
......
/*
* Copyright 2007 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ch.systemsx.cisd.common.exceptions;
import org.testng.annotations.Test;
import static org.testng.AssertJUnit.*;
/**
* Test cases for the {@link NotImplementedException}.
*
* @author Christian Ribeaud
*/
public final class NotImplementedExceptionTest
{
@Test
public final void testEmptyConstructor()
{
try
{
notImplemented();
} catch (NotImplementedException ex)
{
assertEquals(String.format(NotImplementedException.MESSAGE_TEMPLATE, "notImplemented",
"NotImplementedExceptionTest"), ex.getMessage());
}
}
private final void notImplemented()
{
throw new NotImplementedException();
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment