Skip to content

Commit

Permalink
Merge pull request EnterpriseQualityCoding#271 from cameronxm/master
Browse files Browse the repository at this point in the history
FindBugs fix; Windows build fix.
  • Loading branch information
emiln authored Jan 7, 2017
2 parents 6880465 + c386ab8 commit 4590711
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,23 @@ public class ApplicationContextHolder implements ApplicationContextAware {

private static ApplicationContext applicationContext;

private static class ApplicationContextReferenceUpdater {
void updateApplicationContextReference(final ApplicationContext applicationContext) {
ApplicationContextHolder.applicationContext = applicationContext;
}
}

private static class ApplicationContextReferenceUpdaterHolder {
static ApplicationContextReferenceUpdater INSTANCE = new ApplicationContextReferenceUpdater();
}

private ApplicationContextHolder() {
super();
}

@Override
public void setApplicationContext(final ApplicationContext applicationContext) throws BeansException {
ApplicationContextHolder.applicationContext = applicationContext;
ApplicationContextReferenceUpdaterHolder.INSTANCE.updateApplicationContextReference(applicationContext);
}

public static ApplicationContext getApplicationContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import org.springframework.stereotype.Service;

import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories.SystemOutFizzBuzzOutputStrategyFactory;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.strategies.adapters.FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.stringreturners.BuzzStringReturner;

@Service
public class BuzzPrinter {
Expand All @@ -18,13 +16,4 @@ public BuzzPrinter(final SystemOutFizzBuzzOutputStrategyFactory _systemOutFizzBu
this._systemOutFizzBuzzOutputStrategyFactory = _systemOutFizzBuzzOutputStrategyFactory;
}

public void printBuzz() {
final BuzzStringReturner myBuzzStringReturner = new BuzzStringReturner();
final FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter myOutputAdapter =
new FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter(
this._systemOutFizzBuzzOutputStrategyFactory.createOutputStrategy());

myOutputAdapter.output(myBuzzStringReturner.getReturnString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import org.springframework.stereotype.Service;

import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories.SystemOutFizzBuzzOutputStrategyFactory;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.strategies.adapters.FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.stringreturners.FizzStringReturner;

@Service
public class FizzPrinter {
Expand All @@ -18,13 +16,4 @@ public FizzPrinter(final SystemOutFizzBuzzOutputStrategyFactory _systemOutFizzBu
this._systemOutFizzBuzzOutputStrategyFactory = _systemOutFizzBuzzOutputStrategyFactory;
}

public void printFizz() {
final FizzStringReturner myFizzStringReturner = new FizzStringReturner();
final FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter myOutputAdapter =
new FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter(
this._systemOutFizzBuzzOutputStrategyFactory.createOutputStrategy());

myOutputAdapter.output(myFizzStringReturner.getReturnString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
import org.springframework.stereotype.Service;

import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories.SystemOutFizzBuzzOutputStrategyFactory;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.strategies.adapters.FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.stringreturners.IntegerIntegerStringReturner;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.interfaces.stringreturners.IntegerStringReturner;

@Service
public class IntegerPrinter {
Expand All @@ -19,15 +16,4 @@ public IntegerPrinter(final SystemOutFizzBuzzOutputStrategyFactory _systemOutFiz
this._systemOutFizzBuzzOutputStrategyFactory = _systemOutFizzBuzzOutputStrategyFactory;
}

public void printInteger(final int theInteger) {
final IntegerStringReturner myIntegerIntegerStringReturner = new IntegerIntegerStringReturner();
final String myIntegerString = myIntegerIntegerStringReturner
.getIntegerReturnString(theInteger);
final FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter myOutputAdapter =
new FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter(
this._systemOutFizzBuzzOutputStrategyFactory.createOutputStrategy());

myOutputAdapter.output(myIntegerString);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import org.springframework.stereotype.Service;

import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.factories.SystemOutFizzBuzzOutputStrategyFactory;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.strategies.adapters.FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter;
import com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.stringreturners.NewLineStringReturner;

@Service
public class NewLinePrinter {
Expand All @@ -18,14 +16,4 @@ public NewLinePrinter(final SystemOutFizzBuzzOutputStrategyFactory _systemOutFiz
this._systemOutFizzBuzzOutputStrategyFactory = _systemOutFizzBuzzOutputStrategyFactory;
}

public void printNewLine() {
final NewLineStringReturner myNewLineStringReturner = new NewLineStringReturner();
final String myNewLineString = myNewLineStringReturner.getReturnString();
final FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter myOutputAdapter =
new FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter(
this._systemOutFizzBuzzOutputStrategyFactory.createOutputStrategy());

myOutputAdapter.output(myNewLineString);
}

}
3 changes: 2 additions & 1 deletion src/test/java/FizzBuzzTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ private void doFizzBuzz(final int n, final String s) throws IOException {
this.fb.fizzBuzz(n);

System.out.flush();
assertEquals(s, baos.toString());
String platformDependentExpectedResult = s.replaceAll("\\n", System.getProperty("line.separator"));
assertEquals(platformDependentExpectedResult, baos.toString());
}

@Test
Expand Down

0 comments on commit 4590711

Please sign in to comment.