Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FindBugs fix; Windows build fix. #271

Merged
merged 6 commits into from
Jan 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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