mirror of
https://github.com/13hannes11/archive.git
synced 2024-09-03 21:50:58 +02:00
added all past projects
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package edu.kit.informatik;
|
||||
|
||||
/**
|
||||
* The Class ExitException.
|
||||
*
|
||||
* @author Hannes Kuchelmeister
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ExitException extends SecurityException {
|
||||
|
||||
/** The status. */
|
||||
private final int code;
|
||||
|
||||
/**
|
||||
* Instantiates a new exit exception.
|
||||
*
|
||||
* @param code
|
||||
* the status
|
||||
*/
|
||||
public ExitException(final int code) {
|
||||
super("JVM exit is forbidden!");
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package edu.kit.informatik;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class MainTest {
|
||||
|
||||
@Test
|
||||
public void testMainWrongFile() {
|
||||
System.setSecurityManager(new NoExitSecurityManager());
|
||||
|
||||
// File not existent
|
||||
try {
|
||||
final String[] args = new String[1];
|
||||
args[0] = "Z:\\";
|
||||
// this should throw an exception
|
||||
Main.main(args);
|
||||
assert false;
|
||||
} catch (final ExitException e) {
|
||||
// if no exception is thrown something went wrong
|
||||
}
|
||||
|
||||
// duplicated Edge
|
||||
try {
|
||||
final String[] args = new String[1];
|
||||
args[0] = "C:\\Eclipse\\workspace\\Final01\\junit\\graphs\\duplicateEdge.txt";
|
||||
// this should throw an exception
|
||||
Main.main(args);
|
||||
assert false;
|
||||
} catch (final ExitException e) {
|
||||
// if no exception is thrown something went wrong
|
||||
}
|
||||
// edgeWithoutVertex
|
||||
try {
|
||||
final String[] args = new String[1];
|
||||
args[0] = "C:\\Eclipse\\workspace\\Final01\\junit\\graphs\\edgeWithoutVertex.txt";
|
||||
// this should throw an exception
|
||||
Main.main(args);
|
||||
assert false;
|
||||
} catch (final ExitException e) {
|
||||
// if no exception is thrown something went wrong
|
||||
}
|
||||
// emptyFile
|
||||
try {
|
||||
final String[] args = new String[1];
|
||||
args[0] = "C:\\Eclipse\\workspace\\Final01\\junit\\graphs\\emptyFile.txt";
|
||||
// this should throw an exception
|
||||
Main.main(args);
|
||||
assert false;
|
||||
} catch (final ExitException e) {
|
||||
// if no exception is thrown something went wrong
|
||||
}
|
||||
// negativeNumber
|
||||
try {
|
||||
final String[] args = new String[1];
|
||||
args[0] = "C:\\Eclipse\\workspace\\Final01\\junit\\graphs\\negativeNumber.txt";
|
||||
// this should throw an exception
|
||||
Main.main(args);
|
||||
assert false;
|
||||
} catch (final ExitException e) {
|
||||
// if no exception is thrown something went wrong
|
||||
}
|
||||
// noDivider
|
||||
try {
|
||||
final String[] args = new String[1];
|
||||
args[0] = "C:\\Eclipse\\workspace\\Final01\\junit\\graphs\\noDivider.txt";
|
||||
// this should throw an exception
|
||||
Main.main(args);
|
||||
assert false;
|
||||
} catch (final ExitException e) {
|
||||
// if no exception is thrown something went wrong
|
||||
}
|
||||
// noFirstPart
|
||||
try {
|
||||
final String[] args = new String[1];
|
||||
args[0] = "C:\\Eclipse\\workspace\\Final01\\junit\\graphs\\noFirstPart.txt";
|
||||
// this should throw an exception
|
||||
Main.main(args);
|
||||
assert false;
|
||||
} catch (final ExitException e) {
|
||||
// if no exception is thrown something went wrong
|
||||
}
|
||||
// noFirstPart
|
||||
try {
|
||||
final String[] args = new String[1];
|
||||
args[0] = "C:\\Eclipse\\workspace\\Final01\\junit\\graphs\\noSecondPart.txt";
|
||||
// this should throw an exception
|
||||
Main.main(args);
|
||||
assert false;
|
||||
} catch (final ExitException e) {
|
||||
// if no exception is thrown something went wrong
|
||||
}
|
||||
// notContinous
|
||||
try {
|
||||
final String[] args = new String[1];
|
||||
args[0] = "C:\\Eclipse\\workspace\\Final01\\junit\\graphs\\notContinous.txt";
|
||||
// this should throw an exception
|
||||
Main.main(args);
|
||||
assert false;
|
||||
} catch (final ExitException e) {
|
||||
// if no exception is thrown something went wrong
|
||||
}
|
||||
// numberOverflow
|
||||
try {
|
||||
final String[] args = new String[1];
|
||||
args[0] = "C:\\Eclipse\\workspace\\Final01\\junit\\graphs\\numberOverflow.txt";
|
||||
// this should throw an exception
|
||||
Main.main(args);
|
||||
assert false;
|
||||
} catch (final ExitException e) {
|
||||
// if no exception is thrown something went wrong
|
||||
}
|
||||
// numberZero
|
||||
try {
|
||||
final String[] args = new String[1];
|
||||
args[0] = "C:\\Eclipse\\workspace\\Final01\\junit\\graphs\\numberZero.txt";
|
||||
// this should throw an exception
|
||||
Main.main(args);
|
||||
assert false;
|
||||
} catch (final ExitException e) {
|
||||
// if no exception is thrown something went wrong
|
||||
}
|
||||
System.setSecurityManager(null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package edu.kit.informatik;
|
||||
|
||||
import java.security.Permission;
|
||||
|
||||
/**
|
||||
* The Class NoExitSecurityManager.
|
||||
*
|
||||
* @author Hannes Kuchelmeister
|
||||
* @version 1.0
|
||||
*/
|
||||
public class NoExitSecurityManager extends SecurityManager {
|
||||
|
||||
/**
|
||||
* Instantiates a new no exit security manager.
|
||||
*/
|
||||
public NoExitSecurityManager() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkPermission(final Permission perm) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkPermission(final Permission perm, final Object context) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkExit(final int status) {
|
||||
super.checkExit(status);
|
||||
throw new ExitException(status);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
Aa
|
||||
bB
|
||||
C
|
||||
d
|
||||
--
|
||||
Aa;bB;1;3
|
||||
Aa;bB;2;4
|
||||
@@ -0,0 +1,11 @@
|
||||
Aa
|
||||
aA
|
||||
AA
|
||||
aa
|
||||
bB
|
||||
--
|
||||
aa;bB;1;3
|
||||
Aa;C;2;4
|
||||
Aa;d;11;20
|
||||
bB;C;5;2
|
||||
C;d;3;1
|
||||
@@ -0,0 +1,5 @@
|
||||
bB
|
||||
C
|
||||
d
|
||||
--
|
||||
Aa;bB;1;3
|
||||
@@ -0,0 +1,4 @@
|
||||
Aa
|
||||
bB
|
||||
--
|
||||
Aa;bB;1;-3
|
||||
@@ -0,0 +1,9 @@
|
||||
Aa
|
||||
bB
|
||||
C
|
||||
d
|
||||
Aa;bB;1;3
|
||||
Aa;C;2;4
|
||||
Aa;d;11;20
|
||||
bB;C;5;2
|
||||
C;d;3;1
|
||||
@@ -0,0 +1,6 @@
|
||||
--
|
||||
Aa;bB;1;3
|
||||
Aa;C;2;4
|
||||
Aa;d;11;20
|
||||
bB;C;5;2
|
||||
C;d;3;1
|
||||
@@ -0,0 +1,5 @@
|
||||
Aa
|
||||
bB
|
||||
C
|
||||
d
|
||||
--
|
||||
@@ -0,0 +1,6 @@
|
||||
Aa
|
||||
bB
|
||||
C
|
||||
d
|
||||
--
|
||||
Aa;bB;1;3
|
||||
@@ -0,0 +1,10 @@
|
||||
Aa
|
||||
bB
|
||||
C
|
||||
d
|
||||
--
|
||||
Aa;bB;1;3
|
||||
Aa;C;2;4
|
||||
Aa;d;11;20
|
||||
bB;C;5;2
|
||||
C;d;3;30000000000
|
||||
@@ -0,0 +1,5 @@
|
||||
C
|
||||
d
|
||||
--
|
||||
bB;C;5;2
|
||||
C;d;0;0
|
||||
Reference in New Issue
Block a user