From 76e7537cb7787b224f96e0edf41aba6a7ebe7db0 Mon Sep 17 00:00:00 2001
From: Jeffrey Phillips Freeman <jeffrey.freeman@syncleus.com>
Date: Tue, 20 Sep 2011 13:18:11 -0700
Subject: [PATCH] Added assert to check for lack of log4j.xml in jar. Enabled
 assertions and forking for unit tests

---
 pom.xml                                            | 10 ++++++++++
 src/main/java/com/syncleus/dann/examples/Main.java |  8 +++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index f0293a9..6e3e187 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,6 +25,16 @@
 
 
 	<build>
+        <plugins>
+            <plugin>
+              <groupId>org.apache.maven.plugins</groupId>
+              <artifactId>maven-surefire-plugin</artifactId>
+              <configuration>
+                <forkMode>pertest</forkMode>
+                <argLine>-enableassertions</argLine>
+              </configuration>
+            </plugin>
+        </plugins>
 		<resources>
 			<resource>
 				<directory>src/main/resources</directory>
diff --git a/src/main/java/com/syncleus/dann/examples/Main.java b/src/main/java/com/syncleus/dann/examples/Main.java
index 795e696..64fcdbb 100644
--- a/src/main/java/com/syncleus/dann/examples/Main.java
+++ b/src/main/java/com/syncleus/dann/examples/Main.java
@@ -21,6 +21,8 @@ package com.syncleus.dann.examples;
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.InputStreamReader;
+import java.net.URL;
+
 import org.apache.log4j.Logger;
 import org.apache.log4j.xml.DOMConfigurator;
 
@@ -45,7 +47,11 @@ public final class Main
 			if(new File("log4j.xml").exists())
 				DOMConfigurator.configure("log4j.xml");
 			else
-				DOMConfigurator.configure(ClassLoader.getSystemResource("log4j.xml"));
+			{
+				final URL logConfig = ClassLoader.getSystemResource("log4j.xml");
+				assert logConfig != null;
+				DOMConfigurator.configure(logConfig);
+			}
 
 			LOGGER.info("program started...");
 
-- 
GitLab