-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1307 from BladeRunnerJS/0.15.3-release
0.15.3 release
- Loading branch information
Showing
36 changed files
with
1,030 additions
and
73 deletions.
There are no files selected for viewing
136 changes: 136 additions & 0 deletions
136
...test-integration/java/org/bladerunnerjs/api/memoization/BundleCachingIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
package org.bladerunnerjs.api.memoization; | ||
|
||
import org.bladerunnerjs.memoization.PollingFileModificationObserverThread; | ||
import org.bladerunnerjs.model.App; | ||
import org.bladerunnerjs.model.Aspect; | ||
import org.bladerunnerjs.model.BRJS; | ||
import org.bladerunnerjs.model.exception.ConfigException; | ||
import org.bladerunnerjs.testing.specutility.engine.SpecTest; | ||
import org.bladerunnerjs.memoization.WatchingFileModificationObserverThread; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
|
||
|
||
public class BundleCachingIntegrationTest extends SpecTest | ||
{ | ||
private StringBuffer response = new StringBuffer(); | ||
|
||
@Before | ||
public void initTestObjects() throws Exception | ||
{ | ||
given(brjs).automaticallyFindsBundlerPlugins() | ||
.and(brjs).automaticallyFindsMinifierPlugins() | ||
.and(brjs).hasBeenCreated(); | ||
|
||
// dont use fields for BRJS objects since we recreate BRJS in each test | ||
} | ||
|
||
@SuppressWarnings("deprecation") | ||
@After | ||
public void stopServer() throws Exception { | ||
if (brjs != null) { | ||
brjs.applicationServer(appServerPort).stop(); | ||
} | ||
try { | ||
brjs.getFileWatcherThread().interrupt(); | ||
brjs.getFileWatcherThread().stop(); | ||
} catch (Exception ex) { | ||
// ignore | ||
} | ||
} | ||
|
||
@Test @Ignore //TODO: this test is unreliable - fix it | ||
public void fileWatcherWatchesFolderBrjsAppsAtTheSameLevelAsSdk() throws Throwable { | ||
given(brjs).hasBeenAuthenticallyCreatedWithFileWatcherThread(); | ||
App app = brjs.app("app1"); | ||
Aspect aspect = app.defaultAspect(); | ||
given(app).hasBeenCreated() | ||
.and(aspect).hasBeenCreated() | ||
.and(aspect).indexPageHasContent("require('appns/App')") | ||
.and(aspect).classFileHasContent("App", "// App.js") | ||
.and(aspect).hasReceivedRequest("js/dev/combined/bundle.js"); | ||
when(aspect).indexPageRefersToWithoutNotifyingFileRegistry("require('appns/AppClass')") | ||
.and(aspect).fileHasContentsWithoutNotifyingFileRegistry("src/AppClass.js", "// AppClass.js"); | ||
then(aspect).devResponseEventuallyContains("js/dev/combined/bundle.js", "AppClass.js", response) | ||
.and(response).doesNotContainText("App.js"); | ||
} | ||
|
||
@Test @Ignore //TODO: this test is unreliable - fix it | ||
public void fileWatcherPollsFolderBrjsAppsAtTheSameLevelAsSdk() throws Throwable { | ||
given(brjs).hasBeenAuthenticallyCreatedWithFilePollingThread(); | ||
App app = brjs.app("app1"); | ||
Aspect aspect = app.defaultAspect(); | ||
given(app).hasBeenCreated() | ||
.and(aspect).hasBeenCreated() | ||
.and(aspect).indexPageHasContent("require('appns/App')") | ||
.and(aspect).classFileHasContent("App", "// App.js") | ||
.and(aspect).hasReceivedRequest("js/dev/combined/bundle.js"); | ||
when(aspect).indexPageRefersToWithoutNotifyingFileRegistry("require('appns/AppClass')") | ||
.and(aspect).fileHasContentsWithoutNotifyingFileRegistry("src/AppClass.js", "// AppClass.js"); | ||
then(aspect).devResponseEventuallyContains("js/dev/combined/bundle.js", "AppClass.js", response) | ||
.and(response).doesNotContainText("App.js"); | ||
} | ||
|
||
@Test | ||
public void brjsConfCanBeUsedToConfigureFileObserverToPolling() throws Throwable { | ||
given(brjs.bladerunnerConf()).hasFileObserverValue("polling") | ||
.and(logging).enabled(); | ||
when(brjs).hasBeenAuthenticallyCreatedWithAutoConfiguredObserverThread(); | ||
then(logging).debugMessageReceived(BRJS.Messages.FILE_WATCHER_MESSAGE, PollingFileModificationObserverThread.class.getSimpleName()) | ||
.and(logging).otherMessagesIgnored(); | ||
|
||
} | ||
|
||
@Test | ||
public void brjsConfCanBeUsedToConfigureFileObserverToPollingWithASetInterval() throws Throwable { | ||
given(brjs.bladerunnerConf()).hasFileObserverValue("polling:1000") | ||
.and(logging).enabled(); | ||
when(brjs).hasBeenAuthenticallyCreatedWithAutoConfiguredObserverThread(); | ||
then(logging).debugMessageReceived(BRJS.Messages.FILE_WATCHER_MESSAGE, PollingFileModificationObserverThread.class.getSimpleName()) | ||
.and(logging).debugMessageReceived(PollingFileModificationObserverThread.THREAD_INIT_MESSAGE, PollingFileModificationObserverThread.class.getSimpleName(), 1000) | ||
.and(logging).otherMessagesIgnored(); | ||
} | ||
|
||
@Test | ||
public void brjsConfCanBeUsedToConfigureFileObserveToWatching() throws Throwable { | ||
given(brjs.bladerunnerConf()).hasFileObserverValue("watching") | ||
.and(logging).enabled(); | ||
when(brjs).hasBeenAuthenticallyCreatedWithAutoConfiguredObserverThread(); | ||
then(logging).debugMessageReceived(BRJS.Messages.FILE_WATCHER_MESSAGE, WatchingFileModificationObserverThread.class.getSimpleName()) | ||
.and(logging).otherMessagesIgnored(); | ||
} | ||
|
||
@Test | ||
public void watchingFileObserverIsUsedAsDefault() throws Throwable { | ||
given(logging).enabled(); | ||
when(brjs).hasBeenAuthenticallyCreatedWithAutoConfiguredObserverThread(); | ||
then(logging).debugMessageReceived(BRJS.Messages.FILE_WATCHER_MESSAGE, WatchingFileModificationObserverThread.class.getSimpleName()) | ||
.and(logging).otherMessagesIgnored(); | ||
} | ||
|
||
@Test @Ignore //TODO: this test is unreliable - fix it | ||
public void brjsConfConfiguredFileObserverDetectsChanges() throws Throwable { | ||
given(brjs).hasBeenAuthenticallyCreatedWithAutoConfiguredObserverThread(); | ||
App app = brjs.app("app1"); | ||
Aspect aspect = app.defaultAspect(); | ||
given(app).hasBeenCreated() | ||
.and(aspect).hasBeenCreated() | ||
.and(aspect).indexPageHasContent("require('appns/App')") | ||
.and(aspect).classFileHasContent("App", "// App.js") | ||
.and(aspect).hasReceivedRequest("js/dev/combined/bundle.js"); | ||
when(aspect).indexPageRefersToWithoutNotifyingFileRegistry("require('appns/AppClass')") | ||
.and(aspect).fileHasContentsWithoutNotifyingFileRegistry("src/AppClass.js", "// AppClass.js"); | ||
then(aspect).devResponseEventuallyContains("js/dev/combined/bundle.js", "AppClass.js", response) | ||
.and(response).doesNotContainText("App.js"); | ||
} | ||
|
||
@Test | ||
public void exceptionIsThrownIfFileObserverValueIsInvalid() throws Throwable { | ||
given(brjs.bladerunnerConf()).hasFileObserverValue("invalid"); | ||
when(brjs).hasBeenAuthenticallyCreatedWithAutoConfiguredObserverThread(); | ||
then(exceptions).verifyException(ConfigException.class, "invalid", "polling(:([0-9]+))?", "watching"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.