Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
vadere
vadere
Commits
db76c70e
Commit
db76c70e
authored
Dec 13, 2016
by
Jakob Schöttl
Browse files
Remove unncessary clone method and related tests
parent
3f189de9
Changes
2
Hide whitespace changes
Inline
Side-by-side
VadereState/src/org/vadere/state/attributes/Attributes.java
View file @
db76c70e
...
...
@@ -22,12 +22,4 @@ public abstract class Attributes extends DefaultSealable implements Cloneable {
public
Attributes
()
{}
public
Attributes
cloneAttributes
()
{
try
{
return
(
Attributes
)
super
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
throw
new
RuntimeException
(
"This should never happen because the base class Attributes is Cloneable."
);
}
}
}
VadereState/tests/org/vadere/state/attributes/TestAttributesCloneable.java
View file @
db76c70e
package
org.vadere.state.attributes
;
import
static
org
.
junit
.
Assert
.*;
import
org.junit.Test
;
public
class
TestAttributesCloneable
{
private
static
class
SimpleAttributes
extends
Attributes
{
int
id
=
1
;
}
private
static
class
NestedAttributes
extends
Attributes
{
int
id
=
1
;
SimpleAttributes
c
=
new
SimpleAttributes
();
SimpleCloneable
d
=
new
SimpleCloneable
();
}
private
static
class
SimpleCloneable
implements
Cloneable
{
int
id
=
1
;
}
private
static
class
NotCloneableClass
{
@Override
public
Object
clone
()
throws
CloneNotSupportedException
{
...
...
@@ -27,30 +11,6 @@ public class TestAttributesCloneable {
}
}
@Test
public
void
testSimpleCloneable
()
{
try
{
SimpleAttributes
a
=
new
SimpleAttributes
();
SimpleAttributes
b
=
(
SimpleAttributes
)
a
.
cloneAttributes
();
assertEquals
(
a
.
id
,
b
.
id
);
}
catch
(
Exception
e
)
{
fail
(
"clone should not throw exception"
);
}
}
@Test
public
void
testExtendedCloneable
()
{
try
{
NestedAttributes
a
=
new
NestedAttributes
();
NestedAttributes
b
=
(
NestedAttributes
)
a
.
cloneAttributes
();
assertEquals
(
a
.
id
,
b
.
id
);
assertEquals
(
a
.
c
.
id
,
b
.
c
.
id
);
assertEquals
(
a
.
d
.
id
,
b
.
d
.
id
);
}
catch
(
Exception
e
)
{
fail
(
"clone should not throw exception"
);
}
}
@Test
(
expected
=
CloneNotSupportedException
.
class
)
public
void
testNotCloneableClass
()
throws
CloneNotSupportedException
{
new
NotCloneableClass
().
clone
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment